# MLX-Tune

> Fine-tune LLMs, vision, speech, embedding and OCR models on an Apple Silicon Mac, with an Unsloth-compatible API built on MLX

- Category: Training & Fine-Tuning / Fine-Tuning Frameworks
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/ARahim3/mlx-tune
- Website: https://arahim3.github.io/mlx-tune/
- Canonical page: https://ai-tldr.dev/tools/mlx-tune/
- Updated: 2026-06-23

## In short

MLX-Tune is a Python library for fine-tuning models locally on Apple Silicon Macs (M1 through M5). It wraps Apple's MLX framework in an API that mirrors Unsloth and TRL: you load a model with FastLanguageModel, add LoRA adapters with get_peft_model, and train with SFTTrainer. It sits in the Fine-Tuning Frameworks category of the Training & Fine-Tuning tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

MLX-Tune is a Python library for fine-tuning models locally on Apple Silicon Macs (M1 through M5). It wraps Apple's MLX framework in an API that mirrors Unsloth and TRL: you load a model with FastLanguageModel, add LoRA adapters with get_peft_model, and train with SFTTrainer. The stated goal is code portability — write a training script on a Mac, test it with small datasets, then run the same script on a CUDA cluster with the original Unsloth by swapping the imports. The project was originally published as unsloth-mlx and was renamed because it is an unofficial community project, not affiliated with Unsloth AI or Apple.

Does Unsloth run on Apple Silicon? Unsloth's requirements page lists the original Unsloth Core library for Linux and Windows with NVIDIA, AMD and Intel GPUs, and still says Apple Silicon/MLX support is "in the works". Unsloth's separate Studio app does list macOS support for training and MLX inference. MLX-Tune is the community route for running Unsloth-style scripts (FastLanguageModel, SFTTrainer) natively on a Mac today, with the same imports you would use on a CUDA machine.

Beyond text LLMs it covers a wide range of model types: vision-language models through mlx-vlm, text-to-speech (Orpheus, OuteTTS, Spark-TTS, Sesame/CSM, Qwen3-TTS), speech-to-text (Whisper, Moonshine, Qwen3-ASR, Canary, Voxtral, Parakeet TDT), sentence-embedding models trained with InfoNCE, dedicated OCR models with built-in CER/WER metrics, Mixture-of-Experts models with per-expert LoRA, and continual pretraining on raw text. Version 0.6.0 added a JEPA family — LeJEPA pretraining, Meta's I-JEPA and V-JEPA 2 encoders, and an LLM-JEPA trainer.

Trained models can be saved as LoRA adapters, merged into a 16-bit model, exported to GGUF for Ollama and llama.cpp, converted from Hugging Face to MLX format, or pushed to the Hugging Face Hub. The README documents known limitations, notably that GGUF export does not work directly from a 4-bit quantized base model (an mlx-lm limitation) and lists workarounds.

## What it does

- Unsloth-compatible API — FastLanguageModel, get_peft_model and SFTTrainer with the same call shapes, so scripts move between Mac and CUDA by changing imports
- Native MLX trainers for SFT, DPO, ORPO, GRPO, KTO and SimPO, plus Vision GRPO and OCR GRPO
- Vision-language, text-to-speech, speech-to-text, embedding and OCR fine-tuning through dedicated FastVisionModel, FastTTSModel, FastSTTModel, FastEmbeddingModel and FastOCRModel classes
- Mixture-of-Experts fine-tuning that detects MoE layers and applies per-expert LoRA automatically
- Continual pretraining with CPTTrainer, including decoupled embedding learning rate and full-weight mode
- Chat templates and response-only training via get_chat_template and train_on_responses_only
- Export to LoRA adapters, merged 16-bit weights, GGUF, MLX format, or the Hugging Face Hub

## Getting started

MLX-Tune needs an Apple Silicon Mac running macOS 13.0 or later, Python 3.9+, and 8GB of unified memory (16GB recommended). It installs from PyPI.

1. Install the package

   The project recommends uv. Audio (TTS/STT) fine-tuning needs the audio extra and ffmpeg.

```bash
uv pip install mlx-tune

# With audio support (TTS/STT fine-tuning)
uv pip install 'mlx-tune[audio]'
brew install ffmpeg
```

2. Load a model and add LoRA adapters

   Any Hugging Face model works; the quick start uses a 4-bit 1B Llama from mlx-community.

```python
from mlx_tune import FastLanguageModel, SFTTrainer, SFTConfig
from datasets import load_dataset

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name="mlx-community/Llama-3.2-1B-Instruct-4bit",
    max_seq_length=2048,
    load_in_4bit=True,
)

model = FastLanguageModel.get_peft_model(
    model,
    r=16,
    target_modules=["q_proj", "k_proj", "v_proj", "o_proj"],
    lora_alpha=16,
)
```

3. Train with SFTTrainer

   The trainer takes the same arguments as TRL's SFTTrainer.

```python
dataset = load_dataset("yahma/alpaca-cleaned", split="train[:100]")

trainer = SFTTrainer(
    model=model,
    train_dataset=dataset,
    tokenizer=tokenizer,
    args=SFTConfig(
        output_dir="outputs",
        per_device_train_batch_size=2,
        learning_rate=2e-4,
        max_steps=50,
    ),
)
trainer.train()
```

4. Save the result

   Save adapters only, a merged 16-bit model, or GGUF. GGUF export needs a non-quantized base model or dequantize=True.

```python
model.save_pretrained("lora_model")  # Adapters only
model.save_pretrained_merged("merged", tokenizer)  # Full model (16-bit)
model.save_pretrained_gguf("model", tokenizer)  # GGUF
```

## When to use it

- Prototype a fine-tuning pipeline on a MacBook before paying for cloud GPUs, then run the same script with Unsloth on NVIDIA hardware
- Adapt a Whisper, Parakeet or other speech-to-text model to a new domain or language entirely on a Mac
- Fine-tune an embedding model on anchor-positive pairs to improve semantic search for a specific corpus
- Train a small LoRA on a local model and export it to GGUF for use in Ollama or llama.cpp

## Version history

- 2026-06-23 v0.6.0: Added the JEPA family: LeJEPA pretraining, Meta's pretrained I-JEPA and V-JEPA 2 encoders, and an LLM-JEPA trainer, with new FastJEPAModel, FastVideoJEPAModel and LLMJEPATrainer entry points.
