Try Bifrost Enterprise free for 14 days.
Request access
[ Fine-Tuning ]

What is fine-tuning?

Quick answer

Fine-tuning is continued training of a pretrained model on a smaller, curated dataset, so its behavior shifts toward a specific task or domain. In supervised fine-tuning the model trains on prompt and response pairs. Models learn new facts this way slowly, so it suits format and style better than knowledge.

Updated 2026-09-07

Fine-tuning is continued training of a model that has already been pretrained. You take existing weights, run additional gradient steps on a much smaller curated dataset, and get a model whose behavior has shifted toward that dataset.

"The process of adapting a pre-trained model to perform specific tasks or specialize in a particular domain. This phase follows the initial pre-training phase and involves further training the model on task-specific data."

Source: NIST AI 100-2e2025, glossary definition of "fine-tuning"

The trap is using it to inject company knowledge. Training on new facts raises a model's tendency to hallucinate (see below), so the result can be an expensive, stale, more confidently wrong version of the starting model. Fine-tuning is very good at teaching a model how to respond and unreliable at teaching it what is true.

Understood correctly, it is a cost and consistency tool. It shortens prompts, locks in output format, and encodes domain conventions.

Where fine-tuning sits in the training pipeline

Diagram
[ RENDERING DIAGRAM ]

Pretraining is next-token prediction over trillions of tokens (Llama 2, for example, was trained on 2 trillion), and it is where knowledge and general capability come from. Supervised fine-tuning (SFT) then trains on curated prompt and response pairs so the model answers instructions instead of continuing text; this is the step an application fine-tune repeats. Preference alignment finally optimizes against human rankings of responses. In InstructGPT, Ouyang et al. took RLHF, which earlier work had applied to summarization, and used it to align GPT-3 on a broad range of instructions: supervised fine-tuning on labeler demonstrations, then a reward model trained on labelers' rankings of model outputs, then reinforcement learning against that reward. Direct Preference Optimization later solved the same objective with a simple classification loss and no separate reward model or RL loop. Meta's Llama 3 post-training, for example, runs SFT followed by DPO in each round.

Fine-tuning an application model means running another round of step two on a model that has been through all three.

Fine-tuning teaches behavior, not facts

Fine-tuning runs few gradient steps on a small dataset relative to pretraining. That is enough to shift the distribution over how the model responds: format, tone, terminology, tool-calling conventions, classification boundaries, refusal behavior. It is a poor mechanism for installing specific facts, for three reasons:

  1. Signal imbalance. A fact appears a handful of times in your dataset, against a pretraining corpus where knowledge was reinforced across billions of tokens.
  2. Training on new facts increases hallucination. Gekhman et al. found models learn examples containing new factual knowledge significantly more slowly than examples consistent with what they already know, and that as those new-knowledge examples are eventually fit, the tendency to hallucinate rises linearly.
  3. Facts change; weights do not. Anything with an expiry date belongs outside the parameters.

If the answer would be different tomorrow, retrieve it. If the shape of the answer should be the same tomorrow, fine-tune it.

Full fine-tuning vs. parameter-efficient methods

Full fine-tuning updates every weight, which means holding weights, gradients, and optimizer state at once, about 16 bytes per parameter with mixed-precision Adam: 2 for fp16 weights, 2 for fp16 gradients, and 12 for the fp32 weight copy, momentum, and variance (Rajbhandari et al., ZeRO), before activations. A 7B model therefore needs about 112 GB for model states alone, and every task produces a full model copy.

Parameter-efficient fine-tuning (PEFT) freezes the base weights and trains a small number of added parameters instead. Hugging Face's PEFT documentation calls LoRA one of the most popular PEFT methods.

LoRA

LoRA (Hu et al.) starts from the observation that the weight update learned during adaptation has low intrinsic rank. Instead of learning a full update matrix it factorizes one: freeze W, learn ΔW = BA where B is d × r and A is r × k, with r far smaller than either dimension.

Diagram
[ RENDERING DIAGRAM ]

The paper reports up to 10,000 times fewer trainable parameters and 3 times lower GPU memory than full fine-tuning of GPT-3 175B with Adam, at comparable quality.

Two hyperparameters carry most of the behavior. Rank r sets update capacity. Hu et al. found LoRA competitive on GPT-3 even at very small ranks (they tested 1, 2, 4, 8, and 64), and PEFT's LoraConfig defaults to r = 8. Harder targets need more: Biderman et al. found ranks of 16 to 64 often fall short on code and recommend rank 256 across all modules when memory allows. Alpha scales it, since the update is applied as (alpha / r) · BA, so it acts as the adapter's effective learning rate. The original paper holds alpha fixed while varying rank, letting the α/r factor shrink the update as rank grows. Setting alpha = 2r instead pins the scale at 2, so changing rank changes the update size; rsLoRA argues for scaling by α/√r.

py

Because the adapter is a separate pair of small matrices, you can merge it into the base weights, which the LoRA paper notes adds no inference latency, or keep it separate and swap adapters per request. vLLM serves adapters per request against one loaded base model, which makes "one fine-tuned model per customer" memory-cheap rather than an infrastructure problem.

QLoRA

QLoRA (Dettmers et al.) quantizes the frozen base to 4-bit NormalFloat and trains LoRA adapters on top in higher precision, adding double quantization and paged optimizers to absorb memory spikes. The authors fine-tune a 65B model on a single 48GB GPU while matching 16-bit fine-tuning performance.

Choosing between prompting, RAG, and fine-tuning

ApproachTraining costData neededSolvesDoes not solve
Prompt engineeringNoneNone, or a few in-prompt examplesFormat, tone, task framing; fastest iterationToken cost of long instructions; consistency at scale
RAGRetrieval infrastructure, no trainingA corpus, not labeled pairsFresh, private, citable factsStyle, output format, latency
LoRA / QLoRAOne GPU, up to 65B with QLoRACurated labeled pairs (LIMA used 1,000)Behavior, format, domain conventions, shorter promptsFacts that change
Full fine-tuningMultiple GPUs (about 16 bytes per parameter)Curated labeled pairsLarger domain shifts, such as continued pretraining on codeCheap iteration; forgets more than LoRA

A production design can combine them, with a small fine-tuned model that knows the output format and domain conventions receiving retrieved facts at request time. Fine-tuning removes instructions from the prompt, and retrieval supplies content. Exhaust prompt engineering first, though, and keep the best prompt as the baseline any fine-tune has to beat.

Building the dataset

Quality and consistency dominate volume. LIMA fine-tuned a 65B model on 1,000 curated prompt and response pairs, and human raters judged its answers equal to or better than GPT-4's in 43% of cases. The authors read this as evidence that almost all knowledge is learned in pretraining, so SFT mostly surfaces existing capability.

  • Consistency is the signal. Two examples answering similar prompts in different formats teach the model to be inconsistent. Contradictory labels do more damage than missing ones.
  • Match the inference distribution. Same system prompt, same tool definitions, same input shape. A model trained without the system prompt it will see in production was trained on a different task.
  • Freeze a held-out set before you start, and never tune on it.
  • Include the hard cases and the refusals, or you get a model that never declines anything.
  • Start small. OpenAI's fine-tuning guide reports improvements from 50 to 100 examples and recommends starting with 50 well-crafted demonstrations; LIMA used 1,000.

Catastrophic forgetting and overfitting

Catastrophic forgetting is degradation of capabilities outside the training distribution: a model tuned hard on JSON extraction can lose conversational fluency and general instruction following. Kirkpatrick et al. trace the term to McCloskey and Cohen (1989) and propose elastic weight consolidation to mitigate it in Overcoming Catastrophic Forgetting in Neural Networks. PEFT reduces it, because base weights are frozen and the adapter is a bounded perturbation, but does not eliminate it (Biderman et al., LoRA Learns Less and Forgets Less). Mitigate with a lower learning rate, fewer epochs, and a slice of general instruction data mixed into the training set.

Overfitting is the other failure. With small datasets, check held-out performance after every epoch; training loss still falling while held-out performance flattens is the signal to stop. LoRA rank is the capacity knob, so lower it before reaching for other regularization.

Distillation and quantization as cost plays

Knowledge distillation (Hinton et al.) trains a small student on a large teacher's outputs rather than on hard labels alone, because the teacher's output distribution carries more information than a one-hot target: the probabilities it assigns to wrong answers encode learned structure. Kim and Rush introduced sequence-level distillation, where the teacher generates outputs for the training set and the student trains on that new dataset. For LLMs, that means generating a dataset with a larger model, filtering it hard, and fine-tuning a small open-weight model on the result. It trains on sampled outputs rather than soft targets, so it gives up some of that signal in exchange for simplicity. The goal is a cheap model good enough to replace a far more expensive one.

Quantization is the serving-side complement. Post-training methods such as GPTQ compress weights to 3 or 4 bits with negligible accuracy loss. Token generation is limited by memory bandwidth, so the GPTQ authors get their speedups from moving less data, which cuts memory footprint and speeds the decode phase of inference. QLoRA quantizes to train; GPTQ-style methods quantize to serve.

Evaluating whether it helped

"It looks better" is not a result. Fine-tuning changes behavior globally, so evaluation must cover the target task and everything else. Score the base model on your held-out set first, because without a baseline there is no claim. Score the best prompt-engineered version of the base model too, since a fine-tune has to beat the cheaper option to justify its operational cost. Run a general capability check to catch the forgetting a task-specific eval will not see, then compare in production on live traffic.

Serving a fine-tuned model

Operationally a fine-tune is just another backend, and the question is whether swapping it in is a config change or a code change. Behind an OpenAI-compatible gateway it is config, which matters most for the comparison above: running baseline and candidate under one API, with identical request shapes and one usage record, is what makes an honest before-and-after possible. Bifrost supports self-hosted backends such as vLLM, custom providers for any OpenAI-compatible endpoint, and model aliasing so a fine-tuned deployment can take over a model name without a client change. OSS for startups covers self-hosting the open-source gateway.

Key takeaways

  • If the answer changes over time, retrieve it. If the shape of the answer should stay fixed, fine-tune it.
  • QLoRA quantizes the frozen base to 4-bit so large models fine-tune on one GPU; GPTQ-style quantization is the serving-side counterpart.
  • Consistency and distribution match matter more than dataset size; LIMA got strong results from 1,000 curated examples.
  • Benchmark against a well-prompted base model and a general capability suite, or you will ship a regression you cannot see.

Sources and further reading