skillfed

mlx-lm

LLMs with MLX and the Hugging Face Hub

mlx-lm v0.31.3 1.4M downloads/30d#3,933 on PyPI6,610
Permissive license MIT Active released

What it is and what it does

MLX LM is a Python package that brings large language model inference, generation, fine-tuning, and quantization to Apple silicon Macs. It wraps the MLX framework and integrates with Hugging Face Hub to let you download and run thousands of pre-built models with a single command or Python call. The package works both as a command-line tool (mlx_lm.generate, mlx_lm.chat) and as a Python module, supporting streaming generation, custom sampling, prompt caching, and rotating key-value caches for long-context work.

The package handles model quantization and can upload converted models back to Hugging Face. It supports low-rank and full model fine-tuning, including on quantized models, and offers distributed inference and fine-tuning via mx.distributed. Runtime dependencies include mlx, numpy, transformers, sentencepiece, protobuf, pyyaml, and jinja2—all standard ML and NLP libraries.

Use it for:

  • Run open-source LLMs locally on a Mac for chat, text generation, or code completion without cloud APIs.
  • Quantize and convert models from Hugging Face to MLX format for efficient inference on Apple silicon.
  • Fine-tune existing models on your own data using low-rank or full fine-tuning with quantized weights.
  • Build interactive chat applications with persistent context using the Python API or command-line REPL.
  • Cache long prompts to speed up repeated queries with the same context across multiple generations.
  • Distribute inference and fine-tuning workloads across multiple devices using mx.distributed.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

MLX LM loads, generates text with, fine-tunes, and quantizes large language models on Apple silicon using the MLX framework and Hugging Face Hub integration.

Yes, if you have Apple silicon and want to run LLMs locally. The package is actively maintained, has no known vulnerabilities, installs cleanly, and offers a mature feature set including generation, fine-tuning, quantization, streaming, and caching. The MIT license imposes no restrictions. The main blocker is hardware: you need a Mac with Apple silicon; it will not work on Intel or non-macOS systems.

Install

mlx-lm on PyPI

pip

pip install mlx-lm

uv

uv add mlx-lm

poetry

poetry add mlx-lm

Installing mlx-lm

Before you install

Low friction installation as a pure Python wheel. Active maintenance with recent commits and a substantial user base (top 5000 PyPI packages). Seven runtime dependencies are all well-established libraries.

License in practice

MIT license is permissive; you can use, modify, and distribute this package with minimal legal restrictions.

Quickstart

pip install mlx-lm

from mlx_lm import load, generate

model, tokenizer = load("mlx-community/Mistral-7B-Instruct-v0.3-4bit")
text = generate(model, tokenizer, prompt="Hello", verbose=True)

Requires macOS with Apple silicon and MLX framework support; large models may require macOS 15.0 or higher for optimal performance.

Verify before relying

  • Whether all quantization formats are equally stable across different model architectures.
  • Performance characteristics and memory overhead for distributed inference and fine-tuning with mx.distributed.
  • Exact list of supported model architectures beyond the examples provided in the description.
  • Hardware requirements and performance characteristics on different Apple silicon generations.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 7 — mlx, numpy, transformers, sentencepiece, protobuf, pyyaml, jinja2
Maintenance actively maintained — 114 days since the last release
Last repo commit
First released
Downloads 1,412,545/month — #3,933 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: mlx_lm-0.31.3-py3-none-any.whl

Tags

llm inference on apple silicontext generation with mlxmodel quantization hugging facefine-tune llms macllm chat repl command linestreaming text generationmodel conversion quantize
apple-siliconllm-inferencemodel-quantization

More Artificial Intelligence packages

Further reading