<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://chengru-song.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://chengru-song.github.io/" rel="alternate" type="text/html" hreflang="en" /><updated>2026-10-15T06:14:54+08:00</updated><id>https://chengru-song.github.io/feed.xml</id><title type="html">Chengru’s Blog</title><subtitle>A personal blog website for sharing of technology, reflection and branding. 
</subtitle><author><name>Chengru Song</name></author><entry><title type="html">【AI】Entropy-Gated Suffix Masking: Turn-Level Credit for Long-Horizon Agentic RL</title><link href="https://chengru-song.github.io/ai/ai_algorithms/2026/10/14/agentic-rl-talk-interview.html" rel="alternate" type="text/html" title="【AI】Entropy-Gated Suffix Masking: Turn-Level Credit for Long-Horizon Agentic RL" /><published>2026-10-14T22:00:00+08:00</published><updated>2026-10-14T22:00:00+08:00</updated><id>https://chengru-song.github.io/ai/ai_algorithms/2026/10/14/agentic-rl-talk-interview</id><content type="html" xml:base="https://chengru-song.github.io/ai/ai_algorithms/2026/10/14/agentic-rl-talk-interview.html"><![CDATA[<div style="width:100%;height:90vh;">
  <iframe src="/assets/html/agentic_rl_talk_interview.html" style="width:100%;height:100%;border:none;" allowfullscreen=""></iframe>
</div>]]></content><author><name>Chengru Song</name></author><category term="[&quot;AI&quot;, &quot;AI_Algorithms&quot;]" /><category term="301-work-ai" /><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">【AI】A Closer Look into Behavior Collapse in Agentic RL</title><link href="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/06/16/Agentic-RL.html" rel="alternate" type="text/html" title="【AI】A Closer Look into Behavior Collapse in Agentic RL" /><published>2026-06-16T22:51:07+08:00</published><updated>2026-06-16T22:51:07+08:00</updated><id>https://chengru-song.github.io/ai/ai_algorithms/vision/2026/06/16/Agentic-RL</id><content type="html" xml:base="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/06/16/Agentic-RL.html"><![CDATA[<h1 id="a-closer-look-into-behavior-collapse-in-agentic-rl">A Closer Look into Behavior Collapse in Agentic RL</h1>

<p>In the previous article, I argued that Agentic RL should be fundamentally different from traditional RLVR. The argument itself was not particularly controversial. In standard RLVR, the model generates a response, receives a reward, and the trajectory ends. Even though policy updates change the distribution of future responses, the environment itself remains fixed.</p>

<p>Agentic RL is different in a subtle but important way. The model is no longer generating a single response. It is making decisions that affect what information it will see in the future. Whether the model decides to search, what query it chooses, whether it reads another document chunk, or whether it decides to terminate early all influence the observations that become available later in the trajectory.</p>

<p>This creates a feedback loop that does not exist in single-turn RLVR. A small policy update can alter future observations, which in turn changes future actions, making the resulting trajectory look very different from the one that generated the gradient in the first place.</p>

<p>My intuition was that this should make Agentic RL much more vulnerable to off-policy staleness than conventional RLVR. The longer the trajectory becomes, the larger the mismatch between the rollout policy and the current policy should be.</p>

<p>At least that was the theory.</p>

<p>The reason I am writing this article is that after reproducing Search-R1 and instrumenting a large number of trajectory-level metrics, I found something that was both more interesting and more confusing than what I originally expected.</p>

<p>I was looking for evidence of off-policy staleness.</p>

<p>What I ended up finding was something that looked much more like behavioral phase transitions.</p>

<h2 id="the-setup">The Setup</h2>

<p>To study the problem in a reasonably controlled environment, we reproduced Search-R1. Compared to production-grade research agents, Search-R1 is intentionally simple, but that simplicity is precisely what makes it useful. The entire training pipeline is open-sourced, the retrieval environment is reproducible, and the search database remains fixed throughout training. This removes many of the confounding factors introduced by live web search and allows us to focus on the training dynamics themselves.</p>

<p>Unless otherwise specified, all experiments use Qwen2.5-7B-Instruct or Qwen3-8B-NoThinking as the base model, GRPO as the RL algorithm, Exact Match as the reward, a training batch size of 128, and a rollout group size of 8.</p>

<p>The action space is also relatively small. For most trajectories, the model is effectively choosing between answering directly and performing a search. This simplicity turns out to be helpful because behavioral changes become easier to identify.</p>

<p>Initially, I was not even looking for behavior changes.</p>

<p>The first thing that caught my attention was a completely different metric.</p>

<h2 id="a-strange-change-in-the-number-of-turns">A Strange Change in the Number of Turns</h2>

<p>One observation that repeatedly appeared during training was that the average number of turns gradually decreased.</p>

<p><img src="/assets/images/image-20260616161225386.png" alt="The num of turns decrease gradually as training continues." /></p>

<p>The num of turns decrease gradually as training continues.</p>

<p>At first glance, this looked perfectly reasonable. If the model becomes better at finding useful information, fewer search calls should be needed. A stronger model should often reach the correct answer with fewer interactions. Since both training accuracy and evaluation accuracy were improving at the same time, there seemed to be little reason to investigate further.</p>

<p>The interesting part only emerged after inspecting rollout traces.</p>

<p>What initially looked like improved efficiency was actually a change in strategy.</p>

<p>Around step 300, the model began answering questions directly before issuing a search call. The change happened surprisingly quickly. For hundreds of optimization steps, the dominant pattern looked roughly like:</p>

<p>Question → Search → Answer</p>

<p>Then within a relatively short period of training, many trajectories started looking like:</p>

<p>Question → Guess → Search → Answer</p>

<p><img src="/assets/images/image-20260616161256125.png" alt="The behavior collapse observed during training. The model will try to answer with its own prior knowledge before consulting the external evidence." /></p>

<p>The behavior collapse observed during training. The model will try to answer with its own prior knowledge before consulting the external evidence.</p>

<p>The search tool was still being used. The model had not forgotten how to search. Instead, it appeared to be increasingly willing to trust its own prior knowledge before consulting external evidence.</p>

<p>The transition was large enough that it became visible in aggregate statistics. If we track the proportion of trajectories that contain zero search turns, the ratio increases sharply around the same time.</p>

<p><img src="/assets/images/image-20260616161318240.png" alt="image-20260616161318240" /></p>

<p>At this point, the most natural explanation seemed straightforward. Perhaps the model was becoming stronger and discovering that many questions could be answered directly without searching.</p>

<p>Unfortunately, the data did not support that interpretation.</p>

<p>Comparing checkpoints immediately before and after the transition revealed a significant drop in four-turn accuracy. The guess-first behavior was not an improvement. In fact, it performed noticeably worse than the original search-first strategy.</p>

<table>
  <thead>
    <tr>
      <th>acc_num_turn/step</th>
      <th>step 278(Before entropy spike)</th>
      <th>Behavior(Search Ratio)</th>
      <th>step 297(After entropy spike)</th>
      <th>Behavior(Search Ratio)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>0</td>
      <td>0.0%</td>
      <td>98.43%</td>
      <td>14.55%</td>
      <td>32.32%</td>
    </tr>
    <tr>
      <td>1</td>
      <td>47.07%</td>
      <td>0.78%</td>
      <td>28.22%</td>
      <td>48.63%</td>
    </tr>
    <tr>
      <td>2</td>
      <td>47.75%</td>
      <td>52.14%</td>
      <td>37.98%</td>
      <td>20.01%</td>
    </tr>
    <tr>
      <td>3</td>
      <td>57.03%</td>
      <td>1.95%</td>
      <td>41.69%</td>
      <td>41.79%</td>
    </tr>
  </tbody>
</table>

<p>Comparing step 278 and step 297(the closest two steps when the spike happens). The accuracy of 4 turns is 57.03% before collapse v.s. 41.69% after collapse.</p>

<p>From a user perspective, this is not particularly surprising. If the model incorrectly answers a question before deciding to search, the interaction is generally worse than simply retrieving evidence first.</p>

<p>What puzzled me was not the accuracy drop itself. What puzzled me was what happened next. The training run did not collapse. The evaluation curve did not collapse. After some fluctuation, accuracy recovered and continued improving. Even more interestingly, the search-first behavior gradually returned. The model appeared to discover a worse strategy, spend some time exploring it, and then move away from it.</p>

<p>This was very different from the failure mode I originally expected when thinking about multi-turn off-policy staleness.</p>

<h2 id="entropy-was-the-first-symptom">Entropy Was the First Symptom</h2>

<p>After noticing the rollout transition, I started looking for signals that could explain what happened.</p>

<p>One hypothesis from the previous article was that tool-generated observations introduce significantly higher uncertainty than standard conversational turns. Since external search results are not generated by the model itself, the distribution of future continuations should be much less predictable. To test this idea, I logged the entropy of the first few generated tokens after every turn. The resulting plots immediately showed something unusual.</p>

<p>Around the same time that the rollout behavior changed, the entropy of early tokens spiked dramatically. More interestingly, the pattern was not uniform across turns. When the entropy was broken down by turn index, some turns exhibited abrupt increases while others remained relatively stable.</p>

<p>Initially, I thought this might be evidence supporting the original hypothesis about tool-induced uncertainty. However, after aligning the entropy curves with rollout traces, a different explanation emerged.</p>

<p>Before the behavioral transition, many of those turns corresponded to tool outputs followed by relatively deterministic responses. After the transition, those same positions increasingly contained answers generated directly from model priors. The model was no longer conditioned on retrieved evidence and therefore had to rely on its own uncertain beliefs.</p>

<p>In retrospect, the entropy spike was not the cause of the behavior change. It was a consequence of it. The model started behaving differently, and the entropy reflected that change.</p>

<p>This distinction sounds subtle, but it turned out to matter. If entropy is merely reacting to behavior changes rather than predicting them, then it is not particularly useful for understanding why the transition occurred in the first place.</p>

<p>That brought me back to the original question. If this behavior change is real, what actually drives it?</p>

<h2 id="looking-for-evidence-of-policy-drift">Looking for Evidence of Policy Drift</h2>

<p>At this point, I returned to the hypothesis that motivated the entire investigation. If multi-turn trajectories are becoming increasingly stale during training, then some measure of policy drift should become visible around the same time as the behavioral transition. The most obvious candidate was importance sampling.</p>

<p>PPO-style algorithms rely heavily on importance sampling corrections, and one might expect large behavioral changes to coincide with large importance weights. We therefore logged clip fraction and several related statistics throughout training. The results were somewhat surprising.</p>

<p>Clip fraction did increase before the behavioral transition, suggesting that token-level importance sampling corrections were becoming more active. However, the increase was not nearly as dramatic as the change observed in rollout behavior. The strongest signal came from a different metric.</p>

<p><img src="/assets/images/image-20260616161331481.png" alt="image.png" /></p>

<p><img src="/assets/images/image-20260616161341140.png" alt="image-20260616161341140" /></p>

<p>Instead of looking at individual tokens, we computed a turn-level measure of divergence from the reference model. Conceptually, the metric answers a simple question: how far has the current policy moved from the original SFT policy when generating an entire turn?</p>

<p>What stood out was not that the divergence increased. Any successful RL run should gradually move away from the reference policy. What stood out was how closely the divergence tracked changes in behavior.</p>

<p>Every major transition in rollout structure was accompanied by a noticeable increase in trajectory-level divergence from the reference model. Long before the behavioral change became obvious in rollout traces, the KL signal had already started drifting upward.</p>

<p>This observation gradually changed how I thought about the problem. I originally expected off-policy staleness to manifest as instability in optimization. Instead, what I observed was instability in behavior.</p>

<p>The optimization process itself remained surprisingly robust. The reward curve continued improving. Training did not diverge. Yet the strategy employed by the agent changed dramatically. The more rollout traces I inspected, the less the phenomenon looked like a classical optimization failure. It increasingly resembled a transition between distinct behavioral modes.</p>

<h2 id="a-simpler-environment-might-be-hiding-the-full-picture">A Simpler Environment Might Be Hiding the Full Picture</h2>

<p>One possible objection is that Search-R1 is too simple. The model only has a small number of meaningful actions available. If a behavioral transition occurs, recovery is relatively easy because the policy only needs to choose among a handful of alternatives.</p>

<p>To test whether the same phenomenon appears in richer environments, we modified the setup by introducing two additional tools. The first tool allows the model to request additional document chunks after an initial search. The second tool performs answer verification using an external verifier.</p>

<p>The resulting decision process becomes substantially more complex.</p>

<p>The model can now search, inspect additional evidence, verify intermediate conclusions, continue exploring, or terminate. Unlike the original setup, the agent is no longer deciding merely whether to search. It is deciding how to search. More importantly, the additional tools introduce qualitatively different behaviors. This turns out to be useful because behavioral transitions become easier to observe.</p>

<h2 id="the-same-pattern-appears-again">The Same Pattern Appears Again</h2>

<p>One of the most striking observations in the expanded environment involves the verification tool.</p>

<p>At the beginning of training, the tool is rarely used. Most trajectories rely on search results alone and proceed directly to answering. Then, within a relatively short span of optimization steps, the behavior changes. Verification usage rapidly increases and eventually becomes almost deterministic. Trajectories that previously followed a simple pattern begin incorporating verification into nearly every interaction.</p>

<p><img src="/assets/images/image-20260616161353340.png" alt="image-20260616161353340" /></p>

<p>What makes this particularly interesting is that the transition looks remarkably similar to the earlier search-collapse phenomenon. In both cases, a stable behavior persists for a long period of time before suddenly giving way to a different strategy. In both cases, the transition occurs much faster than one would expect from a sequence of small policy updates. The difference is that this time the transition is beneficial.</p>

<p>Training accuracy increases after the verification tool becomes widely adopted. Unlike the previous collapse, which temporarily hurt performance, the new behavior improves it. This creates an interesting tension.</p>

<p>From the perspective of rollout dynamics, the two transitions look almost identical. In both cases, the policy rapidly shifts from one mode of behavior to another. From the perspective of reward, however, one transition is good and the other is bad. This suggests that what we are observing is not simply collapse.</p>

<p>The broader phenomenon is that Agentic RL appears capable of rapidly reorganizing its tool-use strategy during training.</p>

<p>Whether that transition is desirable depends entirely on where the new behavior leads.</p>

<h2 id="what-metrics-actually-capture-these-changes">What Metrics Actually Capture These Changes?</h2>

<p>Once multiple behavioral transitions became visible, a natural question emerged. Can existing RL metrics reliably detect them?</p>

<p>The answer appears to be mixed.</p>

<p><img src="/assets/images/image-20260616161401838.png" alt="image-20260616161401838" /></p>

<p>KL divergence, particularly divergence measured against the reference model, consistently tracks major behavioral transitions. Whenever the policy begins moving toward a new strategy, KL tends to increase beforehand. Importance sampling statistics are much less informative.</p>

<p>Despite substantial changes in tool usage, both token-level and turn-level importance sampling remain relatively stable in many cases. This is particularly surprising because one might expect large strategy shifts to be accompanied by correspondingly large importance weights.</p>

<p>What these experiments seem to suggest is that trajectory-level behavioral changes can occur without triggering dramatic changes in token-level correction mechanisms. A policy can remain locally similar while becoming globally different.</p>

<p>The sequence of actions chosen by the agent changes, even though individual token probabilities do not necessarily move far enough to activate strong clipping behavior. This may partially explain why reward curves often fail to reveal what is happening underneath. The agent is changing how it solves the task, not necessarily whether it solves the task.</p>

<h2 id="what-changed-my-mind">What Changed My Mind</h2>

<p>I started this investigation looking for evidence that multi-turn off-policy staleness is a fundamental obstacle for Agentic RL. I still think staleness matters, especially as trajectories become longer and tool interactions become more complex, but it is no longer the phenomenon I find most interesting in these runs.</p>

<p>What repeatedly surfaced across these experiments is that agent policies can move between qualitatively different modes of behavior during training. Sometimes the transition hurts performance, as in the guess-first behavior. Sometimes it improves performance, as in the adoption of the verification tool. Sometimes the policy eventually returns to its previous behavior after briefly exploring an inferior strategy.</p>

<p>The difficult part is that these transitions do not look equally important from the perspective of reward. A behavior shift may be harmful, helpful, or mostly neutral, while the reward curve remains too coarse to explain what actually changed. The agent is not only becoming better or worse at solving the task; it is changing how it chooses to solve the task.</p>

<p>This is why I now find behavior-level monitoring more important than I initially expected. Reward curves tell us whether the agent is succeeding. Rollout structure tells us how it is succeeding, and sometimes also whether it is succeeding for the wrong reason. In Agentic RL, those two stories are not always the same.</p>

<h2 id="limitations-and-follow-ups">Limitations and Follow-ups</h2>

<p>There are two limitations that I would like to explore next.</p>

<p>The first is whether the same phenomenon becomes stronger or weaker in thinking-mode models. The experiments in this article are still relatively short-horizon compared with modern reasoning agents. As response length increases, and as a larger fraction of tokens are spent on intermediate thinking rather than directly contributing to the final answer, the relationship between token-level optimization and trajectory-level behavior may become different. It is possible that longer reasoning traces smooth out some of the abrupt transitions observed here. It is also possible that they make the problem worse, because there are more opportunities for the policy to drift into locally rewarded but globally undesirable behaviors.</p>

<p>The second follow-up is how to automatically identify and mitigate bad explorations without suppressing useful ones. The verification-tool transition is a good example of exploration that should be encouraged, while the guess-first behavior is an example of exploration that looks more like metric hacking. For deep research tasks, one simple solution is to directly penalize obviously undesirable behavior. For example, if a task is identified as requiring external evidence, we can set the reward to incorrect and terminate the rollout when the agent attempts to answer in the first round without making any search call.</p>

<p>However, this kind of rule-based punishment is brittle. It depends heavily on human-defined heuristics and may not generalize across tasks, tools, or domains. A more flexible alternative is to use a model-based monitor that evaluates whether the trajectory is following a reasonable research process. Instead of hard-coding rules such as “always search first,” we can ask a separate model to judge whether the agent’s behavior is justified given the task. This would allow the training process to penalize bad shortcuts while still preserving useful exploration when the model genuinely has enough information to answer.</p>

<p>The broader question is whether we can build training systems that distinguish productive behavioral transitions from harmful ones as they happen. If Agentic RL is better understood as a sequence of behavioral phase transitions rather than a smooth optimization process, then stabilizing training may require more than token-level clipping or standard reward shaping. We may need trajectory-level monitors that understand not only whether the final answer is correct, but also whether the agent arrived there through a robust and desirable process.</p>]]></content><author><name>Chengru Song</name></author><category term="[&quot;AI&quot;, &quot;AI_Algorithms&quot;, &quot;Vision&quot;]" /><category term="301-work-ai" /><summary type="html"><![CDATA[A Closer Look into Behavior Collapse in Agentic RL In the previous article, I argued that Agentic RL should be fundamentally different from traditional RLVR. The argument itself was not particularly controversial. In standard RLVR, the model generates a response, receives a reward, and the trajectory ends. Even though policy updates change the distribution of future responses, the environment itself remains fixed. Agentic RL is different in a subtle but important way. The model is no longer generating a single response. It is making decisions that affect what information it will see in the future. Whether the model decides to search, what query it chooses, whether it reads another document chunk, or whether it decides to terminate early all influence the observations that become available later in the trajectory. This creates a feedback loop that does not exist in single-turn RLVR. A small policy update can alter future observations, which in turn changes future actions, making the resulting trajectory look very different from the one that generated the gradient in the first place. My intuition was that this should make Agentic RL much more vulnerable to off-policy staleness than conventional RLVR. The longer the trajectory becomes, the larger the mismatch between the rollout policy and the current policy should be. At least that was the theory. The reason I am writing this article is that after reproducing Search-R1 and instrumenting a large number of trajectory-level metrics, I found something that was both more interesting and more confusing than what I originally expected. I was looking for evidence of off-policy staleness. What I ended up finding was something that looked much more like behavioral phase transitions. The Setup To study the problem in a reasonably controlled environment, we reproduced Search-R1. Compared to production-grade research agents, Search-R1 is intentionally simple, but that simplicity is precisely what makes it useful. The entire training pipeline is open-sourced, the retrieval environment is reproducible, and the search database remains fixed throughout training. This removes many of the confounding factors introduced by live web search and allows us to focus on the training dynamics themselves. Unless otherwise specified, all experiments use Qwen2.5-7B-Instruct or Qwen3-8B-NoThinking as the base model, GRPO as the RL algorithm, Exact Match as the reward, a training batch size of 128, and a rollout group size of 8. The action space is also relatively small. For most trajectories, the model is effectively choosing between answering directly and performing a search. This simplicity turns out to be helpful because behavioral changes become easier to identify. Initially, I was not even looking for behavior changes. The first thing that caught my attention was a completely different metric. A Strange Change in the Number of Turns One observation that repeatedly appeared during training was that the average number of turns gradually decreased. The num of turns decrease gradually as training continues. At first glance, this looked perfectly reasonable. If the model becomes better at finding useful information, fewer search calls should be needed. A stronger model should often reach the correct answer with fewer interactions. Since both training accuracy and evaluation accuracy were improving at the same time, there seemed to be little reason to investigate further. The interesting part only emerged after inspecting rollout traces. What initially looked like improved efficiency was actually a change in strategy. Around step 300, the model began answering questions directly before issuing a search call. The change happened surprisingly quickly. For hundreds of optimization steps, the dominant pattern looked roughly like: Question → Search → Answer Then within a relatively short period of training, many trajectories started looking like: Question → Guess → Search → Answer The behavior collapse observed during training. The model will try to answer with its own prior knowledge before consulting the external evidence. The search tool was still being used. The model had not forgotten how to search. Instead, it appeared to be increasingly willing to trust its own prior knowledge before consulting external evidence. The transition was large enough that it became visible in aggregate statistics. If we track the proportion of trajectories that contain zero search turns, the ratio increases sharply around the same time. At this point, the most natural explanation seemed straightforward. Perhaps the model was becoming stronger and discovering that many questions could be answered directly without searching. Unfortunately, the data did not support that interpretation. Comparing checkpoints immediately before and after the transition revealed a significant drop in four-turn accuracy. The guess-first behavior was not an improvement. In fact, it performed noticeably worse than the original search-first strategy. acc_num_turn/step step 278(Before entropy spike) Behavior(Search Ratio) step 297(After entropy spike) Behavior(Search Ratio) 0 0.0% 98.43% 14.55% 32.32% 1 47.07% 0.78% 28.22% 48.63% 2 47.75% 52.14% 37.98% 20.01% 3 57.03% 1.95% 41.69% 41.79% Comparing step 278 and step 297(the closest two steps when the spike happens). The accuracy of 4 turns is 57.03% before collapse v.s. 41.69% after collapse. From a user perspective, this is not particularly surprising. If the model incorrectly answers a question before deciding to search, the interaction is generally worse than simply retrieving evidence first. What puzzled me was not the accuracy drop itself. What puzzled me was what happened next. The training run did not collapse. The evaluation curve did not collapse. After some fluctuation, accuracy recovered and continued improving. Even more interestingly, the search-first behavior gradually returned. The model appeared to discover a worse strategy, spend some time exploring it, and then move away from it. This was very different from the failure mode I originally expected when thinking about multi-turn off-policy staleness. Entropy Was the First Symptom After noticing the rollout transition, I started looking for signals that could explain what happened. One hypothesis from the previous article was that tool-generated observations introduce significantly higher uncertainty than standard conversational turns. Since external search results are not generated by the model itself, the distribution of future continuations should be much less predictable. To test this idea, I logged the entropy of the first few generated tokens after every turn. The resulting plots immediately showed something unusual. Around the same time that the rollout behavior changed, the entropy of early tokens spiked dramatically. More interestingly, the pattern was not uniform across turns. When the entropy was broken down by turn index, some turns exhibited abrupt increases while others remained relatively stable. Initially, I thought this might be evidence supporting the original hypothesis about tool-induced uncertainty. However, after aligning the entropy curves with rollout traces, a different explanation emerged. Before the behavioral transition, many of those turns corresponded to tool outputs followed by relatively deterministic responses. After the transition, those same positions increasingly contained answers generated directly from model priors. The model was no longer conditioned on retrieved evidence and therefore had to rely on its own uncertain beliefs. In retrospect, the entropy spike was not the cause of the behavior change. It was a consequence of it. The model started behaving differently, and the entropy reflected that change. This distinction sounds subtle, but it turned out to matter. If entropy is merely reacting to behavior changes rather than predicting them, then it is not particularly useful for understanding why the transition occurred in the first place. That brought me back to the original question. If this behavior change is real, what actually drives it? Looking for Evidence of Policy Drift At this point, I returned to the hypothesis that motivated the entire investigation. If multi-turn trajectories are becoming increasingly stale during training, then some measure of policy drift should become visible around the same time as the behavioral transition. The most obvious candidate was importance sampling. PPO-style algorithms rely heavily on importance sampling corrections, and one might expect large behavioral changes to coincide with large importance weights. We therefore logged clip fraction and several related statistics throughout training. The results were somewhat surprising. Clip fraction did increase before the behavioral transition, suggesting that token-level importance sampling corrections were becoming more active. However, the increase was not nearly as dramatic as the change observed in rollout behavior. The strongest signal came from a different metric. Instead of looking at individual tokens, we computed a turn-level measure of divergence from the reference model. Conceptually, the metric answers a simple question: how far has the current policy moved from the original SFT policy when generating an entire turn? What stood out was not that the divergence increased. Any successful RL run should gradually move away from the reference policy. What stood out was how closely the divergence tracked changes in behavior. Every major transition in rollout structure was accompanied by a noticeable increase in trajectory-level divergence from the reference model. Long before the behavioral change became obvious in rollout traces, the KL signal had already started drifting upward. This observation gradually changed how I thought about the problem. I originally expected off-policy staleness to manifest as instability in optimization. Instead, what I observed was instability in behavior. The optimization process itself remained surprisingly robust. The reward curve continued improving. Training did not diverge. Yet the strategy employed by the agent changed dramatically. The more rollout traces I inspected, the less the phenomenon looked like a classical optimization failure. It increasingly resembled a transition between distinct behavioral modes. A Simpler Environment Might Be Hiding the Full Picture One possible objection is that Search-R1 is too simple. The model only has a small number of meaningful actions available. If a behavioral transition occurs, recovery is relatively easy because the policy only needs to choose among a handful of alternatives. To test whether the same phenomenon appears in richer environments, we modified the setup by introducing two additional tools. The first tool allows the model to request additional document chunks after an initial search. The second tool performs answer verification using an external verifier. The resulting decision process becomes substantially more complex. The model can now search, inspect additional evidence, verify intermediate conclusions, continue exploring, or terminate. Unlike the original setup, the agent is no longer deciding merely whether to search. It is deciding how to search. More importantly, the additional tools introduce qualitatively different behaviors. This turns out to be useful because behavioral transitions become easier to observe. The Same Pattern Appears Again One of the most striking observations in the expanded environment involves the verification tool. At the beginning of training, the tool is rarely used. Most trajectories rely on search results alone and proceed directly to answering. Then, within a relatively short span of optimization steps, the behavior changes. Verification usage rapidly increases and eventually becomes almost deterministic. Trajectories that previously followed a simple pattern begin incorporating verification into nearly every interaction. What makes this particularly interesting is that the transition looks remarkably similar to the earlier search-collapse phenomenon. In both cases, a stable behavior persists for a long period of time before suddenly giving way to a different strategy. In both cases, the transition occurs much faster than one would expect from a sequence of small policy updates. The difference is that this time the transition is beneficial. Training accuracy increases after the verification tool becomes widely adopted. Unlike the previous collapse, which temporarily hurt performance, the new behavior improves it. This creates an interesting tension. From the perspective of rollout dynamics, the two transitions look almost identical. In both cases, the policy rapidly shifts from one mode of behavior to another. From the perspective of reward, however, one transition is good and the other is bad. This suggests that what we are observing is not simply collapse. The broader phenomenon is that Agentic RL appears capable of rapidly reorganizing its tool-use strategy during training. Whether that transition is desirable depends entirely on where the new behavior leads. What Metrics Actually Capture These Changes? Once multiple behavioral transitions became visible, a natural question emerged. Can existing RL metrics reliably detect them? The answer appears to be mixed. KL divergence, particularly divergence measured against the reference model, consistently tracks major behavioral transitions. Whenever the policy begins moving toward a new strategy, KL tends to increase beforehand. Importance sampling statistics are much less informative. Despite substantial changes in tool usage, both token-level and turn-level importance sampling remain relatively stable in many cases. This is particularly surprising because one might expect large strategy shifts to be accompanied by correspondingly large importance weights. What these experiments seem to suggest is that trajectory-level behavioral changes can occur without triggering dramatic changes in token-level correction mechanisms. A policy can remain locally similar while becoming globally different. The sequence of actions chosen by the agent changes, even though individual token probabilities do not necessarily move far enough to activate strong clipping behavior. This may partially explain why reward curves often fail to reveal what is happening underneath. The agent is changing how it solves the task, not necessarily whether it solves the task. What Changed My Mind I started this investigation looking for evidence that multi-turn off-policy staleness is a fundamental obstacle for Agentic RL. I still think staleness matters, especially as trajectories become longer and tool interactions become more complex, but it is no longer the phenomenon I find most interesting in these runs. What repeatedly surfaced across these experiments is that agent policies can move between qualitatively different modes of behavior during training. Sometimes the transition hurts performance, as in the guess-first behavior. Sometimes it improves performance, as in the adoption of the verification tool. Sometimes the policy eventually returns to its previous behavior after briefly exploring an inferior strategy. The difficult part is that these transitions do not look equally important from the perspective of reward. A behavior shift may be harmful, helpful, or mostly neutral, while the reward curve remains too coarse to explain what actually changed. The agent is not only becoming better or worse at solving the task; it is changing how it chooses to solve the task. This is why I now find behavior-level monitoring more important than I initially expected. Reward curves tell us whether the agent is succeeding. Rollout structure tells us how it is succeeding, and sometimes also whether it is succeeding for the wrong reason. In Agentic RL, those two stories are not always the same. Limitations and Follow-ups There are two limitations that I would like to explore next. The first is whether the same phenomenon becomes stronger or weaker in thinking-mode models. The experiments in this article are still relatively short-horizon compared with modern reasoning agents. As response length increases, and as a larger fraction of tokens are spent on intermediate thinking rather than directly contributing to the final answer, the relationship between token-level optimization and trajectory-level behavior may become different. It is possible that longer reasoning traces smooth out some of the abrupt transitions observed here. It is also possible that they make the problem worse, because there are more opportunities for the policy to drift into locally rewarded but globally undesirable behaviors. The second follow-up is how to automatically identify and mitigate bad explorations without suppressing useful ones. The verification-tool transition is a good example of exploration that should be encouraged, while the guess-first behavior is an example of exploration that looks more like metric hacking. For deep research tasks, one simple solution is to directly penalize obviously undesirable behavior. For example, if a task is identified as requiring external evidence, we can set the reward to incorrect and terminate the rollout when the agent attempts to answer in the first round without making any search call. However, this kind of rule-based punishment is brittle. It depends heavily on human-defined heuristics and may not generalize across tasks, tools, or domains. A more flexible alternative is to use a model-based monitor that evaluates whether the trajectory is following a reasonable research process. Instead of hard-coding rules such as “always search first,” we can ask a separate model to judge whether the agent’s behavior is justified given the task. This would allow the training process to penalize bad shortcuts while still preserving useful exploration when the model genuinely has enough information to answer. The broader question is whether we can build training systems that distinguish productive behavioral transitions from harmful ones as they happen. If Agentic RL is better understood as a sequence of behavioral phase transitions rather than a smooth optimization process, then stabilizing training may require more than token-level clipping or standard reward shaping. We may need trajectory-level monitors that understand not only whether the final answer is correct, but also whether the agent arrived there through a robust and desirable process.]]></summary></entry><entry><title type="html">【AI】Early Termination Collapse in Agentic RL</title><link href="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/06/08/ETC-RL.html" rel="alternate" type="text/html" title="【AI】Early Termination Collapse in Agentic RL" /><published>2026-06-08T22:51:07+08:00</published><updated>2026-06-08T22:51:07+08:00</updated><id>https://chengru-song.github.io/ai/ai_algorithms/vision/2026/06/08/ETC-RL</id><content type="html" xml:base="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/06/08/ETC-RL.html"><![CDATA[<h1 id="early-termination-collapse-in-agentic-rl---a-simple-rollout-continuation-strategy-improves-search-r1-to-70-em">Early Termination Collapse in Agentic RL - A Simple Rollout Continuation Strategy Improves Search-R1 to 70% EM</h1>

<h2 id="background">Background</h2>

<p>With the rapid rise of agent frameworks such as OpenClaw in early 2026, Agentic RL training has become an increasingly important research direction. However, compared to standard RLHF or single-turn reasoning tasks, agentic training introduces several unique optimization challenges.</p>

<p>In particular, we found the following issues especially important:</p>

<h3 id="long-horizon-trajectories">Long-Horizon Trajectories</h3>

<p>Agent trajectories are substantially longer than conventional post-training sequences. A single rollout may contain multiple tool calls, external environment interactions, retrieval steps, and iterative reasoning turns.</p>

<p>This significantly increases:</p>

<ul>
  <li>trajectory variance,</li>
  <li>delayed credit assignment difficulty,</li>
  <li>and optimization instability.</li>
</ul>

<h3 id="multi-turn-interaction-dynamics">Multi-Turn Interaction Dynamics</h3>

<p>Unlike fixed-format instruction tuning, agent training involves dynamically evolving conversational states.</p>

<p>Each rollout may contain:</p>

<ul>
  <li>different numbers of tool calls,</li>
  <li>varying observation lengths,</li>
  <li>branching execution paths,</li>
  <li>and non-stationary dialogue structures.</li>
</ul>

<p>This makes trajectory optimization substantially harder than standard next-token prediction.</p>

<h3 id="severe-off-policy-staleness">Severe Off-Policy Staleness</h3>

<p>We hypothesize that off-policy staleness becomes significantly more severe in long-horizon agent trajectories.</p>

<p>In standard RLHF, a small policy drift usually affects only local token distributions. However, in agentic environments, a single divergent tool call may invalidate the entire downstream trajectory.</p>

<p>As a result:</p>

<ul>
  <li>rollout reuse becomes fragile,</li>
  <li>token-level gradients become increasingly stale,</li>
  <li>and optimization noise accumulates rapidly across turns.</li>
</ul>

<p>In practice, we found this issue much more severe than in conventional RLHF settings.</p>

<hr />

<p>To study these problems in a controlled environment, we reproduced Search-R1.</p>

<p>Search-R1 provides several advantages for agentic RL research:</p>

<ul>
  <li>fully open-sourced training pipeline,</li>
  <li>reproducible offline retrieval environment,</li>
  <li>stable search database without real-time web dependency.</li>
</ul>

<p>This allows us to analyze agent training dynamics without the instability introduced by live internet retrieval systems.</p>

<p>Unless otherwise specified, all experiments use:</p>

<ul>
  <li>Base Model: Qwen2.5-7B-Instruct / Qwen3-8B-NoThinking</li>
  <li>RL Algorithm: GRPO</li>
  <li>Reward: Exact Match (EM)</li>
  <li>Train Batch Size: 128</li>
  <li>Rollout Group Size: 8</li>
</ul>

<hr />

<h2 id="initial-observation">Initial Observation</h2>

<p>Our initial goal was not to improve Search-R1 performance directly.</p>

<p>Instead, we introduced finer-grained rollout logging to investigate whether long-horizon agent training exhibits optimization behaviors fundamentally different from standard RLHF.</p>

<p>Surprisingly, we observed several interesting phenomena.</p>

<h3 id="qwen25-7b-consistently-outperformed-qwen3-8b-nothinking">Qwen2.5-7B Consistently Outperformed Qwen3-8B-NoThinking</h3>

<p><img src="/assets/images/image.png" alt="Search R1 train and eval EM Acc curve. Qwen2.5-7B’s EM Acc is generally higher than that of Qwen3-8B." /></p>

<p><em>Search R1 train and eval EM Acc curve. Qwen2.5-7B’s EM Acc is generally higher than that of Qwen3-8B.</em></p>

<p>Although Qwen3-8B-NoThinking should theoretically possess stronger base capabilities, its EM performance remained consistently below Qwen2.5-7B throughout training.</p>

<p>This result was initially unexpected.</p>

<p>To better understand the discrepancy, we further analyzed rollout statistics.</p>

<h3 id="early-termination-collapse">Early Termination Collapse</h3>

<p>The key difference was not reasoning quality itself.</p>

<p>Instead, the major discrepancy emerged from search behavior.</p>

<p>Although the Search-R1 prompt explicitly states:</p>

<blockquote>
  <p>“You can search as many times as you want.”</p>
</blockquote>

<p>Qwen3-8B-NoThinking consistently avoided iterative search behavior.</p>

<p>Instead, it rapidly converged toward a policy of:</p>

<ul>
  <li>performing minimal retrieval,</li>
  <li>answering immediately,</li>
  <li>and terminating the trajectory early.</li>
</ul>

<p>In contrast, Qwen2.5-7B naturally performed substantially deeper search trajectories with multiple iterative tool calls.</p>

<p><img src="/assets/images/image 1.png" alt="Qwen2.5-7B tends to follow the instruction and search multiple times. However, Qwen3-8B-No-Thinking fails to do so. " />
<em>Qwen2.5-7B tends to follow the instruction and search multiple times. However, Qwen3-8B-No-Thinking fails to do so.</em></p>

<p>We refer to this phenomenon as:</p>

<p><strong>Early Termination Collapse (ETC)</strong></p>

<p>Formally, ETC describes a policy failure mode where:</p>

<ul>
  <li>the model prematurely terminates interaction trajectories,</li>
  <li>despite insufficient external evidence,</li>
  <li>because shorter trajectories become implicitly favored during RL optimization.</li>
</ul>

<h3 id="why-does-early-termination-collapse-happen">Why Does Early Termination Collapse Happen?</h3>

<p>We hypothesize that ETC emerges from the interaction between:</p>

<ul>
  <li>aligned model training priors,</li>
  <li>sparse terminal rewards,</li>
  <li>trajectory variance growth,</li>
  <li>and implicit horizon minimization during policy optimization.</li>
</ul>

<p>In GRPO-style optimization, longer trajectories are inherently more difficult to optimize because they introduce:</p>

<ul>
  <li>larger variance,</li>
  <li>delayed reward propagation,</li>
  <li>higher rollout instability,</li>
  <li>and more opportunities for off-policy divergence.</li>
</ul>

<p>As a result, the policy gradually discovers a low-cost local optimum:</p>

<blockquote>
  <p>answer early instead of searching deeply.</p>
</blockquote>

<p>Importantly, search depth itself is not explicitly supervised.</p>

<p>Instead, it emerges implicitly from the optimization dynamics between:</p>

<ul>
  <li>policy prior,</li>
  <li>reward sparsity,</li>
  <li>rollout termination behavior,</li>
  <li>and trajectory variance.</li>
</ul>

<p>This explains why stronger base models do not necessarily produce deeper search behavior under agentic RL training.</p>

<hr />

<h2 id="rollout-analysis">Rollout Analysis</h2>

<p>When visualizing actual rollout trajectories, the difference becomes highly apparent.</p>

<h3 id="qwen3-8b-nothinking">Qwen3-8B-NoThinking</h3>

<p>Typical behavior:</p>

<ul>
  <li>perform one retrieval,</li>
  <li>immediately attempt an answer,</li>
  <li>terminate trajectory.</li>
</ul>

<p>The model rarely performs iterative evidence gathering.</p>

<h3 id="qwen25-7b">Qwen2.5-7B</h3>

<p>In contrast, Qwen2.5-7B frequently exhibits:</p>

<ul>
  <li>multi-step retrieval,</li>
  <li>iterative refinement,</li>
  <li>repeated search attempts,</li>
  <li>and substantially deeper interaction horizons.</li>
</ul>

<p>This deeper search behavior correlates strongly with higher final EM accuracy.</p>

<hr />

<h2 id="method-reflection-guided-rollout-continuation">Method: Reflection-Guided Rollout Continuation</h2>

<p>Based on the above observation, we explored a simple question:</p>

<blockquote>
  <p>Can we prevent the model from prematurely terminating trajectories?</p>
</blockquote>

<p>Instead of allowing the rollout to terminate immediately after answer generation, we introduce a lightweight continuation mechanism.</p>

<p>Specifically:</p>

<ul>
  <li>the environment checks answer correctness,</li>
  <li>incorrect answers trigger additional search turns,</li>
  <li>rollout terminates only when:
    <ul>
      <li>the answer becomes correct,</li>
      <li>or maximum turn budget is reached.</li>
    </ul>
  </li>
</ul>

<p>In our experiments, the maximum number of turns is set to 10.</p>

<p><img src="/assets/images/image 2.png" alt="image.png" /></p>

<p>Importantly, this approach does not require:</p>

<ul>
  <li>reward model redesign,</li>
  <li>context compression,</li>
  <li>additional supervised datasets,</li>
  <li>or architectural modifications.</li>
</ul>

<p>Instead, it directly reshapes the rollout distribution toward deeper evidence collection behaviors.</p>

<p>We refer to this mechanism as: <strong>Reflection-Guided Rollout Continuation (RGC)</strong></p>

<hr />

<h2 id="results">Results</h2>

<p>The effect is surprisingly large.</p>

<p>By introducing only lightweight continuation reminders at appropriate stages, the model rapidly learns:</p>

<ul>
  <li>deeper search behavior,</li>
  <li>iterative verification,</li>
  <li>and more persistent evidence collection.</li>
</ul>

<p>Most importantly, the model begins to reflect on whether its current knowledge is actually sufficient before terminating the trajectory.</p>

<p>With only 300 training steps, the model reaches: <strong>70%+ EM Accuracy</strong></p>

<p><img src="/assets/images/image 3.png" alt="image.png" /></p>

<p><img src="/assets/images/image 4.png" alt="image.png" /></p>

<p>without using:</p>

<ul>
  <li>context compression,</li>
  <li>advanced memory systems,</li>
  <li>retrieval distillation,</li>
  <li>or specialized agent architectures.</li>
</ul>

<hr />

<h2 id="discussion">Discussion</h2>

<p>Our experiments suggest that:</p>

<p><strong>Premature answering is one of the core failure modes in agentic RL.</strong></p>

<p>More importantly, search depth itself appears to be an emergent optimization behavior rather than an explicitly supervised capability.</p>

<p>This has several implications:</p>

<h3 id="stronger-base-models-may-still-collapse">Stronger Base Models May Still Collapse</h3>

<p>Even stronger instruction models may converge toward shallow interaction policies under sparse-reward RL optimization.</p>

<h3 id="long-horizon-rl-requires-explicit-trajectory-stabilization">Long-Horizon RL Requires Explicit Trajectory Stabilization</h3>

<p>Without mechanisms that encourage sustained exploration, policy optimization naturally favors shorter trajectories.</p>

<h3 id="agentic-rl-introduces-unique-optimization-dynamics">Agentic RL Introduces Unique Optimization Dynamics</h3>

<p>In multi-turn environments, a single tool-call divergence may invalidate all downstream token updates.</p>

<p>This makes off-policy staleness substantially more severe than in conventional RLHF.</p>

<hr />

<h2 id="conclusion">Conclusion</h2>

<p>We reproduced Search-R1 in a fully controlled offline environment and observed a distinct agentic RL failure mode:</p>

<h4 id="early-termination-collapse-1">Early Termination Collapse.</h4>

<p>Under GRPO optimization, models tend to prematurely terminate trajectories instead of performing iterative evidence gathering.</p>

<p>To mitigate this issue, we introduced a lightweight continuation strategy:</p>

<h4 id="reflection-guided-rollout-continuation">Reflection-Guided Rollout Continuation.</h4>

<p>Despite its simplicity, this method improves Search-R1 to over 70% EM within only 300 training steps, without requiring additional architectural complexity.</p>

<p>More importantly, our experiments suggest that many behaviors in agentic systems — including search depth itself — emerge directly from RL optimization dynamics.</p>

<p>We believe understanding these dynamics will become increasingly important for future long-horizon agent training systems.</p>

<h2 id="final-remarks">Final Remarks</h2>

<p>It is important to note that this work does not yet address the full set of optimization challenges unique to long-horizon agentic RL.</p>

<p>In this article, we primarily focus on identifying and mitigating one specific failure mode:</p>

<h3 id="early-termination-collapse-etc">Early Termination Collapse (ETC)</h3>

<p>While ETC significantly affects Search-R1 performance, we do not believe it fully explains the instability observed in long-horizon agent training.</p>

<p>In our subsequent experiments, we observed additional phenomena that appear to be unique to long-horizon agent trajectories, including various forms of:</p>

<h3 id="behavior-collapse">Behavior Collapse</h3>

<p>These behaviors are substantially more complex than premature answering alone, and seem to emerge from the interaction between:</p>

<ul>
  <li>extended trajectory horizons,</li>
  <li>multi-turn policy drift,</li>
  <li>off-policy branching instability,</li>
  <li>and long-range credit assignment failures.</li>
</ul>

<p>We are currently conducting deeper investigations into these dynamics and will present our findings in a follow-up article.</p>

<h1 id="appendix">Appendix</h1>

<p><img src="/assets/images/image 5.png" alt="Qwen3 response: one tool call only and respond" />
<em>Qwen3 response: one tool call only and respond</em></p>

<p><img src="/assets/images/image 6.png" alt="Qwen3-8B-No-Thinking dominantly search once and answer" />
<em>Qwen3-8B-No-Thinking dominantly search once and answer</em></p>]]></content><author><name>Chengru Song</name></author><category term="[&quot;AI&quot;, &quot;AI_Algorithms&quot;, &quot;Vision&quot;]" /><category term="301-work-ai" /><summary type="html"><![CDATA[Early Termination Collapse in Agentic RL - A Simple Rollout Continuation Strategy Improves Search-R1 to 70% EM Background With the rapid rise of agent frameworks such as OpenClaw in early 2026, Agentic RL training has become an increasingly important research direction. However, compared to standard RLHF or single-turn reasoning tasks, agentic training introduces several unique optimization challenges. In particular, we found the following issues especially important: Long-Horizon Trajectories Agent trajectories are substantially longer than conventional post-training sequences. A single rollout may contain multiple tool calls, external environment interactions, retrieval steps, and iterative reasoning turns. This significantly increases: trajectory variance, delayed credit assignment difficulty, and optimization instability. Multi-Turn Interaction Dynamics Unlike fixed-format instruction tuning, agent training involves dynamically evolving conversational states. Each rollout may contain: different numbers of tool calls, varying observation lengths, branching execution paths, and non-stationary dialogue structures. This makes trajectory optimization substantially harder than standard next-token prediction. Severe Off-Policy Staleness We hypothesize that off-policy staleness becomes significantly more severe in long-horizon agent trajectories. In standard RLHF, a small policy drift usually affects only local token distributions. However, in agentic environments, a single divergent tool call may invalidate the entire downstream trajectory. As a result: rollout reuse becomes fragile, token-level gradients become increasingly stale, and optimization noise accumulates rapidly across turns. In practice, we found this issue much more severe than in conventional RLHF settings. To study these problems in a controlled environment, we reproduced Search-R1. Search-R1 provides several advantages for agentic RL research: fully open-sourced training pipeline, reproducible offline retrieval environment, stable search database without real-time web dependency. This allows us to analyze agent training dynamics without the instability introduced by live internet retrieval systems. Unless otherwise specified, all experiments use: Base Model: Qwen2.5-7B-Instruct / Qwen3-8B-NoThinking RL Algorithm: GRPO Reward: Exact Match (EM) Train Batch Size: 128 Rollout Group Size: 8 Initial Observation Our initial goal was not to improve Search-R1 performance directly. Instead, we introduced finer-grained rollout logging to investigate whether long-horizon agent training exhibits optimization behaviors fundamentally different from standard RLHF. Surprisingly, we observed several interesting phenomena. Qwen2.5-7B Consistently Outperformed Qwen3-8B-NoThinking Search R1 train and eval EM Acc curve. Qwen2.5-7B’s EM Acc is generally higher than that of Qwen3-8B. Although Qwen3-8B-NoThinking should theoretically possess stronger base capabilities, its EM performance remained consistently below Qwen2.5-7B throughout training. This result was initially unexpected. To better understand the discrepancy, we further analyzed rollout statistics. Early Termination Collapse The key difference was not reasoning quality itself. Instead, the major discrepancy emerged from search behavior. Although the Search-R1 prompt explicitly states: “You can search as many times as you want.” Qwen3-8B-NoThinking consistently avoided iterative search behavior. Instead, it rapidly converged toward a policy of: performing minimal retrieval, answering immediately, and terminating the trajectory early. In contrast, Qwen2.5-7B naturally performed substantially deeper search trajectories with multiple iterative tool calls. Qwen2.5-7B tends to follow the instruction and search multiple times. However, Qwen3-8B-No-Thinking fails to do so. We refer to this phenomenon as: Early Termination Collapse (ETC) Formally, ETC describes a policy failure mode where: the model prematurely terminates interaction trajectories, despite insufficient external evidence, because shorter trajectories become implicitly favored during RL optimization. Why Does Early Termination Collapse Happen? We hypothesize that ETC emerges from the interaction between: aligned model training priors, sparse terminal rewards, trajectory variance growth, and implicit horizon minimization during policy optimization. In GRPO-style optimization, longer trajectories are inherently more difficult to optimize because they introduce: larger variance, delayed reward propagation, higher rollout instability, and more opportunities for off-policy divergence. As a result, the policy gradually discovers a low-cost local optimum: answer early instead of searching deeply. Importantly, search depth itself is not explicitly supervised. Instead, it emerges implicitly from the optimization dynamics between: policy prior, reward sparsity, rollout termination behavior, and trajectory variance. This explains why stronger base models do not necessarily produce deeper search behavior under agentic RL training. Rollout Analysis When visualizing actual rollout trajectories, the difference becomes highly apparent. Qwen3-8B-NoThinking Typical behavior: perform one retrieval, immediately attempt an answer, terminate trajectory. The model rarely performs iterative evidence gathering. Qwen2.5-7B In contrast, Qwen2.5-7B frequently exhibits: multi-step retrieval, iterative refinement, repeated search attempts, and substantially deeper interaction horizons. This deeper search behavior correlates strongly with higher final EM accuracy. Method: Reflection-Guided Rollout Continuation Based on the above observation, we explored a simple question: Can we prevent the model from prematurely terminating trajectories? Instead of allowing the rollout to terminate immediately after answer generation, we introduce a lightweight continuation mechanism. Specifically: the environment checks answer correctness, incorrect answers trigger additional search turns, rollout terminates only when: the answer becomes correct, or maximum turn budget is reached. In our experiments, the maximum number of turns is set to 10. Importantly, this approach does not require: reward model redesign, context compression, additional supervised datasets, or architectural modifications. Instead, it directly reshapes the rollout distribution toward deeper evidence collection behaviors. We refer to this mechanism as: Reflection-Guided Rollout Continuation (RGC) Results The effect is surprisingly large. By introducing only lightweight continuation reminders at appropriate stages, the model rapidly learns: deeper search behavior, iterative verification, and more persistent evidence collection. Most importantly, the model begins to reflect on whether its current knowledge is actually sufficient before terminating the trajectory. With only 300 training steps, the model reaches: 70%+ EM Accuracy without using: context compression, advanced memory systems, retrieval distillation, or specialized agent architectures. Discussion Our experiments suggest that: Premature answering is one of the core failure modes in agentic RL. More importantly, search depth itself appears to be an emergent optimization behavior rather than an explicitly supervised capability. This has several implications: Stronger Base Models May Still Collapse Even stronger instruction models may converge toward shallow interaction policies under sparse-reward RL optimization. Long-Horizon RL Requires Explicit Trajectory Stabilization Without mechanisms that encourage sustained exploration, policy optimization naturally favors shorter trajectories. Agentic RL Introduces Unique Optimization Dynamics In multi-turn environments, a single tool-call divergence may invalidate all downstream token updates. This makes off-policy staleness substantially more severe than in conventional RLHF. Conclusion We reproduced Search-R1 in a fully controlled offline environment and observed a distinct agentic RL failure mode: Early Termination Collapse. Under GRPO optimization, models tend to prematurely terminate trajectories instead of performing iterative evidence gathering. To mitigate this issue, we introduced a lightweight continuation strategy: Reflection-Guided Rollout Continuation. Despite its simplicity, this method improves Search-R1 to over 70% EM within only 300 training steps, without requiring additional architectural complexity. More importantly, our experiments suggest that many behaviors in agentic systems — including search depth itself — emerge directly from RL optimization dynamics. We believe understanding these dynamics will become increasingly important for future long-horizon agent training systems. Final Remarks It is important to note that this work does not yet address the full set of optimization challenges unique to long-horizon agentic RL. In this article, we primarily focus on identifying and mitigating one specific failure mode: Early Termination Collapse (ETC) While ETC significantly affects Search-R1 performance, we do not believe it fully explains the instability observed in long-horizon agent training. In our subsequent experiments, we observed additional phenomena that appear to be unique to long-horizon agent trajectories, including various forms of: Behavior Collapse These behaviors are substantially more complex than premature answering alone, and seem to emerge from the interaction between: extended trajectory horizons, multi-turn policy drift, off-policy branching instability, and long-range credit assignment failures. We are currently conducting deeper investigations into these dynamics and will present our findings in a follow-up article. Appendix Qwen3 response: one tool call only and respond Qwen3-8B-No-Thinking dominantly search once and answer]]></summary></entry><entry><title type="html">【AI】GRPO Robust Reward Normalization</title><link href="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/05/15/robust-rm-normalization.html" rel="alternate" type="text/html" title="【AI】GRPO Robust Reward Normalization" /><published>2026-05-15T14:51:07+08:00</published><updated>2026-05-15T14:51:07+08:00</updated><id>https://chengru-song.github.io/ai/ai_algorithms/vision/2026/05/15/robust-rm-normalization</id><content type="html" xml:base="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/05/15/robust-rm-normalization.html"><![CDATA[<h1 id="原创grpo-robust-reward-nomalization">原创：GRPO Robust Reward Nomalization</h1>

<h2 id="问题引入">问题引入</h2>

<p>在常规的GRPO训练过程中，我们使用到的往往是Verifiable的反馈，其优点是一致性高，没有偏差，信号稳定。但是在实际应用场景中，一般会出现以下两个挑战</p>

<ol>
  <li><strong>结果没有Golden Answer</strong>：模型没有明确的Verifiable Reward Signal，或Signal本身存在一定偏差、波动，导致信号只在统计意义上有效，而非每条都是Ground Truth；</li>
  <li><strong>只能采用Reward Model</strong>：第一个挑战会带来的问题就是我们在实际使用中，往往需要自行训练一个Reward Model，作为Verifiable Reward Signal的替代；实际上，从25年开始，大家都在尝试融合Reward Model和Verifiable Reward Signal，来统一后训练。</li>
  <li><strong>VLM Reward Concentration</strong>：如果我们使用Bredley-Terry方法训练一个Scalar RM，则在我们的实际观察中，在视频理解场景，Vision的Context较长情况下，回复占用的篇幅往往远低于Prompt的篇幅，这会导致一组GRPO的Rollouts，Reward Model所打出来的分数，聚集（concentrate）在一个比较小的区间。</li>
</ol>

<p>所以，我们实际观测到挑战如下所述，</p>

<h3 id="video-scalar-rm-grpo核心挑战reward-shaping">Video Scalar RM GRPO核心挑战：Reward Shaping</h3>

<ol>
  <li><strong>Reward concentration &amp; Outlier</strong>：GRPO开源多在Rule-based Reward上训练，分数天然Normalize在0-1区间，没有Outlier，但是Scalar RM存在Score concentrate和Outlier问题；</li>
  <li><strong>Advantage Spike</strong>：同策略视频组内std过小，导致Advantage计算波动巨大。</li>
</ol>

<table>
  <thead>
    <tr>
      <th>Reward concentration &amp; Outlier</th>
      <th>Advantage Spike</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><img src="/assets/images/image-20260517231811708.png" alt="image-20260517231811708" /><br />当前RM因为不设置上下界，且无Normalization，所以存在Score的Outlier，并且分布比较集中</td>
      <td><img src="/assets/images/adv_scale_comp.png" alt="adv_scale_comp" /><br />黄色线：w/o Robust Reward Norm，优势计算波动大，更新不稳定<br />红色线：w/ Robust Reward Norm, 优势计算稳定</td>
    </tr>
  </tbody>
</table>

<h2 id="核心优化robust-reward-nomalization">核心优化：Robust Reward Nomalization</h2>

<p>属于GRPO-like算法中，Reward Shaping方向优化</p>

<p><img src="/assets/images/(null)-9085715." alt="img" /></p>

<h2 id="实验及结论">实验及结论</h2>

<ol>
  <li>Reward Shaping: Clamping outlier和RM Score nomalization两个操作，训练提升较大
    <ol>
      <li>Training Reward -1.04 -&gt; -0.77</li>
      <li>Eval Reward：-0.61 -&gt; -0.21</li>
    </ol>
  </li>
  <li>为什么当前操作work？
    <ol>
      <li>Robust Score Normalization避免了Refresh视频的差别过小，而导致的Advantage尖锐噪声的问题，从而稳定了训练；</li>
      <li>Clamping outlier防止了部分Outlier的Advantage过大，从而过分boost或者打压低分sample，导致训练崩溃。</li>
      <li>本质：组内优势优化，和DAPO的dynamic sampling，curriculum learning的思路一致，都是让每一个prompt Group产生有效的gradient update</li>
    </ol>
  </li>
</ol>]]></content><author><name>Chengru Song</name></author><category term="[&quot;AI&quot;, &quot;AI_Algorithms&quot;, &quot;Vision&quot;]" /><category term="301-work-ai" /><summary type="html"><![CDATA[原创：GRPO Robust Reward Nomalization 问题引入 在常规的GRPO训练过程中，我们使用到的往往是Verifiable的反馈，其优点是一致性高，没有偏差，信号稳定。但是在实际应用场景中，一般会出现以下两个挑战 结果没有Golden Answer：模型没有明确的Verifiable Reward Signal，或Signal本身存在一定偏差、波动，导致信号只在统计意义上有效，而非每条都是Ground Truth； 只能采用Reward Model：第一个挑战会带来的问题就是我们在实际使用中，往往需要自行训练一个Reward Model，作为Verifiable Reward Signal的替代；实际上，从25年开始，大家都在尝试融合Reward Model和Verifiable Reward Signal，来统一后训练。 VLM Reward Concentration：如果我们使用Bredley-Terry方法训练一个Scalar RM，则在我们的实际观察中，在视频理解场景，Vision的Context较长情况下，回复占用的篇幅往往远低于Prompt的篇幅，这会导致一组GRPO的Rollouts，Reward Model所打出来的分数，聚集（concentrate）在一个比较小的区间。 所以，我们实际观测到挑战如下所述， Video Scalar RM GRPO核心挑战：Reward Shaping Reward concentration &amp; Outlier：GRPO开源多在Rule-based Reward上训练，分数天然Normalize在0-1区间，没有Outlier，但是Scalar RM存在Score concentrate和Outlier问题； Advantage Spike：同策略视频组内std过小，导致Advantage计算波动巨大。 Reward concentration &amp; Outlier Advantage Spike 当前RM因为不设置上下界，且无Normalization，所以存在Score的Outlier，并且分布比较集中 黄色线：w/o Robust Reward Norm，优势计算波动大，更新不稳定红色线：w/ Robust Reward Norm, 优势计算稳定 核心优化：Robust Reward Nomalization 属于GRPO-like算法中，Reward Shaping方向优化 实验及结论 Reward Shaping: Clamping outlier和RM Score nomalization两个操作，训练提升较大 Training Reward -1.04 -&gt; -0.77 Eval Reward：-0.61 -&gt; -0.21 为什么当前操作work？ Robust Score Normalization避免了Refresh视频的差别过小，而导致的Advantage尖锐噪声的问题，从而稳定了训练； Clamping outlier防止了部分Outlier的Advantage过大，从而过分boost或者打压低分sample，导致训练崩溃。 本质：组内优势优化，和DAPO的dynamic sampling，curriculum learning的思路一致，都是让每一个prompt Group产生有效的gradient update]]></summary></entry><entry><title type="html">【AI】Rubrics in CoT</title><link href="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/05/14/cot-reward.html" rel="alternate" type="text/html" title="【AI】Rubrics in CoT" /><published>2026-05-14T14:51:07+08:00</published><updated>2026-05-14T14:51:07+08:00</updated><id>https://chengru-song.github.io/ai/ai_algorithms/vision/2026/05/14/cot-reward</id><content type="html" xml:base="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/05/14/cot-reward.html"><![CDATA[<h1 id="大家用ai一定要做好fact-check">大家用AI一定要做好Fact Check</h1>

<h2 id="问题引入">问题引入</h2>

<p>最近听了姚顺宇的访谈播客，现在已经有非常多的总结，我就不赘述了，但关于其中他提到的，做模型的人要多思考，多check，方法本身是否能在不同参数量，不同模型架构，更好的数据上依然生效，是一个需要反复验证和研究的过程，这一点我深感其然。</p>

<p>有些工作看着很基础，也不一定是当下研究的热点，但实际上在应用过程中却异常重要。就拿我最近使用某AI软件的过程来说吧，我本来以为在如今的模型参数量和规模的情况下，模型应该会很少出现幻觉的问题了，但实际上这个问题比我想象的要严重很多。以我最近的工作为例，我最近在看到了不同的GRPO-like算法都存在不同程度的长度偏置，于是我让某AI帮我总结了一下关于这方面的研究。</p>

<p>于是，我得到了下面的回复，在我想要继续查看，这篇OpenAI的内部研究报告的时候，我搜遍了全网，没有通过名字找到这篇文章，于是我又把arXiv的编号搜索了一番，最终得到了一篇既不是来自于OpenAI，也和长度偏置没有任何关系的文章。所以幻觉本身还是一个比较严重，需要被正确看待并解决的问题。<img src="/assets/images/image-20260514004341045.png" alt="image-20260514004341045" /></p>

<p><img src="/assets/images/image-20260514004604944.png" alt="image-20260514004604944" /></p>

<h2 id="工作介绍">工作介绍</h2>

<p>于是我看到了千问团队最近的这篇文章，MARCH: Multi-Agent Reinforced Self-Check for LLM Hallucination，专门解决涉及到搜索召回过程中存在的幻觉问题。幻觉是一个老生常谈的问题，也是模型在实际应用里面要被解决的基础问题，对模型和平台的可信度影响非常大，一旦出现一次幻觉问题，可能用户就会完全脱离这个平台。因为用户问AI，代表其本身对问题的理解程度可能不高，很容易信任AI的回复，因此就会出现You don’t know what you don’t know这个现象，会产生生理性恐惧。那么上面这篇论文提出了什么机制来解决这个问题呢？可以参考下面这个图</p>

<p><img src="/assets/images/image-20260514005934313.png" alt="image-20260514005934313" /></p>

<p>简单来说，就是在一个需要检查真实信息的环境中，设定了三个角色，也是三个Agent，每个Agent不能既当裁判员，又当运动员，而是分属于Solver（RAG Model），Proposer（事实检查Question pairs）和Checker（基于每个问题进行回复）。</p>

<p>所以我们基本关心两个问题</p>

<ol>
  <li>这三个角色怎么设计Reward？</li>
  <li>具体在RL update的时候怎么训练？</li>
</ol>

<h3 id="reward设计">Reward设计</h3>

<ol>
  <li>
    <p>Zero-tolerance Reward：在Proposer给定的claim里面，有一条对不上，整条trajectory都要被惩罚。</p>
  </li>
  <li>
    <p>只有0和-1这两个Reward，对的是0，错了是-1；</p>
  </li>
</ol>

<h3 id="rl-update">RL Update</h3>

<p>本体使用了PPO算法，MARCH 把两类 trajectory 都放进 PPO batch：</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1. Solver trajectory y
2. Checker audit trajectory λ
</code></pre></div></div>

<p>每条原始样本 <code class="language-plaintext highlighter-rouge">(x, D)</code> 会产生：</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>y_i = Solver response
λ_i = Checker audit response
R_i = ZTR reward
</code></pre></div></div>

<p>然后它把 <code class="language-plaintext highlighter-rouge">y_i</code> 和 <code class="language-plaintext highlighter-rouge">λ_i</code> 都加入 unified trajectory batch <code class="language-plaintext highlighter-rouge">TB</code>，并且两者共享同一个 terminal reward <code class="language-plaintext highlighter-rouge">R_i</code>。Algorithm 1 里就是这么写的：先生成 y，再 Proposer 拆 QA，再 Checker 生成 λ，再算 ZTR，最后把 y_i 和 λ_i 都加入 unified batch trajectory set。</p>

<h2 id="实验结果">实验结果</h2>

<p>可以看到，实验整体的效果还是不错的</p>

<table>
  <thead>
    <tr>
      <th> </th>
      <th> </th>
      <th> </th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><img src="/assets/images/image-20260514011820324.png" alt="image-20260514011820324" /></td>
      <td><img src="/assets/images/image-20260514011833796.png" alt="image-20260514011833796" /></td>
      <td><img src="/assets/images/image-20260514011842627.png" alt="image-20260514011842627" /></td>
    </tr>
  </tbody>
</table>

<p>除了今天提到的这篇，千问C端应用团队四篇论文今年有四篇论文都入选ICML、ACL，覆盖推理加速、幻觉治理、架构优化与结构化推理四个方向。其中一篇ECHO框架的中了ICML 2026的SpotLight，还是很有含金量的，毕竟是前2.2%了，今天投稿量还翻倍了</p>

<p>整体看下来，不愧是做C端应用的，论文里的框架都很实际，大家感兴趣可以去看看。</p>

<h2 id="总结">总结</h2>

<p>基础的工作往往需要更持续的投入和更多方法的总结，尤其是现在Agent方案逐渐被大家接受，模型怎么能在这个过程中避免Tool Use，使用Tool Use的结果，整个过程完整任务，没有幻觉，也会持续被大家讨论。千问这篇文章工作算是用Agent方案进行的一个新的尝试，还是很不错的。</p>]]></content><author><name>Chengru Song</name></author><category term="[&quot;AI&quot;, &quot;AI_Algorithms&quot;, &quot;Vision&quot;]" /><category term="301-work-ai" /><summary type="html"><![CDATA[大家用AI一定要做好Fact Check 问题引入 最近听了姚顺宇的访谈播客，现在已经有非常多的总结，我就不赘述了，但关于其中他提到的，做模型的人要多思考，多check，方法本身是否能在不同参数量，不同模型架构，更好的数据上依然生效，是一个需要反复验证和研究的过程，这一点我深感其然。 有些工作看着很基础，也不一定是当下研究的热点，但实际上在应用过程中却异常重要。就拿我最近使用某AI软件的过程来说吧，我本来以为在如今的模型参数量和规模的情况下，模型应该会很少出现幻觉的问题了，但实际上这个问题比我想象的要严重很多。以我最近的工作为例，我最近在看到了不同的GRPO-like算法都存在不同程度的长度偏置，于是我让某AI帮我总结了一下关于这方面的研究。 于是，我得到了下面的回复，在我想要继续查看，这篇OpenAI的内部研究报告的时候，我搜遍了全网，没有通过名字找到这篇文章，于是我又把arXiv的编号搜索了一番，最终得到了一篇既不是来自于OpenAI，也和长度偏置没有任何关系的文章。所以幻觉本身还是一个比较严重，需要被正确看待并解决的问题。 工作介绍 于是我看到了千问团队最近的这篇文章，MARCH: Multi-Agent Reinforced Self-Check for LLM Hallucination，专门解决涉及到搜索召回过程中存在的幻觉问题。幻觉是一个老生常谈的问题，也是模型在实际应用里面要被解决的基础问题，对模型和平台的可信度影响非常大，一旦出现一次幻觉问题，可能用户就会完全脱离这个平台。因为用户问AI，代表其本身对问题的理解程度可能不高，很容易信任AI的回复，因此就会出现You don’t know what you don’t know这个现象，会产生生理性恐惧。那么上面这篇论文提出了什么机制来解决这个问题呢？可以参考下面这个图 简单来说，就是在一个需要检查真实信息的环境中，设定了三个角色，也是三个Agent，每个Agent不能既当裁判员，又当运动员，而是分属于Solver（RAG Model），Proposer（事实检查Question pairs）和Checker（基于每个问题进行回复）。 所以我们基本关心两个问题 这三个角色怎么设计Reward？ 具体在RL update的时候怎么训练？ Reward设计 Zero-tolerance Reward：在Proposer给定的claim里面，有一条对不上，整条trajectory都要被惩罚。 只有0和-1这两个Reward，对的是0，错了是-1； RL Update 本体使用了PPO算法，MARCH 把两类 trajectory 都放进 PPO batch： 1. Solver trajectory y 2. Checker audit trajectory λ 每条原始样本 (x, D) 会产生： y_i = Solver response λ_i = Checker audit response R_i = ZTR reward 然后它把 y_i 和 λ_i 都加入 unified trajectory batch TB，并且两者共享同一个 terminal reward R_i。Algorithm 1 里就是这么写的：先生成 y，再 Proposer 拆 QA，再 Checker 生成 λ，再算 ZTR，最后把 y_i 和 λ_i 都加入 unified batch trajectory set。 实验结果 可以看到，实验整体的效果还是不错的       除了今天提到的这篇，千问C端应用团队四篇论文今年有四篇论文都入选ICML、ACL，覆盖推理加速、幻觉治理、架构优化与结构化推理四个方向。其中一篇ECHO框架的中了ICML 2026的SpotLight，还是很有含金量的，毕竟是前2.2%了，今天投稿量还翻倍了 整体看下来，不愧是做C端应用的，论文里的框架都很实际，大家感兴趣可以去看看。 总结 基础的工作往往需要更持续的投入和更多方法的总结，尤其是现在Agent方案逐渐被大家接受，模型怎么能在这个过程中避免Tool Use，使用Tool Use的结果，整个过程完整任务，没有幻觉，也会持续被大家讨论。千问这篇文章工作算是用Agent方案进行的一个新的尝试，还是很不错的。]]></summary></entry><entry><title type="html">【AI】DPO实战Sharing</title><link href="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/04/07/DPO-sharing.html" rel="alternate" type="text/html" title="【AI】DPO实战Sharing" /><published>2026-04-07T04:11:07+08:00</published><updated>2026-04-07T04:11:07+08:00</updated><id>https://chengru-song.github.io/ai/ai_algorithms/vision/2026/04/07/DPO-sharing</id><content type="html" xml:base="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/04/07/DPO-sharing.html"><![CDATA[<h1 id="vlm-rl算法的思考三">VLM RL算法的思考（三）</h1>

<p>之前分享过很多和DPO训练相关的文章，DPO在数据组织方式上存在巨大优势（主要两点，可离线收集，只需要Rollout两条数据即可），在训练效率上相比PPO和GRPO也有相对优势（比PPO少load一个Critic Model和Reward Model，比GRPO Rollout次数少），外加天然比较适配做业务的AB实验组，因此是一个快速开展业务RL的起步算法，或者至少是一个值得对比的算法baseline。</p>

<p>但DPO本身的问题实在是比较多，因此这篇文章在之前文章的基础上，又深化了一下基于理论而不是单纯在实践上的思考，分享出来可供大家实操。</p>

<h2 id="本文目标">本文目标</h2>

<ol>
  <li>明确DPO算法本身存在怎样的设计缺陷；</li>
  <li>回顾DPO的发展历程，和DPO算法相关发生过怎样的优化；</li>
  <li>针对业务场景，到底什么优化是管用的，我们应该如何调参。</li>
</ol>

<h2 id="背景dpo存在怎样的设计缺陷">背景：DPO存在怎样的设计缺陷？</h2>

<p>先说结论</p>

<blockquote>
  <p>[!WARNING]</p>

  <ol>
    <li>正优化失效：Rejected降的速度快于Chosen升的速度，导致Acc上涨，但实际上Policy Model的回复更差了（Format约束失效）；</li>
    <li>长度偏置：较长样本天然具有更高rewards，导致DPO优化后模型输出变长，甚至停不下来；</li>
    <li>Reward Hacking。</li>
    <li>训练效果不稳定，常出现相同参数无法适配到所有任务中。</li>
  </ol>
</blockquote>

<p>为什么DPO会存在以上缺陷？</p>

<p>从DPO的loss公式出发，DPO天然被定义为，最大化Policy的Reward，同时用KL散度保证待优化的Policy不要太远离ref Policy。</p>

\[\max_{\pi_\theta} J(\pi_\theta) = \mathbb{E}*{x\sim\mathcal{D}, y\sim\pi*\theta(y|x)} \left[ r(y|x) - \beta \cdot D_{\text{KL}}\left( \pi_\theta(y|x) \parallel \pi_{\text{ref}}(y|x) \right) \right]\]

<p>将KL散度展开可得，对于每个独立的\(x\)(prompt)，优化目标为</p>

\[\max_{\pi_\theta(\cdot|x)} \sum_y \pi_\theta(y|x) r(y|x) - \beta \sum_y \pi_\theta(y|x) \log \frac{\pi_\theta(y|x)}{\pi_{\text{ref}}(y|x)}\]

<table>
  <tbody>
    <tr>
      <td>s.t. $$\sum_y \pi_\theta(y</td>
      <td>x) = 1 $$</td>
    </tr>
  </tbody>
</table>

<p><strong>注意这里的比较容易迷惑的点</strong>：限制条件是，针对输入\(x\) ，所有可能的回复\(\)的总概率为1。而基于Policy Gradient或者Natural Gradient的RL算法来说，一般来说都是Action粒度的，每个Action的优势都是需要估计的。所以虽然都是优化一条回复的Reward，但是Policy Gradient一般来说不这么建模。</p>

<p>DPO具体推导过程参考Reference</p>

<p>对我们有用的是最终的Loss function为</p>

\[\mathcal{L}*{\text{DPO}}(\pi*\theta; \pi_{\text{ref}}) = - \mathbb{E}*{(x,y_w,y_l)\sim\mathcal{D}} \left[ \log \sigma\left( \beta \log \frac{\pi*\theta(y_w|x)}{\pi_{\text{ref}}(y_w|x)} - \beta \log \frac{\pi_\theta(y_l|x)}{\pi_{\text{ref}}(y_l|x)} \right) \right]\]

<p>把比值简化能得到下列公式，在实现的时候就是</p>

\[\mathcal{L}*{\text{DPO}} = - \mathbb{E}*{(x,y_w,y_l)} \left[ \log \sigma\left( \hat{r}*\theta(y_w|x) - \hat{r}*\theta(y_l|x) \right) \right]\]

<p>实际实现时，loss = sum(logps(chosen) - sum(lops(reject))</p>

<p>单条样本的梯度公式：</p>

\[\nabla_\theta L = - \beta \cdot \sigma(-\Delta_\theta) \cdot \left( \nabla_\theta \log \pi_\theta(y_w|x) - \nabla_\theta \log \pi_\theta(y_l|x) \right)\]

\[\nabla_\theta \mathcal{L}*{\text{DPO}} = -\beta \cdot \underbrace{\left( 1 - \sigma\left( \beta \cdot \Delta_r \right) \right)}*{\text{样本权重项}} \cdot \underbrace{\left( \nabla_\theta \log \pi_\theta(y_w|x) - \nabla_\theta \log \pi_\theta(y_l|x) \right)}_{\text{偏好梯度方向}}\]

<p>对于以上缺陷，从Loss和Gradient角度出发理解</p>

<ol>
  <li>Loss本身只鼓励Chosen和Reject的Margin，并不实际能增大Chosen输出的概率，在BT概率模型中，训练RM没有问题，但是DPO这样使用，就出现了问题；</li>
  <li>在样本梯度公式中，\(\beta\) 扮演了如下的角色，因此会出现天然悖论：<strong>当你想让模型更保守的时候，梯度会变大，训练不稳定；当你想让模型更激进的时候，梯度较小，sigmoid很平，样本都学但KL弱，可能偏离ref特别大，还是会变差。</strong></li>
</ol>

<table>
  <thead>
    <tr>
      <th><strong>β 大</strong></th>
      <th><strong>β 小</strong></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>梯度大</td>
      <td>梯度小</td>
    </tr>
    <tr>
      <td>sigmoid 很陡（hard）</td>
      <td>sigmoid 很平（soft）</td>
    </tr>
    <tr>
      <td>只学错的样本</td>
      <td>所有样本都学</td>
    </tr>
    <tr>
      <td>KL 强（贴近 reference）</td>
      <td>KL弱</td>
    </tr>
    <tr>
      <td>更保守</td>
      <td>更激进</td>
    </tr>
  </tbody>
</table>

<table>
  <thead>
    <tr>
      <th><strong>Δᵣ 的值</strong></th>
      <th><strong>含义</strong></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Δᵣ ≫ 0</td>
      <td>模型已经能很好区分 yᵥ over yₗ</td>
    </tr>
    <tr>
      <td>Δᵣ ≈ 0</td>
      <td>模型不能区分win和lose</td>
    </tr>
    <tr>
      <td>Δᵣ ≪ 0</td>
      <td>模型非常prefer yₗ，gradient巨大</td>
    </tr>
  </tbody>
</table>

<p><strong>全是太难的样本，将直接导致DPO训练崩溃；全是太简单的样本，DPO训练不会更新模型权重，等于没学；中间的样本，DPO能学的比较好，梯度比较稳定，但如何调整</strong>\(\beta\) <strong>成为一门手艺。</strong></p>

<h2 id="如何解决以上问题">如何解决以上问题？</h2>

<table>
  <thead>
    <tr>
      <th><strong>时间</strong></th>
      <th><strong>暴露的问题</strong></th>
      <th><strong>代表工作/方向</strong></th>
      <th><strong>核心思路</strong></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>2024 Q1</td>
      <td>DPO 理论近似有偏，BT 假设太强</td>
      <td>IPO, KTO</td>
      <td>改偏好建模/改 loss，不再完全信 DPO 原始推导</td>
    </tr>
    <tr>
      <td>2024 Q1-Q2</td>
      <td>reference 成本高、限制强</td>
      <td>ORPO, SimPO</td>
      <td>去 reference 或弱化 reference，降低内存和约束</td>
    </tr>
    <tr>
      <td>2024 Q2</td>
      <td>排序没学好</td>
      <td>Preference Learning Algorithms Do Not Learn Preference Rankings</td>
      <td>指出 DPO 不一定真修正 preference ranking</td>
    </tr>
    <tr>
      <td>2024 Q2</td>
      <td>rejected 降得快于 chosen 升得快</td>
      <td>Theoretical Perspective on DPO Limitations</td>
      <td>揭示梯度不平衡，为后续 BDPO 铺路</td>
    </tr>
    <tr>
      <td>2024 Q2-Q3</td>
      <td>长度偏置</td>
      <td>Disentangling Length from Quality, SamPO</td>
      <td>去 verbosity bias / length exploitation</td>
    </tr>
    <tr>
      <td>2024 Q2-Q4</td>
      <td>pairwise 太粗糙，数据利用率低</td>
      <td>RPO, mDPO</td>
      <td>用相似 prompt、多样本比较补信息</td>
    </tr>
    <tr>
      <td>2024 Q3</td>
      <td>reference 到底怎么影响 DPO</td>
      <td>Understanding Reference Policies in DPO</td>
      <td>说明 reference 既稳又会带来 ceiling/mismatch</td>
    </tr>
    <tr>
      <td>2025 Q1</td>
      <td>训练注意力分配不合理</td>
      <td>FocalPO</td>
      <td>动态重加权样本，改善 ranking 学习</td>
    </tr>
    <tr>
      <td>2025 Q2</td>
      <td>data utilization 不佳</td>
      <td>Pre-DPO, Omni-DPO</td>
      <td>用 guiding reference / 动态样本权重提升数据效率</td>
    </tr>
    <tr>
      <td>2025 Q2</td>
      <td>rejected influence 过强</td>
      <td>BDPO</td>
      <td>给 rejected 项加边界，平衡 chosen/rejected 学习</td>
    </tr>
    <tr>
      <td>2025 Q2-Q3</td>
      <td>偏好多样、群体冲突</td>
      <td>GDPO, λ-DPO</td>
      <td>从单峰偏好转向 group/listwise/multi-dimensional preference</td>
    </tr>
    <tr>
      <td>2024–2026</td>
      <td>偏好数据噪声</td>
      <td>Distributionally Robust DPO, wDPO</td>
      <td>用 DRO、winsorization 做鲁棒训练</td>
    </tr>
    <tr>
      <td>2026 Q1</td>
      <td>pessimistic reference 导致 premature satisfaction</td>
      <td>HyPO</td>
      <td>条件性 debias reference，而非完全去掉</td>
    </tr>
    <tr>
      <td>2026 Q1</td>
      <td>只有 pairwise 胜负太浪费</td>
      <td>RDPO/RIPO</td>
      <td>加入 rating gap，提升统计效率</td>
    </tr>
    <tr>
      <td>2026 Q1</td>
      <td>OOD / confounder 问题</td>
      <td>CausalDPO</td>
      <td>用因果不变性提升分布外泛化</td>
    </tr>
  </tbody>
</table>

<h2 id="experiments">Experiments</h2>

<table>
  <thead>
    <tr>
      <th>beta=0.1</th>
      <th>Math</th>
      <th> </th>
      <th> </th>
      <th> </th>
      <th> </th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>DPO baseline</td>
      <td>$$\mathcal{L}<em>{\text{DPO}} = - \mathbb{E}{(x, y^+, y^-)} \left[ \log \sigma \left( \beta \cdot \left( \log\pi</em>\theta(y^+</td>
      <td>x) - \log \pi_\theta(y^-</td>
      <td>x) \left(\log \pi_{\text{ref}}(y^+</td>
      <td>x) - \log \pi_{\text{ref}}(y^-</td>
      <td>x)\right) \right) \right) \right] $$</td>
    </tr>
    <tr>
      <td>DPO + SFT Baseline</td>
      <td>\(L=\alpha \mathcal{L}_{\text{DPO-LN}} + \beta \mathcal{L}_{\text{SFT}}\)</td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
    </tr>
    <tr>
      <td>DPO + BCO baseline</td>
      <td>\(L=\alpha \mathcal{L}_{\text{DPO-LN}} + \gamma\mathcal{L}_{\text{BCO}}\)</td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
    </tr>
    <tr>
      <td>MPO Baseline</td>
      <td>\(L=\alpha \mathcal{L}_{\text{DPO}} + \beta \mathcal{L}_{\text{SFT}} + \gamma\mathcal{L}_{\text{BCO}}\)</td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
    </tr>
    <tr>
      <td>SimPO</td>
      <td>$$ \mathcal{L}<em>{\text{SimPO}} = -\mathbb{E}</em>{(x,y_w,y_l)\sim \mathcal{D}} \left[ \log \sigma \left(\beta \left(\frac{1}{</td>
      <td>y_w</td>
      <td>} \log \pi_\theta(y_w \mid x) -\frac{1}{</td>
      <td>y_l</td>
      <td>} \log \pi_\theta(y_l \mid x) \right)- \gamma \right) \right ] $$</td>
    </tr>
    <tr>
      <td>OrPO</td>
      <td>\(\mathcal{L}_{\mathrm{ORPO}}(\theta)=\mathbb{E}_{(x,y_w,y_l)\sim\mathcal{D}}\left[- \log \pi_\theta(y_w \mid x)+ \lambda \log \sigma \left(\log\frac{\pi_\theta(y_w\mid x)}{\pi_\theta(y_l \mid x)}\right)\right]\)</td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
    </tr>
    <tr>
      <td>DPO Length Norm</td>
      <td>\(\mathcal{L}_{\text{DPO-LN}} =- \mathbb{E} \left[\log \sigma \left(\beta \cdot \left(\frac{\log \pi_\theta(y^+)}{L_+^{\alpha}}-\frac{\log \pi_\theta(y^-)}{L_-^{\alpha}}-\left(\frac{\log \pi_{\text{ref}}(y^+)}{L_+^{\alpha}}-\frac{\log \pi_{\text{ref}}(y^-)}{L_-^{\alpha}}\right)\right)\right)\right]\)</td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
    </tr>
    <tr>
      <td>MPO Length Norm</td>
      <td>\(L=\alpha \mathcal{L}_{\text{DPO-LN}} + \beta \mathcal{L}_{\text{SFT}} + \gamma\mathcal{L}_{\text{BCO}}\)</td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
    </tr>
  </tbody>
</table>

<h2 id="learnings">Learnings</h2>

<ol>
  <li>数据
    <ol>
      <li>正负样本标注需用不同模型组合或者真实信号，避免Reward hacking；</li>
      <li>正负样本之间的margin不要过大，最好能在模型的自Context上学习，避免强模型输出内容distribution偏离过大</li>
    </ol>
  </li>
  <li>训练
    <ol>
      <li>\(\beta\)和LR要联合调整，建议beta从0.1开始，分别向0.05和0.2两边调整，如果中间都优化不好，最好调整解决一下数据问题。</li>
    </ol>
  </li>
</ol>

<h2 id="whats-next">What’s Next？</h2>

<p><strong>第一，vanilla DPO  baseline效果从优化角度很好，各种优化的Acc大概率都比Vanilla DPO差，但实际应用没办法直接使用。</strong>因为真实偏好远比 pairwise logistic + static reference 更复杂，并且其隐含在baseline loss function里面的固有问题是严重的。</p>

<p><strong>第二，后续优化正在把 DPO 从“一个公式”变成“一个框架”。</strong> 你现在看到的主要增强件，已经覆盖了 reference design、sample weighting、noise robustness、pluralistic preference、listwise/rating supervision、OOD generalization。</p>

<p><strong>第三，最有前景的方向不是单点改 loss，而是“更丰富监督 + 更合理数据选择 + 更精细 reference 使用”。</strong> 也就是从纯 pairwise DPO，走向 listwise/rating/multi-sample；从 uniform weighting，走向 difficulty-aware / quality-aware weighting；从 static reference，走向 conditional / guiding / debiased reference。</p>

<h2 id="reference">Reference</h2>

<p>所以原问题被转化为这是一个带等式约束的泛函优化问题，我们构造拉格朗日函数：</p>

\[\mathcal{L} = \sum_y \pi_\theta(y|x) r(y|x) - \beta \sum_y \pi_\theta(y|x) \log \frac{\pi_\theta(y|x)}{\pi_{\text{ref}}(y|x)} + \lambda \left( 1 - \sum_y \pi_\theta(y|x) \right)\]

<p>其中\(\lambda\)是拉格朗日常数。</p>

<table>
  <tbody>
    <tr>
      <td>对$$\pi_\theta(y</td>
      <td>x$$求偏导，极值为0时L取得最大值，可得</td>
    </tr>
  </tbody>
</table>

\[\frac{\partial \mathcal{L}}{\partial \pi_\theta(y|x)} = r(y|x) - \beta \left( \log \frac{\pi_\theta(y|x)}{\pi_{\text{ref}}(y|x)} + 1 \right) - \lambda = 0\]

<p>变形后两边取指数：</p>

\[\pi_\theta(y|x) = \pi_{\text{ref}}(y|x) \cdot \exp\left( \frac{r(y|x)}{\beta} \right) \cdot \exp\left( -\frac{\lambda + \beta}{\beta} \right)\]

<table>
  <tbody>
    <tr>
      <td>根据归一化条件$$\sum_y \pi_\theta(y</td>
      <td>x) = $$，定义归一化配分(partion function)函数：</td>
    </tr>
  </tbody>
</table>

\[Z(x) = \sum_y \pi_{\text{ref}}(y|x) \exp\left( \frac{r(y|x)}{\beta} \right)\]

<p>最终得到DPO最优Policy的closed Form：</p>

\[\pi^*(y|x) = \frac{1}{Z(x)} \cdot \pi_{\text{ref}}(y|x) \cdot \exp\left( \frac{r(y|x)}{\beta} \right)\]

<p>两边同时取对数可以得到</p>

\[\log \pi^*(y|x) = \log \pi_{\text{ref}}(y|x) + \frac{r(y|x)}{\beta} - \log Z(x)\]]]></content><author><name>Chengru Song</name></author><category term="[&quot;AI&quot;, &quot;AI_Algorithms&quot;, &quot;Vision&quot;]" /><category term="301-work-ai" /><summary type="html"><![CDATA[VLM RL算法的思考（三） 之前分享过很多和DPO训练相关的文章，DPO在数据组织方式上存在巨大优势（主要两点，可离线收集，只需要Rollout两条数据即可），在训练效率上相比PPO和GRPO也有相对优势（比PPO少load一个Critic Model和Reward Model，比GRPO Rollout次数少），外加天然比较适配做业务的AB实验组，因此是一个快速开展业务RL的起步算法，或者至少是一个值得对比的算法baseline。 但DPO本身的问题实在是比较多，因此这篇文章在之前文章的基础上，又深化了一下基于理论而不是单纯在实践上的思考，分享出来可供大家实操。 本文目标 明确DPO算法本身存在怎样的设计缺陷； 回顾DPO的发展历程，和DPO算法相关发生过怎样的优化； 针对业务场景，到底什么优化是管用的，我们应该如何调参。 背景：DPO存在怎样的设计缺陷？ 先说结论 [!WARNING] 正优化失效：Rejected降的速度快于Chosen升的速度，导致Acc上涨，但实际上Policy Model的回复更差了（Format约束失效）； 长度偏置：较长样本天然具有更高rewards，导致DPO优化后模型输出变长，甚至停不下来； Reward Hacking。 训练效果不稳定，常出现相同参数无法适配到所有任务中。 为什么DPO会存在以上缺陷？ 从DPO的loss公式出发，DPO天然被定义为，最大化Policy的Reward，同时用KL散度保证待优化的Policy不要太远离ref Policy。 \[\max_{\pi_\theta} J(\pi_\theta) = \mathbb{E}*{x\sim\mathcal{D}, y\sim\pi*\theta(y|x)} \left[ r(y|x) - \beta \cdot D_{\text{KL}}\left( \pi_\theta(y|x) \parallel \pi_{\text{ref}}(y|x) \right) \right]\] 将KL散度展开可得，对于每个独立的\(x\)(prompt)，优化目标为 \[\max_{\pi_\theta(\cdot|x)} \sum_y \pi_\theta(y|x) r(y|x) - \beta \sum_y \pi_\theta(y|x) \log \frac{\pi_\theta(y|x)}{\pi_{\text{ref}}(y|x)}\] s.t. $$\sum_y \pi_\theta(y x) = 1 $$ 注意这里的比较容易迷惑的点：限制条件是，针对输入\(x\) ，所有可能的回复\(\)的总概率为1。而基于Policy Gradient或者Natural Gradient的RL算法来说，一般来说都是Action粒度的，每个Action的优势都是需要估计的。所以虽然都是优化一条回复的Reward，但是Policy Gradient一般来说不这么建模。 DPO具体推导过程参考Reference 对我们有用的是最终的Loss function为 \[\mathcal{L}*{\text{DPO}}(\pi*\theta; \pi_{\text{ref}}) = - \mathbb{E}*{(x,y_w,y_l)\sim\mathcal{D}} \left[ \log \sigma\left( \beta \log \frac{\pi*\theta(y_w|x)}{\pi_{\text{ref}}(y_w|x)} - \beta \log \frac{\pi_\theta(y_l|x)}{\pi_{\text{ref}}(y_l|x)} \right) \right]\] 把比值简化能得到下列公式，在实现的时候就是 \[\mathcal{L}*{\text{DPO}} = - \mathbb{E}*{(x,y_w,y_l)} \left[ \log \sigma\left( \hat{r}*\theta(y_w|x) - \hat{r}*\theta(y_l|x) \right) \right]\] 实际实现时，loss = sum(logps(chosen) - sum(lops(reject)) 单条样本的梯度公式： \[\nabla_\theta L = - \beta \cdot \sigma(-\Delta_\theta) \cdot \left( \nabla_\theta \log \pi_\theta(y_w|x) - \nabla_\theta \log \pi_\theta(y_l|x) \right)\] \[\nabla_\theta \mathcal{L}*{\text{DPO}} = -\beta \cdot \underbrace{\left( 1 - \sigma\left( \beta \cdot \Delta_r \right) \right)}*{\text{样本权重项}} \cdot \underbrace{\left( \nabla_\theta \log \pi_\theta(y_w|x) - \nabla_\theta \log \pi_\theta(y_l|x) \right)}_{\text{偏好梯度方向}}\] 对于以上缺陷，从Loss和Gradient角度出发理解 Loss本身只鼓励Chosen和Reject的Margin，并不实际能增大Chosen输出的概率，在BT概率模型中，训练RM没有问题，但是DPO这样使用，就出现了问题； 在样本梯度公式中，\(\beta\) 扮演了如下的角色，因此会出现天然悖论：当你想让模型更保守的时候，梯度会变大，训练不稳定；当你想让模型更激进的时候，梯度较小，sigmoid很平，样本都学但KL弱，可能偏离ref特别大，还是会变差。 β 大 β 小 梯度大 梯度小 sigmoid 很陡（hard） sigmoid 很平（soft） 只学错的样本 所有样本都学 KL 强（贴近 reference） KL弱 更保守 更激进 Δᵣ 的值 含义 Δᵣ ≫ 0 模型已经能很好区分 yᵥ over yₗ Δᵣ ≈ 0 模型不能区分win和lose Δᵣ ≪ 0 模型非常prefer yₗ，gradient巨大 全是太难的样本，将直接导致DPO训练崩溃；全是太简单的样本，DPO训练不会更新模型权重，等于没学；中间的样本，DPO能学的比较好，梯度比较稳定，但如何调整\(\beta\) 成为一门手艺。 如何解决以上问题？ 时间 暴露的问题 代表工作/方向 核心思路 2024 Q1 DPO 理论近似有偏，BT 假设太强 IPO, KTO 改偏好建模/改 loss，不再完全信 DPO 原始推导 2024 Q1-Q2 reference 成本高、限制强 ORPO, SimPO 去 reference 或弱化 reference，降低内存和约束 2024 Q2 排序没学好 Preference Learning Algorithms Do Not Learn Preference Rankings 指出 DPO 不一定真修正 preference ranking 2024 Q2 rejected 降得快于 chosen 升得快 Theoretical Perspective on DPO Limitations 揭示梯度不平衡，为后续 BDPO 铺路 2024 Q2-Q3 长度偏置 Disentangling Length from Quality, SamPO 去 verbosity bias / length exploitation 2024 Q2-Q4 pairwise 太粗糙，数据利用率低 RPO, mDPO 用相似 prompt、多样本比较补信息 2024 Q3 reference 到底怎么影响 DPO Understanding Reference Policies in DPO 说明 reference 既稳又会带来 ceiling/mismatch 2025 Q1 训练注意力分配不合理 FocalPO 动态重加权样本，改善 ranking 学习 2025 Q2 data utilization 不佳 Pre-DPO, Omni-DPO 用 guiding reference / 动态样本权重提升数据效率 2025 Q2 rejected influence 过强 BDPO 给 rejected 项加边界，平衡 chosen/rejected 学习 2025 Q2-Q3 偏好多样、群体冲突 GDPO, λ-DPO 从单峰偏好转向 group/listwise/multi-dimensional preference 2024–2026 偏好数据噪声 Distributionally Robust DPO, wDPO 用 DRO、winsorization 做鲁棒训练 2026 Q1 pessimistic reference 导致 premature satisfaction HyPO 条件性 debias reference，而非完全去掉 2026 Q1 只有 pairwise 胜负太浪费 RDPO/RIPO 加入 rating gap，提升统计效率 2026 Q1 OOD / confounder 问题 CausalDPO 用因果不变性提升分布外泛化 Experiments beta=0.1 Math         DPO baseline $$\mathcal{L}{\text{DPO}} = - \mathbb{E}{(x, y^+, y^-)} \left[ \log \sigma \left( \beta \cdot \left( \log\pi\theta(y^+ x) - \log \pi_\theta(y^- x) \left(\log \pi_{\text{ref}}(y^+ x) - \log \pi_{\text{ref}}(y^- x)\right) \right) \right) \right] $$ DPO + SFT Baseline \(L=\alpha \mathcal{L}_{\text{DPO-LN}} + \beta \mathcal{L}_{\text{SFT}}\)         DPO + BCO baseline \(L=\alpha \mathcal{L}_{\text{DPO-LN}} + \gamma\mathcal{L}_{\text{BCO}}\)         MPO Baseline \(L=\alpha \mathcal{L}_{\text{DPO}} + \beta \mathcal{L}_{\text{SFT}} + \gamma\mathcal{L}_{\text{BCO}}\)         SimPO $$ \mathcal{L}{\text{SimPO}} = -\mathbb{E}{(x,y_w,y_l)\sim \mathcal{D}} \left[ \log \sigma \left(\beta \left(\frac{1}{ y_w } \log \pi_\theta(y_w \mid x) -\frac{1}{ y_l } \log \pi_\theta(y_l \mid x) \right)- \gamma \right) \right ] $$ OrPO \(\mathcal{L}_{\mathrm{ORPO}}(\theta)=\mathbb{E}_{(x,y_w,y_l)\sim\mathcal{D}}\left[- \log \pi_\theta(y_w \mid x)+ \lambda \log \sigma \left(\log\frac{\pi_\theta(y_w\mid x)}{\pi_\theta(y_l \mid x)}\right)\right]\)         DPO Length Norm \(\mathcal{L}_{\text{DPO-LN}} =- \mathbb{E} \left[\log \sigma \left(\beta \cdot \left(\frac{\log \pi_\theta(y^+)}{L_+^{\alpha}}-\frac{\log \pi_\theta(y^-)}{L_-^{\alpha}}-\left(\frac{\log \pi_{\text{ref}}(y^+)}{L_+^{\alpha}}-\frac{\log \pi_{\text{ref}}(y^-)}{L_-^{\alpha}}\right)\right)\right)\right]\)         MPO Length Norm \(L=\alpha \mathcal{L}_{\text{DPO-LN}} + \beta \mathcal{L}_{\text{SFT}} + \gamma\mathcal{L}_{\text{BCO}}\)         Learnings 数据 正负样本标注需用不同模型组合或者真实信号，避免Reward hacking； 正负样本之间的margin不要过大，最好能在模型的自Context上学习，避免强模型输出内容distribution偏离过大 训练 \(\beta\)和LR要联合调整，建议beta从0.1开始，分别向0.05和0.2两边调整，如果中间都优化不好，最好调整解决一下数据问题。 What’s Next？ 第一，vanilla DPO baseline效果从优化角度很好，各种优化的Acc大概率都比Vanilla DPO差，但实际应用没办法直接使用。因为真实偏好远比 pairwise logistic + static reference 更复杂，并且其隐含在baseline loss function里面的固有问题是严重的。 第二，后续优化正在把 DPO 从“一个公式”变成“一个框架”。 你现在看到的主要增强件，已经覆盖了 reference design、sample weighting、noise robustness、pluralistic preference、listwise/rating supervision、OOD generalization。 第三，最有前景的方向不是单点改 loss，而是“更丰富监督 + 更合理数据选择 + 更精细 reference 使用”。 也就是从纯 pairwise DPO，走向 listwise/rating/multi-sample；从 uniform weighting，走向 difficulty-aware / quality-aware weighting；从 static reference，走向 conditional / guiding / debiased reference。 Reference 所以原问题被转化为这是一个带等式约束的泛函优化问题，我们构造拉格朗日函数： \[\mathcal{L} = \sum_y \pi_\theta(y|x) r(y|x) - \beta \sum_y \pi_\theta(y|x) \log \frac{\pi_\theta(y|x)}{\pi_{\text{ref}}(y|x)} + \lambda \left( 1 - \sum_y \pi_\theta(y|x) \right)\] 其中\(\lambda\)是拉格朗日常数。 对$$\pi_\theta(y x$$求偏导，极值为0时L取得最大值，可得 \[\frac{\partial \mathcal{L}}{\partial \pi_\theta(y|x)} = r(y|x) - \beta \left( \log \frac{\pi_\theta(y|x)}{\pi_{\text{ref}}(y|x)} + 1 \right) - \lambda = 0\] 变形后两边取指数： \[\pi_\theta(y|x) = \pi_{\text{ref}}(y|x) \cdot \exp\left( \frac{r(y|x)}{\beta} \right) \cdot \exp\left( -\frac{\lambda + \beta}{\beta} \right)\] 根据归一化条件$$\sum_y \pi_\theta(y x) = $$，定义归一化配分(partion function)函数： \[Z(x) = \sum_y \pi_{\text{ref}}(y|x) \exp\left( \frac{r(y|x)}{\beta} \right)\] 最终得到DPO最优Policy的closed Form： \[\pi^*(y|x) = \frac{1}{Z(x)} \cdot \pi_{\text{ref}}(y|x) \cdot \exp\left( \frac{r(y|x)}{\beta} \right)\] 两边同时取对数可以得到 \[\log \pi^*(y|x) = \log \pi_{\text{ref}}(y|x) + \frac{r(y|x)}{\beta} - \log Z(x)\]]]></summary></entry><entry><title type="html">【AI】小红书workflow</title><link href="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/04/07/agentic-ai.html" rel="alternate" type="text/html" title="【AI】小红书workflow" /><published>2026-04-07T04:09:07+08:00</published><updated>2026-04-07T04:09:07+08:00</updated><id>https://chengru-song.github.io/ai/ai_algorithms/vision/2026/04/07/agentic-ai</id><content type="html" xml:base="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/04/07/agentic-ai.html"><![CDATA[<h1 id="对agentic-ai快速发展的思考">对Agentic AI快速发展的思考</h1>

<p>最近个人AI工作流疯狂爆发，我自己都陷入了比较严重的FOMO（Fear of Missing Out）情绪，这种情绪我分析主要是下面几个方面造成的：</p>

<ol>
  <li><strong>对未来工作不确定性的焦虑</strong>：经常刷到漫天的专家预测，未来不仅简单的任务，中等甚至高级难度的工作，也有非常大被取代的可能性，每个人都在纠结，自己的工作到底是不是那个被取代的一部分，以及怎么能不被取代。</li>
  <li><strong>对AI本身发展速度的焦虑</strong>：试图拥抱AI，但是发现知识更新速度日新月异，今天才学到的知识，明天可能又过时了；</li>
  <li><strong>不知道AI的正确使用方式</strong>：ChatGPT刚兴起的时候，有人专门教大家做Prompt Engineering，PE做得好和不好，任务完成度差异非常之大；发展到现在，这个趋势变成了怎么使用OpenClaw，怎么高效使用Token。我自己的认知也经历了很多次迭代，从我认为AI没有办法做任何严肃的工作，到我认为AI至少可能可以完成部分严肃工作，都源于<strong>我对AI使用方法的改变</strong>。</li>
</ol>

<p>坦白来讲，我至今都无法摆脱这种焦虑，但是有两个心态和两个行动，让我能稍微从AI焦虑中喘息。</p>

<ol>
  <li><strong>心态1：理解市场的真实需求</strong>，即痛点是永恒的，但流程不是。来自这篇文章：https://x.com/sathyanellore/status/2040550670575792441。因此，我认为我应该更关注结果本身，而不是流程。比如视频编辑，痛点是如何快速产出消费者爱看的内容，而不是如何使用达芬奇剪辑软件。</li>
  <li><strong>心态2：理解AI能力的边界</strong>。能理解AI的上限，再加上对真实需求的理解，就能判断，哪些工作未来可能会被取代，哪些不能。而且AI的发展飞快，只是被个人焦虑+算法推送给蒙蔽了。实际上，目前的OpenClaw基本上和最早的Agent方法，硬要说和最开始有什么特别的，就是模型自身的上下文变长了，Planning和Execute变好了；能控制电脑，所以自动化能力变强了。同时，虽然模型能力变强是事实，但AI的幻觉问题至今没有解决，或者说，AI的幻觉是否能被解决？一个靠预测下一个Token运行机制的概率模型，该怎么给定一个完全确定无误的答案？</li>
  <li><strong>行动1：尝试做一人公司</strong>。有什么想做的事情，有任何想法，想完成的任务，直接开始vibe coding。</li>
  <li><strong>行动2：只用AI产出最终结果</strong>。私以为，理解模型上限的最好做法就是不对模型的任何中间产出做干扰，让模型端到端输出结果，只对结果不满足需求的地方给AI进行上下文补充或者让AI直接修改结果，而不做任何手动修改，不断迭代直到没有任何办法能优化了，看下最终结果和人工的差距有多大。</li>
</ol>

<p>基于以上心态和行动，我的焦虑被显著的缓解了。只有行动是缓解焦虑的唯一良药，而不是思虑。同时，我坚信两点</p>

<ol>
  <li>社会的巨大变革对普通人来说永远是机会，我作为普通人，没有什么可失去的，还不如孤注一掷，让自己对AI的理解超过大部分人；</li>
  <li>历史上类似的事情在不断重演，这次也没什么不同。可能电气时代，人们也经常听到哪个工厂因为引入了电气设备，而导致很多人失业，也觉得天翻地覆，日新月异，只是我们不是那个时代的普通人，没办法听到他们的抱怨；白领也只是电脑普及之后才存在的工作，不然哪有这么多坐办公室的。</li>
</ol>

<p>保持对世界的好奇，保持对解决问题的欣喜，积极向前，才是最终解法。</p>

<p>下面分享两个我自己的尝试流程，大家可以参考下。</p>

<h2 id="行动时间">行动时间</h2>

<p>以下尝试均以悟空AI为例。（为什么不使用OpenClaw等，配置略微复杂且当前没有现成的小红书Skill）</p>

<h3 id="发布有价值的小红书笔记">发布有价值的小红书笔记</h3>

<p>悟空AI有小红书Skill，我的笔记内容主要围绕小红书展开，且我的目标是发表一篇对读者有实际价值的笔记，因此我的思考过程如下</p>

<ol>
  <li>Literature Review：在当前文献和开源博客中，做较为详尽的Literature Review，找寻是否有我当前笔记相关内容的方法介绍，是否有比较好的总结文章；</li>
  <li>小红书Research：在小红书平台，是否存在相关笔记内容；</li>
  <li>小红书风格润色：根据我的历史高赞笔记，对最新内容进行风格润色；根据小红书的文风，对内容进行调整。</li>
</ol>

<p>但我其实也想看下现在模型的思考能力，和我自己的思考是否能有所互补，因此我实际给到悟空AI的输入是我整个博客的内容并告诉他要使用小红书Skill。</p>

<table>
  <thead>
    <tr>
      <th>不给思路Prompt+执行结果</th>
      <th>给思路Prompt+执行结果</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><img src="/assets/images/image-20260406161320882.png" alt="image-20260406161320882" /><br /><img src="/assets/images/image-20260406171120091.png" alt="image-20260406171120091" /></td>
      <td><img src="/assets/images/image-20260406170642729.png" alt="image-20260406170642729" /><br /><img src="/assets/images/image-20260406171139314.png" alt="image-20260406171139314" /></td>
    </tr>
  </tbody>
</table>

<p>第一版迭代就发现了很多问题，</p>

<ol>
  <li><strong>执行步骤和时间差别</strong>：不给思路的Agent执行步骤相比给思路的Agent执行步骤多很多，前者先确定了整体思路，再执行了非常多步骤完成了整体的流程；</li>
  <li><strong>不给思路的结果更多</strong>：给定思路的Agent小红书笔记内容明显要短小非常多，在有Reference笔记的情况下依然如此，看来有时候不给思路反而是更好的？让Agent自己探索说不定比自己的思路更好。</li>
</ol>

<p>当然以上结论并没有Finalize，仅靠两次对比并不能形成严肃的结论，Agent明显在开源文献的Literature Review的部分偷懒了，明确可以给到第二版优化的。不过我们可以先对比下这两版的结果，看大家喜欢哪个版本。</p>]]></content><author><name>Chengru Song</name></author><category term="[&quot;AI&quot;, &quot;AI_Algorithms&quot;, &quot;Vision&quot;]" /><category term="301-work-ai" /><summary type="html"><![CDATA[对Agentic AI快速发展的思考 最近个人AI工作流疯狂爆发，我自己都陷入了比较严重的FOMO（Fear of Missing Out）情绪，这种情绪我分析主要是下面几个方面造成的： 对未来工作不确定性的焦虑：经常刷到漫天的专家预测，未来不仅简单的任务，中等甚至高级难度的工作，也有非常大被取代的可能性，每个人都在纠结，自己的工作到底是不是那个被取代的一部分，以及怎么能不被取代。 对AI本身发展速度的焦虑：试图拥抱AI，但是发现知识更新速度日新月异，今天才学到的知识，明天可能又过时了； 不知道AI的正确使用方式：ChatGPT刚兴起的时候，有人专门教大家做Prompt Engineering，PE做得好和不好，任务完成度差异非常之大；发展到现在，这个趋势变成了怎么使用OpenClaw，怎么高效使用Token。我自己的认知也经历了很多次迭代，从我认为AI没有办法做任何严肃的工作，到我认为AI至少可能可以完成部分严肃工作，都源于我对AI使用方法的改变。 坦白来讲，我至今都无法摆脱这种焦虑，但是有两个心态和两个行动，让我能稍微从AI焦虑中喘息。 心态1：理解市场的真实需求，即痛点是永恒的，但流程不是。来自这篇文章：https://x.com/sathyanellore/status/2040550670575792441。因此，我认为我应该更关注结果本身，而不是流程。比如视频编辑，痛点是如何快速产出消费者爱看的内容，而不是如何使用达芬奇剪辑软件。 心态2：理解AI能力的边界。能理解AI的上限，再加上对真实需求的理解，就能判断，哪些工作未来可能会被取代，哪些不能。而且AI的发展飞快，只是被个人焦虑+算法推送给蒙蔽了。实际上，目前的OpenClaw基本上和最早的Agent方法，硬要说和最开始有什么特别的，就是模型自身的上下文变长了，Planning和Execute变好了；能控制电脑，所以自动化能力变强了。同时，虽然模型能力变强是事实，但AI的幻觉问题至今没有解决，或者说，AI的幻觉是否能被解决？一个靠预测下一个Token运行机制的概率模型，该怎么给定一个完全确定无误的答案？ 行动1：尝试做一人公司。有什么想做的事情，有任何想法，想完成的任务，直接开始vibe coding。 行动2：只用AI产出最终结果。私以为，理解模型上限的最好做法就是不对模型的任何中间产出做干扰，让模型端到端输出结果，只对结果不满足需求的地方给AI进行上下文补充或者让AI直接修改结果，而不做任何手动修改，不断迭代直到没有任何办法能优化了，看下最终结果和人工的差距有多大。 基于以上心态和行动，我的焦虑被显著的缓解了。只有行动是缓解焦虑的唯一良药，而不是思虑。同时，我坚信两点 社会的巨大变革对普通人来说永远是机会，我作为普通人，没有什么可失去的，还不如孤注一掷，让自己对AI的理解超过大部分人； 历史上类似的事情在不断重演，这次也没什么不同。可能电气时代，人们也经常听到哪个工厂因为引入了电气设备，而导致很多人失业，也觉得天翻地覆，日新月异，只是我们不是那个时代的普通人，没办法听到他们的抱怨；白领也只是电脑普及之后才存在的工作，不然哪有这么多坐办公室的。 保持对世界的好奇，保持对解决问题的欣喜，积极向前，才是最终解法。 下面分享两个我自己的尝试流程，大家可以参考下。 行动时间 以下尝试均以悟空AI为例。（为什么不使用OpenClaw等，配置略微复杂且当前没有现成的小红书Skill） 发布有价值的小红书笔记 悟空AI有小红书Skill，我的笔记内容主要围绕小红书展开，且我的目标是发表一篇对读者有实际价值的笔记，因此我的思考过程如下 Literature Review：在当前文献和开源博客中，做较为详尽的Literature Review，找寻是否有我当前笔记相关内容的方法介绍，是否有比较好的总结文章； 小红书Research：在小红书平台，是否存在相关笔记内容； 小红书风格润色：根据我的历史高赞笔记，对最新内容进行风格润色；根据小红书的文风，对内容进行调整。 但我其实也想看下现在模型的思考能力，和我自己的思考是否能有所互补，因此我实际给到悟空AI的输入是我整个博客的内容并告诉他要使用小红书Skill。 不给思路Prompt+执行结果 给思路Prompt+执行结果 第一版迭代就发现了很多问题， 执行步骤和时间差别：不给思路的Agent执行步骤相比给思路的Agent执行步骤多很多，前者先确定了整体思路，再执行了非常多步骤完成了整体的流程； 不给思路的结果更多：给定思路的Agent小红书笔记内容明显要短小非常多，在有Reference笔记的情况下依然如此，看来有时候不给思路反而是更好的？让Agent自己探索说不定比自己的思路更好。 当然以上结论并没有Finalize，仅靠两次对比并不能形成严肃的结论，Agent明显在开源文献的Literature Review的部分偷懒了，明确可以给到第二版优化的。不过我们可以先对比下这两版的结果，看大家喜欢哪个版本。]]></summary></entry><entry><title type="html">【AI】Qwen3.5的野心很大</title><link href="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/02/18/qwen3_5.html" rel="alternate" type="text/html" title="【AI】Qwen3.5的野心很大" /><published>2026-02-18T09:57:07+08:00</published><updated>2026-02-18T09:57:07+08:00</updated><id>https://chengru-song.github.io/ai/ai_algorithms/vision/2026/02/18/qwen3_5</id><content type="html" xml:base="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/02/18/qwen3_5.html"><![CDATA[<h1 id="解读下qwen35">解读下Qwen3.5</h1>

<h2 id="序言">序言</h2>

<p>不知道是不是去年Deepseek开启了中国AI届的传统，大公司几乎都赶在春节前Release了一波模型，这几天比较火的就是SeedDance 2.0和Qwen3.5的模型，现在的大模型赛道确实比较卷，要知道Qwen3.5是除夕当天发布的。虽然官方的Tech Report还没有发布，但是我们可以先通过Release出来的模型权重和inference代码，看下这个官方宣称的<strong>原生多模态智能体</strong>是个什么。</p>

<h2 id="模型架构">模型架构</h2>

<p>首先Qwen3.5官方Release出来的是397B-A17B的MOE模型，MOE模型是一个Inference性价比很高的架构，这比较符合现在大模型的发展趋势：在OpenClaw相关的个人助理式应用发展出来以后，inference性价比在应用侧是一个关注度很高的指标；</p>

<p>其次，我研究了一下release出来模型的架构，即<code class="language-plaintext highlighter-rouge">Qwen3_5MoeForConditionalGeneration</code>。官方提到的<strong>原生多模态</strong>，并非是多模态模型的原生，即并没有进行Vision的tokenization，而是沿用了QwenVL的架构，即依然使用Vision Transformer编码图片，经过patchmerger对ViT结果进行下采样，最终投射到LLM的embedding空间上，不过注意这里和Qwen3VL有一些异同；</p>

<ol>
  <li>相同：都是采用了ViT + LLM的整体架构，视频采用了时间戳+Frames的处理方式；</li>
  <li>不同：Qwen3.5抛弃了Qwen3VL中的Deepstack，可能这种方式带来的提升比较有限？</li>
</ol>

<h2 id="有什么highlights">有什么Highlights？</h2>

<p>总结来说，这次Qwen3.5最重要的，就是在未来各类Agent任务场景上的适配，真正做到泛化性和实用层面的第一，而不是为了刷一些Benchmark，下面我quote一段Qwen3.5在网页上的原话。</p>

<blockquote>
  <p>[!IMPORTANT]</p>

  <p>相对于 Qwen3 系列模型，Qwen3.5 的 Post-training 性能提升主要来自于我们对各类 RL 任务和环境的全面扩展。我们更加强调 RL 环境的难度与可泛化性，而非针对特定指标或狭隘类别的 query 进行优化。下图展示了在通用 Agent 能力上，模型效果随 RL Environment scaling 带来的增益。整体性能由各模型在以下基准上的平均排名计算得出：BFCL-V4、VITA-Bench、DeepPlanning、Tool-Decathlon 和 MCP-Mark。更多任务的 scaling 效果将在我们即将发布的技术报告中详述。</p>
</blockquote>

<p><img src="/assets/images/qwen3.5_397b_a17b_scaling.png" alt="img" /></p>

<h3 id="从demo展示看qwen的野心">从Demo展示看Qwen的野心</h3>

<p>Qwen重点展示了几个场景</p>

<ol>
  <li>仰望星空：Qwen官方使用Qwen3.5对Agent能力的支持，这个是各个大厂在26年正在大力发展的方向；</li>
  <li>脚踏实地：
    <ol>
      <li>网页和coding开发；</li>
      <li>第三方智能体的集成：OpenClaw的适配；</li>
      <li>视觉智能体、视觉编程。</li>
    </ol>
  </li>
  <li>惊喜：自动驾驶场景的应用潜力。</li>
</ol>

<p>以上几个都是Qwen官方放出来的Demo，可以看出其希望通过Qwen3.5这个模型来开启26年的Agent爆发元年。</p>

<h2 id="总结">总结</h2>

<p>Qwen这波发布，赶在年前开启了Agent的元年，通过官方发布的一些Demo，看到了他们期望通过模型达成的最终结果。这里其实还有个小细节就是在基础设施这里的工作，内容虽然不多，但是从简短的一些文字中就感受到了巨大的Infra工作，全尺寸模型的训推一致性、训推解耦、Rollout路由回放、面向Agent工作流的训练框架搭建和长尾Rollout延迟处理，哪一个听上去都是巨大无比的工作量。</p>

<p>想到这里也十分感慨，使用现在的开源框架进行的Agentic的RL训练，虽然已经避免了很多Infra的工作，但实际上在真正开始之前，需要对训练和推理有非常深入的了解和研究，否则但凡存在个训推不一致的问题，都会造成效果上的下降或者不及预期。RL时代，真正考研Infra功底和训练资源利用率了，否则算法上的优化将无从谈起。</p>]]></content><author><name>Chengru Song</name></author><category term="[&quot;AI&quot;, &quot;AI_Algorithms&quot;, &quot;Vision&quot;]" /><category term="301-work-ai" /><summary type="html"><![CDATA[解读下Qwen3.5 序言 不知道是不是去年Deepseek开启了中国AI届的传统，大公司几乎都赶在春节前Release了一波模型，这几天比较火的就是SeedDance 2.0和Qwen3.5的模型，现在的大模型赛道确实比较卷，要知道Qwen3.5是除夕当天发布的。虽然官方的Tech Report还没有发布，但是我们可以先通过Release出来的模型权重和inference代码，看下这个官方宣称的原生多模态智能体是个什么。 模型架构 首先Qwen3.5官方Release出来的是397B-A17B的MOE模型，MOE模型是一个Inference性价比很高的架构，这比较符合现在大模型的发展趋势：在OpenClaw相关的个人助理式应用发展出来以后，inference性价比在应用侧是一个关注度很高的指标； 其次，我研究了一下release出来模型的架构，即Qwen3_5MoeForConditionalGeneration。官方提到的原生多模态，并非是多模态模型的原生，即并没有进行Vision的tokenization，而是沿用了QwenVL的架构，即依然使用Vision Transformer编码图片，经过patchmerger对ViT结果进行下采样，最终投射到LLM的embedding空间上，不过注意这里和Qwen3VL有一些异同； 相同：都是采用了ViT + LLM的整体架构，视频采用了时间戳+Frames的处理方式； 不同：Qwen3.5抛弃了Qwen3VL中的Deepstack，可能这种方式带来的提升比较有限？ 有什么Highlights？ 总结来说，这次Qwen3.5最重要的，就是在未来各类Agent任务场景上的适配，真正做到泛化性和实用层面的第一，而不是为了刷一些Benchmark，下面我quote一段Qwen3.5在网页上的原话。 [!IMPORTANT] 相对于 Qwen3 系列模型，Qwen3.5 的 Post-training 性能提升主要来自于我们对各类 RL 任务和环境的全面扩展。我们更加强调 RL 环境的难度与可泛化性，而非针对特定指标或狭隘类别的 query 进行优化。下图展示了在通用 Agent 能力上，模型效果随 RL Environment scaling 带来的增益。整体性能由各模型在以下基准上的平均排名计算得出：BFCL-V4、VITA-Bench、DeepPlanning、Tool-Decathlon 和 MCP-Mark。更多任务的 scaling 效果将在我们即将发布的技术报告中详述。 从Demo展示看Qwen的野心 Qwen重点展示了几个场景 仰望星空：Qwen官方使用Qwen3.5对Agent能力的支持，这个是各个大厂在26年正在大力发展的方向； 脚踏实地： 网页和coding开发； 第三方智能体的集成：OpenClaw的适配； 视觉智能体、视觉编程。 惊喜：自动驾驶场景的应用潜力。 以上几个都是Qwen官方放出来的Demo，可以看出其希望通过Qwen3.5这个模型来开启26年的Agent爆发元年。 总结 Qwen这波发布，赶在年前开启了Agent的元年，通过官方发布的一些Demo，看到了他们期望通过模型达成的最终结果。这里其实还有个小细节就是在基础设施这里的工作，内容虽然不多，但是从简短的一些文字中就感受到了巨大的Infra工作，全尺寸模型的训推一致性、训推解耦、Rollout路由回放、面向Agent工作流的训练框架搭建和长尾Rollout延迟处理，哪一个听上去都是巨大无比的工作量。 想到这里也十分感慨，使用现在的开源框架进行的Agentic的RL训练，虽然已经避免了很多Infra的工作，但实际上在真正开始之前，需要对训练和推理有非常深入的了解和研究，否则但凡存在个训推不一致的问题，都会造成效果上的下降或者不及预期。RL时代，真正考研Infra功底和训练资源利用率了，否则算法上的优化将无从谈起。]]></summary></entry><entry><title type="html">【AI】Qwen端侧Agent</title><link href="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/02/02/qwen-hardware.html" rel="alternate" type="text/html" title="【AI】Qwen端侧Agent" /><published>2026-02-02T03:20:07+08:00</published><updated>2026-02-02T03:20:07+08:00</updated><id>https://chengru-song.github.io/ai/ai_algorithms/vision/2026/02/02/qwen-hardware</id><content type="html" xml:base="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/02/02/qwen-hardware.html"><![CDATA[<h1 id="聊聊on-policy-distillation1">聊聊On-policy Distillation（1）</h1>

<h2 id="背景">背景</h2>

<p>前段时间，On-policy Distillation这个方法特别火，主要是Thinking Machine Lab这个团队有一篇爆火的文章出圈了，让大家关注到了这个方法，各种新的方法也都雨后春笋般冒出来了。</p>

<p>其中千问AI硬件团队刚中的这篇ICLR的文章引起了我的关注：<a href="https://openreview.net/forum?id=uU96luC4dp">STAR: Similarity-guided Teacher-Assisted Refinement for Super-Tiny Function Calling Models</a></p>

<p>AI硬件这个领域现在逐渐步入大众视野，如果所有需求都调用云端大模型，势必会有token吃不消的情况，小模型在端侧的需求是非常强劲的，因此，On-policy Distillation的价值就体现出来了。</p>

<p>但这篇文章没有简单使用On-policy Distillation，而是进行了效果优化，简单来说</p>

<p>为了让小模型从大模型 “学到更多有用的概率输出”，并<strong>避免训练崩溃，错误输出过于自信</strong>。</p>

<ul>
  <li>
    <p>传统 KD 会用 KL 散度衡量学生和教师之间的输出分布差异，但：</p>

    <ul>
      <li>
        <p>直接用传统 KL 在 “top-k” 截断时不稳定</p>
      </li>
      <li>
        <p>小模型容易过信错误的输出，导致学习效果差</p>
      </li>
    </ul>
  </li>
</ul>

<p>文中提出的CKD设计思路：</p>

<ul>
  <li>重点保留教师模型 top-k 分布（概率最高的前 k 个 token）</li>
  <li>对学生模型在 top-m（比 k 大）但不在 top-k 的错误概率进行惩罚</li>
</ul>

<p>实现方式：</p>

<ul>
  <li>用前向 KL（Forward KL）保留教师 top-k 的概率分布</li>
  <li>加了一个额外的正则项来压制学生错误输出概率（L1 抑制）</li>
</ul>

<p>这篇文章还针对这个端侧小模型进行了进一步的强化学习，也没有基于传统的verifiable的结果来直接做，而是做了基于相似度的优化。这里没有非常强硬使用Verifiable的结果，相似度计算不仅能带来结果上一定的鲁棒性，同时也间接提升了Reward的density，对于训练稳定有至关重要的作用。</p>

<p>该方法在Qwen-0.6B上验证的效果，在某些领域甚至超过了3-4B的大模型。</p>

<h2 id="总结">总结</h2>

<p>相比于基于SFT的蒸馏来说，On-policy Distillation的想法非常直白，就是用RL的方法，通过token Level来约束两个大小不同的概率模型的分布，提升小模型的效果。相比于SFT蒸馏而言，RL蒸馏的最大区别在<strong>自上下文学习</strong>。</p>

<p>传统意义上讲，如果我们直接用更大模型产生的数据来蒸馏小模型，是在<strong>更大模型的上下文里</strong>学习，假设这个更大模型和小模型的分布不同，比如在某个token上的entropy特别高，就会导致小模型的更新梯度更大，从而造成灾难性遗忘等问题。因此简单来说，On-policy Distillation的两个重大优势就是</p>

<ol>
  <li>能显著避免小模型的灾难性遗忘问题；</li>
  <li>能显著提升训练效率，用极少的数据和业务侧的数据混合就能训练出和混大量数据的SFT效果。</li>
</ol>

<p>更准确点说，我觉得更吸引人的是这个<strong>自上下文学习的概念</strong>，用这个比喻更好些：老师告诉你的并非题的解法，而是告诉你你错在哪里了，你本身就大概知道怎么改，适合模型能力本身就还可以，但是需要引入额外能力的场景。</p>

<p>之前听到蒸馏，总有种拉不高模型能力上限的感觉；但基于应用场景看，才发现蒸馏是一种智慧：在资源有限场景下，如何提升小模型的专项能力，如何让小模型保持更好的通用能力。千问的这篇文章，就是未来AI硬件卷模型的一个很重要的参考，什么时候才用到云端的大模型，什么时候端侧的小模型就能解决。我相信在未来，谁能更好的利用好用户手里的设备的算力，谁就能在运行成本上和别人拉开更大的差距，从而就能更多投入到研发上，进而拉大和别家的差距。</p>]]></content><author><name>Chengru Song</name></author><category term="[&quot;AI&quot;, &quot;AI_Algorithms&quot;, &quot;Vision&quot;]" /><category term="301-work-ai" /><summary type="html"><![CDATA[聊聊On-policy Distillation（1） 背景 前段时间，On-policy Distillation这个方法特别火，主要是Thinking Machine Lab这个团队有一篇爆火的文章出圈了，让大家关注到了这个方法，各种新的方法也都雨后春笋般冒出来了。 其中千问AI硬件团队刚中的这篇ICLR的文章引起了我的关注：STAR: Similarity-guided Teacher-Assisted Refinement for Super-Tiny Function Calling Models AI硬件这个领域现在逐渐步入大众视野，如果所有需求都调用云端大模型，势必会有token吃不消的情况，小模型在端侧的需求是非常强劲的，因此，On-policy Distillation的价值就体现出来了。 但这篇文章没有简单使用On-policy Distillation，而是进行了效果优化，简单来说 为了让小模型从大模型 “学到更多有用的概率输出”，并避免训练崩溃，错误输出过于自信。 传统 KD 会用 KL 散度衡量学生和教师之间的输出分布差异，但： 直接用传统 KL 在 “top-k” 截断时不稳定 小模型容易过信错误的输出，导致学习效果差 文中提出的CKD设计思路： 重点保留教师模型 top-k 分布（概率最高的前 k 个 token） 对学生模型在 top-m（比 k 大）但不在 top-k 的错误概率进行惩罚 实现方式： 用前向 KL（Forward KL）保留教师 top-k 的概率分布 加了一个额外的正则项来压制学生错误输出概率（L1 抑制） 这篇文章还针对这个端侧小模型进行了进一步的强化学习，也没有基于传统的verifiable的结果来直接做，而是做了基于相似度的优化。这里没有非常强硬使用Verifiable的结果，相似度计算不仅能带来结果上一定的鲁棒性，同时也间接提升了Reward的density，对于训练稳定有至关重要的作用。 该方法在Qwen-0.6B上验证的效果，在某些领域甚至超过了3-4B的大模型。 总结 相比于基于SFT的蒸馏来说，On-policy Distillation的想法非常直白，就是用RL的方法，通过token Level来约束两个大小不同的概率模型的分布，提升小模型的效果。相比于SFT蒸馏而言，RL蒸馏的最大区别在自上下文学习。 传统意义上讲，如果我们直接用更大模型产生的数据来蒸馏小模型，是在更大模型的上下文里学习，假设这个更大模型和小模型的分布不同，比如在某个token上的entropy特别高，就会导致小模型的更新梯度更大，从而造成灾难性遗忘等问题。因此简单来说，On-policy Distillation的两个重大优势就是 能显著避免小模型的灾难性遗忘问题； 能显著提升训练效率，用极少的数据和业务侧的数据混合就能训练出和混大量数据的SFT效果。 更准确点说，我觉得更吸引人的是这个自上下文学习的概念，用这个比喻更好些：老师告诉你的并非题的解法，而是告诉你你错在哪里了，你本身就大概知道怎么改，适合模型能力本身就还可以，但是需要引入额外能力的场景。 之前听到蒸馏，总有种拉不高模型能力上限的感觉；但基于应用场景看，才发现蒸馏是一种智慧：在资源有限场景下，如何提升小模型的专项能力，如何让小模型保持更好的通用能力。千问的这篇文章，就是未来AI硬件卷模型的一个很重要的参考，什么时候才用到云端的大模型，什么时候端侧的小模型就能解决。我相信在未来，谁能更好的利用好用户手里的设备的算力，谁就能在运行成本上和别人拉开更大的差距，从而就能更多投入到研发上，进而拉大和别家的差距。]]></summary></entry><entry><title type="html">【AI】GPT RL Issue</title><link href="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/01/08/gpt-rl.html" rel="alternate" type="text/html" title="【AI】GPT RL Issue" /><published>2026-01-08T08:35:07+08:00</published><updated>2026-01-08T08:35:07+08:00</updated><id>https://chengru-song.github.io/ai/ai_algorithms/vision/2026/01/08/gpt-rl</id><content type="html" xml:base="https://chengru-song.github.io/ai/ai_algorithms/vision/2026/01/08/gpt-rl.html"><![CDATA[<h1 id="gpt一句狠但真实的话">GPT：一句狠但真实的话</h1>

<p>现在大部分人都已经把LLM等纳入了自己的工作流中，相信很多人在GPT-5.2的回复中都发现了类似的内容：“一句狠但真实的话”，甚至在一些社交媒体上这都成了GPT相关的一个梗，说出来很多人觉得搞笑。如果观察足够仔细，我们可以发现模型可能有自己的“口头禅”，但这到底是什么导致的呢？</p>

<p>先说结论：<strong>这背后可能是RL阶段的Reward Model更新导致的</strong>，RL阶段发生了Reward hacking，导致RL后的模型学习到了RM中的伪特征（spurious feature），也可以说RM学习到了一部分伪特征，而不是真正语义上的分别。例如，只要回复中带有“狠但真实的话”，RM就会倾向于打高分，而这个特质也在RL过程中被加给了模型。下面我们简述下背景，这个现象产生的原因，以及如何进行避免。</p>

<h2 id="背景">背景</h2>

<p>2025年可以说是RL post-train爆发的一年，引爆的起点就是25年初来自于Deepseek发表的R1系列的工作，如何通过verifiable rewards ➕ GRPO算法，通过Scale RL训练过程，让模型具备了远超Base Model的智能。（这里我夹带一点私货，个人认为Thinking CoT的引入其实比RL的作用要大很多，无论是专项涨点还是泛化能力，加上CoT就已经强了太多，以至于后面verifiable RL经常是掉点的）</p>

<p>在R1系列中，Reward Model的角色被淡化了，取而代之的是直接用可验证结果来作为rewards，这个做法的好处是避免了模型产生Reward hacking，因为结果正确与否是客观的，实在的。但在模型的交付上，除了可验证结果的数据，还有很多Creative Writing的任务，因此Reward Model是一个绕不开的话题。但Reward Model在这一年里就好像是房间里的大象，RM相关的文献和verifiable RL算法的优化相比，数量上是少非常多的。因此我做了一个简单的调研，并结合自己的实践，把我的一些想法写出来，和大家讨论。</p>

<h2 id="问题初发现">问题初发现</h2>

<p>很多人做RM优化，甚至直接做DPO优化，首先在脑海中的想法就是，我是否能把一个牛逼模型的回复（例如GPT-5）直接当成好的，把我现在的模型直接当做差的，这样是否就能学好了？这是很多人包括我在内最开始的误区，答案肯定是不行的，从结果来看，这种学习无一例外都让最后的模型结果掉点了。</p>

<p>这是为什么呢？</p>

<p>相信很多人都看过下面的训练曲线，以上做法在RM或者DPO一开始训练的几个Steps之后就迅速饱和，后续的Acc就一直在1左右，loss也基本上不下降了，即使做了数据去重也是没用的。这个肯定是训崩了。如果我们试图调整LR或者Batch_size等超参，避免过拟合等问题，你会发现这种方法也不行，所以问题肯定不是出现在训练过程中，而是数据本身出了问题。</p>

<p><img src="/assets/images/image-20260107174414204.png" alt="image-20260107174414204" /></p>

<h2 id="从他人工作中找答案">从他人工作中找答案</h2>

<p>一个学科蓬勃发展的好处就是可以站在巨人的肩膀上解决问题（坏处是创新变难了），通过大量进行Research，发现其实这个问题很早就有人开始解决了。</p>

<p>早在2024年的这篇文章（<strong>A Long Way to Go: Investigating Length Correlations in RLHF）</strong>中就提到了，PPO的RM可能只学习到了回复的长度，而不是真正语义上的好坏。作者做了几个实验</p>

<ol>
  <li>把Reward打出的分数和长度画出correlation，发现长度和Reward是有正相关关系的；</li>
  <li>控制PPO训练中的输出长度，所有之前PPO训练带来的Gain都消失了；</li>
  <li>直接在PPO训练中把RM替换成直接根据长度assign Reward，发现两个训练的效果非常接近（只提升长度也能涨点）</li>
</ol>

<p>所以可以看到，这里RM的伪特征是长度；当然，GPT回答相比于你要优化的模型，也许伪特征不存在于长度这个维度，而是其他维度，比如tone，或者就是那句“狠但真实的话”。</p>

<p>在另一篇文章（Rectifying Shortcut Behaviors in Preference-based Reward Learning）里，也有人提到了类似的观点，即Reward学习过程中，长度、语气、隐式的固定模式，都是RM较容易学习到的伪特征，同样会造成训练的崩坏。</p>

<h2 id="我的实践confirmation">我的实践confirmation</h2>

<p>我们在进行DPO训练时，其实观测到类似的曲线，其核心原因还是DPO和RM训练都share了相同的训练objective，因此两者训练的表现也呈现了类似的趋势。</p>

<p>与此同时，我们发现DPO的模型，经常会使SFT模型中的问题更加严重。例如，假设你的SFT模型有一定的Format问题，你把Format有问题的部分给到低分或者reject里面，好的格式放到chosen里面，训练完发现格式有问题的情况更多了；</p>

<p>PPO+RM的情况是，如果SFT中有5%的数据发现用了一定的语气，SFT后这种语气在inference时候出现的概率远高于训练集中的统计值（这种是已知的，数据不均衡会导致的问题）；而这种情况在RL训练后，可能更甚，产生了模型能力下降的死亡螺旋。</p>

<h2 id="他人的解法">他人的解法</h2>

<p>解法其实已经呼之欲出了，既然问题的核心原因是，RM很容易学习到伪特征，我们就可以通过一些手段，<strong>根据语义内核来rank RM的训练数据</strong>，这个问题就可以解决了。</p>

<p>因此，总结下目前比较流行的方法</p>

<ol>
  <li>模型层
    <ol>
      <li>生成式Reward：通过生成式结果让模型给判断，例如LLM-as-a-Judge、Reasoning RM等；</li>
    </ol>
  </li>
  <li>训练层
    <ol>
      <li>loss function优化：在loss function中加入正则项，用先验知识判断是否表层伪特征，是的话给予惩罚；</li>
      <li>RM Majority Voting：用多种、多个、多样Reward Model打分，去除单一模型的bias；</li>
      <li>额外信息引入：在训练过程中，RM的loss后期会忽略Prompt的因素，因此加入Prompt插值到优化目标中，强行让模型考虑Prompt给response打分。</li>
    </ol>
  </li>
  <li>数据层
    <ol>
      <li>伪特征去除：在伪特征一致的情况下（长度统一、语气近似），给到不同的分数，让模型学习时放弃shortcut。</li>
    </ol>
  </li>
</ol>

<h2 id="总结">总结</h2>

<p>RM作为RL中的重要一环，可以说RM训练效果直接导致了基于RM的RL是否能成功，其重要程度甚至比优化RL中的一些小trick要高得多；如果RL后的模型出现了效果下降且使用了RM，别犹豫，先去debug下RM的问题。</p>

<h2 id="还存在的一些疑问">还存在的一些疑问</h2>

<ol>
  <li>为什么DPO会导致格式崩坏，但是GRPO却能进行格式的修复？是因为GRPO的格式Reward更加直白？还是因为DPO其算法本身因为过度打压reject导致chosen同样下降的本身缺陷导致的？</li>
  <li>在<strong>Unified Reinforcement and Imitation Learning for Vision-Language Models</strong>这篇文章中，作者的Imitation learning的思路是，用一个RM分类器区分Teacher和Student的回复，把这个RM分类器作为GRPO时候的Reward，训练效果得到了提升。但其RM分类器的训练也是快速饱和了；不确定这个文章里，到底是因为GRPO本身能一定程度上避免Reward hacking，还是因为作者同时引入了verifiable Reward + LLM as a judge，实际上这个RM起的作用不大呢？</li>
</ol>]]></content><author><name>Chengru Song</name></author><category term="[&quot;AI&quot;, &quot;AI_Algorithms&quot;, &quot;Vision&quot;]" /><category term="301-work-ai" /><summary type="html"><![CDATA[GPT：一句狠但真实的话 现在大部分人都已经把LLM等纳入了自己的工作流中，相信很多人在GPT-5.2的回复中都发现了类似的内容：“一句狠但真实的话”，甚至在一些社交媒体上这都成了GPT相关的一个梗，说出来很多人觉得搞笑。如果观察足够仔细，我们可以发现模型可能有自己的“口头禅”，但这到底是什么导致的呢？ 先说结论：这背后可能是RL阶段的Reward Model更新导致的，RL阶段发生了Reward hacking，导致RL后的模型学习到了RM中的伪特征（spurious feature），也可以说RM学习到了一部分伪特征，而不是真正语义上的分别。例如，只要回复中带有“狠但真实的话”，RM就会倾向于打高分，而这个特质也在RL过程中被加给了模型。下面我们简述下背景，这个现象产生的原因，以及如何进行避免。 背景 2025年可以说是RL post-train爆发的一年，引爆的起点就是25年初来自于Deepseek发表的R1系列的工作，如何通过verifiable rewards ➕ GRPO算法，通过Scale RL训练过程，让模型具备了远超Base Model的智能。（这里我夹带一点私货，个人认为Thinking CoT的引入其实比RL的作用要大很多，无论是专项涨点还是泛化能力，加上CoT就已经强了太多，以至于后面verifiable RL经常是掉点的） 在R1系列中，Reward Model的角色被淡化了，取而代之的是直接用可验证结果来作为rewards，这个做法的好处是避免了模型产生Reward hacking，因为结果正确与否是客观的，实在的。但在模型的交付上，除了可验证结果的数据，还有很多Creative Writing的任务，因此Reward Model是一个绕不开的话题。但Reward Model在这一年里就好像是房间里的大象，RM相关的文献和verifiable RL算法的优化相比，数量上是少非常多的。因此我做了一个简单的调研，并结合自己的实践，把我的一些想法写出来，和大家讨论。 问题初发现 很多人做RM优化，甚至直接做DPO优化，首先在脑海中的想法就是，我是否能把一个牛逼模型的回复（例如GPT-5）直接当成好的，把我现在的模型直接当做差的，这样是否就能学好了？这是很多人包括我在内最开始的误区，答案肯定是不行的，从结果来看，这种学习无一例外都让最后的模型结果掉点了。 这是为什么呢？ 相信很多人都看过下面的训练曲线，以上做法在RM或者DPO一开始训练的几个Steps之后就迅速饱和，后续的Acc就一直在1左右，loss也基本上不下降了，即使做了数据去重也是没用的。这个肯定是训崩了。如果我们试图调整LR或者Batch_size等超参，避免过拟合等问题，你会发现这种方法也不行，所以问题肯定不是出现在训练过程中，而是数据本身出了问题。 从他人工作中找答案 一个学科蓬勃发展的好处就是可以站在巨人的肩膀上解决问题（坏处是创新变难了），通过大量进行Research，发现其实这个问题很早就有人开始解决了。 早在2024年的这篇文章（A Long Way to Go: Investigating Length Correlations in RLHF）中就提到了，PPO的RM可能只学习到了回复的长度，而不是真正语义上的好坏。作者做了几个实验 把Reward打出的分数和长度画出correlation，发现长度和Reward是有正相关关系的； 控制PPO训练中的输出长度，所有之前PPO训练带来的Gain都消失了； 直接在PPO训练中把RM替换成直接根据长度assign Reward，发现两个训练的效果非常接近（只提升长度也能涨点） 所以可以看到，这里RM的伪特征是长度；当然，GPT回答相比于你要优化的模型，也许伪特征不存在于长度这个维度，而是其他维度，比如tone，或者就是那句“狠但真实的话”。 在另一篇文章（Rectifying Shortcut Behaviors in Preference-based Reward Learning）里，也有人提到了类似的观点，即Reward学习过程中，长度、语气、隐式的固定模式，都是RM较容易学习到的伪特征，同样会造成训练的崩坏。 我的实践confirmation 我们在进行DPO训练时，其实观测到类似的曲线，其核心原因还是DPO和RM训练都share了相同的训练objective，因此两者训练的表现也呈现了类似的趋势。 与此同时，我们发现DPO的模型，经常会使SFT模型中的问题更加严重。例如，假设你的SFT模型有一定的Format问题，你把Format有问题的部分给到低分或者reject里面，好的格式放到chosen里面，训练完发现格式有问题的情况更多了； PPO+RM的情况是，如果SFT中有5%的数据发现用了一定的语气，SFT后这种语气在inference时候出现的概率远高于训练集中的统计值（这种是已知的，数据不均衡会导致的问题）；而这种情况在RL训练后，可能更甚，产生了模型能力下降的死亡螺旋。 他人的解法 解法其实已经呼之欲出了，既然问题的核心原因是，RM很容易学习到伪特征，我们就可以通过一些手段，根据语义内核来rank RM的训练数据，这个问题就可以解决了。 因此，总结下目前比较流行的方法 模型层 生成式Reward：通过生成式结果让模型给判断，例如LLM-as-a-Judge、Reasoning RM等； 训练层 loss function优化：在loss function中加入正则项，用先验知识判断是否表层伪特征，是的话给予惩罚； RM Majority Voting：用多种、多个、多样Reward Model打分，去除单一模型的bias； 额外信息引入：在训练过程中，RM的loss后期会忽略Prompt的因素，因此加入Prompt插值到优化目标中，强行让模型考虑Prompt给response打分。 数据层 伪特征去除：在伪特征一致的情况下（长度统一、语气近似），给到不同的分数，让模型学习时放弃shortcut。 总结 RM作为RL中的重要一环，可以说RM训练效果直接导致了基于RM的RL是否能成功，其重要程度甚至比优化RL中的一些小trick要高得多；如果RL后的模型出现了效果下降且使用了RM，别犹豫，先去debug下RM的问题。 还存在的一些疑问 为什么DPO会导致格式崩坏，但是GRPO却能进行格式的修复？是因为GRPO的格式Reward更加直白？还是因为DPO其算法本身因为过度打压reject导致chosen同样下降的本身缺陷导致的？ 在Unified Reinforcement and Imitation Learning for Vision-Language Models这篇文章中，作者的Imitation learning的思路是，用一个RM分类器区分Teacher和Student的回复，把这个RM分类器作为GRPO时候的Reward，训练效果得到了提升。但其RM分类器的训练也是快速饱和了；不确定这个文章里，到底是因为GRPO本身能一定程度上避免Reward hacking，还是因为作者同时引入了verifiable Reward + LLM as a judge，实际上这个RM起的作用不大呢？]]></summary></entry></feed>