LLaMA-Berry: Pairwise Optimization for Olympiad-level Mathematical Reasoning via O1-like Monte Carlo Tree Search

Di Zhang, Jianbo Wu, Jingdi Lei, Tong Che, Jiatong Li, Tong Xie, Xiaoshui Huang, Shufei Zhang, Marco Pavone, Yuqiang Li, Wanli Ouyang, Dongzhan Zhou

Abstract

LLaMA-Berry is a novel reasoning framework designed to elevate standard Large Language Models (LLMs) to "O1-like" performance levels in complex mathematical reasoning. By integrating Monte Carlo Tree Search (MCTS) with an iterative self-refinement mechanism and a robust Pairwise Preference Reward Model (PPRM), LLaMA-Berry enables smaller models, such as Llama-3.1-8B, to compete with state-of-the-art proprietary models on elite benchmarks like the AIME and AMC. The framework replaces volatile absolute reward scores with stable pairwise comparisons, allowing for more effective exploration of the solution space.

Introduction

While Large Language Models have demonstrated proficiency in basic arithmetic, high-level mathematical reasoning—specifically Olympiad-level problems—remains a significant challenge. Traditional Chain-of-Thought (CoT) approaches are brittle; a single error in the early stages of reasoning often leads to an incorrect final answer. Conversely, iterative self-refinement techniques frequently struggle with "local optima" or drift toward lower-quality solutions due to inconsistent feedback. LLaMA-Berry addresses these limitations by framing the reasoning process as a search over complete solution states rather than individual tokens, guided by a stable preference-based reward signal.

Methodology

The core of LLaMA-Berry is the Self-Refine Monte Carlo Tree Search (SR-MCTS) framework, which combines the systematic exploration of MCTS with the corrective power of self-refinement.

Self-Refine Monte Carlo Tree Search (SR-MCTS)

In SR-MCTS, the expansion of a node involves generating a critique of the current solution and subsequently rewriting it. This allows the model to explore the space of complete arguments and perform global re-thinking. The search process follows the standard MCTS cycle: selection of promising nodes, expansion via refinement, evaluation of the new state, and backpropagation of rewards.

The SR-MCTS cycle: Selection, Expansion with Self-Refine, Evaluation, and Backpropagation.

The Self-Refine Process

The refinement process is driven by a feedback loop where the model acts as its own critic. For a given solution $S_i$, the model generates a critique $C_i$ identifying errors or areas for improvement. A new solution $S_{i+1}$ is then generated based on this critique. This ensures that each iteration is informed by the identified weaknesses of the previous state.

The Self-Refine process illustrating how an original solution is critiqued and rewritten into an improved version using a concrete math example.

Pairwise Preference Reward Model (PPRM)

To guide the search effectively, LLaMA-Berry utilizes a Pairwise Preference Reward Model (PPRM). Traditional Outcome Reward Models (ORM) and Process Reward Models (PRM) often suffer from scoring volatility, where absolute scores for the same solution can vary significantly. PPRM mitigates this by training the model to perform pairwise comparisons (e.g., "Is Solution A better than Solution B?"). This approach leverages the inherent strengths of LLMs in following instructions and provides a more stable signal. To derive a global ranking from these local comparisons, the framework employs an Enhanced Borda Count (EBC) method, utilizing the Floyd-Warshall algorithm to ensure transitive consistency (if A > B and B > C, then A > C).

Key Insights

  • The "Whole-State" Advantage: By treating the entire reasoning path as a state, the model can perform "global re-thinking." If a critique identifies a fundamental logical flaw at the start of a proof, the rewrite can fix it entirely, whereas step-wise search often struggles to backtrack that far.
  • Pairwise Stability: Moving from absolute rewards to pairwise preferences mitigates the "non-independent distribution" problem in math scoring. Since the difficulty of problems varies wildly, a fixed score like "0.7" is often meaningless across different contexts; pairwise comparisons provide a relative, and thus more robust, measure of quality.
  • Inference-Time Scaling: Much like OpenAI’s o1, LLaMA-Berry shows that performance can be "bought" with compute. As the number of search rollouts increases, accuracy continues to climb, suggesting that search is a viable path to super-intelligence in closed-domain reasoning.

Experimental Results

LLaMA-Berry was evaluated on a gauntlet of rigorous benchmarks, including AIME24, AMC23, and GPQA Diamond. The results demonstrate significant performance gains for the Llama-3.1-8B-Instruct model:

  • AIME24: Accuracy jumped from 6.7% (base) to 26.7%, outperforming many 70B+ models and rivaling GPT-4 Turbo.
  • OlympiadBench: Performance surged from 15.4% to 55.1%.
  • GPQA Diamond: The framework achieved 92.4% accuracy, showing that these reasoning improvements transfer well to high-level science.
  • Efficiency: LLaMA-Berry achieved higher accuracy than competing tree-search methods (like rStar) while using significantly fewer rollouts, proving the efficiency of the Self-Refine expansion strategy.

Conclusion

LLaMA-Berry demonstrates that sophisticated search and refinement strategies can significantly enhance the reasoning capabilities of relatively small open-source models. By moving from absolute scoring to pairwise preferences and treating solutions as holistic states, LLaMA-Berry provides a robust and efficient framework for tackling the most challenging mathematical and scientific problems.

Summary updated

BibTeX
@inproceedings{zhang2025llama,
  author = {Di Zhang and Jianbo Wu and Jingdi Lei and Tong Che and Jiatong Li and Tong Xie and Xiaoshui Huang and Shufei Zhang and Marco Pavone and Yuqiang Li and Wanli Ouyang and Dongzhan Zhou},
  title = {{LLaMA-Berry: Pairwise Optimization for Olympiad-level Mathematical Reasoning via O1-like Monte Carlo Tree Search}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.naacl-long.375},
}
Figure