Skip to content
AI360Xpert
Paper Breakdowns
Paper breakdown

LoRA

The 2021 Microsoft paper that made fine-tuning massive models accessible to anyone by training only a tiny fraction of the parameters.

Paper: LoRA: Low-Rank Adaptation of Large Language Models

Authors: Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, Weizhu Chen · 2021

Read the paper
Instead of updating a massive weight matrix, LoRA freezes it and adds a small parallel bypass consisting of two low-rank matrices (A and B). Only A and B are trained.
Instead of updating a massive weight matrix, LoRA freezes it and adds a small parallel bypass consisting of two low-rank matrices (A and B). Only A and B are trained.

The Problem

As language models grew to 100 billion+ parameters, fine-tuning them for specific tasks (like coding or medical diagnosis) became impossible for most researchers. "Full fine-tuning" requires updating every single parameter in the model, which means you need enough VRAM to store the model, the gradients, and the optimizer states. Fine-tuning GPT-3 (175B) required a massive cluster of expensive GPUs. The community desperately needed a Parameter-Efficient Fine-Tuning (PEFT) method.

The Idea

Microsoft researchers introduced LoRA (Low-Rank Adaptation). They hypothesized that while a neural network has billions of parameters, the actual "change" needed to learn a new task has a very low "intrinsic rank" (it's mathematically simple). Instead of updating the massive original weight matrix (WW), they completely freeze WW. They then add a parallel "bypass" path consisting of two very small matrices (AA and BB). During training, only AA and BB are updated. During inference, the outputs of the original frozen matrix and the new tiny matrices are simply added together.

How It Works

Let the original pre-trained weight matrix be WW (dimension d×dd \times d).

  1. LoRA injects two trainable matrices: AA (dimension d×rd \times r) and BB (dimension r×dr \times d), where the rank rr is a very small number (e.g., r=8r = 8).
  2. The forward pass becomes: h=Wx+BAxh = Wx + BAx.
  3. Because rr is so small, the number of trainable parameters drops by roughly 10,000x, and the VRAM required to train drops by 3x.
  4. No Inference Penalty: Once training is done, you can multiply BB and AA together, and add the result directly to WW (Wnew=W+BAW_{new} = W + BA). The architecture remains exactly the same, meaning there is zero latency added during generation.

Why It Mattered

LoRA democratized AI fine-tuning. It allowed hobbyists to fine-tune 7B and 13B parameter models on a single consumer GPU (like an RTX 3090). It also solved the storage problem: instead of saving a 20GB file for every custom model, you only save a 50MB LoRA "adapter" file, allowing you to swap between hundreds of fine-tuned behaviors instantly.

What Came After

LoRA became the absolute standard for fine-tuning open-source LLMs and Stable Diffusion models. It spawned a massive ecosystem of "adapters" shared on Civitai and Hugging Face. Subsequent research focused on optimizing it further (QLoRA, DoRA) and figuring out optimal ranks and target layers.