New Tool Radar

Local AI

How to Convert and Quantize a Model to MLX Format with mlx_lm.convert

Convert a Hugging Face model to MLX format and quantize it to 4-bit with mlx_lm.convert, so it runs on an Apple Silicon Mac.

Schematic diagram with three boxes: a Hugging Face model, the command mlx_lm.convert with the quantize flag, and a 4-bit MLX model folder ready to run.

Many models on Hugging Face are not in MLX format, and MLX LM cannot run them as they are. Converting is the step that bridges the two: mlx_lm.convert downloads a Hugging Face model, replaces its linear layers with quantized equivalents, and writes an MLX-format model you can use immediately. Before you convert, check the MLX Community organisation on Hugging Face — thousands of pre-converted models live there, and if the one you want already exists, downloading it is faster than converting it yourself.

Convert and quantize in one command

To quantize a model from the command line, run:

mlx_lm.convert --model mistralai/Mistral-7B-Instruct-v0.3 -q

The -q flag turns quantization on; without it you just get a format conversion. This generates a 4-bit quantized Mistral 7B, and it will save the converted model in the path mlx_model by default. You can also do the same conversion from Python:

from mlx_lm import convert
convert("mistralai/Mistral-7B-Instruct-v0.3", quantize=True)

Check the converted model and run it

Confirm the conversion worked before you delete the original download:

Check What you should see
Output folder A folder named mlx_model in the directory where you ran the command
Quantization The converted model is the 4-bit quantized version, not a full-precision copy
It runs mlx_lm.generate --model mlx_model --prompt "hello" returns a reply

If the mlx_model folder is missing, the conversion did not finish — read the command’s output for the error before running it again. Expected result. We checked the MLX LM README for the convert command, the quantize flag, and the default save path. We did not run mlx_lm.convert.

Limits

Quantization is lossy by design: a 4-bit model is smaller and faster than the original, but its answers can differ from the full-precision model, so check its replies on your own prompts before relying on it. Conversion downloads the full source model first, so you need the disk space and the download time for that, on top of the converted copy. If you want to share the result, the convert command can upload it to Hugging Face with --upload-repo, but that publishes your conversion — do not do it with a model whose licence forbids redistribution. This needs an Apple Silicon Mac; MLX LM is built for Apple silicon. We did not run mlx_lm.convert, so no converted model here is a measured result.

Sources

See all