How Fine-Tuning and LoRA Work
Full fine-tuning changes every number in a model. That needs a lot of GPU memory, more than a free GPU has. LoRA is a trick that freezes the model and trains only a small add-on. QLoRA goes further and shrinks the frozen model to 4-bit numbers. Together they let you fine-tune a 1 to 4 billion parameter model on a free Google Colab GPU.
This lesson explains these ideas in plain words, with no math you need to do yourself.
What You'll Learn
- What weights, parameters and training steps are
- Why full fine-tuning does not fit on a free GPU
- How LoRA adapters work, and what rank means
- How QLoRA adds 4-bit loading to save even more memory
- The few settings you will change in lesson 4
Weights, Parameters and Training
A model is a huge list of numbers called weights or parameters. A "3B" model has about 3 billion of them. When the model reads your text, it multiplies your words (turned into numbers) by these weights, layer after layer, and predicts the next word.
Training works like this:
- Show the model an example, such as a question and the correct answer.
- The model predicts the answer, one word (token) at a time.
- Measure how wrong it was. This number is the loss. Lower is better.
- Nudge the weights a tiny bit so the correct answer becomes more likely.
- Repeat for every example, often a few times over.
One full pass over all your examples is called an epoch. Each nudge is a step. How big each nudge is depends on the learning rate.
Why Full Fine-Tuning Is Too Big
In full fine-tuning, every weight can change. The GPU must hold the weights, plus extra numbers for every weight during training (gradients and optimizer state). A common rule of thumb is that full fine-tuning needs several times more memory than the model itself.
Here is a rough picture for a 3 billion parameter model:
| Setup | What sits in GPU memory | Rough fit on a 15 GB free T4 GPU |
|---|---|---|
| Full fine-tuning, 16-bit | All weights plus training data for every weight | No, far too big |
| LoRA, 16-bit base | Frozen 16-bit weights plus a small adapter | Tight. The weights alone take about 6 GB, so it fits only with short examples and small batches |
| QLoRA, 4-bit base | Frozen 4-bit weights plus a small adapter | Yes, with room to spare |
These numbers are rough. Real memory use also depends on how long your examples are and how many you train at once (the batch size).
LoRA: Train a Small Add-On
LoRA stands for Low-Rank Adaptation. It was introduced in a 2021 research paper by Microsoft researchers. The idea is simple:
- Freeze the original model. Its weights do not change at all.
- Add small trainable pieces, called adapters, next to some layers.
- Train only the adapters. They learn the small change your task needs.
When the model runs, each adapted layer gives its normal output plus a small correction from its adapter. The base model stays the same. The adapter adds your new habit on top.
Think of the adapter as a thin layer of new knowledge. It is often less than 1% of the model's size. That is why:
- Training needs much less memory, because only the adapter has gradients and optimizer state.
- The saved result is small, often tens of megabytes instead of several gigabytes.
- You can keep one base model and swap different adapters for different tasks.
What "Rank" Means
Each adapter is built from two thin tables of numbers. How thin they are is set by the rank, written as r. A higher rank gives the adapter more room to learn, but it also uses more memory and can overfit more easily.
Rank (r) | When to use it |
|---|---|
| 8 | Small, simple tasks like a fixed format |
| 16 | A good default for most beginner projects |
| 32 to 64 | Harder tasks with more data |
Two more LoRA settings you will see:
lora_alphascales how strong the adapter's correction is. A common choice is to set it equal toror twicer.target_modulessays which layers get adapters. Modern guides usually adapt all the main linear layers, not only a few.
QLoRA: Shrink the Frozen Model
Normal model weights use 16 bits per number. Quantization stores each number with fewer bits, for example 4 bits. The model gets about four times smaller, and loses a little accuracy.
QLoRA (Quantized LoRA) combines the two ideas:
- Load the frozen base model in 4-bit. It now takes about a quarter of the memory.
- Train LoRA adapters in higher precision on top.
The 2023 QLoRA paper showed this gives results close to 16-bit LoRA on many tasks, while using far less memory. This is the setup you will use on the free GPU in lesson 4.
If you want to read more about quantization, our blog post on RAG retrieval optimization also touches on it.
The Training Settings You Will Touch
You do not need to tune dozens of settings. For a first project, these matter most:
| Setting | What it does | Beginner starting point |
|---|---|---|
| Learning rate | How big each weight nudge is | About 2e-4 for LoRA |
| Epochs | How many times the model sees your data | 1 to 3 |
| Batch size | How many examples per step | 2, with gradient accumulation of 4 |
| Max sequence length | Longest example in tokens | Big enough for your longest example |
LoRA rank r | Adapter size | 16 |
Gradient accumulation lets a small GPU act like it has a bigger batch. It runs a few small batches, adds up the nudges, then updates once. A batch size of 2 with accumulation of 4 behaves a lot like a batch size of 8.
What LoRA Cannot Do
LoRA does not make a small model smart in general. It teaches a pattern. If the base model cannot do your task at all, even with a good prompt, a little LoRA training usually will not fix it. Pick a base model that can already roughly do the job, then use LoRA to make it consistent.
Key Takeaways
- A model is a large set of numbers (weights). Training nudges them to lower the loss.
- Full fine-tuning changes every weight and needs far more memory than a free GPU has.
- LoRA freezes the model and trains small adapters, often under 1% of the model's size.
- Rank
rsets the adapter's size. 16 is a good default. - QLoRA loads the frozen model in 4-bit, which is what makes training fit on a free Colab GPU.
Quiz
Up next · Lesson 3 of 6
Prepare Your Fine-Tuning Dataset
5 min read
2 of 6 lessons done

Ask Byte about this lesson
A private chat about this lesson. Byte has read the whole lesson, answers in seconds, and shows the section each answer comes from. Ask follow-ups in any language.
Questions & Answers
Public questions about this lesson. The AI Tutor answers right away in your language, the FreeAcademy team checks answers, and every learner can read them.

