Introduction
Reinforcement Learning with Verifiable Rewards (RLVR) has emerged as a primary method for enhancing the reasoning capabilities of Large Language Models (LLMs), particularly following the success of models like DeepSeek-R1. While most research in this area focuses on refining loss functions or improving data efficiency through gradient-based filtering, the role of dynamic data selection during the RL process remains under-explored.
Recent observations suggest a strong correlation between response length and reasoning quality—a phenomenon often associated with "overthinking." This paper introduces Length-aware Sampling for Policy Optimization (LSPO), a dynamic filtering technique that leverages average response length as a real-time signal to select the most informative training data. By focusing on the extremes of response length, LSPO consistently improves the final reasoning accuracy of models such as Qwen and Llama.
Methodology: Length-aware Filtering
LSPO functions as a meta-algorithm compatible with standard RLVR frameworks like GRPO, DAPO, or GSPO. The core innovation is a dynamic filtering step applied after the rollout phase.
The process involves three key steps:
- Average Length Calculation: For every prompt in a rollout batch, the algorithm computes the average token length across all generated responses.
- Dynamic Percentile Filtering: Rather than using static thresholds, LSPO calculates length percentiles for each specific batch. It retains prompts at the extremes: the shortest (e.g., bottom 30%) and the longest (e.g., 65th to 95th percentiles).
- Strategic Selection: The shortest responses represent efficient, confident reasoning paths, while the longest responses capture difficult problems where the model is actively "thinking through" the solution. Intermediate-length responses are discarded as they are often less informative for gradient updates. To prevent performance degradation from runaway "infinite loops," the absolute longest 5% of responses are also capped.
Experimental Setup
The effectiveness of LSPO was evaluated using models including Qwen-2.5-Math-7B, Qwen3-4B-Base, and Llama-3.2-4B-Instruct. Training utilized the DAPO-17K dataset and the MATH training set. To ensure rigorous evaluation and avoid data leakage, the models were tested on high-level benchmarks including AIME25 (released February 2025), Olympiad-bench, and Minerva-Math.
Key Results and Insights
Experimental results demonstrate that LSPO provides a consistent accuracy boost across various base algorithms and model architectures.
The Value of Extremes
Ablation studies confirmed that training on the "middle" of the length distribution results in the poorest performance. The synergy between short and long responses is critical: short responses promote generalization and efficiency, while long responses enable the model to tackle complex tasks.
Efficiency vs. Performance
While LSPO increases per-step rollout time—due to the need to generate more responses to fill a filtered batch—it achieves higher peak accuracy within the same total training time budget (e.g., 24 hours). This indicates that the data selected by LSPO is significantly more informative than random or accuracy-only filtered samples. For instance, on Qwen-2.5-Math-7B, applying LSPO on top of standard GRPO boosted average benchmark accuracy from 37.5% to 38.7%.
Conclusion and Future Work
LSPO demonstrates that dynamic, length-based data selection is a powerful lever for improving LLM reasoning. By focusing on the most informative extremes of the model's own generations, it pushes the boundaries of final model capability.
Future research directions include developing predictors to estimate response length before full generation to reduce compute overhead. Additionally, exploring adaptive filtering thresholds and other signals, such as model entropy or self-confidence, could further refine the selection process.
Summary updated