ml-explore/mlx-swift-lm

LLMs and VLMs with MLX Swift

What it solves

MLX Swift LM is a Swift package designed to simplify the creation of applications using large language models (LLMs) and vision language models (VLMs). It provides the necessary infrastructure to load, run, and fine-tune these models on Apple hardware using the MLX Swift framework.

How it works

The package provides a common API for LLMs and VLMs, along with example implementations of various model architectures. It integrates with tokenizer and model downloading packages via protocol conformance, allowing developers to choose between different integration methods. It also includes specialized libraries for grammar-constrained generation (JSON Schema or EBNF) and a bridge to Apple's FoundationModels framework for standardized API usage.

Who it’s for

Swift developers building AI-powered tools and apps for macOS, iOS, and visionOS who want to leverage MLX for efficient local model execution.

Highlights

  • Model Loading: Integrated support for various tokenizer and model downloading packages.
  • Fine-tuning: Supports both Low-rank (LoRA) and full model fine-tuning, including support for quantized models.
  • Architecture Support: Includes implementations for a wide range of LLM and VLM architectures.
  • Guided Generation: Provides grammar-constrained generation to ensure model outputs follow specific schemas like JSON.
  • FoundationModels Bridge: Bridges MLX models into Apple's FoundationModels.LanguageModel for use with LanguageModelSession.

Related

  • Project
  • Project
  • Project
  • Project
  • Project