Dive into Deep Learning · §15.7
Sequences are trajectories
text generation as an MDP · response factorization · terminal rewards · group baselines and KL penalties
| language modeling | reinforcement learning |
|---|---|
| prompt x | start state s_0 \sim \mu_0 |
| token y_t | action a_t |
| prefix (x, y_{<t}) | state s_t |
| response y | trajectory \tau |
| EOS | terminal state |
| next-token softmax | the policy \pi_\theta |
generate |
rollout |
Transitions are concatenation: deterministic, known, probability one. All randomness comes from policy sampling; the reward is terminal.
\nabla_\theta \log \pi_\theta(y \mid x) = \sum_{t=1}^{T} \nabla_\theta \log \pi_\theta(y_t \mid x, y_{<t})
sec_qlearning; multi-turn interaction restores sequential dependenceDeterministic concatenation and terminal reward remove the need for transition learning and intermediate Bellman targets; policy optimization components remain applicable.
Sample K responses per prompt, standardize within the group, one step on the log-probs. Same-group centering is biased: its expectation is (K-1)/K of the gradient (leave-one-out is exact). Prediction: at K = 1 the shrinkage reaches zero and the update vanishes identically.
K = 1: success of a sampled response 0.062
K = 2: success of a sampled response 0.500
K = 4: success of a sampled response 0.500
K = 8: success of a sampled response 0.500
K = 32: success of a sampled response 0.500
0.062 is the unchanged reference score. At K=1, including the sample in its own baseline makes the reward-gradient update identically zero.
A grader that searches for the answer accepts a response listing every candidate. :eqref:eq_kl_optimum predicts that this response is favored when $< $ reward gap / reference log-odds = 1/4.
beta = 0.0: sloppy 1.00, gold 0.50, hedge 0.50
beta = 0.1: sloppy 0.99, gold 0.50, hedge 0.49
beta = 0.2: sloppy 0.60, gold 0.48, hedge 0.12
beta = 0.3: sloppy 0.42, gold 0.39, hedge 0.04
beta = 0.5: sloppy 0.25, gold 0.24, hedge 0.01
At \beta=0, the approximate score is perfect while the exact score is 0.5. Above the predicted threshold, the multi-answer response is suppressed. The penalty limits rather than prevents exploitation.
sec_baselines’s :eqref:eq_pg_normalized, group mean as baseline (biased by self-inclusion; LOO is the exact variant), no value networkeq_ppo_clipeq_kl_objectiveRead :eqref:eq_kl_optimum backwards and preferences fit the policy directly: DPO :cite:Rafailov.Sharma.Mitchell.ea.2023.
Reward is learned (Bradley-Terry, :numref:sec_regularized) or checked (a verifier: RLVR :cite:DeepSeekAI.2025). Both can omit aspects of the intended objective, as do \hat{Q} in :numref:sec_offline, r_\phi in :numref:sec_regularized, and the approximate grader here.
:numref:tab_rl_notation_contract: x, y, \tau, \mu_0, \pi_{\textrm{ref}}, \hat{G}_t, A, K, \rho_t, \epsilon, \beta, \delta_t, w: inherited verbatim by the Language Models part.
Lambert.2026