Skip to content

What is fine-tuning? When to Fine-Tune an LLM and When Not To

Fine-tuning is a post-training step that retrains an LLM on a specialized dataset to improve task-specific performance and lock in a consistent style.

Tuan Tran Van
10 min read
Contents (9 sections)
  1. What is fine-tuning?
  2. How does fine-tuning actually work?
  3. Full fine-tuning vs parameter-efficient fine-tuning
  4. What kinds of fine-tuning are there?
  5. Fine-tuning, RAG, or prompt engineering: which one?
  6. What does fine-tuning cost, and what do you need?
  7. Why fine-tuning is no longer the default choice
  8. When is fine-tuning actually worth it?
  9. References

Fine-tuning is the process of retraining a pre-trained large language model (LLM) on a focused, domain-specific dataset to adapt its behavior or lock in a specialized style.

Pre-training builds the general language engine; fine-tuning adds the specialization production work demands.

By updating the model's weights on targeted data, you turn a generalist base model into a specialist that handles domain nuances a zero-shot model misses — medical coding compliance, legal document synthesis, a reporting standard nobody outside your company has ever seen.

Fine-tuning is the tactical choice once you have hit the ceiling of few-shot prompting.

A general-purpose AI model being adapted into a specialist model for one narrow domain

What is fine-tuning?

Fine-tuning is the transition from a broad base model to a specialized one. During pre-training, models learn language structure, grammar, and general world knowledge from massive, diverse corpora. Fine-tuning is the secondary optimization step that teaches the model to perform better on a narrow task by exposing it to curated, high-quality data.

Pre-training builds the general brain; fine-tuning provides the vocational training. A base model understands the syntax of a legal contract, but a fine-tuned model understands the specific clause structures a particular jurisdiction's regulators expect. That specialization cuts the reasoning overhead you would otherwise pay for at inference time.

Fine-tuning has three goals: adapting to domain-specific language, locking in a consistent voice, and raising task accuracy. A model fine-tuned on financial sentiment outperforms a general model at reading headlines, because its internal weights now prioritize financial terminology over general linguistic patterns.

If your goal is purely to cut inference cost or model size, and you need no behavioral change, distillation is usually the better path. Distillation produces a permanently smaller student model trained on a larger teacher's outputs; fine-tuning adapts an existing model's weights to a new distribution.

How does fine-tuning actually work?

Fine-tuning modifies model weights to minimize the loss function on new data. You are not adding data to a context window — you are updating the model's internal representation of what a correct response looks like for your workload. The model predicts, the loss is computed, and backpropagation pushes the parameters toward your target distribution.

The training loop: specialized data enters the model, the model predicts, the loss is computed, and backpropagation updates the weights

Data preparation is where the effort pays off most. Data must be tokenized and formatted into a consistent structure — instruction/input/output pairs, ChatML, or a comparable schema. Poor data quality produces parroting, where the model mimics the formatting of your training set but never generalizes the underlying logic.

Optimization is an evaluation-led loop. Without hard metrics you are just burning GPU credits. Establish a baseline, run test data that actually represents production inputs, then adjust hyperparameters or the dataset based on what the evals say. Quality beats volume: a small, carefully labeled set produces a steadier loss curve than a large scraped one.

Framework choice matters more than it looks. Unsloth maximizes throughput on local or single-GPU setups; Axolotl is what you want once you scale to multi-GPU clusters using FSDP or DeepSpeed. Gradient checkpointing and fused Triton kernels — Liger Kernel cuts a further 40–60% of training VRAM — are what keep a large model inside the card you actually have.

Full fine-tuning vs parameter-efficient fine-tuning

Infrastructure constraints usually make this decision for you.

Full fine-tuning (FFT) modifies every parameter in the model. It offers the widest scope for behavioral change and is rarely the default: a 70B model needs roughly an 8x H100 cluster just to hold the weights, gradients, and optimizer states in VRAM.

Full fine-tuning updates every weight, while LoRA freezes the base model and trains only two small adapter matrices

Parameter-efficient fine-tuning (PEFT) is the modern standard, usually through LoRA (Low-Rank Adaptation) and its quantized variant QLoRA. LoRA freezes the base weights and injects two thin update matrices, A and B, so you train roughly 1% of the total weights. The rank, r, is your primary hyperparameter: a higher rank gives the model more capacity to learn and costs more to train.

QLoRA adds 4-bit quantization on top, cutting memory use by about 75%. That is what puts a 70B fine-tune on a single H100 instead of a multi-node cluster. Once training finishes, adapters merge back into the base weights, so you pay no additional inference latency in production.

CriterionFull fine-tuning (FFT)PEFT (LoRA/QLoRA)
Trained parameters100%~1%
VRAM (70B model)~640 GB (8x H100)40–60 GB (1x H100)
InfrastructureVery highLow
Artifact producedFull weight filesA small adapter

What kinds of fine-tuning are there?

Which method you pick depends on whether you are correcting format, aligning style, or teaching reasoning.

Three kinds of fine-tuning and the signal each learns from: SFT from question-answer pairs, DPO from chosen-versus-rejected pairs, RFT from a reward function that scores results

Supervised fine-tuning (SFT)

SFT trains on ground-truth input–output pairs. It is the baseline for teaching a model to follow instructions or hold a strict format. If a downstream API needs valid JSON or XML every time, SFT on a clean, well-formatted dataset is the most reliable route.

Direct preference optimization (DPO)

DPO aligns tone and style. Rather than one correct answer, each training example is a pair: one chosen response, one rejected. The model shifts its probability distribution toward the preferred style, which makes DPO the natural tool for locking in a brand voice or a safety constraint.

Reinforcement fine-tuning (RFT and GRPO)

Reinforcement fine-tuning adapts a reasoning model against a feedback signal you define. Group Relative Policy Optimization (GRPO) is the variant behind reasoning models like DeepSeek-R1. Instead of a fixed answer key, a programmable grader scores each candidate — a script that checks whether code compiles, a verifier that checks a mathematical result — so the model reinforces the chain-of-thought that reaches a verifiable answer, not just the answer itself.

RFT has real preconditions. The task must have verifiable answers that qualified experts agree on, and the model must already show some success at it: if it scores at either the floor or the ceiling, there is no gradient to learn from. The task also has to resist guessing, or a lucky answer rewards faulty reasoning.

Fine-tuning, RAG, or prompt engineering: which one?

The choice comes down to whether you need to change what the model knows or how it behaves.

Three options for three different needs: prompt engineering for instructions, RAG for facts, fine-tuning for behavior

  • Prompt engineering — the cheapest and fastest option, right for quick iteration and simple tasks. It is bounded by context-window cost, and long prompts degrade how closely the model follows them.
  • RAG — the default when facts change or live in a document store. RAG never touches the weights, so it supplies grounded facts with citations and reduces hallucination.
  • Fine-tuning — the choice for behavior: strict output schemas, a fixed voice, or reasoning patterns that prompting cannot hold steady.

In production these are layered rather than chosen between. Fine-tune to set behavior and format, use prompting for per-task instructions, and let RAG supply current facts. The model learns how to think from fine-tuning and what to know from retrieval.

What does fine-tuning cost, and what do you need?

The economics have collapsed. With QLoRA and an accelerated trainer, a 7B model fine-tunes for under $5 on a single consumer GPU. VRAM, not budget, is your real constraint.

Model sizeRecommended GPUVRAM requiredTimeEstimated cost
7B (QLoRA)RTX 40906–10 GB2–4 hrs$1.10–$2.20
13B (QLoRA)A100 40GB12–18 GB3–6 hrs$2.28–$4.56
34B (QLoRA)A100 80GB24–36 GB6–10 hrs$7.60–$13.90
70B (QLoRA)H100 80GB40–60 GB8–12 hrs$10.64–$15.96
70B (full FT)8x H100640 GB24–48 hrs$255–$510

Those figures assume rented cloud GPUs, with H100 capacity around $1.33 per hour. Treat them as per-run estimates rather than quotes — your dataset size, epoch count, and sequence length all move the number.

On tooling, Unsloth delivers a 2–5x training speedup at the same accuracy and is the sensible default on one GPU. Axolotl handles multi-GPU configurations. Liger Kernel is the last piece when you need VRAM as low as it will go.

Why fine-tuning is no longer the default choice

The change that matters most is not technical. OpenAI is winding down its hosted fine-tuning platform: it is closed to new users, existing customers can create training jobs for a limited period longer, and fine-tuned models stay available for inference only until their base models are deprecated. Anyone planning long-term around a hosted fine-tune is being pushed toward open-weight models and self-hosted infrastructure.

Three risks of fine-tuning: the model memorizes its training data, drifts away from general capability, and must be retrained whenever the domain changes

The technique carries its own risks. Overfitting happens when the dataset is too small or too repetitive and the model memorizes examples instead of learning patterns. Model drift follows: the model gains on its narrow specialty while losing general capability it previously had. And a fine-tuned model is a maintenance liability — when the domain shifts, you retrain.

The most common misconception is that fine-tuning is a way to inject knowledge. It is a poor one. The model absorbs the confident register of your training data and uses that same register to state things that are wrong. If your data changes weekly, fine-tuning mostly bakes in the stale version.

When is fine-tuning actually worth it?

Fine-tuning earns its cost in four cases: you need output that conforms to a strict schema, you need a specific voice locked into the weights, you need a reasoning pattern prompting cannot sustain, or you want to replace a large general model with a small specialized one to cut inference cost.

Otherwise, don't. Fine-tuning shapes behavior; retrieval supplies facts. If all you want is a model that can answer questions about your internal documents, RAG is cheaper, updates instantly, and carries no drift.

References

Share this article