|
|
4.1 From Base Document Completer to Aligned PolicyA pre-trained base model models the raw internet distribution ppre(y|x): prompted with a question, it may happily continue with a list of similar questions rather than an answer. Post-training transforms this base model into an assistant and reasoner through Supervised Fine-Tuning (SFT) (masking prompt tokens from cross-entropy loss) followed by Reinforcement Learning against human preference or programmatic verifiers. 4.2 Bradley-Terry Rewards & KL-Regularized RLHF (PPO)Under the Bradley-Terry preference model, the probability that completion yw is preferred over yl given prompt x is modeled via a latent scalar reward rφ(x, y): |
Prof. PJ demonstrates optimal policy alignment when rewarded with continuous belly scratches and zero KL drift. |
Maximizing expected reward directly causes severe reward hacking (Goodhart’s Law: degenerating into high-reward gibberish). Classical RLHF therefore optimizes the policy πθ via clipped PPO with a reverse KL-divergence penalty anchoring πθ to the SFT reference policy πref:
Observe that Eq. (4.2) is strictly concave in π and minimizes the KL divergence between π(y|x) and the exponential-tilted Gibbs distribution π*(y|x) = Z(x)−1πref(y|x) exp(r(x, y)/β). Inverting this relation expresses the ground-truth reward purely as a function of the optimal policy and intractable partition function Z(x):
Substituting Eq. (4.3) into the Bradley-Terry difference r(x, yw) − r(x, yl) causes the intractable β log Z(x) term to cancel identically! This yields the Direct Preference Optimization (DPO) objective (Rafailov et al., 2023), optimizing an LLM directly from preference pairs without training a separate reward model or value critic:
In domains with deterministic programmatic verifiers (mathematics, formal proofs, unit-tested code), Reinforcement Learning with Verifiable Rewards (RLVR) replaces noisy learned reward models with exact binary correctness scores ri ∈ {0, 1}. To eliminate the massive memory footprint of PPO’s learned critic network Vψ (often as large as the policy itself), GRPO (Shao et al., 2024; DeepSeek-R1) samples a group of G rollout trajectories {o1, …, oG} for each prompt q and computes normalized group-relative advantages:
Under pure RLVR with GRPO, models spontaneously emerge sophisticated test-time compute behaviors—self-verification, backtracking, hypothesis branching, and extended chain-of-thought reasoning—trading inference tokens for monotonic accuracy gains on hard reasoning benchmarks.
Empirical intrinsic-dimension analyses show that task-specific weight updates ΔW ∈ ℝdout×din occupy a low-rank subspace. Low-Rank Adaptation (LoRA) freezes pretrained weights W0 and optimizes two narrow bottleneck matrices A ∈ ℝr×din (Gaussian init) and B ∈ ℝdout×r (zero init, so ΔW = 0 at step 0) with rank r ≪ min(din, dout):
QLoRA quantizes the frozen base weights W0 into 4-bit NormalFloat (NF4) with double quantization of scaling constants while backpropagating BF16 gradients exclusively through A and B, allowing a 65B–70B model to fine-tune on a single 48 GB GPU.
| « Previous: Ch. 3 — Scaling Laws & 3D Parallel | [ Table of Contents ] | Next: Ch. 5 — Inference, MoE & Quantization » |