TL;DR
SHARPO introduces a segment-level credit assignment mechanism for agentic reinforcement learning that uses successful peer rollouts to provide dense, "hindsight" feedback. By reweighting trajectory-level advantages based on teacher-student log-probability gaps at the level of specific actions or reasoning steps, it significantly improves LLM performance on complex, multi-step tasks like ALFWorld and WebShop.
What Problem Does This Paper Address?
Training Large Language Models (LLMs) to act as agents in interactive environments is notoriously difficult due to the credit assignment problem. In most agentic tasks, rewards are sparse—you usually only get a binary "success" or "failure" signal at the very end of a long sequence of actions.
Standard algorithms like Group Relative Policy Optimization (GRPO) treat the entire trajectory as a single unit. If an agent performs nine perfect steps but fails on the tenth, the entire trajectory receives a negative advantage. This "blames" the successful early steps for the final failure. Conversely, a lucky success might reinforce a clumsy intermediate mistake. The authors aim to bridge this gap by providing finer-grained signals that can distinguish between helpful and harmful decisions within a single interaction.
Methods
The authors propose SHARPO (Segment-level Hindsight Advantage Reweighting for Policy Optimization). The framework refines the base GRPO advantage by looking at "interaction segments"—contiguous spans of text representing a coherent behavior, such as a reasoning thought or a specific environment action.
The process follows these key steps:
- Identify Segments: The trajectory is broken down into meaningful units (e.g., text inside
<action>or<thinking>tags). - Hindsight Teacher: For every group of rollouts, the algorithm identifies a successful "peer" rollout. A copy of the current policy acts as a "teacher," but it is given the successful rollout as additional context (hindsight).
- Compute the Gap: For each segment in a failed trajectory, SHARPO compares the teacher's log-probability of that segment (knowing how to succeed) against the student's original log-probability. A positive gap suggests the teacher supports that specific decision more than the student did.
- Reweighting: This gap is converted into a bounded multiplier. If the teacher strongly supports a segment even in a failed run, that segment's penalty is reduced. If the teacher dislikes a segment, the penalty is increased.
- Length Balancing: To prevent long segments from dominating the update, the authors include a normalization factor based on the mean segment length.
Datasets
The researchers evaluated SHARPO using the Qwen2.5-7B-Instruct model on two popular interactive benchmarks:
- ALFWorld: A synthetic environment where agents must complete household tasks (e.g., "put a clean sponge in the cabinet") across six different task families.
- WebShop: A simulated e-commerce site where agents must search for, navigate to, and purchase products that match specific user requirements (attributes, price, etc.).
Key Insights and Ideas
- Segments over Tokens: While previous "on-policy distillation" methods worked at the token level, SHARPO argues that segments are the true units of agentic behavior. Reweighting at the segment level reduces noise and aligns better with how agents actually make decisions.
- Self-Distillation as Hindsight: You don't need a larger "teacher" model (like GPT-4) to provide dense supervision. By simply giving the same model access to a successful rollout from its own group, it gains enough "hindsight" to effectively critique its own failed attempts.
- Theoretical Grounding: The authors provide a theoretical proof showing that their hindsight adjustment aligns with the "local value" of a segment—meaning the adjustment correctly identifies whether a specific action increased or decreased the overall probability of success, regardless of the final outcome of that specific trajectory.
Key Results
SHARPO consistently outperformed GRPO and several other distillation-based baselines (like StepOPSD and RLSD) across both benchmarks.
- ALFWorld: SHARPO achieved a success rate of 84.90%, a massive +14.32 point gain over standard GRPO.
- WebShop: SHARPO reached a 75.26% success rate, improving over GRPO by +9.11 points.
- Robustness: The gains were consistent across different "mixing weights" ($\lambda$), suggesting the method is not overly sensitive to hyperparameter tuning.
Detailed analysis of ALFWorld subtasks (Table 2) showed that SHARPO was particularly effective in complex scenarios like "Pick2" (handling multiple objects) and "Heat" (requiring object state changes), where precise credit assignment is most critical.
Limitations and Future Work
- Dependence on Success: The method relies on having at least one successful rollout within a group to provide the hindsight context. In extremely difficult tasks where success is rare, the "teacher" might not have enough high-quality references to provide useful feedback.
- Segmentation Logic: SHARPO currently relies on clear markers (like XML-style tags) to define segments. Applying this to unstructured natural language trajectories might require more sophisticated automated segmentation.
- Static Hyperparameters: The mixing weight $\lambda$ was held fixed during training; the authors suggest that dynamically scheduling this weight could further optimize the learning process.
Summary updated