Book a free call

What Is LoRA, and How Does It Fine-Tune LLMs?

LoRA fine-tunes a large language model by training two small adapter matrices instead of every weight, cutting GPU memory and training time.

Hertiv engineering teamReviewed by a senior engineer
6 min read
What Is LoRA, and How Does It Fine-Tune LLMs?
On this page

Short answer

LoRA, short for Low-Rank Adaptation, is a fine-tuning method that freezes a pre-trained model and trains only two small adapter matrices inserted into its layers. The adapters learn the new task while the base weights stay fixed, so training needs far less memory and storage than full fine-tuning. After training, the adapters can be merged into the base model for inference.

What is LoRA?

LoRA, short for Low-Rank Adaptation, is a method for adapting a large pre-trained model to a new task by training a small set of extra weights instead of updating the whole model. The base model stays frozen, and two small matrices, called adapters, are added to selected layers.

During training, only the adapter matrices change. The base weights, which hold the general knowledge learned during pre-training, are never touched. This is the key difference from full fine-tuning, where every weight in the model is updated.

LoRA was introduced as a way to make fine-tuning practical on modest hardware. A team that cannot afford to train a 7-billion-parameter model end to end can often train LoRA adapters for it on a single GPU. The idea rests on a simple observation: the weight updates needed for a new task usually have low rank, so they can be represented by small matrices.

For teams working with language models, LLM fine-tuning covers the wider set of options, of which LoRA is the most widely used.

How does LoRA training work?

LoRA training works by inserting a pair of small matrices into a layer and learning only those matrices, while the original weight matrix stays frozen throughout training.

For a weight matrix W, LoRA learns two matrices, A and B, whose product has the same shape as W. The model output becomes W plus the product of B and A, scaled by a factor. The rank r of these matrices controls their size: a rank of 8 or 16 is common, and the matrices are far smaller than W.

The training loop follows these steps:

  1. Freeze the base model. No gradients flow into the original weights, so memory for optimiser state drops sharply.
  2. Attach adapters. Add A and B matrices to the attention layers, and sometimes to feed-forward layers.
  3. Train on task data. Update only the adapters with your labelled examples, using a higher learning rate than full fine-tuning usually needs.
  4. Merge or serve separately. Merge the adapters into the base weights for a single model file, or keep them separate and swap them per task.

Keeping adapters separate is useful when one base model serves several tasks. Each task gets its own small adapter file, and the base model is loaded once.

LoRA vs full fine-tuning

LoRA and full fine-tuning differ mainly in how much of the model changes, which decides memory use, training speed and storage cost. LoRA trains a fraction of the weights; full fine-tuning trains all of them.

Factor LoRA Full fine-tuning
Weights trained Adapters only, often under 1% of the model Every weight in the model
GPU memory Low, one GPU often enough High, often several GPUs
Training time Shorter, fewer gradients to compute Longer, full backward pass over all weights
Storage per task A few megabytes per adapter A full copy of the model per task
Quality Close to full fine-tuning on most tasks Slightly better when the task needs deep change
Risk of forgetting Lower, base weights are untouched Higher, the whole model shifts

The quality gap is small for tasks that stay close to what the base model already does, such as style, format or domain vocabulary. It grows when the task needs the model to learn genuinely new behaviour or knowledge.

Choose full fine-tuning when you have the hardware, the data and a task that demands deep change. Choose LoRA when you need to move fast, serve many tasks from one base model, or train on limited hardware.

When should you use LoRA?

LoRA fits best when the task is a variation on what the base model already does well, the dataset is modest, and you need several adapted models from one base.

Good fits include:

  • Style and format. Teaching a model to answer in a house style, a fixed JSON schema or a specific tone.
  • Domain vocabulary. Adapting a general model to support tickets, medical notes or legal text in a narrow domain.
  • Many tasks, one base. Running several adapters on one deployed model, one per team or product.
  • Limited hardware. Training on one GPU, or on a rented instance, without a multi-GPU cluster.

LoRA is a weaker fit when the model must learn a new domain from scratch, when the task needs long chains of new reasoning, or when the training set is so large that full fine-tuning costs about the same. In those cases, the adapter may not have enough capacity to hold the change.

A practical test is to train a LoRA adapter first, measure it on a held-out set, and only move to full fine-tuning if the gap matters. The adapter run is cheap, so it is a good baseline.

How do you pick the rank and alpha?

You pick the LoRA rank by starting small, measuring on held-out data, and raising it only if the model underfits. Rank 8 or 16 is a good starting point for most tasks.

Rank r sets the size of the adapter matrices. A higher rank gives the adapter more capacity but also more parameters to train, which raises memory and training time. Most teams try rank 8 first, then 16, then 32, and stop when accuracy stops improving.

Alpha is a scaling factor applied to the adapter output. A common rule is to set alpha to twice the rank, so the adapter contribution stays in a useful range as rank changes. The learning rate for LoRA is usually higher than for full fine-tuning, often around 1e-4 to 2e-4, because only a few weights are moving.

Also decide which layers get adapters. Attention layers are the usual target, and adding feed-forward layers helps when the task needs more capacity. Start with attention only, measure, and expand only if the results justify it. For help judging the results, how to test AI models explains how to build an evaluation set.

Example (hypothetical): fine-tuning a support model

Example (hypothetical): a support team wants a 7-billion-parameter model to draft replies in the company tone, using 20,000 past tickets with approved answers.

Full fine-tuning would update all 7 billion weights and store a second 14 GB copy of the model. LoRA with rank 16 trains about 4 million parameters instead, which is roughly 0.06% of the model, since 4,000,000 divided by 7,000,000,000 is about 0.0006.

The adapter file is about 10 MB, against 14 GB for a full model copy. Training takes about 2 hours on one GPU instead of about 14 hours, and the team can keep a separate adapter for each product line without copying the base model each time.

After training, the team checks the adapter on 500 held-out tickets. If 420 drafts need no edit, the adapter ships behind a human review step. If the score is far lower, the team raises the rank to 32 and retrains before deciding whether full fine-tuning is needed.

What are the common mistakes?

The most common LoRA mistakes are picking the wrong rank, training on messy data, and skipping evaluation, which leaves teams guessing whether the adapter helped.

  • Rank too high too early. A large rank on a small dataset overfits and wastes the memory LoRA was meant to save.
  • Dirty training data. Adapters learn the formatting errors in the data, so clean the examples first.
  • No held-out set. Without fresh examples, you cannot tell whether the adapter generalises or just memorised the training set.
  • Adapting the wrong layers. Adding adapters everywhere when attention layers alone would do adds cost without gain.
  • Forgetting the base model limits. LoRA cannot add knowledge the base model lacks; for new facts, retrieval-augmented generation is often the better tool.
  • Skipping the merge test. Always test the merged model, not just the adapter, before deploying.

Key takeaways

  • LoRA freezes the base model and trains only small adapters
  • Rank 8 or 16 is a good starting point; raise it only if the model underfits
  • Adapters are a few megabytes, so one base model can serve many tasks
  • LoRA matches full fine-tuning on most near-domain tasks
  • Clean data and a held-out set matter more than rank choice

Frequently asked questions

What does LoRA stand for?

LoRA stands for Low-Rank Adaptation. It is a method for fine-tuning a large model by training two small low-rank matrices, called adapters, while the base model weights stay frozen. The adapters learn the new task and can be merged into the base model afterwards.

Is LoRA as good as full fine-tuning?

For most tasks that stay close to what the base model already does, LoRA performs about as well as full fine-tuning. Full fine-tuning can be slightly better when the task needs deep changes to model behaviour, but it needs far more memory and storage.

How much memory does LoRA save?

LoRA trains a small fraction of the weights, often under 1% of the model, so optimiser memory and storage drop sharply. A 7-billion-parameter model that needs several GPUs for full fine-tuning can often be adapted with LoRA on a single GPU.

Can one base model use several LoRA adapters?

Yes. Each task gets its own small adapter file, and the base model is loaded once. Adapters can be swapped at request time, which makes one deployed model serve many tasks without keeping a full copy per task.

Does LoRA work for models other than language models?

The idea applies to any large neural network, and it is most used with language models. It also appears in image and speech models, wherever fine-tuning a large pre-trained model is expensive and the task change is small.

What rank should I start with?

Start with rank 8 or 16 and alpha set to about twice the rank. Measure on held-out data, then raise the rank only if the model underfits. Raising rank on a small dataset usually overfits rather than helping.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Planning to fine-tune a model on limited hardware? Talk to Hertiv.

A senior engineer replies within one business day. Or see our LLM Fine-Tuning service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call