Token Lab검색

← 논문 라이브러리
Efficient adaptation & alignment / 2021

LoRA: constrain the update, not the whole model

Factor a weight update, count trainable parameters and explain the asymmetric first gradient.

LoRA: Low-Rank Adaptation of Large Language Models · Hu et al. · arXiv:2106.09685

Original editorial analysis by Token Lab · Source checked 2026-10-25 · Paper claims and synthetic examples are separated.

Detailed technical articles are available in English and Chinese. This locale shows the English article with localized navigation.

01 · What the paper establishes

LoRA freezes pretrained weights and learns a low-rank additive update. The paper studies several language models and adaptation tasks. Its empirical success does not establish that every useful update has the same small rank.

Primary source: paper abstract ↗
Study guide & lesson outlineLEARNING CONTRACT

Understand → implement → investigate

Goal: explain the mechanism in this lesson, reproduce one example and test a failure case. Reading alone does not mark mastery.

  • Understand: state assumptions, shapes/units and a counterexample.
  • Implement: reproduce a numerical example and inspect boundaries.
  • Investigate: compare one alternative under a matched budget.

02 · The mechanism

Text / 原始公式
W ∈ Rᵈˣᵏ, A ∈ Rʳˣᵏ, B ∈ Rᵈˣʳ
W′ = W + (α/r)BA
Trainable parameters = r(k+d)
∂L/∂A = (α/r)BᵀG; ∂L/∂B = (α/r)GAᵀ

The base matrix can remain full rank; only its learned change is constrained. Two thin matrices provide a bottleneck through which the update passes. With B initialized to zero and A nonzero, the initial function is unchanged, the gradient for A is zero, and B can begin moving. Setting both to zero would block both gradients.

Notation and intuition are teaching explanations. Consult the original method for complete assumptions and implementation details.

Mechanism map & worked derivation

Input x → Frozen Wx + trainable (α/r)BAx → Loss and backpropagation → Update A/B; preserve W
Original schematic; read the steps from top to bottom. SVG ↓
Symbols and assumptions
SymbolMeaning
W ∈ ℝᵈˣᵏFrozen base weight
A ∈ ℝʳˣᵏ, B ∈ ℝᵈˣʳTrainable low-rank factors
′Gradient arriving at the effective weight
  1. The chain rule gives ′). Substitute α·A+B·dA) and collect coefficients to obtain the two factor gradients.
  2. Tiny example with α/: ,2], ,0]ᵀ and Then ∂L/∂,2]ᵀ while ∂L/∂,0]. A zero initial update can still start learning through B.
  3. With learning rate 0.1, B becomes [−0.1,−0.2]ᵀ, giving -0.1,-0.2],[-0.2,-0.4]]. Its rank is at most one; the next step can now give A a nonzero gradient.
Experiment checkpoint

Assert that W stays unchanged and that the initial output matches the base model. Test gradients before testing downstream quality.

LOCAL / SYNTHETIC / INTERACTIVE

Change one variable. Explain what moves.

Original teaching calculation, not a reproduction of the paper’s benchmark. Bars are relative within this panel; numeric values and units are authoritative.

04 · Work through an example

Original example: a 4096×4096 matrix has 16,777,216 entries. Rank 8 adds 8×8192=65,536 trainable entries, or 0.390625% of the dense count. This is a parameter ratio, not a total training-memory ratio. A rank-r optimum for a squared-error matrix approximation leaves the squared singular-value tail as residual; neural task loss is a different objective.

05 · Design your experiment

Start with the site’s small matrix-fit experiment. Sweep rank while holding target matrix and seed fixed, then compare with the singular-value lower bound. In a real language-model study, additionally fix target modules, adapter scaling, token budget and validation selection. Compare rank increases against wider module coverage at similar trainable-parameter budgets.

Research deliverable

State one hypothesis; save the configuration and raw results; identify a competing explanation; report the narrowest supported conclusion. Use the linked lab as a local starting point, not a full paper reproduction.

Open related lesson / lab →

06 · Limits & reviewer questions

Editorial caution: fewer trainable weights do not remove backbone forward passes or activation storage. Merging BA into a compatible dense weight can remove the separate adapter path, but serving many adapters or a quantized backbone introduces other constraints. Rank alone is an incomplete experiment description.

Why is zero-initializing both factors a bad idea?

Both gradients contain the other factor. With =0, the displayed derivatives are zero, so gradient descent cannot leave the zero update without another intervention.

07 · Read the original

Low-rank parameterization and initialization, followed by rank and target-module experiments.

Year is the first arXiv submission year. Unversioned links follow revisions; record the exact version in your reproduction report. DeepSeek-R1 here is explicitly pinned to v1.

Continue this topic

MATHEMATICAL REVIEW · 2026-10-26

Assumptions, implementation & acceptance

G denotes ∂L/∂W′. B is d_out×r and A is r×d_in; retain α/r in both gradients and the forward path. The singular-value residual bound concerns Frobenius low-rank approximation, not downstream language accuracy.

Displayed formula, bilingual explanation and declared slider range. This code reproduces the scalar teaching calculation, not the paper training system.

Before running: predict a boundary case

Start with the site’s small matrix-fit experiment. Sweep rank while holding target matrix and seed fixed, then compare with the singular-value lower bound. In a real language-model study, additionally fix target modules, adapter scaling, token budget and validation selection. Compare rank increases against wider module coverage at similar trainable-parameter budgets.

Hint: isolate the assumption

Keep the baseline input fixed, change one parameter or boundary, and compare both the numerical result and the claimed units. A passing example verifies this fixture only.

Minimal executable example

Save the example and linked modules in one folder. Use Node.js 22 or newer, then run node lora.mjs. No third-party runtime dependencies.

import {paperCalc} from './paper-core.mjs';
const result=paperCalc("lora",8);
console.log(result);
Reference output — reveal after predicting
{
  "labels": [
    "Dense parameters",
    "Trainable adapter parameters"
  ],
  "values": [
    16777216,
    65536
  ],
  "unit": "parameters",
  "extra": 0.390625,
  "extraLabel": "Adapter / dense (%)"
}

Test and transfer

Start with the site’s small matrix-fit experiment. Sweep rank while holding target matrix and seed fixed, then compare with the singular-value lower bound. In a real language-model study, additionally fix target modules, adapter scaling, token budget and validation selection. Compare rank increases against wider module coverage at similar trainable-parameter budgets.

Record input, code version, expected result and observed result in the notebook below. Then construct a counterexample that violates the assumption above and explain why the original conclusion no longer follows.

Download complete kit (.tar.gz) · Complete reference kit and regression checks

Predict, test and keep evidence

Before revealing an answer, predict one result. After the exercise, record the discrepancy and a transfer test. Saved locally across language editions.

Open notebook / export / clear →

The mathematical review scope is recorded per lesson. It does not establish empirical paper reproduction; report suspected errors in your notes. Review scope