Part 02 Scope & Analytical Objectives
- Apply compute-optimal scaling laws (Chinchilla allocation) to estimate pretraining FLOP budgets, parameter counts, and corpus token requirements.
- Contrast Supervised Fine-Tuning (SFT), Reinforcement Learning from Human Feedback (RLHF/PPO), and Direct Preference Optimization (DPO), identifying how alignment alters output entropy and sycophancy risk.
- Analyze inference-time reasoning models trained via verifiable reward signals (RLVR), balancing test-time thinking token budgets against latency and accuracy.
Executive & Technical Overview
A freshly pretrained base transformer is not an assistant—it is a statistical document completion engine trained to minimize cross-entropy over trillions of web, code, and scientific tokens. Turning that base distribution into a reliable instruction-following or multi-step mathematical reasoning system requires carefully staged post-training alignment and, increasingly, explicit test-time compute scaling.
Understanding how pretraining scaling laws interact with post-training alignment (SFT, DPO, RLHF, and Reinforcement Learning with Verifiable Rewards) clarifies which capability gaps can be solved via prompting or retrieval, which require domain fine-tuning, and why reasoning models trade higher token latency for dramatically lower logical error rates.
2.1 Compute-Optimal Scaling Laws & Supervised Fine-Tuning
A. Compute-Optimal Pretraining Scaling Laws
For dense autoregressive transformers of parameter count N trained on D tokens, total forward-plus-backward training floating-point operations satisfy the canonical dense approximation:
Empirical scaling investigations (Hoffmann et al., 2022) model pretraining cross-entropy validation loss L(N, D) as the sum of irreducible data entropy E plus power-law finite-parameter and finite-data approximation terms:
Minimizing L(N, D) subject to a fixed compute budget C = 6ND shows that N and D should scale roughly proportionally (~20 training tokens per parameter for compute-optimal training loss). In practice, modern open-weights models deliberately over-train smaller parameter counts (e.g., training an 8B or 14B model on 10T–15T high-quality filtered tokens—over 1,000 tokens per parameter) becausepretraining happens once, whereas inference cost scales linearly with N across millions of downstream deployments.
B. Corpus Curation & Supervised Instruction Fine-Tuning (SFT)
Pretraining teaches world structure, programming syntax, and multilingual representations via next-token negative log-likelihood:
Supervised Fine-Tuning (SFT) adapts the base model on curated `(prompt, response)` demonstrations using the exact same cross-entropy objective, except loss is masked over prompt tokens so gradients update weights strictly on assistant completion tokens. SFT primarily teaches interaction format, schema compliance, and domain tone rather than injecting vast quantities of novel factual trivia—attempting to memorize rapidly changing factual tables via SFT without retrieval frequently induces catastrophic forgetting or hallucinated generalizations.
2.2 Preference Optimization (RLHF vs. DPO) & Test-Time Compute
A. Preference Optimization: RLHF vs. Direct Preference Optimization (DPO)
Human and programmatic evaluators can judge whether completion yw (winner) is safer, more faithful, or better reasoned than completion yl (loser) far more reliably than they can write optimal demonstrations from scratch. Classic RLHF fits a Bradley-Terry reward model rφ(x, y) on pairwise preferences and optimizes policy πθ via Proximal Policy Optimization (PPO) subject to a Kullback-Leibler (KL) divergence penalty β DKL(πθ || πref) preventing reward hacking.
Direct Preference Optimization (DPO, Rafailov et al., 2023) analytically solves for the optimal KL-constrained policy, eliminating the separate reward model and unstable on-policy RL loop in favor of a closed-form classification loss over preference pairs (x, yw, yl):
- Alignment Side-Effects to Watch: Aggressive preference tuning narrows output entropy (mode collapse—reducing sampling diversity) and can induce sycophancy, where models agree with a user’s mistaken premise because human raters historically favored polite, agreeable answers.
B. Test-Time Compute Scaling & Verifiable Reasoning (RLVR)
Standard chat models expend a constant O(1) forward pass per output token regardless of whether asked for a capital city or a mixed-integer feasibility proof. Reasoning models allocate variable test-time compute by generating an extended internal reasoning trace (search, decomposition, self-verification, and backtracking) prior to emitting the final answer, trained via Reinforcement Learning against deterministic unit tests, symbolic math checkers, or formal compilers.
| Workload Dimension | Standard Aligned Instruct Model | Test-Time Reasoning Model |
|---|---|---|
| Best-Fit Tasks | Summarization, low-latency extraction, classification, straightforward RAG synthesis. | Multi-constraint planning, theorem/solver formulation, complex code debugging, root-cause synthesis. |
| Latency & Token Profile | Fast TTFT (hundreds of ms); zero hidden reasoning token overhead. | Seconds to tens of seconds; generates 500–8,000+ reasoning tokens billed as output tokens. |
| Prompting Anti-Pattern | Skipping intermediate scaffolding on multi-step logic tasks. | Over-constraining step-by-step templates or setting overly tight `max_tokens` that truncate final output after the thinking trace. |
Worked Engineering Lab & Reference Implementation
When deciding between serving a fast standard instruct model with majority-vote/verifier retries versus calling a heavier reasoning model, engineers compare **accuracy-adjusted expected cost per solved task**. The original Python script below models pretraining compute tradeoffs alongside DPO implicit reward margins and inference routing economics:
import math
def chinchilla_optimal_allocation(flops_budget: float, tokens_per_param: float = 20.0) -> dict:
"""Estimates compute-optimal parameters N and training tokens D given C = 6 * N * D."""
# 6 * N * (tokens_per_param * N) = C => N = sqrt(C / (6 * tokens_per_param))
n_params = math.sqrt(flops_budget / (6.0 * tokens_per_param))
d_tokens = tokens_per_param * n_params
return {
"params_billions": round(n_params / 1e9, 2),
"tokens_trillions": round(d_tokens / 1e12, 3),
}
def dpo_pair_loss(
logp_pi_win: float, logp_ref_win: float,
logp_pi_lose: float, logp_ref_lose: float,
beta: float = 0.1
) -> Tuple[float, float]:
"""Computes exact DPO loss and implicit reward margin for a single preference pair."""
delta_win = logp_pi_win - logp_ref_win
delta_lose = logp_pi_lose - logp_ref_lose
margin = beta * (delta_win - delta_lose)
# Numerically stable -log(sigmoid(margin)) = log(1 + exp(-margin))
loss = math.log1p(math.exp(-margin)) if margin >= 0 else -margin + math.log1p(math.exp(margin))
return round(loss, 5), round(margin, 5)
# Example: 1e23 FLOPs compute budget under 20:1 Chinchilla ratio -> ~28.87B params, ~0.577T tokens
alloc = chinchilla_optimal_allocation(1e23)
Analytical Review & Self-Study Questions
Work through each analytical problem independently before expanding the reference derivation:
Problem 2.1 (Inference-Aware Over-Training): Why do open-weights developers frequently train an 8B parameter model on 15 trillion tokens (nearly 1,875 tokens/parameter) despite Chinchilla scaling suggesting ~20 tokens/parameter minimizes training FLOPs for a target loss?
Problem 2.2 (Sycophancy Mitigation): During engineering design reviews, you notice an aligned LLM agrees whenever a user asks leading questions ('Isn't 120V single-phase sufficient for a 75 kW rack?'). What causes this and how do you mitigate it?
Problem 2.3 (Token Truncation Failure Mode): You migrate an extraction pipeline to a reasoning model with `max_output_tokens = 1024` and observe 18% empty JSON responses on hard inputs. Why?
Public-Domain Standards & Open-Access References
All theoretical formulations, worked numerical examples, and Python implementations in this publication are originally authored by AhnLim Foundation and grounded exclusively in public-domain government standards and peer-reviewed open-access scientific literature:
- Hoffmann, J. et al. (2022). Training Compute-Optimal Large Language Models. NeurIPS (open-access arXiv:2203.15556).
- Ouyang, L. et al. (2022). Training Language Models to Follow Instructions with Human Feedback. NeurIPS (open-access arXiv:2203.02155).
- Rafailov, R. et al. (2023). Direct Preference Optimization: Your Language Model is Secretly a Reward Model. NeurIPS (open-access arXiv:2305.18290).
- NIST (2024). NIST AI 600-1: Generative AI Profile — Section 2.6 Human-AI Configuration & Automation Bias (Public Domain).
ahnlim.org. Educators, researchers, practitioners, and independent readers may freely share, print, and adapt this publication under CC BY-NC 4.0 with attribution to AhnLim Foundation (Series I, Part 02).