Reinforcement Learning for LLM Post-Training: Why Learn from Rewards?


A language model can write a convincing explanation and still reach the wrong answer. It can produce valid-looking code that fails a test, or respond fluently while missing what the user actually asked. Learning to predict text gives a model a broad foundation, but the training signal does not directly measure all the qualities we want from an assistant.

Post-training helps shape that foundation into useful behavior. One approach is to show the model examples of good responses. Another is to let it generate responses, evaluate them, and use that feedback to update how it responds in the future.

That second idea is the starting point for reinforcement learning in LLM post-training. This series will explore how it works, where its learning signal comes from, and why optimizing a reward can both improve a model and create new failure modes.

This first post is also the series index. The later articles will move from the foundations to algorithms, reasoning tasks, practical training, evaluation, and agents.

Why training does not end at pretraining

In conventional autoregressive pretraining, a model learns to predict the next token from the tokens that precede it. Across a large corpus, that task can teach language, factual associations, programming patterns, and structures useful for reasoning.

But predicting a continuation and satisfying a user’s request are different objectives. A corpus contains examples of helpful explanations alongside mistakes, arguments, fiction, and incomplete answers. Matching those patterns does not by itself specify which behavior an assistant should choose in a particular interaction.

Consider a request to implement a function. Several responses may look plausible:

  • code that resembles familiar solutions but fails on an edge case;
  • a correct implementation that ignores the requested interface;
  • a correct implementation that follows the interface and explains its assumptions.

A next-token objective does not explicitly test these candidates against the user’s requirements. Post-training introduces signals that are closer to the desired behavior: demonstrations, preferences, correctness checks, or feedback from an environment.

It does not replace the pretrained foundation. It changes the model’s behavior using that foundation, and the result depends on the starting model, the training tasks, the feedback signal, and the optimization procedure.

Three ways to shape behavior

Supervised fine-tuning, preference learning, and reinforcement learning are closely connected, but their training signals differ.

Approach Training signal What the update encourages
Supervised fine-tuning (SFT) A prompt paired with a target response Increasing the probability of the demonstrated response
Direct preference optimization A prompt paired with preferred and dispreferred responses Favoring preferred responses under a preference-based objective
Rollout-based RL Responses or interaction trajectories evaluated by a reward signal Increasing expected reward under the model’s policy

To make the differences precise, let $x$ be a prompt, $y=(y_1,\ldots,y_T)$ a response including its end-of-sequence token, and $\theta$ the model parameters. Write $\pi_\theta(y\mid x)$ for the probability the model assigns to the response. Because generation proceeds one token at a time,

\[\pi_\theta(y\mid x)=\prod_{t=1}^{T}\pi_\theta(y_t\mid x,y_{<t}).\]

Here, $y_{<t}$ means the tokens generated before position $t$. This factorization connects a score for a whole response to the token probabilities the model produces.

Supervised fine-tuning: learn from demonstrations

With SFT, we provide an example of what the model should say. Training increases the likelihood of that response token by token.

For a dataset $\mathcal{D}_{\mathrm{SFT}}$ of prompts and demonstrations, a standard objective is to minimize the negative log-likelihood:

\[\mathcal{L}_{\mathrm{SFT}}(\theta) =-\mathbb{E}_{(x,y)\sim\mathcal{D}_{\mathrm{SFT}}} \left[\sum_{t=1}^{T}\log\pi_\theta(y_t\mid x,y_{<t})\right].\]

The expectation denotes an average over training examples. Lower loss means the model assigns higher probability to the demonstrated tokens, conditioned on the prompt and the preceding demonstration tokens.

This is useful for teaching instruction-following conventions, response formats, and examples of desired behavior. The target is explicit: the training data supplies a response to imitate. However, a task may have many valid solutions, and producing a good demonstration may be harder than checking a proposed answer.

Preference learning: learn which response is better

A reviewer may find it easier to compare two answers than to write an ideal answer from scratch. Preference data records those comparisons.

In a classic RLHF pipeline, comparisons train a reward model, which then scores responses for an RL stage. The InstructGPT paper demonstrates a pipeline combining supervised fine-tuning, human comparisons, and reinforcement learning.

There are also ways to train directly on preference pairs. Direct Preference Optimization (DPO) derives a preference objective from a KL-regularized reward optimization formulation and avoids an explicit reward-model training stage and an RL rollout loop in its original setup. We will study that connection without treating every preference method as the same training procedure.

For DPO, let $y^+$ be the preferred response and $y^-$ the dispreferred response for the same prompt. Define the response’s log-probability change relative to a fixed reference policy $\pi_{\mathrm{ref}}$ as

\[s_\theta(x,y)=\log\frac{\pi_\theta(y\mid x)}{\pi_{\mathrm{ref}}(y\mid x)}.\]

The reference policy $\pi_{\mathrm{ref}}$ is a frozen copy of a model used as a baseline. In a common setup, it is the SFT model at the start of preference training, and the trainable policy $\pi_\theta$ starts with the same weights. As training proceeds, $\theta$ changes while the reference weights stay fixed. The reference is not the human reviewer or a reward model: it assigns probabilities to responses, just as the trainable language model does.

Why keep it? The reference records the starting model’s behavior. Comparing against it lets us measure what preference training changed, rather than simply which response was already more likely. In DPO, this comparison is built into the loss; in the RL objective below, the reference appears in an explicit KL penalty that makes large departures from its behavior costly.

For example, suppose the reference assigns probabilities $0.10$ to $y^+$ and $0.20$ to $y^-$. Its odds for the preferred response are $0.5$. If the trained policy assigns $0.15$ to each, its odds become $1$, and the preference margin is $\log(1/0.5)=\log 2$. Training has doubled the odds toward the preferred response, even though the two responses now have equal probability. These are probabilities of two complete responses; the remaining probability belongs to other possible responses.

The reference provides an anchor, not a guarantee that every starting behavior will be preserved. Its choice and the strength of regularization affect how much the trained model can change. We will examine that tradeoff in the article on KL regularization.

The original DPO loss can then be written compactly as

\[\mathcal{L}_{\mathrm{DPO}}(\theta) =-\mathbb{E}_{(x,y^+,y^-)\sim\mathcal{D}_{\mathrm{pref}}} \left[\log\sigma\left(\beta\left[s_\theta(x,y^+)-s_\theta(x,y^-)\right]\right)\right].\]

The preference margin is the difference between the two relative scores:

\[\Delta_\theta=s_\theta(x,y^+)-s_\theta(x,y^-) =\log\frac{\pi_\theta(y^+\mid x)/\pi_\theta(y^-\mid x)} {\pi_{\mathrm{ref}}(y^+\mid x)/\pi_{\mathrm{ref}}(y^-\mid x)}.\]

This asks a comparative question: how much has the policy shifted the odds toward the preferred response, compared with the reference? A positive margin means those odds have shifted toward $y^+$; zero means the pair’s odds are unchanged; a negative margin means they have shifted toward $y^-$. It does not necessarily mean $y^+$ has a higher absolute probability than $y^-$.

Why use a difference? A preference label tells us that one response is better than another, but does not supply an absolute quality score for either. The margin matches that information: it measures the separation between the two responses. Adding the same amount to both relative scores leaves their difference unchanged, so a common score increase cannot satisfy the preference objective by itself. Here, “margin” means a score gap; the original DPO loss does not impose a fixed minimum gap that must be reached.

The sigmoid, $\sigma(z)=1/(1+e^{-z})$, turns that unbounded gap into a number between zero and one. Under DPO’s pairwise preference model,

\[P_\theta(y^+\succ y^-\mid x)=\sigma(\beta\Delta_\theta),\]

where $\succ$ means “is preferred to.” This is the model’s implied probability of the observed preference, rather than the probability of generating $y^+$. The positive parameter $\beta$ scales the margin before the sigmoid and is tied to the underlying KL-regularized formulation.

For an illustration with $\beta=1$:

Margin $\Delta_\theta$ Implied preference probability Pair loss $-\log\sigma(\Delta_\theta)$
$-2$ $0.12$ $2.13$
$0$ $0.50$ $0.69$
$2$ $0.88$ $0.13$

At initialization, if the policy equals the reference, both relative scores are zero. The implied preference probability is therefore $0.5$, even if the reference already generates one response more often. The training label supplies the direction in which to move the odds.

The negative log makes assigning a low probability to the observed preference costly. Increasing the margin raises that probability and lowers the loss. The sigmoid also makes the push diminish as a pair becomes well separated: for one pair, the loss derivative with respect to the margin is

\[\frac{\partial\ell}{\partial\Delta_\theta} =-\beta\left[1-\sigma(\beta\Delta_\theta)\right].\]

With $\beta=1$, its magnitude is about $0.88$ at margin $-2$ but only $0.12$ at margin $2$. Thus, a pair the model gets wrong receives a stronger push than one it already strongly favors. These are gradients with respect to the margin; actual parameter updates also depend on how the model’s scores change with its parameters and on other examples in the batch.

The margin provides a relative training target, while the sigmoid and negative log provide a smooth way to optimize it. They do not make preference labels correct or remove the need for independent evaluation. Favoring $y^+$ can involve raising its probability, lowering $y^-$’s probability, or both.

Reinforcement learning: learn from evaluated attempts

In rollout-based RL, the model generates an attempt, receives a reward, and is updated so that its policy achieves higher expected reward. A policy is the rule for choosing actions; for a language model, it includes the probability distribution over the next token given the current context.

The reward might come from a learned preference model, a check of a final answer, a set of code tests, or success in an interactive task. These sources provide different information and have different weaknesses.

Let $r(x,y)$ be the reward assigned to a response and $\mathcal{D}_x$ the training prompt distribution. A common regularized objective is to maximize

\[J(\theta)=\mathbb{E}_{x\sim\mathcal{D}_x} \left[ \mathbb{E}_{y\sim\pi_\theta(\cdot\mid x)}[r(x,y)] -\lambda D_{\mathrm{KL}}\left( \pi_\theta(\cdot\mid x)\,\Vert\,\pi_{\mathrm{ref}}(\cdot\mid x) \right) \right].\]

The first term rewards successful sampled responses. The second penalizes departure from a reference policy, with $\lambda\geq 0$ controlling its strength. The KL divergence compares response distributions; it is not a distance between model parameters. Later posts will explain how practical algorithms estimate and optimize these terms from sampled tokens.

The key difference from SFT is inside the expectation: here $y$ is sampled from the policy being trained, rather than supplied as a demonstration. The reward evaluates that attempt without necessarily providing a target response to imitate.

The distinction between RLHF and RL with verifiable rewards therefore concerns where feedback comes from. Human-preference-based reward models estimate qualities such as helpfulness. A verifier checks some property of an outcome. Neither label, by itself, tells us which policy optimization algorithm is used.

A worked example: writing a function

Suppose the task is to implement a function that returns the second-largest distinct integer in a list.

With SFT, we provide a correct implementation as the target response. The model learns from that demonstration.

With preference training, we might compare two implementations and prefer the one that handles duplicate values and documents what happens when fewer than two distinct values exist.

With RL, the model samples implementations and an evaluator runs them against tests. An implementation that returns the wrong result for repeated values receives a lower reward than one that handles the tested cases correctly. The optimizer then uses the sampled responses and their rewards to update the policy.

This is a conceptual description, not a rule that every token in a successful response should receive the same naive update. Turning a response-level score into useful token updates is part of the credit assignment problem we will examine later.

The example also exposes a limitation: passing the reward evaluator is not proof of full correctness. If the tests omit negative numbers or ambiguous input cases, the model can receive a high score while producing an incomplete solution. Reward quality is part of the learning problem.

What RL can teach—and what a reward cannot tell us

RL is especially interesting when we can evaluate a result without prescribing the exact response that must produce it. Several programs can pass the same tests; several solution paths can reach the same mathematical answer. Outcome feedback leaves room for the model to explore alternatives.

DeepSeekMath is one concrete reference for studying this setting and introduces Group Relative Policy Optimization (GRPO), an algorithm we will cover in the series.

But a reward is a measurement with a particular scope. A final-answer check may not assess the explanation. A preference model may favor persuasive language. An incomplete test suite may miss a bug. Improving that measurement can diverge from improving the behavior we actually care about.

We will therefore keep three questions separate:

  1. Is the model earning more reward on its training tasks?
  2. Is it performing better on independent, held-out evaluations?
  3. Does that improvement transfer to the situations where we want to use it?

Longer responses, higher training reward, and more convincing explanations do not answer all three questions. Evaluation must also account for inference-time sampling and compute: allowing more attempts can improve task success even without a change to the trained policy.

The series roadmap

The reading order below is the plan for the series. This introduction is the first article; the remaining articles are planned, and links will be added as they are published.

  1. Why use RL after pretraining? This introduction: the role of post-training, demonstrations, preferences, rewards, and evaluation.
  2. LLM generation as a reinforcement learning problem. Tokens as actions, prompts and prefixes as states, policies, trajectories, and credit assignment.
  3. Policy gradients and actor–critic methods. REINFORCE, baselines, advantages, value functions, and how rewards become parameter updates.
  4. Where rewards come from. Human preferences, reward models, AI feedback, verifiable outcomes, and the limits of each signal.
  5. The classic RLHF pipeline. An end-to-end walkthrough from demonstrations and comparisons to reward modeling and policy optimization.
  6. PPO for language models. Probability ratios, clipping, value estimation, and the mechanics of a PPO training loop.
  7. KL regularization and the reference policy. Why constrain policy changes and how the constraint interacts with reward optimization.
  8. DPO and other direct preference methods. Their connection to RL objectives, their assumptions, and their differences from rollout-based training.
  9. GRPO and group-based policy optimization. Relative rewards, group baselines, and the tradeoffs of avoiding a learned value function.
  10. RL with verifiable rewards for reasoning. Math, code, outcome checking, and what a correct final result tells us about a solution.
  11. Credit assignment in long reasoning traces. Sparse rewards, process supervision, and intermediate feedback.
  12. Exploration, sampling, and the rollout budget. Diversity, temperature, response length, and the number of attempts used during training.
  13. Reward hacking and training instability. Evaluator exploitation, length biases, policy collapse, and misleading reward improvements.
  14. Building a practical RL post-training loop. Generation, scoring, updates, batching, monitoring, and a small reproducible experiment.
  15. Evaluating what the model actually learned. Generalization, robustness, capability retention, and separating training gains from inference-time compute.
  16. RL for tool use and agents. Multi-turn trajectories, environment feedback, delayed rewards, and learning from task completion.

How to read the series

The early posts will assume familiarity with basic machine learning, probability, and gradient-based optimization, but no prior experience implementing RL. The ML Basics and Concepts series provides complementary background on generalization and evaluation.

The technical articles will pair intuition with key equations, worked examples, and practical failure modes. We will introduce notation when it becomes useful and trace how each objective connects to an actual training update. The goal is to make it possible to read an algorithm, understand its assumptions, and identify what evidence would support a claim that it improved a model.

The next article will start with the object being optimized: a language model viewed as a policy that chooses tokens one step at a time.




Enjoy Reading This Article?

Here are some more articles you might like to read next: