AI glossary
LoRA (Low-Rank Adaptation)
LoRA (low-rank adaptation) is a parameter-efficient fine-tuning technique that adapts a pretrained model to a new task by training a small number of additional low-rank matrices inserted into the model’s layers, while keeping the original pretrained weights frozen and unchanged.
The method was introduced in the 2021 paper “LoRA: Low-Rank Adaptation of Large Language Models” by Edward Hu and colleagues at Microsoft. It was designed to make fine-tuning large language models more practical by drastically reducing the number of parameters that need to be trained and stored for each new task or use case, compared to updating and storing a full copy of the model’s weights for every fine-tuned version.
How LoRA Works
Traditional fine-tuning updates the entire set of weights in a model. LoRA takes a different approach. Instead of updating a model’s full weight matrices directly, LoRA freezes the original pretrained weights and adds a pair of much smaller “low-rank” matrices alongside each targeted weight matrix.
Only these small low-rank matrices are trained during fine-tuning. Because their combined size is far smaller than the original weight matrix, the number of trainable parameters, and the memory needed to store gradients and optimizer states during training, is dramatically reduced. This makes the process significantly less resource-intensive, allowing teams to experiment with more variants without requiring massive GPU clusters.
At inference time, the low-rank update can be mathematically merged back into the original weight matrix. This means the fine-tuned model runs with no additional latency compared to the original model. You get the benefits of a specialized model without the performance penalty of extra layers or complex routing during deployment.
LoRA vs Full Fine-Tuning
The distinction between full fine-tuning and LoRA matters primarily when dealing with large language models or even small language models. Full fine-tuning updates all of a model’s weights and requires storing a complete separate copy of the model for each fine-tuned variant. This is expensive in both compute and storage, especially as model sizes grow.
LoRA trains and stores only the small low-rank matrices. These often amount to well under 1% of the original model’s parameter count. This makes it far cheaper to create and store many task-specific adaptations of the same base model. You can swap between different LoRA adapters for different tasks without loading multiple gigabytes of weight data.
Because the base model’s weights are frozen, LoRA also reduces the risk of “catastrophic forgetting.” In full fine-tuning, adapting to a narrow new task can cause a model to lose more of its general capabilities than necessary. LoRA’s constrained updates help preserve the foundational knowledge of the original model parameter set while still allowing for specific behavioral adjustments.
QLoRA
QLoRA, introduced in 2023, extends LoRA by combining it with a quantized (lower numeric precision) version of the base model. Quantization reduces the precision of the weights, which further reduces memory use during fine-tuning.
This combination makes it possible to fine-tune large language models on a single consumer-grade GPU. Previously, you would not have enough memory for full fine-tuning or even standard LoRA fine-tuning of the same model at full precision. By lowering the precision of the base model and adding LoRA adapters, QLoRA democratizes access to high-quality model adaptation for developers without enterprise-grade hardware.
Limitations
LoRA is not a silver bullet. LoRA fine-tuning can underperform full fine-tuning on tasks that require substantial changes to the model’s underlying knowledge or behavior. Since it only adjusts a low-rank subset of the model’s capacity, it may struggle with tasks that demand deep restructuring of the model’s internal representations.
Choosing the rank (the size of the low-rank matrices) and which layers to apply LoRA to involves trade-offs between adaptation quality and the number of trainable parameters. The best settings can vary by task and model. If the rank is too low, the adapter may lack the capacity to learn the new task. If it is too high, you lose some of the efficiency benefits. Finding the right balance often requires experimentation.
FAQ
What is LoRA in machine learning?
LoRA stands for Low-Rank Adaptation. It is a technique that freezes a pretrained model’s weights and trains small, additional matrices to adapt the model to a new task efficiently.
Is LoRA better than full fine-tuning?
LoRA is generally cheaper and faster, requiring significantly less memory and storage. However, full fine-tuning may yield better results for tasks that require extensive changes to the model’s core knowledge.
What is the difference between LoRA and QLoRA?
QLoRA combines LoRA with quantization. It uses a lower-precision version of the base model, allowing fine-tuning on smaller hardware like consumer GPUs, whereas standard LoRA typically requires more memory.
Does LoRA add latency to inference?
No. The low-rank updates can be mathematically merged into the original weights before deployment, resulting in no additional latency during inference compared to the original model.
Related terms
Fine-tuning Model parameter Quantization Large language model Small language model GPU