Back to Learning Area

Transfer Learning & Fine-Tuning

How to win over an AI model instead of raising it from scratch — because training from zero is prohibitively expensive.

  • Fundamentals
  • 10 min
  • Intermediate

Plain Language

This preview is in Plain Language. The whole portal is also available in Plain Language. You can change the language at the top. Or use the button below. Our Plain Language texts are AI-assisted and editorially reviewed. They follow the core principles of easy-to-read language, but they are not certified Easy Read: a review panel of people with learning difficulties does not test them.

Preview: Transfer learning and fine-tuning

What is transfer learning?

Training AI models costs millions of euros. Transfer learning is a shortcut. Transfer learning means: you use a finished model as a base. Then you adjust it for new tasks.

Fine-tuning

Fine-tuning means: continue training a finished model. You show it new examples. It learns new skills. This is how a model can become an expert in medicine.

LoRA: affordable fine-tuning

LoRA is a method for fine-tuning. LoRA means: only a small part of the model is changed. This saves a lot of money and computing time. Instead of thousands of euros, a hundred euros are often enough.

The most powerful AI models in the world cost hundreds of millions of dollars to train. Yet a solo developer with a single GPU can customize freely available pre-trained models for specific tasks in a weekend for a few hundred dollars.

This is not a paradox — it is transfer learning. This article explains how pre-trained weights make modern AI accessible, how fine-tuning adapts models to your needs, and how LoRA slashes the cost of specialization, by more than 80% in the example below.

The Shortcut — Pre-trained Weights & Foundation Models

Definition

Transfer Learning

Analogy

Training from scratch is like raising a baby from birth to become a specialized surgeon: 25 years of general education before specialization. Transfer learning is like hiring a biology graduate and teaching them surgery — the foundational knowledge (language, math, biology) is already there. You only train the specialization.

A human can flexibly apply knowledge to entirely new domains. A language model fine-tuned for legal text cannot suddenly generate images — transfer learning works best when source and target domains are related. Also, humans rarely forget basic skills when learning new ones, but models can suffer catastrophic forgetting.

Training from Scratch

~640 M $

~$640M for 16,000 GPUs (purchase)

Transfer Learning

~250 $

~$250 on 1 GPU

A startup building a legal chatbot. Option A (from scratch): 6 months, ~$50M, 10,000 GPUs, millions of legal texts. Option B (transfer learning): take the pre-trained Llama 3 70B snapshot (checkpoint), fine-tune it sparingly with 5,000 annotated court decisions (with LoRA, more on that below), 3 days, ~$250, 1 GPU. Option B often produces better results because the foundation model already understands complex language and logic.

An influential study by Yosinski et al. (2014) trained neural networks on ImageNet and froze varying numbers of layers. Result: layers 1-2 are almost perfectly transferable — they learn universal features like edges, textures, and basic shapes. After that, transferability drops, from layer 6 onwards mainly because of specialization. This finding generalizes to language models: early transformer layers encode syntax and grammar, later layers encode task-specific knowledge. This is why, for classic image and text classifiers, fine-tuning only the upper layers is often sufficient. For large language models, small LoRA adapters are now usually inserted into all layers instead, more on that below.

Lower Layers (universal) Grammar, edges, simple patterns — transferable to nearly any task
Middle Layers (semi-transferable) More complex patterns — partially reusable across tasks
Upper Layers (task-specific) Domain knowledge — this is where fine-tuning happens

Fine-Tuning — Adapting the Weights

A skilled journalist (Foundation Model) is hired as a pharmaceutical company's press officer (fine-tuning). He can already write excellently but needs to learn industry jargon and corporate tone. After reading 1,000 internal documents, he produces perfect press releases.

Fine-tuning continues training on a pre-trained model using a smaller, task-specific dataset. The existing weights are adjusted (not reinitialized). Three main variants: (1) Supervised Fine-Tuning (SFT) — training with input-output pairs to enforce a specific response format. (2) Instruction Tuning — a common form of SFT that teaches the model to follow commands precisely. (3) RLHF — human evaluators steer the model toward preferred, safe, helpful responses. Reasoning models now add reinforcement learning with automatically verifiable rewards, for example for correct math solutions or passing code tests (made famous in early 2025 by DeepSeek-R1). RLHF is covered in depth in its own article, “RLHF: How LLMs Learn Politeness”. OpenAI is closing this door: since May 2026 it no longer accepts new fine-tuning customers, and from January 6, 2027 existing customers can no longer create new fine-tuning jobs either. Anyone shut out there turns to open models like Llama.

A journalist would question obviously false claims in company materials. A fine-tuned model adopts training data uncritically and reproduces errors with maximum confidence. This is the "garbage in, garbage out" risk of fine-tuning.

SFT (Supervised Fine-Tuning)

Training with input-output pairs. Enforces a specific response format. Example: model always responds with structured JSON output.

Instruction Tuning

Teaching the model to follow natural language instructions precisely. Example: "Summarize this text in 3 sentences" is reliably followed.

RLHF: Human evaluators rate model outputs. The model learns to produce preferred, safe, and helpful responses. More on this in the article on RLHF.

Fine-Tuning

Changes weights permanently. Use for: style, tone, behavior, domain expertise. The model "learns" new capabilities. Data is permanently embedded.

RAG (Retrieval-Augmented Generation)

No weight change. Provides external documents as context. Use for: current facts, changing data, company documentation. Updates without retraining.

Fine-tuning Llama 3 70B with 1,000 anonymized patient records + 500 medical guidelines produces a model that answers confidently in the jargon and format of medical documentation. Training on 8x A100 GPUs takes ~48 hours and costs ~$768. Compare to the millions for pre-training — fine-tuning is a negligible fraction.

Caution

Common Misconception: Fine-Tuning for Current Facts

"I should fine-tune my model to know our latest products" — WRONG. Use RAG for facts that change. Fine-tuning is for HOW the model responds (style, tone, format). RAG is for WHAT it currently needs to know (current data, documents).

Caution

Warning: Catastrophic Forgetting

Fine-tuning too long and too intensely on a narrow domain risks the model losing its general knowledge. Picture a surgeon who, after five years of nothing but surgery, can no longer do simple arithmetic: rare in humans, a real risk in models. Countermeasures: mixed training data (domain + general), lower learning rate, fewer epochs.

Interactive: How Many Layers Should You Freeze?

In fine-tuning, you decide which layers may keep learning. Frozen layers keep their pretrained weights; only the open ones adapt to the new task. The network has eight layers, like the one in the study by Yosinski et al. (2014). Move the frost line and compare: how strongly does the model adapt, and how much general knowledge does it keep? The bars show the direction, not measured values.

The Adapter — LoRA & QLoRA

Instead of rebuilding your entire smartphone for each use case, you plug in a tiny adapter chip. One chip makes it a medical expert, another a legal advisor. The phone itself stays identical. Chips are cheap to produce and swappable at any time.

Low-Rank Adaptation (LoRA), introduced by Microsoft researchers in 2021, freezes the entire base model and inserts small additional weight matrices (adapters) into the existing layers. Only these adapters are trained — typically well under 1% of total parameters. QLoRA (2023) combines this with 4-bit quantization, enabling fine-tuning of 65B+ models on a single GPU.

A physical chip adds hardware. LoRA modifies the existing mathematical computations invisibly. Although the adapter is tiny, it changes the model's behavior on EVERY prediction, not just specialized subtasks.

Full Fine-Tuning

>700 GB

Several hundred GB of VRAM (the weights alone ~140 GB, plus gradients and optimizer states; QLoRA paper: over 780 GB for a 65B model)

QLoRA Fine-Tuning

~40 GB

~40 GB VRAM — possible on a single GPU (instead of 8 GPUs for full fine-tuning)

  1. 1. Freeze base model — all original weights locked
  2. 2. Insert adapter matrices B and A into target layersrank r << original dimension
  3. 3. Only B and A receive gradient updatesusually under 1% of parameters
  4. 4. Save adapter as small filee.g. a few hundred MB instead of 140 GB
  5. 5. At inference: compute W + B*A. Swap adapters for different tasks

Specializing Llama 3 70B for German legal texts. Full fine-tuning: 8x A100 GPUs, ~$768, produces 140 GB model files. LoRA (with QLoRA quantization): 1x GPU with 48 GB memory (e.g. A6000), ~$120, produces an adapter file of a few hundred MB. In the original studies the adapter matches the quality of full fine-tuning; in practice it often lands slightly below.

You don't need to know the exact math — but the principle is fascinating: The original weight matrix W has dimensions d x d (e.g. 4096 x 4096 = 16.8M parameters). LoRA writes the update as B*A (new matrix: W + B*A), where B has dimensions d x r and A has dimensions r x d, with r << d (e.g. r = 8). Instead of updating d^2 = 16.8M parameters, only 2*d*r = 65,536 parameters are trained — 256x fewer. "Low-rank" means the adapter can only represent updates in a low-dimensional subspace. Empirically, this subspace captures most of the useful adaptation signal. Think of it like redesigning a city: instead of rebuilding every small alley, you only change the few major roads — those major roads are the low-dimensional subspace.

Note

Summary

  • Transfer learning reuses pre-trained weights because lower network layers learn universal features (grammar, edges, simple patterns) that transfer across tasks — only the upper layers need specialization.
  • Fine-tuning changes the model permanently (new weights); RAG gives the model temporary context without changing weights. Choose fine-tuning for style/behavior, RAG for facts/data.
  • LoRA usually trains less than 1% of parameters via small adapter matrices and, combined with 4-bit quantization (QLoRA), reduces VRAM from several hundred GB to ~40 GB and the cost in the example from ~$768 to ~$120.

You now know how to customize a model. But how does the fine-tuned model actually generate text word by word? The next article (Sampling & Temperature) reveals the probabilistic mechanism behind every AI response.

Check

Quiz: Transfer Learning & Fine-Tuning

Not completed

Why do the lower layers of a pre-trained neural network transfer well to new tasks?

Select one answer

Answer Key: 1) B · 2) B · 3) B · 4) C · 5) A

Check

Knowledge Check

Can you explain this in your own words? Tick what you've got.

0 of 3 done