ml-explore/mlx-swift-examples
53.2
Weak · 30 September 2026
9.7k
lines of production code
Swift
primary language
2
measurements over time
What this system is
This system is a collection of Swift-based example applications and command-line tools designed to demonstrate machine learning capabilities using the MLX framework on Apple platforms. It provides concrete implementations for running large language models, vision-language models, and image generation tasks, alongside utilities for fine-tuning via LoRA and performing semantic search. The repository also includes numerical computing examples and modular libraries that serve as reference architectures for integrating MLX into iOS and macOS applications.
How it got here
2024 — modularization and LoRA integration
16 changes.
The project underwent a major structural refactor to separate core ML libraries into a dedicated repository, focusing the remaining codebase on example applications and specific tools like Stable Diffusion. Significant features were added to support Low-Rank Adaptation (LoRA) for fine-tuning, alongside new interactive CLI tools and SwiftUI apps for LLM evaluation and image generation.
2025–2026 — MLX application and tooling expansion
8 changes.
This period focused on expanding the MLX ecosystem with new user-facing applications and developer tools, including the MLXChatExample app for LLM and VLM interaction, an embedder-tool CLI for semantic search, and numerical computing examples. It also introduced support scripts for batch model evaluation and enhanced the core chat interface with robust media handling and model management services.
Features
Add MLXChatExample iOS app support assets and default HubApi configuration
The MLXChatExample application now includes the necessary asset catalogs for iOS, defining an accent color and app icon variants (including dark and tinted appearances). Additionally, a default HubApi instance is provided to handle model downloads, automatically selecting the user's Downloads directory on macOS or the Caches directory on iOS to ensure proper sandbox compliance.
Applications/MLXChatExample/Support · high confidence
Add MNISTTrainer example app for training and predicting digits
The MNISTTrainer application has been added, providing a SwiftUI-based example that downloads MNIST data, trains a LeNet model, and allows users to draw digits for real-time prediction. The app includes a training view that displays epoch accuracy and timing, and a prediction view with a canvas for drawing input. It supports both macOS and iOS platforms, requiring appropriate team signing for iOS builds and network sandbox permissions to download the dataset.
Applications/MNISTTrainer · high confidence
Add command-line image generation tool with Stable Diffusion support
Introduces a new command-line utility (\image-tool\) for generating images using Stable Diffusion models on MLX. The tool provides two subcommands: \sd text\ for text-to-image generation and \sd image\ for image-to-image transformation. Users can configure model presets (defaulting to SDXL Turbo), adjust generation parameters such as prompt, steps, and seed, and manage memory usage via cache and size limits. The tool supports downloading models automatically, offers options for float16 conversion and quantization, and allows outputting results as PNG files.
Tools/image-tool · high confidence
Added LoRA training and test datasets for text-to-SQL tasks
The Data directory now includes \lora/train.jsonl\ and \lora/test.jsonl\, providing structured examples for fine-tuning models using LoRA (Low-Rank Adaptation). These datasets contain natural language questions paired with corresponding SQL queries across various tabular domains, enabling the model to learn text-to-SQL conversion patterns.
Data · high confidence
Added support scripts to run and evaluate all available LLMs
A new shell script, \support/generate-run-all-llms.sh\, has been added to automatically generate a batch execution script (\support/run-all-llms.sh\). This generated script allows users to sequentially run and evaluate a comprehensive list of supported Large Language Models (LLMs) and Vision-Language Models (VLMs) using the \mlx-run\ tool, including specific handling for image resizing for VLMs.
support · high confidence
Introduce MLX-based Stable Diffusion library
Added a new Swift library for Stable Diffusion image generation powered by MLX. The implementation includes core components such as the CLIP text encoder, UNet, VAE, and tokenizers, along with configuration presets for models like SDXL Turbo and Stable Diffusion 2.1. Users can now generate images from text prompts or modify existing images using these models, with support for memory-efficient loading and quantization.
Libraries/StableDiffusion · high confidence
Introduce MLXChatExample SwiftUI chat interface with media and markdown support
The MLXChatExample application now includes a complete SwiftUI-based chat interface. Users can view scrollable conversation histories where assistant and user messages render markdown formatting via LocalizedStringKey. The interface supports rich media attachments, allowing users to preview and remove images and videos directly within the chat stream. A prompt field enables text input and generation control, while a toolbar provides model selection, generation statistics (tokens per second), and status indicators for model downloads and errors.
Applications/MLXChatExample/Views · high confidence
Introduce MLXChatExample app with vision model support and iOS media handling
The MLXChatExample application is introduced, providing a cross-platform SwiftUI interface for interacting with MLX-based Large Language Models (LLMs) and Vision Language Models (VLMs). On iOS, the app integrates PhotosPicker to allow users to attach images and videos to their prompts; it specifically handles image orientation normalization to ensure VLMs receive correctly oriented input. The chat interface supports markdown rendering for assistant responses and includes entitlements for sandboxed file access and increased memory limits required for model inference.
Applications/MLXChatExample · high confidence
Introduce embedder-tool CLI for document indexing and semantic search
A new command-line utility is available for working with MLX embedder models. It provides commands to index local document corpora into embedding files, search those indexes for semantic matches, and interactively explore embeddings via a REPL. The tool supports configurable model selection, pooling strategies (mean, cls, first, last, max, none), normalization options, and GPU memory limits, and includes a demo command to showcase the workflow using sample repository documentation.
Tools/embedder-tool · high confidence
LLMEval example adds function calling, performance metrics, and memory limit support
The LLMEval example app now supports function calling via a ToolExecutor that implements weather, addition, and time tools, controlled by a new 'Tools' toggle in the UI. It also introduces a performance metrics panel displaying tokens per second, time to first token, and GPU memory usage (active, cache, and peak), driven by a DeviceStat service that polls memory snapshots. To handle large models on iOS, the app requests the increased memory limit entitlement and enforces a 20 MB buffer cache limit.
Applications/LLMEval · high confidence
MLXChatExample introduces secure media attachment handling
The new ChatViewModel in the MLXChatExample app enables users to attach images and videos to chat messages. To support file selection from the system, the MediaSelection component now manages security-scoped bookmarks, automatically starting access for newly added media URLs and stopping it for removed ones, ensuring compliant access to user-selected files.
Applications/MLXChatExample/ViewModels · high confidence
MLXChatExample introduces unified MLXService for model management and generation
The MLXChatExample application now includes a new MLXService class that centralizes the loading, caching, and inference of both language models (LLMs) and vision-language models (VLMs). This service registers a comprehensive list of available models, including Qwen3 variants, Gemma 4 VLMs, and AceReason-Nemotron-7B, and handles their retrieval from the Hugging Face hub with progress tracking. It manages GPU memory limits, caches loaded model containers to avoid redundant loading, and processes chat messages by mapping app-specific types to the MLXLMCommon format, supporting text, images, and video inputs for VLMs while excluding trailing empty assistant messages to keep the generation turn open.
Applications/MLXChatExample/Services · high confidence
New LoRA training and evaluation example application
The LoRATrainingExample application has been added, providing a complete workflow to download a quantized Mistral-7B model, apply LoRA adapters, train the model on local data, and evaluate prompts. The UI guides users through the training progress and allows for interactive evaluation of the adapted model.
Applications/LoRATrainingExample · high confidence
New Xcode schemes for example apps and CLI tools
The project now includes build and launch schemes for several new example applications and command-line tools, making them directly runnable from Xcode. These include HeatTransfer, LLMBasic, LLMEval, MLXChatExample, Mandelbrot, and StableDiffusionExample. Additionally, schemes are provided for the embedder-tool, image-tool, and llm-tool CLIs, with the llm-tool scheme pre-configured with various command-line arguments for testing different models (such as Qwen3, Gemma-3, and Phi-4-mini) and features like repetition penalty and top-p sampling. A package-level scheme for mlx-libraries is also added to build and test the underlying MLX libraries (MLXEmbedders, MLXLLM, MLXLMCommon, MLXMNIST, MLXVLM, StableDiffusion).
mlx-swift-examples.xcodeproj/xcshareddata · high confidence
New numerical computing examples: CurveFit, HeatTransfer, and Mandelbrot
Added three new interactive Swift apps in the Numerical directory to demonstrate MLX-based numerical computing. The CurveFit app visualizes gradient descent fitting a quadratic model to noisy data using MLX's automatic differentiation. The HeatTransfer app simulates 2D heat diffusion with three distinct algorithm implementations (convolution, stencil, and successive over-relaxation) and allows users to compare their performance. The Mandelbrot app renders the Mandelbrot set using four different approaches (plain MLX, compiled MLX, custom Metal kernel, and reference CPU) to showcase performance trade-offs in parallel computation.
Numerical · high confidence
llm-tool gains interactive chat, LoRA fine-tuning, and model listing commands
The llm-tool command-line interface has been significantly expanded with new subcommands. Users can now engage in multi-turn interactive conversations via the new 'chat' command, which supports multimodal inputs (images and videos) and provides runtime controls for generation parameters like temperature and top-p. A new 'lora' command suite enables fine-tuning models using Low-Rank Adaptation (LoRA/QLoRA), offering subcommands for training, testing, evaluating, and fusing adapter weights back into the base model. Additionally, a 'list' command allows users to view available registered LLM and VLM model configurations, and the tool now supports loading prompts from files and includes a simple 'get\_time' tool integration for testing.
Tools/llm-tool · high confidence
Removals
Removal of MNIST library and documentation
The MNIST library and its associated README documentation have been removed from the codebase. This eliminates the previously available port of the MNIST model and training code, including utilities for downloading data, the MLP model implementation, and data shuffling/batching functions.
Libraries/MNIST · high confidence
Architecture
Project structure refactored to support modular MLX libraries
The Xcode project has been significantly reorganized to support a modular architecture, introducing new framework targets for MLXLLM, MLXVLM, MLXEmbedders, MLXMNIST, and MLXHuggingFace. This change removes legacy embedded frameworks (LLM.framework, MNIST.framework) and AsyncAlgorithms, replacing them with explicit dependencies on the new modular libraries and standard tools like ArgumentParser and Tokenizers. This structural shift enables better separation of concerns for large language model, vision-language model, and embedding capabilities within the examples.
mlx-swift-examples.xcodeproj · high confidence
Behavioural changes
Introduce Stable Diffusion example app with offline fallback
The StableDiffusionExample application now supports loading the SDXL Turbo model from local storage when an internet connection is unavailable, ensuring the app remains functional in offline scenarios. The UI allows users to generate images from text prompts, with optional negative prompts and progress indicators, while automatically conserving memory on devices with limited resources.
Applications/StableDiffusionExample · high confidence
LLM library refactored with breaking API changes and MNIST example updated to LeNet
The LLM library has undergone a significant architectural refactor that introduces breaking API changes, removing the previous \Configuration.swift\, \LLMModel.swift\, and individual model files (Gemma, Llama, Phi) in favor of a new structure. Concurrently, the MNIST example library has been renamed to MLXMNIST and its model architecture switched from a Multi-Layer Perceptron (MLP) to a LeNet convolutional network, with associated data handling and random number generators updated for Swift concurrency (Sendable).
Libraries/LLM · high confidence
MNIST tool now uses LeNet and simplifies command-line execution
The MNIST training tool has been updated to use the LeNet architecture instead of the previous configurable MLP, and the default device has changed from CPU to GPU. Additionally, running the tool from the command line is now simplified by using the \mlx-run\ script, removing the need to manually set \DYLD\_FRAMEWORK\_PATH\. The code also includes a Swift 5.10 compatibility fix for the \ExpressibleByArgument\ conformance and adopts the \MLXMNIST\ library.
Tools/mnist-tool · high confidence
Repository restructuring and new developer tooling
The repository has been reorganized to clarify its scope: LLM and VLM implementations (MLXLLM, MLXVLM, MLXLMCommon, MLXEmbedders) have moved to a dedicated library repository (mlx-swift-lm), while this repo now focuses on example applications and specific reusable libraries like StableDiffusion and MLXMNIST. To support this, a new .spi.yml file configures documentation generation for the remaining targets, and a new mlx-run shell script simplifies launching command-line tools by handling build directory detection and framework path setup. Additionally, contributor acknowledgments, a Code of Conduct, and updated contributing guidelines have been added to formalize community standards.
(repo-wide) · high confidence
Fixes
Added configuration to generate unique bundle identifiers for sample projects
A new Build.xcconfig file has been introduced to resolve bundle identifier conflicts in sample code projects. By deriving the bundle ID from the DEVELOPMENT\_TEAM via a DISAMBIGUATOR variable, the configuration ensures unique identifiers for users who have set up their development teams, addressing the issue where frequently downloaded samples previously lacked unique IDs.
Configuration · high confidence
Dependencies
Update core dependencies and resolve package pins
This change updates the project's dependency graph, pinning specific versions in Package.resolved and adjusting version constraints in Package.swift. Key updates include upgrading swift-transformers to 1.3.0, mlx-swift to 0.31.3/0.31.4, and swift-collections to 1.3.0, while removing the swift-async-algorithms dependency. The Package.swift also explicitly defines the MLXMNIST and StableDiffusion products and their required dependencies, ensuring consistent builds across the workspace.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 57 → 53 (-3.5)
- Rubric changed (rubric-2026.09.11 → rubric-2026.09.18) — scores are not directly comparable.
Lenses
- Code Health 95 → 94 (-0.7)
- Architecture 100 → 98 (-1.9)
- Maturity 61 → 61 (+0.0)
- Readiness 33 → 29 (-4.9)
- Security 85 → 85 (+0.0)
Resolved (2)
- Documentation: no project overview (README.md)
- Off-boarding risk: anonymized user #1
New (30)
- ChatView.body (cognitive 17) (Applications/MLXChatExample/ChatView.swift)
- Dependency not covered by the committed resolution: swift-docc-plugin
- Documentation: no installation or build instructions (README.md)
- Duplicated block (10 lines × 2) (Tools/embedder-tool/ModelArguments.swift)
- Duplicated block (10 lines × 3) (Numerical/HeatTransfer/Utilities/MLX+IOSurface.swift)
- Duplicated block (11 lines × 2) (Applications/StableDiffusionExample/ContentView.swift)
- Duplicated block (14 lines × 2) (Numerical/Mandelbrot/Algorithm/Mandelbrot+CPU.swift)
- Duplicated block (18 lines × 2) (Numerical/HeatTransfer/ContentView.swift)
- Duplicated block (29 lines × 2) (Numerical/HeatTransfer/Utilities/MLX+IOSurface.swift)
- Duplicated block (29 lines × 2) (Numerical/HeatTransfer/Utilities/MLX+IOSurface.swift)
- Duplicated block (6–7 lines × 2) (Applications/LLMEval/Views/MetricsView.swift)
- Duplicated block (7 lines × 2) (Numerical/Mandelbrot/Algorithm/Mandelbrot+MLX.swift)
- Off-boarding risk: anonymized user #1
- Outdated: eventsource
- Outdated: gzipswift
- Outdated: mlx-swift
- Outdated: mlx-swift
- Outdated: mlx-swift-lm
- Outdated: swift-argument-parser
- Outdated: swift-asn1
- …and 10 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
ml-explore/mlx-swift-examples was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 30 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 378f2449c257788c5067b9f8b086731d76b39b33 — the exact code this score is about.
- Scored under rubric-2026.09.18 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-cb25ca4feafa.