Skip to content

What is LoRA (Low-Rank Adaptation)?

LoRA adapts a pretrained model by freezing its weights and training updates built as the product of two small tables of numbers. It must be tested on the task.

LoRA, or Low-Rank Adaptation, is a technique for adapting a pretrained model to a task while keeping its weights, the numerical values learned earlier, fixed. With LoRA, fine-tuning, an additional round of training, updates small sets of added values, called adapters, instead of the entire model. When the original model processes a request, the adapters' effect is combined with its own. The term “low rank” means that each update is represented by two smaller tables of numbers, a choice that reduces the number of parameters to train and store. Adapters keep updates for different tasks separate, all on top of the same base model. Fewer parameters do not guarantee the same quality as full fine-tuning, however: teams must compare responses on held-out examples, measure actual resource use, and retest what the model could already do. File size is therefore only part of the decision, which also turns on quality, operations, and cost.

See also: Fine-tuningFine-tuning adapts a pretrained model to a task using additional examples, changing its parameters or those of an adapter used alongside the base model.

How it works

An update to a table of weights is expressed as the product of two smaller tables. Rank, a number set in the configuration, fixes an internal dimension of those tables and, with it, the number of values to train. Teams also choose which parts of the model receive adapters. The original LoRA paper reports results comparable to or better than full fine-tuning on the models and tasks it tested. For GPT-3 175B, compared with full fine-tuning using the Adam optimizer, the authors report up to 10,000 times fewer trainable parameters and a third of the GPU memory. Those savings are not guaranteed for other models, configurations, or workloads.

When to consider QLoRA

QLoRA combines adapters with a frozen base model stored in 4 bits through quantization, which uses fewer bits to represent values. In the QLoRA paper, the authors trained a 65-billion-parameter model on a GPU with 48 GB of memory. They report performance matching 16-bit fine-tuning in their tests, but quantization introduces some approximation: QLoRA is worth considering when GPU memory is what limits training, and quality should then be measured on the chosen configuration.

An enterprise example

An insurance company uses the same base model for two tasks: classifying claims and summarizing adjusters' reports. Its team trains one adapter per task on authorized examples, holds out evaluation cases, and keeps the adapters separate instead of merging them into the model one after another. Each adapter is compared with the base model on the same cases, including ambiguous ones, measuring memory, time, and quality. If the gain on a task does not justify the cost of maintaining its adapter, the company sticks with the base model for that task. This is a hypothetical example, not a research result or a performance guarantee.

Why it matters for decision makers

Before buying or starting a project, decision makers should ask which version of the base model the adapter uses, who stores the two, and how evaluation is rerun after an update. A research comparison finds that after a single task LoRA tends to forget less than full fine-tuning, though not always. In the setting studied, however, it forgets more when trained on several tasks in sequence, with each adapter merged into the model. Evaluation should therefore cover earlier capabilities as well as the new task. An adapter does not replace the base model, and access to the adapter's training examples still has to be controlled.

Frequently asked questions

LoRA keeps the original weights fixed and trains adapters; full fine-tuning updates all of the model's parameters. Compare quality on the target task.

No. QLoRA uses LoRA adapters with a frozen base model quantized to 4 bits, to cut the memory needed for training.
  • Fine-tuningFine-tuning adapts a pretrained model to a task using additional examples, changing its parameters or those of an adapter used alongside the base model.
  • Quantization (quantizzazione)Quantization represents model values with fewer bits, reducing the memory footprint but introducing a quality trade-off that must be verified case by case.
  • SLMAn SLM is a compact language model, general-purpose or specialized, best chosen by weighing task quality, resource requirements, and deployment constraints.

See it in the universe

If you need the AI in production, not in a demo, that is my job.

See AI integrations

Or write to me.