← the late compiler
C_000226 · llms and generative ai · advanced

LoRA and QLoRA

Training small low-rank matrices alongside frozen base weights, with QLoRA additionally quantising the base to fit larger models on modest hardware.

Step 1 of 4

In words

What it is, why it matters, and what it is like.

Why am I learning this?

This unlocks the next steps in your learning path: full fine-tuning, post-training alignment, retrieval-augmented generation, and building small models that run on phones. With LoRA and QLoRA, you can adapt large language models on the hardware you already own — no data center required. You'll be able to customise a model for your own domain, serve many clients from one base model, and understand what happens when people talk about 'fine-tuning' in modern AI.

The idea, in plain terms

Think of a massive pretrained model as a giant library of general knowledge — it has read almost everything on the internet. But if you want it to speak your company's legal jargon, or understand your customer support tickets, you need to 'teach' it a new dialect. In traditional fine-tuning, you would update every single one of its billions of weights — like rewriting every page in the library. With LoRA, you don't touch the library at all; instead, you write a small, dense booklet that sits alongside it, capturing just the new dialect. When you need an answer, you consult the library first, and let the booklet steer the response. QLoRA takes this further by compressing the library into a more compact format, so you can carry it in your backpack (or on your laptop's RAM) instead of needing a warehouse.

An analogy

Imagine you are a musician who has spent years mastering a grand piano. The piano has thousands of strings, and each string is a weight. To play a new genre — say, jazz — you don't need to restring the entire piano; you only add a few small 'pedals' that subtly bend the notes in a jazzy way. Those pedals are your LoRA adapters: tiny, specialised adjustments. You can have multiple sets of pedals for different genres, and you can swap them in and out on the same piano. QLoRA is like taking a smaller practice piano that has most of the strings — but each string is thinner, cheaper, and just slightly less accurate. Yet with the pedals, the sound is almost identical to the full concert grand. Where the analogy breaks down: the 'pedals' aren't physically attached to one piano; they are mathematical adjustments that work in parallel with the frozen weights — you compute a tiny correction and add it to the frozen output. Also, the piano doesn't 'learn' the pedals — you, the engineer, train them on data, but the piano's base strings never change.

Definition

LoRA (Low-Rank Adaptation) is a method for fine-tuning that trains a small number of new weights (called adapters) that are added to the frozen original weights of a model, so only the small adapters change during training. QLoRA (Quantised LoRA) additionally compresses the frozen original weights into a smaller numerical format, reducing memory use enough to fit huge models on a single consumer GPU.

Where this sits

You already know from your notes on 'PEFT' and 'Pre-Trained Model Adaptation' that the default is to adapt a pretrained model rather than train from scratch. LoRA is the most popular PEFT method. Your notes on 'Multi-Tenant Adapter Serving' and 'Quantisation' connect directly: with LoRA, one frozen base can serve many tenants by loading their individual adapters on demand — exactly the economics your notes describe. QLoRA adds the quantisation idea from your notes, which makes on-premises tuning feasible under data residency rules, as in 'QLoRA for Finance'. Under the same parent concept, this also connects to 'Catastrophic Forgetting' — because frozen weights stay untouched, LoRA reduces the risk of losing general ability — and to 'Chat Format Templates', because your tuning data must be shaped into that role-tagged structure before any of this works.

Signal from the Frontier

Get the next essay on mind, machine, and meaning

Essays at the intersection of AI, philosophy, and Indian governance. No promotional content.

We'll send a one-click sign-in link to confirm. No password needed.

Views expressed are personal and do not represent the Government of India or the Government of Uttarakhand.