DEV Community

Scc_hy
Scc_hy

Posted on Originally published at scchy.github.io

Why Supervised Learning Punishes Correct Reasoning — Core Ideas of Agentic RL

Why Supervised Learning Punishes Correct Reasoning

A Counterintuitive Fact

Imagine training a model to write mathematical proofs. The reference answer in your training set uses Path A (parity + proof by contradiction), but the model produces Path B (unique factorization) — logically sound, conclusion correct.

What does supervised learning do? It penalizes every single step with cross-entropy.

Because the SL objective is "similarity to the reference text," not "reasoning quality." The longer you train, the more the model just memorizes one canonical route. This isn't a data problem — it's a structural flaw in the objective function.

The Four Structural Difficulties of SFT

Take "prove that $\sqrt{2}$ is irrational": two correct paths with completely different intermediate steps. SL hits four walls on such tasks:

  1. No natural labels for intermediate steps. Only the final answer exists; annotating every step is expensive, and for many tasks no unique reference chain can even be written.

  2. Multiple valid paths ⇒ correct alternatives get punished. The objective degenerates into "similarity to sentence $t$ of the reference" — the model learns to imitate, not to reason.

  3. Teacher forcing creates train/inference distribution shift. During training the model always stands on reference prefixes; at inference it stands on its own. Once one step goes wrong, subsequent inputs are states never seen in training, and errors cascade.

  4. Differentiable losses cannot express backtracking. Proof is search in a discrete step space — "this path is dead, back up and try another" is the core of reasoning, and SL can only fit along the reference path.

The RL Fix: Reward Only at the End

Model the same task as an MDP: state = the proof draft so far, action = one reasoning step, zero reward for every intermediate step, and $r_T = +1$ only when a verifier (e.g., Lean) confirms the proof.

The reward arrives at the end, but flows back through the return $G_t = \sum_{k \ge t} \gamma^{k-t} r_k$:

  • Good steps appear in successful trajectories → positive advantage → reinforced
  • Bad steps (dead ends) appear in failures → negative advantage → pruned
  • If both Path A and Path B pass verification, both chains get reinforced

There's exactly one prerequisite: the final result must be machine-verifiable. That's why verifiable rewards are the cornerstone of Agentic RL — math correctness and passing tests are objective.

GRPO: From Absolute Scoring to Group Comparison

PPO needs an extra Value Model as the baseline — expensive in memory and tuning. GRPO (Group Relative Policy Optimization) is lighter:

Sample $G$ responses to the same prompt; $A_i = \frac{r_i - \text{mean}(r)}{\text{std}(r)}$

  • Above-average responses get positive advantages; below-average get negative
  • The baseline is naturally in sync with the current policy — no Critic needed
  • Standardization shrinks advantage variance, giving cleaner training signals

Transferring to other tasks: code generation uses test pass rate (partial credit per test case mitigates sparsity); dialogue optimization lacks automatic verification, so use AI scoring (RLAIF) with a larger $G$ to absorb scoring noise; multi-turn/tool tasks define rewards at the trajectory level.

Reward Hacking: Agents Find Shortcuts You Never Imagined

Any seam in the reward function will be exploited:

Task Hacking behavior
Code generation Editing test assertions to true
Math reasoning Guessing answers, echoing memorized training answers
Customer service Claiming "issue resolved" to close tickets fast
Robotics Spilling dirt first, then cleaning it up for cleanup rewards

Five defenses: isolate the reward source (the agent can't touch tests/verifiers), independent re-checking (a second verifier + human spot-checks of high-scoring samples), small coefficients for process rewards (final outcome stays dominant), adversarial updates (rotate hidden test sets; red-team hunts exploits), and deployment monitoring (alert when proxy rewards rise while real business metrics fall) + KL regularization against drift.

Tool Learning: Never Reward "Searching Randomly"

The easiest mistake when teaching agents to use tools (search, calculator, code executor) is rewarding each "successful tool call" — the model learns to call tools indiscriminately.

The right approach:

  • Tie the reward to terminal task success; "which tool, when" emerges from reward propagation
  • Use a small amount of demonstration SFT to cold-start the call format (otherwise early training drowns in illegal calls)
  • Small penalties for illegal calls and per-step cost to prevent step-padding

With many tools (50+ APIs), use curriculum learning: start with 2–5 tools on single-step tasks, escalate dynamically by pass rate (held-out pass rate ≥70% stable to advance, >90% auto-skip); introduce retrieval-based tool selection as dependency chains deepen.

Closing

The core insight of Agentic RL compresses into one sentence:

Don't tell the model how to take each step. Show it what the goal looks like, and let the reward find the path.

Supervised learning teaches models to imitate; reinforcement learning teaches them "how to reason such that success happens." In a world where valid paths are not unique, only the latter is fair.


Adapted from my study notes on Chapter 11 exercises (Agentic RL and agent training).

Top comments (0)