ml-explore/mlx-swift-lm

LLMs and VLMs with MLX Swift

What it solves

MLX Swift LM provides a comprehensive Swift-native framework for developers to integrate, run, and fine-tune Large Language Models (LLMs) and Vision Language Models (VLMs) within Apple's ecosystem. It bridges the gap between high-performance MLX model architectures and standard Swift application development.

How it works

The project acts as a modular Swift package that interfaces with the MLX Swift framework. It offers a set of libraries for model loading, tokenization, and inference. Developers can use provided macros—such as those for Hugging Face integration—to load models with minimal boilerplate. It also includes specialized libraries for grammar-constrained generation (JSON/EBNF) and a bridge to Apple's native FoundationModels framework, allowing developers to use standard Apple APIs to interact with custom MLX-based models.

Who it’s for

This project is for Swift developers building AI-powered applications for macOS, iOS, and visionOS who want to leverage the performance of MLX while maintaining idiomatic Swift code.

Highlights

  • Supports both full model and LoRA (Low-Rank Adaptation) fine-tuning, including quantized models.
  • Includes grammar-constrained generation to force model outputs into specific JSON schemas or EBNF formats.
  • Provides a bridge to Apple's FoundationModels framework for seamless integration with native system APIs.
  • Offers flexible integration options for various model downloaders and tokenizers via protocol conformance.
  • Includes dedicated libraries for LLMs, VLMs, and embedding models.

Related

  • Project
  • Project
  • Project
  • Project
  • Project