Unit 1 of 11 · about 3 hours · explain

Language generation as a decision process, and sequence, token, outcome and process rewards

An RL result is about a particular task and trajectory contract. Changing answer extraction or the stopping rule can change the measured gain without changing the model.

You'll be able to

  • Specify the prompt distribution, token actions, prefix transitions and stopping events for a verifiable language task.
  • Distinguish reward timing from reward meaning, and record what the verifier actually observes.

Covers

Prompts, prefixes, tokens, trajectories and terminal events as a decision processSequence, token, outcome and process rewards
1

Read

In this order, only the parts listed

0 of 3 done

  1. CS336 Spring 2026 Assignment 5: language trajectoriesCS336 Assignment 5 - Alignment and Reasoning RL

    Sections 4.1.1 to 4.1.3, Language models as policies, Trajectories, and Rewards and return

  2. RLHF Book Chapter 6: Reinforcement LearningRLHF Book - Policy Gradients, Reasoning and Rejection Sampling

    Implementation, Related: MDP vs. Bandit Framing

  3. RLHF Book Chapter 7: Reasoning and Inference-Time ScalingRLHF Book - Policy Gradients, Reasoning and Rejection Sampling

    The Role of RLVR: math-answer extraction, code-test rewards and the verifier loop

2

Focus on

  • The Reinforcement Learning unit on trajectory objectives and the likelihood-ratio identity supplies the estimator. For a single-turn task, the prompt is sampled externally; appending a generated token is the deterministic transition.
  • Sequence versus token describes where reward attaches. Outcome versus process describes what it judges. A step reward can attach to the last token of a multi-token step.
  • Record EOS, a stop string and a token-limit stop separately. A token limit does not imply a sampled EOS, and a multi-token stop string is not necessarily one action.
  • Use one small task in lmlab, such as reversing short strings. Freeze train, validation and test prompt identities, the accepted output grammar and the independent exact-answer evaluator before collecting data.
Common mistakes · 3
  • Calling deterministic prefix transitions a deterministic policy. The next token is still sampled.
  • Treating a correct final answer as proof that every intermediate step is correct. The verifier may inspect only the answer.
  • Dropping malformed or truncated outputs. Keep their outcome classes and costs even when the declared loss excludes them.
3

Try it yourself

Closed-book, before checking anything

Closed-book, write the trajectory contract for reversing ab to ba, with one character per token and a sampled EOS. List the three sampled actions and their prefixes. Put reward 1 only on the correct terminal answer and use : each action's reward-to-go is 1. Then place an additional process reward after the first character and show which returns change.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Does broadcasting a terminal reward to every token create process supervision?Answer

    No. It assigns outcome credit through the estimator; no intermediate step has been checked.

  2. 2.When do the bandit and token views describe the same expected reward?Answer

    When they induce the same distribution over completed responses and use the same terminal reward and stopping contract, without changing length weighting or discounting.

  3. 3.What belongs in the state for a token action?Answer

    The prompt and all preceding generated tokens, plus any task state needed for the declared environment. The completed answer must not leak into an earlier prefix.

You're done when

Your task contract assigns a state, action mask, stopping reason and reward to a correct, incorrect, malformed and truncated response without ambiguity.

Only when you can do this without notes.

Leads to

Notes

Resources · 2 for this unit, 18 more in the section
  • CS336 Assignment 5 - Alignment and Reasoning RLStanford University · primary

    Do Sections 3 to 5: prompting and grading baselines, baseline_calcs, then the Section 4.2 functions (tokenization, response log probabilities, rollout rewards, group-normalized rewards, loss aggregation, the on-policy GRPO step) until the GRPO and metrics tests pass on CPU. The handout runs OLMo-2 1B with a two-GPU vLLM loop; run a small GRPO on a model and task that fit your GPU instead, with one normalization ablation and one preserved failure.

  • RLHF Book - Policy Gradients, Reasoning and Rejection SamplingNathan Lambert · required

    Read Chapter 6 (policy gradients: REINFORCE, RLOO, PPO, GRPO and loss aggregation), Chapter 7 (reasoning), Chapter 9 (rejection sampling), Chapter 12 (distillation) and Chapter 15 (regularization). Do the Suggested Experiments in Chapters 6 and 9. Derive only the estimator used in your experiment, then use Chapters 14 and 15 to design the reward-hacking tests.

Also in this section