Abstract
Mathematical reasoning remains a significant challenge for Large Language Models (LLMs) due to the "brittle" nature of multi-step logic, where a single error can derail an entire solution. We present the Chain of Self-Correction (CoSC), a framework that embeds iterative verification and rectification directly into the model's weights. By training models to generate code, execute it via a Python interpreter, and verify results against the original query, we developed the CoSC-Code-34B model. This model achieves a 53.5% score on the challenging MATH dataset, outperforming proprietary giants like GPT-4 and Gemini-1.0 Ultra in zero-shot settings.
Introduction
While LLMs have achieved human-level performance in many linguistic tasks, mathematical reasoning often fails because models lack internal mechanisms to detect and fix errors. Existing methods like Chain-of-Thought (CoT) provide a structured reasoning path but do not include a "sanity check" phase. Current self-correction strategies often rely on expensive external feedback from human or proprietary models, which is difficult to scale.
The Chain of Self-Correction (CoSC) aims to make error detection and correction an inherent, autonomous ability. Instead of a single-pass generation, the model is trained to "think, check, and fix" through a multi-round loop, significantly improving its robustness in solving complex competition-level problems.
Methodology: The CoSC Framework
The CoSC protocol operates through a four-stage iterative loop:
- Program Generation (p): The model generates a Python function to represent the problem's logic.
- Execution (o): The code is executed to obtain a numerical output.
- Verification (v): The model evaluates the consistency between the question, the code logic, and the output.
- Conclusion (c): Based on the verification, the model either provides a final answer or initiates another round of correction to fix identified bugs.
To instill this behavior, the researchers employed a two-phase training strategy to move from structural learning to autonomous enhancement.
Phase 1: Foundational Learning
The model is first fine-tuned on 37,000 "seeding" trajectories generated by GPT-4. These trajectories demonstrate the structured p-o-v-c loop, teaching the model the fundamental syntax and logic of self-correction.
Phase 2: Self-Enhancement
To further refine the model, a larger dataset of 302,000 samples was generated using the model itself. Through "dense sampling"—generating multiple solutions and rephrasing questions—the model identifies successful correction paths. Only trajectories leading to the correct ground-truth answer are retained, allowing the model to learn from its own successes without additional proprietary model costs.
Experimental Results
The CoSC approach was evaluated on the MATH and GSM8K benchmarks. The results indicate that embedding self-correction as an inherent ability allows open-source models to rival or exceed the performance of much larger proprietary systems.
As shown in the performance comparison, CoSC-Code-34B (built on CodeLLaMA) achieved a 53.5% score on the MATH dataset. This performance is particularly notable as it surpasses GPT-4 (42.5%), GPT-4V (52.9%), and Gemini-1.0 Ultra (53.2%) in zero-shot evaluations. On the GSM8K benchmark, the 34B model reached 82.3%, demonstrating a massive jump over its base model.
Key Insights
- The Multi-Round Advantage: Iteration is crucial. For instance, the 7B model's performance on MATH improved from 40.2% to 47.9% simply by being allowed multiple correction rounds.
- Verification Accuracy: The internal verification module identifies errors with approximately 70% accuracy, providing a strong enough signal to trigger effective corrections.
- Zero-Shot Capability: Unlike many prompting-based methods, CoSC logic is embedded in the model weights, allowing it to perform complex reasoning without few-shot examples.
Discussion and Limitations
While CoSC represents a significant step forward, it introduces certain trade-offs:
- Computational Cost: Multi-round generation and execution increase inference time and resource consumption compared to single-pass models.
- Domain Specificity: The current implementation relies on a Python interpreter for verification, which is highly effective for mathematics but may not translate directly to non-computational domains.
- Iteration Caps: In these experiments, the model was limited to three interpreter calls. Further performance gains might be possible with additional iterations for extremely complex tasks.
Conclusion
The Chain of Self-Correction (CoSC) demonstrates that self-correction can be treated as an inherent reasoning ability rather than an external prompting trick. By integrating code execution and verification into the training loop, CoSC-Code models set new benchmarks for open-source mathematical reasoning, proving that structured, iterative "thinking" is a powerful path toward more reliable AI.
Summary updated