Scale and post-training
MDPs, returns and values
The vocabulary of reinforcement learning. An agent acts, the environment returns a state and a reward, and returns and values measure how good those actions are over time.
Supervised learning gets the right answer for each input. Reinforcement learning (RL) gets a reward, a single number that may arrive only at the end of a long sequence of decisions. Language model training works this way. A whole completion is scored as good or bad, and the model has to work out which of its earlier choices mattered. The vocabulary below is what every RL paper assumes.
Concept
In a Markov decision process (MDP), an agent picks an action in a state. The environment returns a new state and a reward. The next state depends only on the current state and action, not on the full history.
The loop
state s_t → agent picks action a_t → environment returns s_{t+1} and reward r_{t+1}Repeat until the episode ends. For a language model, the state is the text so far, an action is the next token, and the episode is the prompt plus the completion.
Returns
The return G_t is the total reward from step t onward, with later rewards discounted by a factor γ between 0 and 1:
G_t = r_{t+1} + γ · r_{t+2} + γ² · r_{t+3} + …Walk through a three-step episode with rewards 0, 0, 1 and γ = 0.9:
G_2 = r_3 = 1
G_1 = r_2 + γ · r_3 = 0 + 0.9 = 0.9
G_0 = r_1 + γ · r_2 + γ² · r_3 = 0 + 0 + 0.81 = 0.81The earlier a step is, the more the final reward has to be discounted to reach it. That is the credit problem in one picture: the step that set up the win gets only a slice of it.
For single-turn language tasks, people often use γ = 1, since the episode is short and the whole completion is scored at the end.
Values
- The state value
V(s)is the expected return from statesif the policy keeps acting as it does. - The action value
Q(s, a)is the expected return if the agent takes actionainsfirst, then follows the policy.
The Bellman equation ties them together. A state's value equals the expected reward plus the discounted value of where you land next:
V(s) = E[ r + γ · V(s′) ]That recursion is why dynamic programming and temporal-difference methods work. For LLM training, people often skip learning a value for every token and use the full return of each completion. The idea of a baseline value still shows up, as shown in policy gradients.
Common mistakes
- Assuming
γis always below 1. Discounting is for long tasks where distant rewards should count less. A single-turn completion can useγ = 1. - Mixing up
VandQ.Vaverages over the actions the policy might take.Qfixes the first action. - Reading a reward as a label. A reward is a score for what happened, and it may be noisy or hackable.
Check yourself
- With
γ = 0.5and rewards0, 0, 1, what isG_0? Answer: 0.25, because0.5² · 1. - How does
Qdiffer fromV? Answer:Qfixes the first action and then follows the policy, whileVaverages over the policy's choices.
Key takeaways
- RL learns from rewards in an MDP loop: state, action, next state, reward.
- A return is the discounted sum of future rewards.
- Values estimate expected return.
Qadds the first action. - Rewards can arrive late, so credit has to flow back through the discount.
Further learning
Next, see how a policy is improved by following the return in policy gradients.
Related
Policy gradients and advantages
Policy gradients adjust the policy directly. Make the actions that led to high returns more likely. Baselines and advantages cut the noise in that update.
Reinforcement learning basics
MDPs, returns, policy gradients, advantages and PPO. The minimum RL needed to read modern LLM post-training papers. Start here for the map.
Optimization and gradient descent
How models learn, from loss landscapes and gradient descent to learning rates, mini-batches, momentum and Adam.