Abstract
Large Language Models (LLMs) often struggle with complex reasoning due to the cascading effect of early errors in autoregressive generation. We present Self-Reflective Generation at Test Time (SRGen), a lightweight, plug-and-play framework that allows models to "think twice" during the generation process. By identifying moments of high uncertainty and optimizing a transient corrective vector on-the-fly, SRGen proactively prevents reasoning errors before they cascade, significantly boosting performance on complex mathematical tasks with minimal computational overhead.
Introduction
Standard LLMs generate text autoregressively—one token at a time, moving strictly forward. While effective for general tasks, this approach is fragile for complex reasoning (Chain-of-Thought). A single logical slip early in a derivation propagates and compounds, inevitably leading to an incorrect conclusion.
Current solutions generally fall into two categories: Post-hoc Refinement, where the model critiques and rewrites a full draft (reactive and slow), and Intrinsic Training, where models are fine-tuned for self-correction (proactive but data-intensive). SRGen addresses this by introducing a proactive mechanism that intervenes at potential error points in real-time during a single decoding pass.
Methodology
SRGen introduces a "monitor-reflect-optimize" loop directly into the inference process, operating in two distinct stages:
1. Dynamic Uncertainty Monitoring
The system tracks the predictive uncertainty (entropy) of each token. Rather than using a static threshold, it employs a sliding window to calculate a dynamic threshold based on the model's recent history. If a token's entropy spikes above this threshold, indicating a "critical junction," the model pauses for reflection.
2. Self-Reflective Optimization
Once a critical token is identified, the model optimizes a transient corrective vector ($\delta$) that is added to the hidden state. This optimization utilizes a hybrid loss function:
- Retrospective Context Loss ($\mathcal{L}_{CE}$): Ensures the correction maintains logical consistency with the previously generated text.
- Anticipatory Entropy Minimization ($\mathcal{L}_{AEM}$): Encourages the model to be more certain and decisive about the subsequent token.
Crucially, this vector is discarded after the token is generated, ensuring the intervention remains local and transient.
Experimental Results
Performance Gains
SRGen was evaluated on high-difficulty mathematical reasoning benchmarks, including AIME 2024/2025, AMC, HMMT 2025, and MATH500. The framework demonstrated consistent improvements across diverse model families:
- AIME 2024: On the DeepSeek-R1-Distill-Qwen-7B model, SRGen delivered a +12.0% absolute improvement in Pass@1 accuracy.
- Scaling: For the larger Qwen3-32B model, accuracy on AIME 2024 rose from 76.7% to 82.7%.
- Sample Efficiency: By improving the quality of individual reasoning paths, SRGen reduces the number of samples needed for self-consistency (Cons@5) to reach a correct answer.
Efficiency and Latency
Unlike post-hoc refinement methods that can double or triple latency, SRGen's overhead is bounded. In practice, it adds approximately 50% additional inference time. This trade-off is visualized in the relationship between the number of iterations per activation and the resulting time increase.
Key Insights
- Critical Token Discovery: Uncertainty spikes most frequently on function words and connectives (e.g., so, but, if). These serve as the "junctions" where the model decides the direction of the reasoning path. Intervening here is significantly more effective than on content-heavy tokens.
- Proactive Error Prevention: By correcting the hidden state before a token is emitted, SRGen steers the model away from mistakes before they are committed to the context window.
- Orthogonality: SRGen is compatible with other test-time techniques. Combining it with methods like SLOT yielded even higher gains, suggesting it addresses a unique layer of the reasoning stack.
Conclusion and Future Work
SRGen provides a principled, efficient way to improve LLM reasoning at test time without retraining. While the current 50% latency overhead is a consideration for real-time applications, the accuracy gains on complex tasks are substantial. Future research will explore more sophisticated triggers beyond entropy and evaluate the framework's effectiveness in non-mathematical domains such as open-ended coding and multi-modal reasoning.
Summary updated