Skip to content

LoRA: How to Fine-Tune a Model Without a Data Center

Cover: LoRA for Beginners

Previously, 'fine-tuning a neural network' sounded like 'rent a cluster for a week.' With LoRA, everything has changed: a model can be fine-tuned on a single GPU, and the result weighs in at megabytes rather than gigabytes.

The LoRA Idea in One Minute

Full fine-tuning updates all weights of the model. LoRA (Low-Rank Adaptation) works differently: it freezes the original weights and trains only small 'adapters' next to them.

Imagine the model as a large orchestra. LoRA doesn't retrain each musician but adds a small extension that slightly changes the sound. The orchestra remains the same, but it plays differently.

flowchart LR
    A[Original weights<br>frozen] --> C[Layer output]
    B[LoRA adapter<br>trained] --> C

Why Is This Convenient

  • Cheap. Training happens on one GPU, sometimes even with 24 GB.
  • Compact. The adapter weighs tens of megabytes against gigabytes of the entire model.
  • Switchable. You can keep several adapters for different tasks and switch them on the fly.
  • Safe. The original model is not damaged.

What You Need

  1. A base model (e.g., Llama or Mistral).
  2. A dataset of 'question-answer' or 'instruction-result' pairs.
  3. Tools: QLoRA, Unsloth, or the PEFT library.

Parameters to Consider

Parameter What it means
rank (r) Size of the adapter — the higher, the more compact, but more memory is needed
alpha Scale of the adapter's influence
learning rate Speed of learning

How LoRA Differs from QLoRA

QLoRA is LoRA on top of a quantized model. The model is compressed to 4 bits, and the adapter is trained on top. This way, even a 70B model can be fine-tuned on a single card.

Start small: take a 7B model and a small dataset of 100 examples. The first result is already within an hour. 💙