Rank r is the shared inner dimension of the LoRA factorisation. It linearly controls trainable parameter count and caps how many directions in weight space the adapter can move.
Picture trying to summarise a thick novel using a fixed number of index cards. With four cards you can capture the broadest strokes; with sixty-four you can keep most of the nuance; with two hundred you are essentially copying the book. The number of cards is the rank. In LoRA, rank r decides how many independent directions of change the adapter has to work with. Too few cards and you cannot capture the new behaviour. Too many and you have lost the whole point of a compact summary. The sweet spot sits in the middle, big enough to express what you need, small enough to stay cheap. The smaller the number, the more compressed the change has to be.
Detailed answer & concept explanation~7 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
6 min: r as the inner dimension + parameter count formula + the rank-of-BA expressive ceiling + alpha/r scaling + typical r ranges + AdaLoRA as a smarter alternative.
| Rank r | Trainable params (per 4096x4096 layer) | Typical use case |
|---|---|---|
| 4 | ~32k | Narrow style adaptation |
| 8 | ~65k | Default starting point |
| 16 | ~131k | Common instruction tuning |
| 64 | ~524k | Broad behaviour shaping |
| 128 | ~1M | Diminishing returns territory |
Real products, models, and research that use this idea.
- Hugging Face PEFT defaults LoRA r to 8 in its example configs, a starting point most teams keep for initial experiments.
- QLoRA fine-tunes of Llama 4 Maverick commonly use r=64 with alpha=16 on all linear layers, balancing capacity against single-GPU memory.
- Mistral's official fine-tuning recipe uses r=16 with alpha=32 as a strong baseline for instruction tuning.
- AdaLoRA lets the trainer redistribute total rank budget across layers based on importance, often allocating higher r to MLP-down projections.
- Anthropic and OpenAI fine-tuning endpoints expose rank as a hidden hyperparameter, typically choosing r between 16 and 64 based on dataset size.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does LoRA initialise B to zero and A randomly?
QWhat does alpha do, and why is the ratio alpha/r more meaningful than alpha alone?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Confusing rank r with the number of LoRA layers. r is the inner dimension of each adapter matrix; the number of layers and which modules get adapted are separate config choices.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.