No Train Still Gain. Unleash Mathematical Reasoning of Large Language Models with Monte Carlo Tree Search Guided by Energy Function

Haotian XuarXiv 2023 · DOI

Abstract

Large Language Models (LLMs) frequently encounter difficulties in multi-step mathematical reasoning, often failing during standard greedy decoding despite possessing the necessary latent knowledge. This paper presents a novel inference-time framework that significantly boosts reasoning accuracy without requiring additional fine-tuning of the base model. By integrating Monte Carlo Tree Search (MCTS) with a lightweight Energy-Based Model (EBM) trained via Noise Contrastive Estimation (NCE), the proposed method achieves substantial gains on benchmarks like GSM8k and AQUA-RAT.

Introduction

While LLMs have revolutionized natural language processing, their performance on complex mathematical tasks remains a bottleneck. Standard decoding strategies, such as greedy search, often lead models into logical dead-ends. Traditional remedies involve computationally intensive Reinforcement Learning from Human Feedback (RLHF) or massive data augmentation. This research explores a more efficient alternative: "unlocking" existing reasoning capabilities by improving how models search for and verify reasoning paths during inference.

Methodology

The proposed framework operates through a four-step pipeline designed to refine the model's output distribution and search strategy.

The four-step pipeline for enhancing LLM reasoning: instruction tuning, ResidualEBM formulation, Noise Contrastive Estimation, and MCTS guidance.

Residual Energy-Based Model (Residual-EBM)

The core idea is to reformulate the LLM's output probability ($P_{LM}$) by introducing a correction factor. The new distribution is defined such that the probability is proportional to $P_{LM} \cdot \exp(-E_\theta(x))$, where $E_\theta(x)$ is an energy function that learns to assign lower energy (higher reward) to logically sound reasoning steps.

Noise Contrastive Estimation (NCE)

To train the energy function efficiently, the authors employ Noise Contrastive Estimation. A DeBERTa-large model is trained as a binary classifier to distinguish between ground-truth solutions ("positive" data) and the LLM's own flawed outputs ("noise"). This approach avoids the computational burden of calculating the partition function while forcing the model to learn subtle logical distinctions.

MCTS Guided by Energy

During inference, the system employs MCTS to explore a tree where each node represents a complete sentence rather than a single token. This sentence-level granularity makes the search space manageable. The energy function provides the critical reward signal, allowing the search algorithm to balance exploration of new paths with exploitation of promising ones.

Experimental Evaluation

The framework was tested on the GSM8k (grade school math) and AQUA-RAT (algebra word problems) benchmarks. The energy function was trained on the respective training sets, while the large-scale LLMs (e.g., Llama2, RFT) remained frozen. This "No Train" approach ensures that the multi-billion parameter base models do not require expensive updates.

Results and Discussion

The results demonstrate that the MCTS-EBM approach consistently outperforms standard greedy decoding across various model sizes and architectures.

Performance gains in pass@1 accuracy using MCTS-EBM across different LLMs.

As shown in the table above, Llama2-7B saw a dramatic increase in pass@1 accuracy, jumping from 41.69% to 52.23% (+10.54%). Similar improvements were observed for RFT-7B (+6.48%) and RFT-13B (+6.08%). Notably, the method outperformed "Self-Consistency" majority voting (which requires 10 paths) while focusing on optimizing a single high-quality path through internal search.

Conclusion and Future Work

The "No Train Still Gain" approach proves that significant reasoning improvements can be achieved by focusing on inference-time search and verification. By keeping the primary LLM frozen and training only a small auxiliary verifier, the method offers a cost-effective path to higher performance. Future work will focus on reducing inference latency caused by MCTS roll-outs and improving the generalizability of the energy function across diverse task formats.

Summary updated

Abstract

Large language models (LLMs) demonstrate impressive language understanding and contextual learning abilities, making them suitable for natural language processing (NLP) tasks and complex mathematical reasoning. However, when applied to mathematical reasoning tasks, LLMs often struggle to generate correct reasoning steps and answers despite having high probabilities for the solutions. To overcome this limitation and enhance the mathematical reasoning capabilities of fine-tuned LLMs without additional fine-tuning steps, we propose a method that incorporates Monte Carlo Tree Search (MCTS) and a lightweight energy function to rank decision steps and enable immediate reaction and precise reasoning. Specifically, we re-formulate the fine-tuned LLMs into a Residual-based Energy Model (Residual-EBM) and employ noise contrastive estimation to estimate the energy function's parameters. We then utilize MCTS with the energy function as a path verifier to search the output space and evaluate the reasoning path. Through extensive experiments on two mathematical reasoning benchmarks, GSM8k and AQUA-RAT, we demonstrate the exceptional capabilities of our method, which significantly improves the pass@1 metric of the fine-tuned model without requiring additional fine-tuning or reinforcement learning with human feedback alignment.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
GSM8KProposed method (MCTS guided by an energy function)pass@1 accuracy52.23+10.33 vs baselinesplit: test · params=7B · backbone=Llama2-7B · decoding=MCTS
Source quote
L186: \item Compared to WizardMath~\citep{luo2023wizardmath} and RFT~\citep{yuan2023RFT}, our method applied to instruction tuned Llama2-7B achieve comparable pass@1 accuracy without using more supervised finetuning data~\citep{yuan2023RFT} or complicated RLHF alignment methods~\citep{luo2023wizardmath}. Our method incorporates Monte Carlo Tree Search (MCTS) during the inference stage, which improves the performance of the baseline model. The baseline model achieved a score of 41.9 using greedy decoding, whereas our method achieves a score of 52.23 on GSM8k.
AQUA-RATMCTS-ebm-bothpass@138.18+3.93 vs baselinesplit: test · fine-tuned · path-num=1 · method-variant=MCTS-ebm-both
Source quote
L202: MCTS-ebm-both │ 38.18 │ 1
Reported baseline / comparator measurements (2)
BenchmarkMethodMetricScoreProtocol / Evidence
GSM8KInstruction-tuned Llama2-7B baseline (greedy decoding) baselinepass@1 accuracy41.9split: test · params=7B · backbone=Llama2-7B · decoding=greedy
Source quote
L186: \item Compared to WizardMath~\citep{luo2023wizardmath} and RFT~\citep{yuan2023RFT}, our method applied to instruction tuned Llama2-7B achieve comparable pass@1 accuracy without using more supervised finetuning data~\citep{yuan2023RFT} or complicated RLHF alignment methods~\citep{luo2023wizardmath}. Our method incorporates Monte Carlo Tree Search (MCTS) during the inference stage, which improves the performance of the baseline model. The baseline model achieved a score of 41.9 using greedy decoding, whereas our method achieves a score of 52.23 on GSM8k.
AQUA-RATgreedy-decoding baselinepass@134.25split: test · fine-tuned · decoding=greedy · path-num=1
Source quote
L201: greedy-decoding │ 34.25 │ 1
BibTeX
@misc{xu2023no,
  author = {Haotian Xu},
  title = {{No Train Still Gain. Unleash Mathematical Reasoning of Large Language Models with Monte Carlo Tree Search Guided by Energy Function}},
  year = {2023},
  eprint = {2309.03224},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2309.03224},
}
Figure