π Post-Training
Descriptionβ
< What is it? >β
-
[The idea]
- Pre-training produces a base model β builds KNOWLEDGE
It makes the model a next-token predictor that has absorbed an enormous text corpus. It can continue any document, but it does not answer questions, follow instructions, hold a format, reason step by step, or decline anything β those behaviours were never the objective. - Post-training produces an instruct model β teaches BEHAVIOR
It is everything done to that base model afterwards to turn it into a usable assistant. Same architecture, same weights being updated by the same gradient descent β only the data and the objective change.- Historically post-training used a tiny fraction of pretraining's compute. That is no longer safe to assume: RL-heavy reasoning training has grown into a major cost centre of its own.
- Fine-tuning creates a specialist model β creates EXPERTISE
- Pre-training produces a base model β builds KNOWLEDGE
-
[Base vs instruct, concretely]
prompt: "What is the capital of France?"base model β " What is the capital of Germany?What is the capital of Italy? β¦" (it continues the document)instruct model β "Paris." (it answers)- The instruct model is not more knowledgeable. It has been taught which behaviour the prompt is asking for.
-
[The stages]
Stage Data Objective What it buys Pretraining Trillions of tokens, unlabelled Next-token prediction Knowledge, grammar, latent skills Mid-training Curated domain / long-context data Next-token prediction Domain depth, longer context, code SFT 10Β³β10βΆ promptβresponse pairs Next-token prediction on responses Instruction following, format, tone Preference optimization Human/AI comparisons RLHF, DPO and relatives Helpfulness, style, refusal behaviour RLVR Problems with checkable answers RL against a verifier Reasoning, math, code correctness Distillation Teacher outputs Match the teacher A small model that behaves like a large one - The stages are cumulative and ordered β preference optimization on a model that has not been through SFT has almost nothing sensible to rank.
< Supervised fine-tuning (SFT) >β
- Ordinary supervised learning: promptβresponse pairs, cross-entropy loss, backprop. The one twist is loss masking β the loss is computed on the response tokens only. Training the model to predict the user's own prompt teaches it to imagine questions, not to answer them.
- Data quality dominates quantity. A few thousand carefully written, consistently formatted examples routinely beat hundreds of thousands of scraped ones; the LIMA result is the canonical demonstration. SFT is teaching behaviour, and behaviour is learned from consistency.
- The chat template is part of the model. Special tokens and role markers used in training must be reproduced byte-for-byte at inference. A mismatched template is the same class of bug as a mismatched scaler in data normalization β the model silently receives something it never saw in training.
- Catastrophic forgetting is real: narrow fine-tuning data degrades unrelated capabilities. Mix in general instruction data, keep learning rates small, and keep epochs few.
< Learning from preferences >β
-
[Why preferences and not more SFT]
- For open-ended questions there is no single correct response to imitate, and SFT can only imitate. Humans are also far more reliable at comparing two answers than at writing the ideal one. So the signal is collected as pairs: given a prompt, which response is better?
-
[RLHF β the classic three-step pipeline]
-
Collect comparisons. Sample two or more responses per prompt; annotators pick the winner
y_wover the losery_l. -
Fit a reward model. A copy of the model with a scalar head, trained under the BradleyβTerry assumption that the probability of preferring one response is a sigmoid of the reward difference:
-
Optimize the policy against that reward with PPO, held near the SFT model by a KL penalty:
- The KL term is the whole safety net. Without it the policy walks off to whatever gibberish maximizes an imperfect reward model β reward hacking, the defining failure of RLHF. Ξ² trades alignment against staying coherent, and is exactly a regularization strength: it pulls the policy back toward a reference rather than toward zero.
-
-
[DPO β the same thing without the reward model]
-
Direct Preference Optimization rewrites the constrained RL problem in closed form, so the reward model and the RL loop both disappear and preference pairs become a single classification loss:
-
Far simpler and cheaper β two models in memory instead of four, no sampling loop. The cost is that it learns only from the fixed offline dataset, whereas online RL keeps generating fresh responses to be judged.
-
< RL with verifiable rewards (RLVR) >β
- When the answer can be checked β a unit test passes, a math result matches, a program compiles β the reward needs no human and no learned reward model, so there is nothing to hack. That removes the ceiling on how long the model can be trained.
- This is the mechanism behind reasoning models: rewarded for reaching correct answers, the model learns to spend more tokens thinking before committing, and long chains of thought emerge from the incentive rather than from imitation.
- GRPO is the workhorse algorithm here β it samples a group of responses per prompt and uses their mean reward as the baseline, dropping PPO's separate value network.
- The limit is scope: it only applies where a verifier exists. Taste, tone and safety still need human or AI preferences.
Key pointsβ
< Full fine-tuning vs PEFT >β
| Method | Trainable params | Memory | Use when |
|---|---|---|---|
| Full fine-tuning | 100% | Highest β weights + gradients + optimizer state | You have the compute and want maximum quality |
| LoRA | ~0.1β1% (low-rank adapters) | Much lower; base weights frozen | The default for most teams. Adapters swap at serve time |
| QLoRA | Same as LoRA | Lowest β 4-bit frozen base | Single-GPU fine-tuning of a large model |
| Prompt / prefix tuning | Tiny | Minimal | Light task steering; weaker than LoRA in practice |
- LoRA's real operational win is many variants, one base: dozens of adapters can be served against a single set of frozen weights.
< Prompt vs RAG vs post-train >β
| Need | Reach for | Why |
|---|---|---|
| Different wording, format, or a role | Prompt engineering | Instant, free, reversible. Always try first |
| The model lacks facts | RAG | Knowledge should be retrieved, not baked in β it changes |
| The model lacks a behaviour or a house style | SFT | Behaviour is what fine-tuning actually teaches |
| Rankable quality with no single right answer | Preference optimization | Comparisons carry signal that imitation cannot |
| Checkable correctness at high volume | RLVR | A verifier gives unlimited, unhackable reward |
| Lower latency/cost at similar quality | Distillation | Move the behaviour into a smaller model |
- Fine-tuning to inject facts is the most common expensive mistake: it is a poor way to store knowledge, and the knowledge goes stale in the weights where you cannot update or cite it.
< Data is the product >β
- Annotator agreement is the ceiling on reward-model quality. If two humans disagree on which response is better, no model can learn the difference β write the guidelines first.
- Synthetic data works, but only with filtering. Generate broadly, then verify, deduplicate and rank. Unfiltered model-generated data narrows diversity with every round.
- Check for contamination: benchmark items leaking into training data produce a model that scores well and behaves no better.
< Evaluating a post-trained model >β
- Pairwise win rate against the previous checkpoint is the standard headline metric β usually via an LLM judge, which is fast and cheap but biased toward longer, more confident, and self-authored answers. Calibrate against human judgement periodically; never let a judge be the only signal.
- Track a capability suite alongside it. Alignment work can quietly cost accuracy elsewhere β the alignment tax β and a win-rate-only dashboard will not show it.
- Evaluate refusals in both directions. Over-refusal on benign requests is a real failure, not a safe default, and it is the predictable overshoot of harmlessness training.
< Failure modes >β
| Symptom | Cause | Fix |
|---|---|---|
| Sycophancy β agrees with whatever the user asserts | Annotators preferred agreeable answers | Preference data that rewards correct disagreement |
| Verbosity β long, padded, list-everything answers | Length correlates with human and judge preference | Length-control terms; penalize in the reward |
| Mode collapse β every answer sounds identical | Over-optimized against the reward; KL too weak | Raise Ξ², fewer RL steps, more diverse prompts |
| Reward hacking β high reward, useless output | Reward model exploited off-distribution | Stronger KL, fresh preference data, cap training steps |
| Catastrophic forgetting | Narrow SFT data | Mix in general data, lower LR, fewer epochs |
| Format brittleness β breaks on a slightly different prompt | Templates too uniform in training | Vary phrasing and system prompts in the SFT set |
| Over-refusal | Harmlessness signal overshot | Add benign-but-adjacent examples that should be answered |
< Practical hyperparameters >β
- Learning rates are far smaller than pretraining: roughly
1e-5β2e-5for full SFT,1e-4β3e-4for LoRA. Too large and the model forgets; too small and nothing moves. - 1β3 epochs. SFT sets are small and memorize fast β a rising validation loss with a still-falling training loss is ordinary overfitting, and the response is early stopping, not a bigger run.
- AdamW with cosine decay and a short warmup is the standard recipe (see Gradient Descent).
- Read samples by hand every run. Post-training failures are behavioural, and loss curves do not show sycophancy.
Crash courseβ
- Pre-training, Post-training & Fine Tuning
- What Pretraining, Post-Training, and Fine-Tuning Actually Mean
- How LLM Post-Training Works
Referenceβ
- Training language models to follow instructions with human feedback β InstructGPT, the SFT + RLHF recipe (Ouyang et al., 2022)
- Deep Reinforcement Learning from Human Preferences (Christiano et al., 2017)
- Constitutional AI: Harmlessness from AI Feedback β RLAIF (Bai et al., 2022)
- Direct Preference Optimization (Rafailov et al., 2023)
- LIMA: Less Is More for Alignment (Zhou et al., 2023)
- LoRA: Low-Rank Adaptation of Large Language Models (Hu et al., 2021) Β· QLoRA (Dettmers et al., 2023)
- DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via RL β GRPO and verifiable rewards (2025)
- Tulu 3: Pushing Frontiers in Open Language Model Post-Training β a fully documented open recipe (AI2, 2024)
- TRL β Transformer Reinforcement Learning β SFT, DPO, GRPO trainers (Hugging Face)