The five knobs you'll always touch
mlx_lm.lora exposes a long list of CLI flags, but for 90% of fine-tuning runs you'll only adjust a handful. Memorize these five — what they mean, what default values look like, when each is the bottleneck — and you can run a meaningful fine-tuning experiment in minutes.
--num-layers— how many of the model's transformer layers get LoRA adapters attached. Default 16. Setting-1attaches LoRA to all layers (more capacity, more memory). Higher is more flexible; lower is faster and cheaper.--learning-rate— the Adam learning rate. Defaults are sane (around 1e-5 for Adam on a 7B base); raise it for faster convergence on small datasets, lower it if loss is unstable. The most common mistake is leaving it at the default when your dataset is tiny.--batch-size— minibatch size in number of examples per step. Higher means more stable gradients but more memory; lower means less memory and noisier gradients. On a 7B base with a 32 GB Mac, batch sizes of 4–16 are typical.--iters— total training steps. For a 200–500-example dataset, 100–500 iters is a reasonable starting range. Watch the validation loss; stop when it stops improving.--max-seq-length— truncates training examples longer than this. Huge impact on memory (KV cache scales with this). Set just above your longest expected example to avoid both truncation losses and wasted memory.
The fine-tune-type knob — pick once, ignore
--fine-tune-type picks between lora (the default), dora (DoRA — see lesson 4), and full (full fine-tuning, almost never the right call on a Mac for a 7B+ model).
Sane defaults you can copy
For a 7B base instruct model, a 200-example domain dataset, and a 32 GB Mac:
--num-layers 16--learning-rate 5e-5(raised from default for small dataset)--batch-size 4--iters 200--max-seq-length 2048(or shorter if your examples are shorter)--steps-per-eval 25(val loss every 25 steps)--save-every 100(checkpoint every 100 steps)
Watch the loss, not the iters
The right number of iterations isn't a number; it's whatever count makes your validation loss stop improving. mlx-lm reports both training and validation loss at intervals — when validation loss plateaus or starts climbing while training loss keeps falling, you've started overfitting. Stop there. The --save-every flag means you have checkpoints to roll back to.