mlx-lm-lora  by Goekdeniz-Guelmez

Train LLMs efficiently on Apple Silicon

Created 9 months ago
269 stars

Top 95.6% on SourcePulse

GitHubView on GitHub
Project Summary

Summary

MLX-LM-LoRA is a Python library designed for training large language models (LLMs) efficiently on Apple Silicon hardware using the MLX framework. It targets researchers, engineers, and power users who need to fine-tune or train LLMs locally, offering a comprehensive suite of training methods and support for a wide array of popular LLM architectures. The primary benefit is enabling powerful LLM training capabilities on consumer-grade Apple hardware, democratizing access to advanced model customization.

How It Works

The project leverages Apple's MLX framework, which is optimized for Apple Silicon's unified memory architecture, to facilitate LLM training. It supports various efficient fine-tuning techniques like LoRA and DoRA, alongside full-precision and quantized training (QLoRA). The library implements a broad spectrum of training algorithms, including Supervised Fine-Tuning (SFT), Direct Preference Optimization (DPO), Contrastive Preference Optimization (CPO), Odds Ratio Preference Optimization (ORPO), and several Reinforcement Learning from Human Feedback (RLHF) variants like PPO and GRPO. This diverse algorithmic support allows for flexible model adaptation based on specific task requirements and data types.

Quick Start & Requirements

  • Installation: pip install -U mlx-lm-lora
  • Prerequisites: Apple Silicon Mac (required for MLX).
  • Usage: The primary command is mlx_lm_lora.train. Detailed examples and command-line flags are provided for various training modes.
  • Links: Example Notebooks are available for fine-tuning and preference optimization. Hugging Face datasets are supported.

Highlighted Details

  • Supports a wide range of LLM architectures including Llama, Phi, Mistral, Mixtral, Qwen, Gemma, and OLMo.
  • Offers advanced training methods beyond SFT, such as DPO, CPO, ORPO, and multiple RLHF variants (GRPO, PPO, etc.).
  • Includes features for synthetic dataset creation (prompts, SFT, preferences) directly on-device.
  • Supports various quantization levels (4-bit, 6-bit, 8-bit) for memory-efficient training.

Maintenance & Community

The repository is actively maintained by Goekdeniz-Guelmez. Specific details on community channels (like Discord/Slack) or major contributors are not explicitly detailed in the README.

Licensing & Compatibility

The license is not explicitly stated in the provided README. Standard GitHub open-source practices suggest it may be MIT or Apache, but users should verify. Compatibility is primarily for macOS on Apple Silicon due to the MLX dependency.

Limitations & Caveats

The project's core dependency on MLX restricts its use to Apple Silicon hardware. While it supports many models, performance and memory usage will be hardware-dependent. The extensive list of training algorithms may require a significant learning curve for users unfamiliar with advanced LLM training methodologies.

Health Check
Last Commit

2 days ago

Responsiveness

Inactive

Pull Requests (30d)
10
Issues (30d)
1
Star History
27 stars in the last 30 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Didier Lopes Didier Lopes(Founder of OpenBB), and
3 more.

instructlab by instructlab

0.1%
1k
CLI tool for LLM alignment tuning via synthetic data
Created 2 years ago
Updated 1 week ago
Feedback? Help us improve.