LLM DAILYA field guide to language models

Day 27 / 8 min read

Credit assignment — how one reward trains 2,000 reasoning tokens

Yesterday we built this loop:

\[ \text{AI proposes} \rightarrow \text{environment responds} \rightarrow \text{AI learns} \]

But we skipped over something rather magical.

Suppose an LLM generates 2,000 tokens of reasoning, submits an answer, and a verifier returns:

\[ R=1 \]

How does that single 1 tell gradient descent which of the 2,000 decisions were good?

It doesn't.

That's the credit-assignment problem, and understanding it gets us to the heart of reinforcement learning for reasoning models.

Start with the simplest possible RL rule

Suppose the model is solving:

\[ 17\times24 \]

and generates:

17 × 24
→ 17 × (20 + 4)
→ 340 + 68
→ 408

The environment checks:

\[ 17\times24=408 \]

and returns:

\[ R=1. \]

The model generated this trajectory token by token:

\[ y_1,y_2,\ldots,y_T. \]

The probability of the whole trajectory is:

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

Take logs:

\[ \log P_\theta(y_{1:T}\mid x) = \sum_t \log P_\theta(y_t\mid x,y_{<t}). \]

A very simple reinforcement-learning objective says:

\[ \boxed{ \text{If a trajectory receives high reward, increase its probability.} } \]

So our gradient contains something like:

\[ R \sum_t \nabla_\theta \log P_\theta(y_t\mid x,y_{<t}). \]

Notice what happened.

The final reward gets attached to every token decision in the trajectory.

Conceptually:

17 × (20 + 4) → 340 + 68 → 408
 ↑   ↑   ↑         ↑          ↑
 +1  +1  +1        +1         +1

The model becomes slightly more likely to generate all those choices in similar situations.

That's the basic policy-gradient idea.

But there's an obvious problem

Consider a much longer solution:

Step 1   useful
Step 2   useful
Step 3   unnecessary
Step 4   useful
Step 5   wrong
Step 6   compensates for Step 5
Step 7   useful
...
Step 73  lucky correction
Step 74  correct answer

Verifier says:

\[ R=1. \]

Naïvely, we reinforce everything.

Including:

Step 3
Step 5
Step 6

The reward tells us:

Somehow, this trajectory worked.

It does not tell us:

Token 847 was the brilliant insight and tokens 911–1052 were useless.

This is temporal credit assignment.

The longer the trajectory, the worse the ambiguity becomes.

Now imagine failure

The model generates 2,000 tokens and gets:

\[ R=0. \]

Perhaps the first 1,950 tokens contained excellent mathematics.

Then at the end it made one arithmetic typo:

\[ 37+28=64. \]

What should training learn?

Ideally:

tokens 1–1950 → mostly good
final arithmetic step → bad

But the outcome reward says only:

\[ \boxed{0} \]

The entire trajectory looks equally unsuccessful.

This is why yesterday's process rewards are attractive: they provide denser information about where things went right or wrong.

But process rewards are difficult and expensive to obtain reliably.

So RL needs other tricks too.

First trick: use a baseline

Suppose the model receives:

\[ R=1. \]

Is that good?

It depends.

If this problem is trivial and the model succeeds 99.9% of the time, reward 1 isn't especially informative.

If the model succeeds only 5% of the time, reward 1 is extremely interesting.

So instead of reinforcing according to raw reward:

\[ R \]

we reinforce according to advantage:

\[ \boxed{A=R-b} \]

where \(b\) is some estimate of expected reward.

Suppose:

\[ b=0.2. \]

Successful trajectory:

\[ A=1-0.2=+0.8. \]

Failed trajectory:

\[ A=0-0.2=-0.2. \]

Now training says:

success → make this trajectory substantially more likely

failure → make this trajectory somewhat less likely

This is much more useful than treating every success identically.

Where does the baseline come from?

One classic approach is to train another network—a value model:

\[ V_\phi(s_t) \]

that predicts:

Given the reasoning so far, how much reward do I expect eventually?

Suppose midway through a solution:

We've reduced the problem to x² = 49...

the value model might predict:

\[ V=0.85. \]

Another branch:

Let's assume x is imaginary...

might receive:

\[ V=0.12. \]

Now the model has a notion of whether its current trajectory looks promising.

This should sound familiar from our verifier lesson.

The line between:

\[ \text{verifier} \]

and:

\[ \text{value function} \]

can become quite blurry.

A concrete four-step example

Suppose a model takes four actions:

\[ a_1,a_2,a_3,a_4 \]

and succeeds:

\[ R=1. \]

Its value estimates along the way were:

\[ V(s_1)=0.3 \]
\[ V(s_2)=0.4 \]
\[ V(s_3)=0.8 \]
\[ V(s_4)=0.9. \]

Something interesting seems to happen between \(s_2\) and \(s_3\).

Our expectation jumps:

\[ 0.4\rightarrow0.8. \]

Perhaps action \(a_2\) discovered the key insight.

A richer RL algorithm can use changes in predicted value to provide more localized learning signals.

Instead of:

everything gets +1

we begin getting something more like:

a1 → mildly useful
a2 → very useful
a3 → useful
a4 → expected completion

Not perfect—but much better credit assignment.

Now we hit the exploration problem

Suppose the model currently believes:

Approach A: probability 98%
Approach B: probability  2%

Approach A usually fails.

Approach B actually works beautifully.

If we always choose the highest-probability continuation, we'll almost never discover B.

So RL needs exploration.

Sampling provides some naturally:

\[ y_t\sim P_\theta(y_t\mid context). \]

Occasionally the model tries unlikely paths.

If one receives unexpectedly high reward, gradient descent increases its probability.

For example:

\[ P(B)=0.02 \]

but B succeeds.

Training might move:

\[ 0.02\rightarrow0.03\rightarrow0.05\rightarrow0.12\rightarrow\cdots \]

Eventually the formerly rare strategy becomes normal behavior.

This is one reason RL can produce capabilities that ordinary imitation learning may struggle to elicit: the model can discover successful behaviors through exploration rather than only copying demonstrations.

But exploration creates instability

Suppose we find one bizarre trajectory that happens to receive reward 1.

Naïve optimization might aggressively increase its probability.

Then the model's behavior changes.

That changes which trajectories it samples.

Those new trajectories change the training distribution again.

Unlike ordinary supervised learning, where the dataset is mostly fixed:

\[ D=\{(x,y)\}, \]

RL training is on-policy-ish:

\[ \boxed{\text{changing the model changes the data it generates}} \]

which changes the next update.

You get a feedback loop:

model
 ↓
behavior
 ↓
reward
 ↓
update
 ↓
different model
 ↓
different behavior
 ↓
...

This can be powerful—and unstable.

This is why algorithms such as PPO exist

We've mentioned PPO in passing before.

Proximal Policy Optimization is fundamentally trying to say:

Improve behavior using the reward signal, but don't change the policy too violently in one update.

Suppose before an update:

\[ P_\text{old}(\text{token A})=0.20. \]

A reward gradient might want:

\[ P_\text{new}(\text{token A})=0.95. \]

PPO effectively constrains how aggressively we trust such updates.

One important quantity is the probability ratio:

\[ r_t(\theta) = \frac{ P_\theta(y_t\mid s_t) }{ P_{\theta_{old}}(y_t\mid s_t) }. \]

If that ratio moves too far from 1, PPO clips the incentive to keep pushing.

Conceptually:

old model
   │
   │ small controlled update
   ▼
new model

rather than:

old model ─────────────────→ wildly different model

This is especially important when reward signals are noisy.

Why reasoning RL is unusual

In classic RL, imagine a robot:

move arm
 ↓
pick object
 ↓
reward

Actions might occur a few times per second.

For an LLM, every token is an action.

A 5,000-token reasoning trajectory means roughly:

\[ 5,000 \]

sequential decisions.

And each decision has a huge action space:

\[ |\mathcal V|\approx100,000 \]

possible tokens.

So we're doing reinforcement learning over extremely long trajectories with enormous branching factors.

Fortunately, pretraining gives us an extraordinary starting policy.

Instead of exploring:

\[ 100,000^{5000} \]

arbitrary token sequences, the pretrained model already assigns almost all probability mass to linguistically and conceptually plausible continuations.

That's another way to understand why pretraining is so foundational.

It massively constrains the search space before RL begins.

Now connect this to distillation

Suppose RL discovers an excellent trajectory:

problem
 ↓
clever decomposition
 ↓
correct derivation
 ↓
verification
 ↓
answer

Initially this trajectory might have probability:

\[ 10^{-6}. \]

Exploration discovers it.

Reward reinforces it.

Eventually perhaps:

\[ P=0.05. \]

Then we can collect these successful trajectories and use them for supervised training or distillation.

So a practical improvement loop can look like:

\[ \boxed{ \text{explore with RL} \rightarrow \text{discover good behavior} \rightarrow \text{distill successful behavior} \rightarrow \text{repeat} } \]

RL is good at discovery.

Supervised learning is often good at imitation and consolidation.

They complement each other.

The deepest point: reward doesn't contain the solution

Suppose the verifier says:

\[ R=1. \]

That single bit does not tell the model:

Decompose 24 into 20+4.

It merely says:

Whatever you just did worked.

The actual strategy had to come from somewhere:

  • pretraining,
  • sampling,
  • previous training,
  • search,
  • tools,
  • or chance.

RL then shifts probability toward successful discoveries.

This is why a tiny reward signal can nevertheless produce substantial learning.

The reward isn't transmitting the knowledge directly.

It's performing selection over behaviors the model can already generate.

This is closely analogous to evolution:

\[ \text{variation} + \text{selection} \rightarrow \text{adaptation}. \]

Today's mental model

Imagine teaching someone to escape a maze while you can only stand outside and ring a bell when they reach the exit.

They try:

left
right
left
straight
right
...

Eventually:

DING!

The bell doesn't tell them which turn was brilliant.

That's the credit-assignment problem.

If you can occasionally shout:

Warmer!

or:

That last turn was promising!

you've created a value/process signal and learning becomes much easier.

And if they already possess a map-reading education—our analogue of pretraining—they aren't randomly bumping into walls. They're exploring plausible routes.

So reasoning RL is roughly:

\[ \boxed{ \text{strong pretrained policy} + \text{exploration} + \text{outcome signal} + \text{credit assignment} + \text{controlled weight updates} } \]
LLM Daily Last updated