LoRA and PEFT

Machine Learning
Introduced by
Hu, E. J. et al.; Lester, B. et al.
Year
2022
Type
Parameter-efficient fine-tuning of large pretrained models

What does it do?

LoRA (Low-Rank Adaptation), introduced by Hu et al. in 2022, belongs to the broader family of parameter-efficient fine-tuning (PEFT) methods.

These methods adapt a large pretrained language model to a new task by training a small number of added parameters instead of every weight in the model. The original model stays frozen, which reduces the GPU memory and compute needed for fine-tuning.

The intuition behind the method

Fully fine-tuning a large language model means updating billions of weights. This is expensive in memory and compute, and it produces a full copy of the model for every task. LoRA rests on an assumption: that the weight change needed for adaptation has low intrinsic rank, so it can be captured by a small pair of matrices rather than a dense update to every weight. PEFT methods more generally freeze the original model and train only a small set of new parameters, so one base model can be specialised to many tasks at low cost.

History

LoRA was introduced by Hu et al. in 2022, proposing that the weight update needed to adapt a large language model can be represented as a low-rank decomposition trained in place of full fine-tuning. A related line of work is the prompt tuning of Lester et al. (2021), which learns soft prompts for a frozen language model and reports that this approach becomes more competitive as model size grows. Both contributions belong to the parameter-efficient fine-tuning family.

When to use it

Choose LoRA or another PEFT method when you want to adapt a large pretrained language model to a text classification or prediction task and cannot afford the memory and compute of full fine-tuning. A suitable pretrained model must already exist, and labelled task-specific text must be prepared; a GPU is recommended. No fixed minimum sample size guarantees a successful adaptation, since the amount of data needed depends on task difficulty and on the base model. With small datasets, adaptation is prone to overfitting, so a classical model such as a random forest or gradient boosting is a useful baseline to compare against before relying on fine-tuning.

Limitations and considerations

  • Requires a large pretrained model to start from; it does not train a model from scratch.
  • A GPU is recommended, and task-specific data must be prepared in advance.
  • On small task datasets the adaptation may not capture enough signal and risks overfitting, so validation performance must be checked.
  • The low-rank assumption constrains the update: if a task needs a change that is not well approximated by a low-rank matrix, the adaptation will be limited.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Drastically lower GPU memory and compute than full fine-tuning, since only a small set of parameters is trained.
  • The original pretrained model is frozen and reused across tasks, so a single base model can be specialised many times.
  • The learned low-rank update can be merged back into the weights, adding no inference-time overhead.
  • Covers a family of options, including LoRA, prefix tuning, and prompt tuning, so the adaptation can be placed where it works best.

Applications

  • Adapting a large pretrained language model to a domain-specific text classification task.
  • Specialising one base model to many tasks without storing a full copy per task.
  • Fine-tuning under limited GPU memory where full fine-tuning is infeasible.
  • Text prediction tasks that build on an existing pretrained language model.

How it works

How it works

1

A large model that has already been pretrained is taken as a fixed starting point. Instead of fine-tuning all of its weights, the original parameters are frozen and only a small set of additional parameters is introduced and trained for the target task. LoRA, prefix tuning, and prompt tuning are among the methods in this family, each adding parameters in a different place. Prompt tuning is described by Lester et al. (2021) as a simplification of prefix tuning (Li and Liang, 2021).

2

In LoRA, the update to a frozen weight matrix is constrained to be low-rank: it is written as the product of two small matrices, so only those small matrices are trained while the original weights stay fixed. Because the rank r is much smaller than the weight dimensions d and k, the number of trainable parameters is far below that of the full matrix, which is what reduces the memory and compute cost of fine-tuning.

Formula
W = W_0 + \Delta W = W_0 + BA,\quad B \in \mathbb{R}^{d\times r},\ A \in \mathbb{R}^{r\times k},\ r \ll \min(d,k)
3

Only the small added parameters are optimised on the task-specific data, which needs far less GPU memory than full fine-tuning. The base model is reused unchanged across tasks, and the learned low-rank update can be merged back into the weights for inference. A GPU is recommended, and the task dataset must be large enough for the adaptation to be meaningful.

Common pitfalls

  • Applying LoRA or PEFT to a tiny dataset and expecting reliable adaptation instead of falling back to a classical model.
  • Treating parameter-efficient fine-tuning as a substitute for having a suitable pretrained base model.
  • Ignoring overfitting risk on small task data rather than monitoring validation performance.
  • Assuming the method removes the need for a GPU when one is recommended.

Frequently asked questions

What is the difference between LoRA and PEFT?

PEFT (parameter-efficient fine-tuning) is the broad family of methods that adapt a large model by training only a small number of extra parameters. LoRA is one specific PEFT method that trains a low-rank update to the weights; prefix tuning and prompt tuning are other members of the same family.

How much data do I need?

There is no fixed minimum sample size that applies to every task; the amount needed depends on how difficult the task is and on the base model. Small datasets are prone to overfitting, so check performance on held-out validation data before relying on the adapted model. If data are scarce, a classical model is a reasonable baseline to compare against.

Do I need a GPU?

A GPU is recommended. Although PEFT methods use far less memory than full fine-tuning, training the added parameters on a large pretrained model still benefits substantially from GPU acceleration.

Why is the update low-rank?

LoRA assumes that the weight change needed for adaptation has low intrinsic rank. Representing the update as the product of two small matrices is what reduces the number of trainable parameters, and with it the memory and compute cost. Whether this assumption holds for a given task should be checked against validation performance.

Related methods

Sources

  1. Hu, E. J. et al. (2022). LoRA: Low-Rank Adaptation of Large Language Models. ICLR.

    Open publication reference
  2. Lester, B. et al. (2021). The Power of Scale for Parameter-Efficient Prompt Tuning. EMNLP.

    Open DOI reference