ml-explore/mlx-swift-examples
57.7
Adequate · 14 November 2026
9.8k
lines of production code
Swift
primary language
5
measurements over time
What this system is
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 examples in the Numerical section to demonstrate MLX capabilities. The CurveFit example visualizes gradient descent fitting a quadratic model to noisy data using SwiftUI and Charts. The HeatTransfer example simulates 2D heat diffusion with walls and heat sources, offering three algorithmic variants (conv2d, roll stencil, and SOR) to compare convergence and performance. The Mandelbrot example renders the Mandelbrot set using four different implementations (plain MLX, compiled MLX, Metal kernel, and CPU reference) to highlight performance trade-offs between high-level array operations and low-level custom kernels.
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 cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 53 → 58 (+5.0)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.4) — scores are not directly comparable.
Lenses
- Code Health 96 → 93 (-3.0)
- Architecture 89 → 98 (+8.6)
- Maturity 54 → 54 (+0.4)
- Readiness 29 → 40 (+11.0)
- Security 90 → 85 (-4.2)
- Performance 100 → 100 (+0.0)
Resolved (14)
- ChatCommand.chat (cognitive 43) (Tools/llm-tool/Chat.swift)
- ChatCommand.chat (cyclomatic 29) (Tools/llm-tool/Chat.swift)
- CorpusLoader.load (cognitive 16) (Tools/embedder-tool/Indexing.swift)
- Duplicated block (11 lines × 2) (Applications/StableDiffusionExample/ContentView.swift)
- Duplicated block (14 lines × 2) (Numerical/Mandelbrot/Algorithm/Mandelbrot+CPU.swift)
- Duplicated block (19–20 lines × 2) (Tools/embedder-tool/EmbedderTool.swift)
- Duplicated block (7 lines × 2) (Numerical/Mandelbrot/Algorithm/Mandelbrot+MLX.swift)
- Duplicated block (8 lines × 2) (Tools/embedder-tool/ReplCommand.swift)
- IndexCommand.embed (cognitive 18) (Tools/embedder-tool/EmbedderTool.swift)
- No tests found
- Off-boarding risk: anonymized user #1
- Orphaned files with no living knowledge
- Outdated: swift-huggingface
- Projects may be oversized for their cohesion
New (50)
- Concentrated knowledge decay
- Duplicated block (11 lines × 2) (Applications/StableDiffusionExample/ContentView.swift)
- Duplicated block (14 lines × 2) (Numerical/Mandelbrot/Algorithm/Mandelbrot+CPU.swift)
- Duplicated block (19–20 lines × 2) (Tools/embedder-tool/EmbedderTool.swift)
- Duplicated block (7 lines × 2) (Numerical/Mandelbrot/Algorithm/Mandelbrot+MLX.swift)
- Edited copies of one member (3 members, 13+ corresponding lines) (Libraries/StableDiffusion/Load.swift)
- Edited copy of a member (11 corresponding lines) (Numerical/HeatTransfer/Renderer.swift)
- Edited copy of a member (12 corresponding lines) (Tools/image-tool/Arguments.swift)
- Edited copy of a member (13 corresponding lines) (Tools/embedder-tool/EmbedderCommand.swift)
- Edited copy of a member (13 corresponding lines) (Tools/embedder-tool/EmbedderTool.swift)
- Edited copy of a member (15 corresponding lines) (Tools/embedder-tool/ReplCommand.swift)
- Edited copy of a member (17 corresponding lines) (Libraries/StableDiffusion/VAE.swift)
- Edited copy of a member (19 corresponding lines) (Numerical/HeatTransfer/Renderer.swift)
- Edited copy of a member (21 corresponding lines) (Numerical/HeatTransfer/ContentView.swift)
- Edited copy of a member (21 corresponding lines) (Numerical/Mandelbrot/Algorithm/Mandelbrot+MLX.swift)
- Edited copy of a member (23 corresponding lines) (Tools/embedder-tool/ReplCommand.swift)
- Edited copy of a member (27 corresponding lines) (Numerical/HeatTransfer/ContentView.swift)
- Edited copy of a member (31 corresponding lines) (Numerical/Mandelbrot/Algorithm/Mandelbrot+CPU.swift)
- Edited copy of a member (48 corresponding lines) (Tools/embedder-tool/EmbedderTool.swift)
- Edited copy of a member (6 corresponding lines) (Numerical/Mandelbrot/Algorithm/Mandelbrot+MLX.swift)
- …and 30 more
Changes since last survey
- 3 commits — 2 feature/other, 1 fixes
By area
- (root) — 1 commit
- Applications/LoRATrainingExample — 1 commit
- Libraries/StableDiffusion — 1 commit
Notable commits
- fix: fix(LoRA): update default model to gemma3_1B_qat_4bit for fast on-device training (#493)
- change: StableDiffusion: cap CLIP tokenizer at 77 tokens; clear unused-value warnings (#496)
- change: StableDiffusion: migrate from Hub (swift-transformers) to swift-huggingface (#494)
Written by cca.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 14 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit ef1084dd5692611a8758b24b07efdad5404ac3ce — the exact code this score is about.
- Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
- Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.65+preprod-3c33c1882dc1.