# Repository Briefing: ARahim3/mlx-tune
> Source: https://repoforai.com/repo/ARahim3/mlx-tune (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/ARahim3/mlx-tune
- **Official Docs / Website**: https://arahim3.github.io/mlx-tune/
- **Category**: LLMs & Inference (大模型与推理微调)
- **Primary Language**: Python
- **License**: Apache-2.0
- **Engineering Health**: B (60/100 · Maintenance 12/35 · Adoption 14/25 · Releases 14/20 · License 20/20)
- **Latest Release**: v0.6.0 (2026-06-23) — https://github.com/ARahim3/mlx-tune/releases
- **Review Snapshot**: 2026-12-03
- **Deployment / Stack Signals**: Local AI, GPU
- **Momentum**: 1,485 ★ total (+0 24h / +7 7d) · 103 forks
- **Topics**: `apple-silicon`, `deep-learning`, `huggingface`, `large-language-models`, `llm`, `llm-finetuning`, `local-llm`, `lora`, `machine-learning`, `macos`, `mlx`, `on-device-ai`
- **When to Use**: Best for: Teams and researchers prototyping language or multimodal fine-tuning on Apple Silicon, validating data and adapter behavior locally, and optionally moving larger text-training jobs to Unsloth on CUDA. Skip if: You need a production inference server, train exclusively on NVIDIA, or must export GGUF directly from a 4-bit base checkpoint.

## Overview
```text
### Architecture & Core Mechanics
mlx-tune is a Python training library, not an inference service. Model wrappers such as `FastLanguageModel`, `FastVisionModel`, and `FastSTTModel` handle model and tokenizer or processor setup, while task-specific trainers define the training objective. A text SFT job loads a supported checkpoint, attaches LoRA with `get_peft_model`, prepares examples with chat templates or response-only masking, runs `SFTTrainer`, then saves adapters or merged weights.

Training runs natively on MLX rather than CUDA/Triton. The dependency list includes `mlx>=0.20.0`, `mlx-lm>=0.18.0`, Transformers, Tokenizers, Datasets, and Hugging Face Hub. The Python API is the integration surface: model wrappers, trainer/config pairs, and helpers such as `UnslothVisionDataCollator` let a training script select the right data and model path. The source tree separates the `mlx_tune/` package from `examples/`, `docs/`, and `tests/`.

### Key Capabilities & Differentiators
Text training covers SFT, DPO, ORPO, KTO, SimPO, multi-generation GRPO, and continual pretraining through `CPTTrainer`. The same language-model wrapper handles supported dense and MoE checkpoints; MoE-aware LoRA can target `SwitchLinear` expert layers in families such as Qwen3.5-MoE and Phi-3.5-MoE. Multimodal paths include VLM SFT and GRPO, Whisper and Parakeet TDT speech recognition, Orpheus and Qwen3-TTS speech synthesis, and OCR with character and word error rates plus exact match. Embedding training uses InfoNCE and exposes mean, CLS, and last-token pooling.

The v0.6.0 JEPA paths serve different purposes: LeJEPA trains a vision transformer from scratch with SIGReg, I-JEPA supports frozen-backbone, LoRA, or full fine-tuning for classification, and V-JEPA 2 exposes clip features, classification, and masked-latent prediction. `LLMJEPATrainer` adds a paired-view alignment term to next-token prediction while retaining a standard LoRA artifact. Export is a separate concern: supported paths include adapter-only saves, merged weights, and GGUF subject to base-model and conversion constraints.

### Trade-offs & Limitations
The strongest reason to adopt mlx-tune is to prototype locally on a Mac while keeping an Unsloth-style script for a later CUDA run. Original Unsloth is the direct alternative on NVIDIA hardware. The two backends are different despite the familiar API: validate trainer arguments, data formatting, and saved artifacts on both sides before assuming portability, throughput parity, or numerical equivalence. Unified memory makes local experimentation practical, but sequence length, batch size, and GRPO rollouts can make a job that loads successfully too large to train.

Export can determine which checkpoint to start with. A 4-bit base supports QLoRA and adapter saves, but direct GGUF export from that base is blocked by the `mlx-lm` conversion path. The default `merged_16bit` dequantizes before fusion, requiring more memory and storage than a quantized artifact. `merged_4bit` is smaller but can round away a small LoRA update. If GGUF is mandatory, choose a supported non-quantized base and test conversion early; if inference stays on MLX, an adapter or merged MLX checkpoint avoids GGUF conversion.

### Hardware & Deployment Guide
The baseline is an Apple Silicon Mac (M1–M5), macOS 13.0+, and Python 3.9+. Install with `pip install mlx-tune` or `uv pip install mlx-tune`; TTS and STT use the `mlx-tune[audio]` extra and system `ffmpeg` for audio codecs. Training executes in the local Python process, without a hosted training API. For an offline workflow, stage the required model, tokenizer or processor, and dataset files ahead of time and verify local loading before disconnecting.

The minimum is 8 GB of unified memory, with 16 GB or more recommended. Size for the chosen checkpoint, sequence length, batch size, and any generation or export step. v0.5.0 improved trainer performance and recorded an ORPO configuration at 4,096 context on a 48 GB Mac; that is not a general capacity guarantee. v0.5.1 addressed a merge bug that could make a reloaded 4-bit-base fine-tune behave like the original model. With v0.6.0 adding JEPA, pin a tested dependency set and make a fresh-process reload part of artifact acceptance.
```

## Key Capabilities
```text
- Backend: Python training runs on Apple MLX, with `mlx-lm` in the language-model stack and `FastLanguageModel` as the Unsloth-style entry point.
- Training objectives: Native MLX trainers cover SFT, DPO, ORPO, KTO, SimPO, and GRPO; GRPO samples multiple completions and uses rewards.
- Adapter targeting: MoE-aware LoRA can target `SwitchLinear` expert layers; vision LoRA exposes separate controls for vision and language layers.
- Multimodal evaluation: OCR exposes CER, WER, and exact match; embedding training uses InfoNCE with mean, CLS, or last-token pooling.
- Research entry points: v0.6.0 adds `FastJEPAModel`, `FastVideoJEPAModel`, and `LLMJEPATrainer`; LLM-JEPA produces a standard LoRA artifact.
- Artifact handling: Save adapters or merged weights; the default 16-bit merge dequantizes a 4-bit base before fusion, while direct GGUF export from that quantized base is unsupported.
```

## Quick Start / Clone
```bash
# Using uv (recommended - faster and more reliable)
uv pip install mlx-tune

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

# Or using pip
pip install mlx-tune

# From source (for development)
git clone https://github.com/ARahim3/mlx-tune.git
cd mlx-tune
uv pip install -e .
```
