Low-Rank Adaptation (LoRA) is a parameter-efficient fine-tuning technique that adapts large pretrained models by injecting trainable low-rank matrices into frozen model layers, drastically reducing memory and compute requirements. LoRA emerged in 2021 as practitioners sought ways to fine-tune billion-parameter models without the prohibitive costs of full fine-tuning β freezing the base model and training only 0.1β1% of parameters while achieving comparable or better performance. The key insight: fine-tuning updates often live in low-rank subspaces, meaning a full-rank weight update can be decomposed into two smaller matrices without sacrificing task adaptation quality. Today, LoRA and its PEFT family (QLoRA, DoRA, PiSSA, rsLoRA, GaLore, etc.) are standard practice for customizing LLMs, vision models, and multimodal systems β enabling practitioners to fine-tune 70B+ models on consumer GPUs and deploy hundreds of task-specific adapters in production. Understanding rank selection, alpha scaling, target modules, initialization strategies, and merging techniques is essential for maximizing performance while minimizing cost.
What This Cheat Sheet Covers
This topic spans 15 focused tables and 111 indexed concepts, 93 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Core LoRA Concepts
The mathematical foundation of LoRA is surprisingly compact: two small matrices multiply to approximate the weight update, with initialization designed so the adapter contributes nothing at the start of training. Mastering these core concepts β rank, alpha, target modules, and the forward-pass formula β is the prerequisite for understanding every variant and extension.
| Concept | Example | Description | |
|---|---|---|---|
$W' = W_0 + \Delta W = W_0 + BA$ where $B \in \mathbb{R}^{d \times r}$, $A \in \mathbb{R}^{r \times k}$ | β’ Freezes pretrained weights $W_0$ and injects trainable low-rank matrices $A$ and $B$ into each layer β’ rank $r \ll \min(d,k)$ drastically reduces parameters. | ||
r=8, r=16, r=64 | β’ Dimensionality of low-rank decomposition β’ controls adapter capacity β lower rank = fewer params but less expressiveness β’ typical range 4β256 depending on model size and task. | ||
alpha=16 (if r=8) | β’ Scaling factor that controls update magnitude via $\frac{\alpha}{r}$ β’ commonly set to $\alpha = 2r$ as heuristic β’ higher alpha = stronger adaptation signal. | ||
$h = W_0 x + \frac{\alpha}{r} B A x$ | β’ During forward pass, base model output $W_0 x$ is adjusted by scaled LoRA term $\frac{\alpha}{r} BA x$ β’ backward pass updates only $A$ and $B$. | ||
7B model: 0.1β1% trainable params (few MB adapters vs 14GB base) | β’ LoRA reduces trainable parameters by 100β1000Γ compared to full fine-tuning β’ a 7B model with rank-8 LoRA trains ~2M params instead of 7B. | ||
target_modules=["q_proj", "v_proj", "k_proj", "o_proj"] | β’ Specifies which linear layers receive LoRA β’ typically query/key/value/output projections in attention β’ can also target MLPs ( gate_proj, up_proj, down_proj). | ||
$W_{merged} = W_0 + BA$ | β’ Combines trained LoRA weights into base model for inference β’ zero latency overhead β model behaves as if fully fine-tuned. | ||
$A \sim \mathcal{N}(0, \sigma^2)$, $B = 0$ | β’ $A$ initialized with Kaiming uniform or Gaussian β’ $B$ starts at zero so initial $\Delta W = BA = 0$ β adapter contributes nothing at start. |