--- id: mlx-lm version: "0.31.3" license: MIT license_treatment: permissive maintenance: active --- # mlx-lm — LLMs with MLX and the Hugging Face Hub License: permissive · Maintenance: active · Downloads: 1.4M/mo ## 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 above — 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 pip install mlx-lm uv add mlx-lm 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_current - Install friction: low - Maintenance: active - Downloads: 1.4M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags llm inference on apple silicon, text generation with mlx, model quantization hugging face, fine-tune llms mac, llm chat repl command line, streaming text generation, model conversion quantize, apple-silicon, llm-inference, model-quantization [View on SkillFed](https://skillfed.io/packages/mlx-lm) · [View on PyPI](https://pypi.org/project/mlx-lm/)