Introduction
Large Language Models (LLMs) have become highly proficient at general conversation, yet they often struggle with complex mathematical reasoning. To solve difficult math problems, models typically need to utilize external tools—such as Python code interpreters—and engage in multi-turn reasoning. This involves writing code, observing the output, and iteratively refining the answer.
While most current training methods rely on Supervised Fine-Tuning (SFT) using synthetic data, standard Reinforcement Learning from Human Feedback (RLHF) techniques like Direct Preference Optimization (DPO) were primarily designed for single-turn chat tasks. They do not naturally account for the dependencies in a multi-turn trajectory, where an agent's previous actions and the environment's feedback shape the final outcome. To address this, researchers have introduced a framework for training LLM "math agents" using Multi-Turn Iterative Preference Learning, significantly boosting the problem-solving accuracy of models like Gemma and Mistral on challenging benchmarks like GSM8K and MATH.
Methodology
The authors propose a framework called Online Iterative Multi-turn Gibbs Sampling from Human Feedback (M-GSHF), which formulates tool-integrated reasoning as a Markov Decision Process (MDP). Key components include:
- Multi-Turn DPO & KTO: The researchers derived multi-turn versions of DPO and Kahneman-Tversky Optimization (KTO). They demonstrate that in deterministic environments (like a Python interpreter where identical code yields identical results), the complex mathematics of multi-turn RL simplifies. This allows the optimization of the entire reasoning trajectory at once.
- Online Iterative Training: Instead of training on a static dataset, the model generates new responses in rounds. After each round, the model is evaluated, and the best trajectories are used to refine the model in the subsequent iteration.
- Reference Model Updates: Unlike standard DPO, which typically uses a fixed reference model, this framework updates the reference model at each iteration. This enables the model to continuously improve, provided the KL divergence regularization is tuned correctly.
- Mixture Sampling: To prevent diversity collapse (where the model becomes too repetitive), the training process uses a mix of responses from the current model and previous checkpoints during data collection.
The models were trained and evaluated on GSM8K (grade-school math) and MATH (high-school competition math). To increase training diversity, the researchers augmented the prompts using roughly 15,000 unique problems from MetaMathQA and MMIQC, alongside a subset of Open-MathInstruct for the initial SFT phase.
Key Insights and Dynamics
- Trajectory-Level vs. Step-Level: For mathematical reasoning, the correctness of the final answer provides a strong enough signal to optimize the entire chain of thought. By masking out irrelevant tokens (like the raw external code output) during training, the model learns to focus purely on its own reasoning and tool-calling logic.
- The "Deterministic" Shortcut: A major theoretical contribution of the paper is showing that because code execution is deterministic, the environment's randomness does not interfere with the DPO loss function. This makes multi-turn preference learning significantly more stable than in stochastic environments.
- Diversity is King: If the model deviates too far from its SFT starting point too quickly, it loses the ability to generate diverse reasoning paths, stalling further improvement. Mixture sampling acts as a crucial safety net to maintain this diversity.
- Pass@n Dynamics: Preference learning primarily improves "top-1" accuracy. Interestingly, for large values of n (e.g., Pass@64), the performance of SFT and DPO models converges. This suggests that RLHF helps the model better "pick" the correct reasoning path rather than teaching it entirely new mathematical knowledge.
Key Results
The iterative multi-turn approach yielded substantial gains across several base models, with aligned models outperforming many larger, SFT-only counterparts:
| Base Model | SFT Accuracy (GSM8K / MATH) | M-DPO Accuracy (GSM8K / MATH) |
|---|---|---|
| Gemma-1.1-it-7B | 77.5% / 46.1% | 83.9% / 51.2% |
| Gemma-2-it-9B | 84.1% / 51.0% | 86.3% / 54.5% |
| Mistral-7B-v0.3 | 77.8% / 42.7% | 82.3% / 47.5% |
Notably, the aligned Gemma-2-it-9B achieved performance competitive with much larger models (in the 70B parameter range) that were trained exclusively with supervised methods.
Limitations and Future Work
While highly effective, the framework currently relies on sparse feedback—using only the final answer's correctness as a binary signal. It does not yet incorporate Process-supervised Reward Models (PRMs) to provide step-by-step feedback. Furthermore, the mathematical simplifications rely on the tool environment being deterministic; applying this to stochastic tools or multi-agent setups would require more complex value-network approaches. Finally, integrating advanced exploration strategies like Monte Carlo Tree Search (MCTS) could further unlock the potential of these math agents.
Summary updated