How ml-explore/mlx-swift-examples works
This repository is a collection of MLX Swift example applications, command-line tools, numerical-computing demos, and two reusable model libraries—not one end-user product. Its principal workflow is prompt-to-result: an app or CLI accepts a prompt, obtains a model, runs generation, and presents or saves output. Other documented workflows cover fine-tuning, MNIST training, embedding search, and numerical simulations. The source index and excerpts support only selected internal connections; unsampled branches are shown as capabilities without guessed call chains.
Main entry points: ImageTool.swift Image CLI · LLMEvaluator.swift LLM Evaluation · MLXService.swift LLM/VLM Chat · ContentView.swift Image Generation App
Components 28
ML Applications
- Minimal LLM Chat
Applications/LLMBasic/ChatModel.swift - LLM Evaluation
Applications/LLMEval/ViewModels/LLMEvaluator.swift - Preset Prompts
Applications/LLMEval/Models/PresetPrompts.swift - Tool Execution
Applications/LLMEval/Services/ToolExecutor.swift - LLM/VLM Chat
Applications/MLXChatExample/Services/MLXService.swift - Chat Model Types
Applications/MLXChatExample/Models/LMModel.swift - Chat Messages
Applications/MLXChatExample/Models/Message.swift - LoRA Fine-Tuning
Applications/LoRATrainingExample/ContentView.swift - Image Generation App
Applications/StableDiffusionExample/ContentView.swift - MNIST Trainer
Applications/MNISTTrainer/ContentView.swift - MNIST Prediction
Applications/MNISTTrainer/PredictionView.swift
Reusable Libraries
- Stable Diffusion
Libraries/StableDiffusion/StableDiffusion.swift - Image Conversion
Libraries/StableDiffusion/Image.swift - MNIST Library
Libraries/MLXMNIST/MNIST.swift
Command-Line Tools
- LLM CLI
Tools/llm-tool/LLMTool.swift - CLI Chat Generation
Tools/llm-tool/Chat.swift - Model Listing
Tools/llm-tool/ListCommands.swift - Image CLI
Tools/image-tool/ImageTool.swift - MNIST CLI
Tools/mnist-tool/MNISTTool.swift - Embedder Commands
Tools/embedder-tool/EmbedderCommand.swift - Embedding Runtime
Tools/embedder-tool/EmbedderRuntime+Embedding.swift - Vector Search
Tools/embedder-tool/SearchCommand.swift - Vector Operations
Tools/embedder-tool/VectorOperations.swift
Numerical Demos
- Curve Fitting
Numerical/CurveFit/Algorithm/Gradient.swift - Heat Transfer
Numerical/HeatTransfer/Algorithm/Jacobi+MLX.swift - Heat Renderer
Numerical/HeatTransfer/Renderer.swift - Mandelbrot Renderer
Numerical/Mandelbrot/Algorithm/Mandelbrot+MLX.swift
Other components
- User
Connections 28
- User → Minimal LLM Chat: prompts
README.md - User → LLM Evaluation: evaluates prompt
README.md - User → LLM/VLM Chat: chats
README.md - User → LoRA Fine-Tuning: fine-tunes
README.md - User → Image Generation App: requests image
README.md - User → MNIST Trainer: trains model
README.md - User → LLM CLI: runs generation
README.md - User → Image CLI: requests image
README.md - User → MNIST CLI: trains model
README.md - User → Embedder Commands: runs commands
- User → Curve Fitting: views fitting
README.md - User → Heat Transfer: views simulation
README.md - User → Mandelbrot Renderer: views rendering
README.md - LLM Evaluation → Preset Prompts: uses presets
Applications/LLMEval/ViewModels/LLMEvaluator.swift - LLM Evaluation → Tool Execution: executes tools
Applications/LLMEval/ViewModels/LLMEvaluator.swift - LLM/VLM Chat → Chat Model Types: loads configuration
Applications/MLXChatExample/Services/MLXService.swift - LLM/VLM Chat → Chat Messages: generates from
Applications/MLXChatExample/Services/MLXService.swift - Image Generation App → Stable Diffusion: loads and generates
Applications/StableDiffusionExample/ContentView.swift - Image Generation App → Image Conversion: uses image type
Applications/StableDiffusionExample/ContentView.swift - MNIST Trainer → MNIST Prediction: presents prediction
Applications/MNISTTrainer/ContentView.swift - LLM CLI → Model Listing: registers commands
Tools/llm-tool/LLMTool.swift - CLI Chat Generation → Image CLI: references image type
- Image CLI → Stable Diffusion: generates images
Tools/image-tool/ImageTool.swift - Image CLI → Image Conversion: uses image type
Tools/image-tool/ImageTool.swift - Embedder Commands → Embedding Runtime: uses runtime
- Vector Search → Embedder Commands: implements command
Tools/embedder-tool/SearchCommand.swift - Vector Search → Vector Operations: scores vectors
Tools/embedder-tool/SearchCommand.swift - Curve Fitting → User: shows fit