<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>Building Math Agents with Multi-Turn Iterative Preference Learning</title></titleStmt>
			<publicationStmt>
				<publisher>The Thirteenth International Conference on Learning Representations</publisher>
				<date>10/09/2024</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10614879</idno>
					<idno type="doi"></idno>
					
					<author>W Xiong</author><author>C Shi</author><author>J Shen</author><author>A Rosenberg</author><author>Z Qin</author><author>D Calandriello</author><author>M Khalman</author><author>R Joshi</author><author>B Piot</author><author>M Saleh</author><author>C Jin</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[Recent studies have shown that large language models' (LLMs) mathematical problem-solving capabilities can be enhanced by integrating external tools, such as code interpreters, and employing multi-turn Chain-of-Thought (CoT) reasoning. While current methods focus on synthetic data generation and Supervised Fine-Tuning (SFT), this paper studies the complementary direct preference learning approach to further improve model performance. However, existing direct preference learning algorithms are originally designed for the single-turn chat task, and do not fully address the complexities of multi-turn reasoning and external tool integration required for tool-integrated mathematical reasoning tasks. To fill in this gap, we introduce a multi-turn direct preference learning framework, tailored for this context, that leverages feedback from code interpreters and optimizes trajectory-level preferences. This framework includes multi-turn DPO and multi-turn KTO as specific implementations. The effectiveness of our framework is validated through training of various language models using an augmented prompt set from the GSM8K and MATH datasets. Our results demonstrate substantial improvements: a supervised fine-tuned Gemma-1.1-it-7B model's performance increased from 77.5% to 83.9% on GSM8K and from 46.1% to 51.2% on MATH. Similarly, a Gemma-2-it-9B model improved from 84.1% to 86.3% on GSM8K and from 51.0% to 54.5% on MATH.Published as a conference paper at ICLR 2025ICLR     et al., 2024)). These synthetic datasets have yielded significant improvements in test accuracy on standard benchmarks like MATH (Hendrycks et al., 2021) and GSM8K (Cobbe et al., 2021a).Built on strong SFT models, Reinforcement Learning from Human Feedback (RLHF) has proven to be a key technique to elicit LLMs' knowledge during the post-training stage and has become standard in the LLM training pipeline (Ouyang et al., 2022;Gemini et al., 2023). Broadly speaking, the RLHF learning paradigm, which was originally designed for aligning LLMs with human values and preferences, is distinct from SFT as it learns from relative feedback. It has notably enhanced the capabilities of models like ChatGPT, Claude, and Gemini, enabling them to generate responses that are more helpful, harmless, and honest (Bai et al., 2022). Inspired by RLHF's success in general chat applications, in this paper, we explore RLHF for improving LLMs' mathematical problemsolving abilities when equipped with external tools. In particular, since deep RL methods (e.g., the proximal policy optimization, PPO algorithm (Schulman et al., 2017)) are often sample inefficient and unstable (Choshen et al., 2019), our goal is to derive direct preference learning algorithms that directly learn from the preference dataset (Zhao et al., 2023;Rafailov et al., 2023).Contribution. We begin by formulating the learning process as a Markov decision process (MDP), distinct from the contextual bandit approach typically used in RLHF for making general chatbots without external environment interactions (Xiong et al., 2024;Rafailov et al., 2023). Then, we derive the optimality condition of the planning with such an MDP and our findings indicate that when the external randomness is low, we can develop multi-turn direct alignment algorithms (M-DPO and M-KTO), where the primary modification is to mask out irrelevant tokens during training. Furthermore, we extend our approach to its online iterative variants, which recent works demonstrated to be promising (Xiong et al., 2024; Guo et al., 2024b). Finally, we evaluate our approach through case studies using augmented training sets from MATH and GSM8K benchmarks, employing various base models such as Gemma (Team et al., 2024), CodeGemma (Team, 2024), and Mistral (Jiang  et al., 2023). For instance, the performance of a supervised fine-tuned Gemma-1.1-it-7B model increased from 77.5% to 83.9% on GSM8K and from 46.1% to 51.2% on MATH. Similarly, a Gemma-2-it-9B model improved from 84.1% to 86.3% on GSM8K and from 51.0% to 54.5% on MATH. These empirical results indicate a significant improvement in performance over standard SFT models, demonstrating the potential of RLHF in complex reasoning task. We also provide a comprehensive recipe for the practical implementation of our online iterative multi-turn methods, and will make our models, datasets, and code publicly available for further research and development.
ALGORITHMS DEVELOPMENT
PROBLEM FORMULATIONWe first formally formulate the tool-integrated reasoning task. At the first step, a prompt x → X is sampled from some distribution d 0 as the initial state s 1 = x. Then, at each step h → [H],• Action: the agent observes the current state s h , which is the history of the first h ↑ 1 interactions with the external environment, and takes an action a h according to some policy ω h (•|s h ) → !(A). • Observation: in response to the agent's action, the environment then returns an observation o h ↓ P → h (•|s h , a h ) 1 based on the history s h and current action a h .Then, we transit to a new state, which is the history up to the step h + 1:and a new step begins. This process repeats for H rounds in total and eventually, we collect a trajectory: εWe present an example of multi-turn tool-integrated reasoning in Figure 4. Typically, the action is in the ReAct manner, which consist of a reasoning step f h and an execution step e h (e.g., writing python code) (Yao et al., 2022). We mention in passing that such an MDP formulation of preference learning was recently studied in Zhong et al. (2024); Rafailov et al. (2024); Xie et al. (2024a) but with a focus on the single-turn chat task and without explicitly considering the external messages.]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1">INTRODUCTION</head><p>Large language models (LLMs) have demonstrated remarkable capacities across a variety of language tasks. Notable models include <ref type="bibr">ChatGPT (OpenAI, 2023)</ref>, Claude <ref type="bibr">(Anthropic, 2023)</ref>, and Gemini <ref type="bibr">(Gemini et al., 2023)</ref>. However, despite these advances, even the most advanced closedsource LLMs still struggle with complex reasoning tasks that require multi-turn decision making. In particular, for the representative task of mathematical problem solving, LLMs often fail with basic arithmetic and symbolic computations <ref type="bibr">(Hendrycks et al., 2021;</ref><ref type="bibr">Zheng et al., 2021)</ref>. To address this issue, recent studies recommend the integration of external tools (e.g., calculators, computational Python libraries and symbolic solvers) to augment the LLMs' mathematical problem-solving capabilities <ref type="bibr">(Shao et al., 2022;</ref><ref type="bibr">Mishra et al., 2022;</ref><ref type="bibr">Zhang et al., 2024a)</ref>. Specifically, by integrating natural language reasoning with the use of these external tools, these enhanced LLMs can receive external messages from tool interactions and reason based on both previously generated tokens and external messages, which significantly improves their performance in mathematical tasks <ref type="bibr">(Gou et al., 2023b;</ref><ref type="bibr">Toshniwal et al., 2024;</ref><ref type="bibr">Shao et al., 2024)</ref>.</p><p>These successes of tool-integrated LLMs lead to a natural research question: how can we better train LLMs to combine tool usage with intrinsic reasoning to tackle complex reasoning tasks? For mathematical problem solving, existing works primarily focus on synthetic data generation (by strong teacher models) and supervised fine-tuning (SFT), as seen in ToRA <ref type="bibr">(Gou et al., 2023b)</ref>, Meta-MathQA <ref type="bibr">(Yu et al., 2023)</ref>, MAmmoTH <ref type="bibr">(Yue et al., 2023;</ref><ref type="bibr">2024)</ref>, and Open-MathInstruct <ref type="bibr">(Toshniwal</ref> To connect the problem with RLHF that learns from relative feedback, we follow <ref type="bibr">Ouyang et al. (2022)</ref>; <ref type="bibr">Bai et al. (2022)</ref> to assume that we can query the Bradley-Terry model for preference signal. Definition 1 (Bradley-Terry model). We denote &#949; /x = y, where the prompt is excluded from the trajectory. We assume that there exists a utility function of the trajectory u &#8594; such that given (x, y 1 , y 2 ), one response y 1 is preferred over another response y 2 , denoted as y 1 &#8596; y 2 , with probability Prob y 1 &#8596; y 2 | x, y 1 , y 2 = &#977; u &#8594; (x, y 1 ) &#8593; u &#8594; (x, y 2 ) ,</p><p>where &#977; is the sigmoid function &#977;(z) = 1/(1 + exp(&#8593;z)). Also, given (x, y 1 , y 2 ) we denote the sampled preference signal as z with z = 1 indicating y 1 &#8596; y 2 while z = 0 indicating y 2 &#8596; y 1 .</p><p>Here we only assume access to the trajectory-level preference, but not an action-level one. However, we remark that the utility function itself can be defined in a step-wise manner. Examples of the utility function include the binary reward from checking final result, outcome-supervised reward models <ref type="bibr">(Cobbe et al., 2021b)</ref>, and process-supervised reward model <ref type="bibr">(Lightman et al., 2023)</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.2">PLANNING WITH A MODEL: OPTIMALITY CONDITION AND PRACTICAL ALGORITHM</head><p>We develop the main algorithms in this section with the general MDP formulation. Following <ref type="bibr">Rafailov et al. (2023)</ref>, we first establish the connection between a model M = (S, A, H, P, d 0 , u) and its associated optimal policy. In particular, we are interested in the following KL-regularized planning problem with respect to a reference policy &#969; ref :</p><p>(2)</p><p>In the single-turn case with H = 1, the optimal solution with respect to a utility function u is the Gibbs distribution (see Lemma 3). Moving toward multi-turn case, we first consider H = 2 to illustrate the idea. The idea is to take a backward iteration from h = H = 2 to h = 1. Specifically, when we fix s 2 and consider only the step 2, it reduces to the single-turn case:</p><p>Then, we can define the value function associated with &#969; M,2 as</p><p>For step 1, since we have determined &#969; M,2 , with the definition of Q M,1 (s 1 , a 1 ), we have</p><p>By construction, {&#969; M,h } 2 h=1 is optimal as it maximizes the KL-regularized target. For general MDP, we can repeat the process for H times starting with V M,H+1 = 0 where we recursively define</p><p>Here the optimal policy and the V -values are given by</p><p>where</p><p>is the normalization constant. The second equality in the definition of the V -value is from Lemma 3. Then, by definition, [&#969; M,h ] H h=1 is optimal. Essentially, we solve H Gibbs distributions in terms of the Q-values. We summarize the results into the following proposition.</p><p>Proposition 1. We can recursively define the following optimal value functions and optimal policies for a KL-regularized MDP with horizon H and external observation o h . For Q value, we have</p><p>if h &#8599; H &#8593; 1.</p><p>(5)</p><p>Also, for all h &#8594; [H], we have:</p><p>We have a few interesting observations that may be of independent interests.</p><p>1. The optimal value function is characterized by the expectation with respect to the initial reference policy due to the additional KL constraint. 2. For a fixed step h and state-action pair (s h , a h ), we can treat the future as a bandit (with only one step), then, we have</p><p>, where z is a completion staring from (s h , a h ). One can use the Monte-Carlo estimation to estimate this value by multiple roll-outs. We notice that the non-regularized version of this process, is commonly referred to as the process-supervised reward (PRM) in the literature <ref type="bibr">(Wang et al., 2023a)</ref>.</p><p>In other words, the PRM constructed in <ref type="bibr">Wang et al. (2023a)</ref> is essentially a Q learning process.</p><p>We remark that the results are essentially from the entropy-regularized MDPs <ref type="bibr">(Williams &amp; Peng, 1991;</ref><ref type="bibr">Ziebart, 2010)</ref>.</p><p>Multi-turn DPO. According to equation 4, we can solve the Q-values as</p><p>Furthermore, combining equation 7 with the definition of Q-values Q M,h in equation 3, we have</p><p>Summing over h &#8594; [H], we have the following re-parameterization result:</p><p>Here, term (A) is similar to the single-turn case and term (B) will be cancelled for the reward difference of two samples with the same prompt s 1 . However, in practice, term (C) is typically not feasible to directly compute as term (C) is related to the randomness of the external environment.</p><p>For the focus of this work, i.e., the tool-integrated mathematical reasoning, luckily the code execution result is determined by the history (the codes written by the LLMs). This leads to term (C) = 0. Therefore, we can plug equation 9 into the maximum likelihood estimation of the utility function with a dataset D consisting of (x, &#949; w , &#949; l ), to get the following multi-turn DPO (M-DPO) loss:</p><p>Similarly, we can implement M-KTO under deterministic transition. We refer interested readers to Appendix A for the loss function details.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.3">ONLINE ITERATIVE TRAINING</head><p>We now combine the planning algorithm M-DPO with the online iterative learning framework, as inspired by its great success in the single-turn case <ref type="bibr">(Xiong et al., 2024;</ref><ref type="bibr">Guo et al., 2024b)</ref>.</p><p>Learning objective. For a more comprehensive understanding of its statistical behavior, we will consider two different learning objectives. The first objective is a KL-regularized one:</p><p>i.e., max &#969; J(&#969;; M &#8594; , &#969; 0 ) where M &#8594; = (S, A, H, P &#8594; , d 0 , u &#8594; ) is the groundtruth environment and &#969; 0 is the initial SFT policy. This target is widely adopted in RLHF and requires us to search for the optimal policy only at a fixed KL ball centered at the SFT policy &#969; 0 . In contrast, the second one is the non-regularized target, i.e., directly optimizing the reward:</p><p>This target is the standard one in canonical RL studies <ref type="bibr">(Sutton &amp; Barto, 2018)</ref>. One motivation for this target is that in the reasoning task, the reward function is more interpretable (e.g. final result checking) compared to the chat task.</p><p>Algorithmic framework. We present a general online iterative algorithmic framework in Algorithm 1. This framework is termed as Online Iterative Multi-turn Gibbs Sampling from Human Feedback (M-GSHF) because the optimal policy is a layer-wise Gibbs distribution that generalizes the result in <ref type="bibr">Xiong et al. (2024)</ref>. We now discuss some features of the framework as follows. we always search the optimal policy within the KL ball centered at &#969; 0 , and thus optimize the KL-regularized target. In contrast, inspired by the mirror descent <ref type="bibr">(Nemirovskij &amp; Yudin, 1983)</ref>, if we update the reference policy every iteration to be the policy learned in the last iteration, i.e., &#969; t,ref = &#969; 1 t&#8593;1 , &#8600;t &#8594; [T ], the cumulative update can make the model to move away from the original &#969; 0 (while a constraint is made on the per-iteration update magnitude) and we thus optimize the non-regularized target in equation 12. See Figure <ref type="figure">1</ref> for an illustration.</p><p>Non-symmetric policy choice for exploration-exploitation trade-off. We update our behavior policies in a non-symmetric way. The first agent aims to extract the historical information we have gathered so far and runs the M-DPO or M-DKO presented in Section 2.2. However, it is widely recognized in RL studies <ref type="bibr">(Sutton &amp; Barto, 2018;</ref><ref type="bibr">Auer et al., 2002)</ref> that simply exploiting the historical data via following the empirically best model is not sufficient to obtain a good final policy, while it is also required to explore the environment so that new information can be collected to facilitate subsequent learning, i.e., the exploration-exploitation tradeoff. Therefore, the second agent will strategically incorporate the uncertainty of the future relative to &#969; 1 t to choose &#969; 2 t , which is referred to as the exploration policy.</p><p>A comprehensive theoretical analysis is derived for Algorithm 1, deferred to Appendix D due to space constraint, with a focus on the KL-regularized target. Here we highlight the following informal result (see Theorem 2 for the complete version), emphasizing the efficiency of Algorithm 1 guaranteed by a sublinear regret. The other target of optimizing the rewards has been theoretically studied in <ref type="bibr">Wang et al. (2023b)</ref> while the techniques of analyzing mirror-descent-style algorithm have been developed in <ref type="bibr">Cai et al. (2020)</ref>.</p><p>Theorem 1 (Informal). Under the realizability assumption, with the KL-regularized target, the theoretical version of Algorithm 1 leads to a regret (defined in equation 15) that is sublinear in horizon T for a broad class of reward and transition models.</p><p>The main take-away message from the theorem is that if we choose suitable exploration policy, the online iterative learning is provably efficient. We also remark that without explicit mechanism to encourage exploration, the randomness of the LLM itself is not sufficient to learn the optimal policy (Zhang, 2022) if we do not make additional assumption.</p><p>Moving toward practical algorithm designs, the exploration is generally interpreted as increasing the diversity of the collected data by adopting inference-time methods with the base DPO policy &#969; 1 t . For instance, one may tune the sampling temperature as in Llama project <ref type="bibr">(Touvron et al., 2023)</ref> or use best-of-n sampling <ref type="bibr">(Xu et al., 2023;</ref><ref type="bibr">Hoang Tran, 2024;</ref><ref type="bibr">Dong et al., 2024)</ref>, where these methods outperform the vanilla on-policy sampling with considerable margin. In this work, we mainly enrich the generated data by various intermediate checkpoints, as done in the Claude project <ref type="bibr">(Bai et al., 2022)</ref>. We refer this approach as mixture sampling. It is also natural to adopt reward-guided Monte Carlo tree search (MCTS) <ref type="bibr">(Xie et al., 2024b)</ref>, which we leave for future work. </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>5:</head><p>&#962; Extract the empirically optimal policy from historical data 6:</p><p>Practical: Perform the planning algorithms on D to get &#969; 1 t (e.g., using the M-DPO loss in equation 10 or the M-KTO loss in equation 13) 7:</p><p>Theoretical: Perform MLE on D to obtain model estimation Mt = (&#251;t, Pt) as in equation 16 and equation 17; call Oracle 2 with Mt, &#949;, &#969; t,ref to get &#969; 1 t 8: &#962; Select the exploration policy to facilitate learning 9:</p><p>Practical: Given &#969; 1 t , select &#969;<ref type="foot">foot_1</ref> t as an exploration policy using heuristic methods (such as mixture sampling, inference parameters tuning and west-of-n sampling. 10:</p><p>Theoretical: Given &#969; 1 t , choose &#969; 2 t as an exploration policy following equation 18 11:</p><p>&#962; Choose the reference model to control regularization level 12:</p><p>Update &#969; t+1,ref &#8599; &#969; 1 t when considering the non-regularized target; keep &#969; t+1,ref &#8599; &#969;0 when considering the KL-regularized target 13: end for 14: Output: the best model in &#969; 1 1:T by a validation set.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">EXPERIMENTS</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1">EXPERIMENT SETUP</head><p>Task, datasets, and models. We use the test sets of MATH <ref type="bibr">(Hendrycks et al., 2021)</ref> and GSM8K <ref type="bibr">(Cobbe et al., 2021a)</ref> to measure the model's ability to solve the mathematical problems. To construct the training prompt set, we use the prompts from MetaMathQA <ref type="bibr">(Yu et al., 2023)</ref> and MMIQC <ref type="bibr">(Liu &amp; Yao, 2024)</ref>, which is an augmented prompt set from the 7.5K training problems of MATH and 7.47K training problems of GSM8K. We provide an example of the data sample in Figure <ref type="figure">4</ref>. We train with a range of base models, including Gemma-1.1-it-7B <ref type="bibr">(Team et al., 2024)</ref>, CodeGemma-1.1-it-7B (Team, 2024), Mistral-7B-v0.3 2 (Jiang et al., 2023), and Gemma2-it-9B. We first fine-tune the model using a subset of the Open-MathInstruct dataset. The details of the SFT process are provided in Appendix B.</p><p>Implementation of Iterative M-DPO and M-KTO. We run the iterative training for 3 epochs in total. For each iteration, we have a prompt set of 20K questions and generate 20 responses per prompt with current DPO model and 10 responses per prompt with the model from last iteration.</p><p>We check the final answer of these responses to determine their correctness. Then, for each prompt, we randomly sample two responses with correct and incorrect final answers and add them into the training samples. Then, we train the model on the collected samples using the M-DPO/M-KTO loss. We also include an ablation of reference model choice. To implement the M-DPO, we simply set the labels of all the user-turn tokens to be -100 and mask the log-probability in the subsequent loss computation. We train the model for 1 epoch at most and tune the learning rate in {2e-7, 4e-7, 7e-7, 1e-6} with the first iteration of iterative training. Eventually, the learning rate of 4e-7 is used for Gemma-1.1 models and 2e-7 is used for Gemma-2 model and Mistral model. The global batch size is 32 with a warm-up step of 40. We evaluate the model every 50 training steps by the split prompt set. The hyper-parameters are of M-KTO are mostly the same as the M-DPO. We also set the &#1009; + = &#1009; &#8593; = 1 following the original KTO paper <ref type="bibr">(Ethayarajh et al., 2024)</ref>.</p><p>Baselines. The existing literature mainly focuses on the synthetic data generation and SFT to teach the models to use the external tool. We use the results from <ref type="bibr">Toshniwal et al. (2024)</ref> as baselines because we use the same SFT dataset so the results are generally comparable. For the CoT baselines, we use the Wizardmath models from <ref type="bibr">Luo et al. (2023)</ref>. We also include the reward ranked fine-tuning (RAFT) as a baseline <ref type="bibr">(Dong et al., 2023)</ref>, which is also known as rejection sampling fine-tuning <ref type="bibr">(Touvron et al., 2023)</ref>. Another baseline is the single-turn online iterative DPO and KTO <ref type="bibr">(Rafailov et al., 2023;</ref><ref type="bibr">Ethayarajh et al., 2024)</ref>, which ignore the problem structure (i.e., the external messages) and treat the trajectory as a whole. In implementation, it means that we do not mask the tokens of external messages.</p><p>Table <ref type="table">1</ref>: Main results of different methods on the test sets of GSM8K and MATH. &#8224;: the model serves as the starting checkpoint of other methods. The results of the CoT methods are borrowed from the technical reports <ref type="bibr">(Toshniwal et al., 2024;</ref><ref type="bibr">Gou et al., 2023b)</ref>. For iterative M-DPO/M-KTO, we update the reference model by default if not specified. The gains relative to the SFT starting checkpoint are marked by &#8656;.</p><p>Base Model Method with Tool GSM8K MATH AVG WizardMath-7B SFT for CoT &#9985; 54.9 10.7 32.8 WizardMath-13B SFT for CoT &#9985; 63.9 14.0 39.0 WizardMath-70B SFT for CoT &#9985; 81.6 22.7 52.2 CodeLLaMA-2-7B SFT &#9986; 75.9 43.6 59.8 CodeLLaMA-2-13B SFT &#9986; 78.8 45.5 62.2 CodeLLaMA-2-34B SFT &#9986; 80.7 48.3 64.5 CodeLLaMA-2-70B SFT &#9986; 84.6 50.7 67.7 Gemma-1.1-it-7B SFT &#8224; &#9986; 77.5 46.1 61.8 Gemma-1.1-it-7B RAFT &#9986; 79.2 47.3 63.3 Gemma-1.1-it-7B Iterative Single-turn DPO &#9986; 81.7 48.9 65.3 Gemma-1.1-it-7B Iterative Single-turn KTO &#9986; 80.6 49.0 64.8 Gemma-1.1-it-7B Iterative M-DPO + fixed reference &#9986; 79.9 48.0 64.0 Gemma-1.1-it-7B M-DPO Iteration 1 &#9986; 81.5 49.1 65.3 Gemma-1.1-it-7B M-DPO Iteration 2 &#9986; 82.5 49.7 66.1 Gemma-1.1-it-7B M-DPO Iteration 3 &#9986; 83.9 &#8656;6.4 51.2 &#8656;5.1 67.6 &#8656;5.8 Gemma-1.1-it-7B Iterative M-KTO &#9986; 82.1 &#8656;4.6 49.5 &#8656;3.4 65.8 &#8656;4.0 CodeGemma-1.1-it-7B SFT &#8224; &#9986; 77.3 46.4 61.9 CodeGemma-1.1-it-7B RAFT &#9986; 78.8 48.4 63.6 CodeGemma-1.1-it-7B Iterative Single-turn DPO &#9986; 79.1 48.9 64.0 CodeGemma-1.1-it-7B Iterative Single-turn KTO &#9986; 80.2 48.6 64.4 CodeGemma-1.1-it-7B Iterative M-DPO &#9986; 81.5 &#8656;4.2 50.1 &#8656;3.7 65.8 &#8656;4.0 CodeGemma-1.1-it-7B Iterative M-KTO &#9986; 81.6 &#8656;4.3 49.6 &#8656;3.2 65.6 &#8656;3.8 Mistral-7B-v0.3 SFT &#8224; &#9986; 77.8 42.7 60.3 Mistral-7B-v0.3 RAFT &#9986; 79.8 43.7 61.8 Mistral-7B-v0.3 Iterative Single-turn DPO &#9986; 79.8 45.1 62.5 Mistral-7B-v0.3 Iterative Single-turn KTO &#9986; 81.3 46.3 63.8 Mistral-7B-v0.3 Iterative M-DPO &#9986; 82.3 &#8656;4.5 47.5 &#8656;4.8 64.9 &#8656;4.7 Mistral-7B-v0.3 Iterative M-KTO &#9986; 81.7 &#8656;3.9 46.7 &#8656;4.0 64.2 &#8656;4.0 Gemma-2-it-9B SFT &#8224; &#9986; 84.1 51.0 67.6 Gemma-2-it-9B RAFT &#9986; 84.2 52.6 68.4 Gemma-2-it-9B Iterative Single-turn DPO &#9986; 85.2 53.1 69.2 Gemma-2-it-9B Iterative Single-turn KTO &#9986; 85.4 52.9 69.2 Gemma-2-it-9B Iterative M-DPO &#9986; 86.3 &#8656;2.2 54.5 &#8656;3.5 70.4 &#8656;2.9 Gemma-2-it-9B Iterative M-KTO &#9986; 86.1 &#8656;2.0 54.5 &#8656;3.5 70.3 &#8656;2.8</p><p>Published as a conference paper at ICLR 2025</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2">MAIN RESULTS</head><p>We evaluate the models in the zero-shot setting and report the main results in Table <ref type="table">1</ref>. From the first two sections in Table <ref type="table">1</ref>, we first observe that the tool-integrated LLMs significantly outperform their CoT counterparts with only SFT, demonstrating the benefits of leveraging external tools. In the subsequent discussions, we focus on the comparison within the scope of tool-integrated LLMs.</p><p>Iterative M-DPO and M-KTO considerably improve the SFT models. Across all four base models, iterative training with M-DPO or M-KTO consistently leads to notable improvements over the initial SFT checkpoint on both GSM8K and MATH. In particular, with M-DPO, the aligned Gemma-1.1-it-7B model attains accuracies of 83.9% and 51.2% on GSM8K and MATH, respectively, and is comparable to the open-source Open-MathInstruct-finetuned CodeLLaMA-2-70B (slightly worse on GSM8K but also slightly better on MATH). Moreover, the aligned Gemma-2it-9B model achieves accuracies of 86.3% and 54.5% on GSM8K and MATH, surpassing all of the open-source models trained with Open-MathInstruct in the 7B to 70B range. Overall, our framework can robustly further boost the tool-integrated models' ability after SFT.</p><p>Iterative M-DPO and M-KTO surpass existing RLHF baselines. We also observe that the iterative M-DPO and M-KTO surpass other existing RLHF baselines. First, they consistently and significantly outperform RAFT across all four base models. This is because RAFT only imitates the correct trajectories, while the DPO-based and KTO-based algorithms further use the negative signal from incorrect trajectories. We note that the SFT stage in our pipeline can also be viewed as an application of RAFT. Consequently, our results should be interpreted to be that after the first stage of SFT, algorithms with negative signal are more sample efficient. Moreover, while the online iterative single-turn DPO (KTO) also gives a better performance, it is generally worse than the multi-turn version. This suggests that learning to predict the off-policy external messages returned by the code interpreter usually has a negative impact on the reasoning ability improvement. We also present a representative example we encounter in Figure <ref type="figure">5</ref>, where LLMs generate poorly constructed code resulting in anomalous and lengthy external messages. Forcing LLMs to learn to predict these messages can significantly hurt the model's reasoning abilities.</p><p>Iterative training and reference update lead to better performance. Using Gemma-1.1-it-7B with M-DPO as an example, we observe that online iterative training leads to better results. The GSM8K test accuracy increases from 77.5% (SFT) to 81.5% (iter 1) to 82.5% (iter2) to 83.9% (iter3), and the test accuracy of MATH improves from 46.1% (SFT) to 49.1% (iter 1) to 49.7% (iter2) to 51.2% (iter3). This aligns with our theoretical insight that iterative training helps models progressively explore and learn the optimal policy. Additionally, if the reference model remains fixed at the SFT policy, the final performance is notably worse compared to updating the reference model at each iteration. This likely occurs because the algorithm, in this case, optimizes the non-regularized reward, and the rewards in mathematical reasoning tasks are more accurate than in general chat tasks, leading to better in-domain performance. A detailed ablation study on the impact of KL regularization is deferred to the next section.</p><p>Figure <ref type="figure">2</ref>: The pass@n rate with respect to the number of candidates n. We evaluate the models using temperature 0.7 following the previous works <ref type="bibr">Shao et al. (2024)</ref>; <ref type="bibr">Toshniwal et al. (2024)</ref>. We notice that preference learning only improves the metric pass@n when n is relatively small.</p><p>Preference learning improves pass@n only when n is relatively small. We plot the pass@n accuracy in terms of the number of candidate trajectories n in Figure <ref type="figure">2</ref>. A question is solved if at least one of the n sampled trajectories is correct. We find that preference learning improves pass@n accuracy only when n is small. For n &gt; 16, all models perform similarly on GSM8K and MATH, indicating that iterative M-DPO does not introduce new knowledge but instead enhances the quality of top-n responses. This observation also aligns with the result of CoT reasoning <ref type="bibr">(Shao et al., 2024)</ref>. (2) updating the reference model to the last iteration's model at each round, which can be viewed as a trade-off between the generation diversity and reward optimization. As shown in Table <ref type="table">3</ref>.3, models with an updated reference model outperform those with a fixed reference model. We hypothesize that in reasoning tasks, the correct reasoning paths are highly concentrated, making diversity less crucial so optimizing the non-regularized reward gives superior model performance.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.3">ABLATION STUDY AND DISCUSSION</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Method</head><p>Previous work <ref type="bibr">(Tunstall et al., 2023)</ref> on offline DPO suggests that a lower KL coefficient (0.01) improves performance by allowing the model to deviate more from the SFT model &#969; 0 . In our ablation study, we search the KL coefficient &#982; &#8594; {0.01, 0.1, 0.5}. According to Table <ref type="table">3</ref>.3, we find that the strongest model is obtained by a moderate KL coefficient of 0.1, outperforming both 0.01 and 0.5. To explain this, we plot the GSM8K test accuracy (Figure <ref type="figure">3</ref>) during iterative training. In the first iteration, lower KL values show larger improvements, consistent with Tunstall et al. ( <ref type="formula">2023</ref>)'s results. However, models trained with very low KL coefficients lose diversity quickly, reducing their ability to generate diverse trajectories for later training, leading to diminishing returns in subsequent iterations. Conversely, a higher KL coefficient of 0.5 imposes too much regularization, limiting improvement per iteration. In summary, for online iterative training, a balance between per-iteration improvement and exploration efficiency is key to optimizing overall performance, an intuition that also applies to sampling strategies and other experimental techniques. The impact of sampling strategy: data diversity and coverage are crucial. During iterative training of Gemma-1.1-it-7B, we see an increase in correct trajectories from 47% in the first iteration to 76% in last iteration. Moreover, as the reference model updates at each step, trajectory diversity declines, which is critical for DPO/KTO training due to its contrastive nature. We follow <ref type="bibr">Bai et al. (2022)</ref>; <ref type="bibr">Dong et al. (2024)</ref> to explore two data collection strategies: (1) on-policy sampling (trajectories sampled from the current model) and (2) mixture sampling (20 trajectories from the current model and 10 from model of previous iteration). As shown in Table <ref type="table">6</ref>, mixture sampling significantly outperforms on-policy sampling, particularly in the third iteration where on-policy sam-pling fails to improve MATH test accuracy. This highlights the importance of diversity in iterative training and aligns with previous findings that advanced exploration strategies help prevent diversity collapse and improve preference learning <ref type="bibr">(Bai et al., 2022;</ref><ref type="bibr">Touvron et al., 2023;</ref><ref type="bibr">Xiong et al., 2024;</ref><ref type="bibr">Pace et al., 2024;</ref><ref type="bibr">Dong et al., 2024)</ref>. It would also be interested to explore more advanced exploration strategy like MCTS in the future study.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Method</head><p>GSM8K MATH SFT 77.5 46.1 N=30 + Mixture 83.9 51.2 N=12 + Mixture 83.5 51.2 N=6 + Mixture 82.0 49.2 N=30 + On-policy 83.1 49.5 Table 3: Ablation study of the sampling strategy with iterative M-DPO and Gemma-1.1-it-7B.</p><p>To ensure both correct and incorrect reasoning paths exist, we collected N trajectories per prompt. A larger N generally improves prompt coverage, as more samples are needed for difficult problems. For example, in iteration 1, with N=30, 92.5% of the prompts are covered, compared to 83.0% for N=12 and 60% for N=6. See Figure <ref type="figure">2</ref> for an illustration of the relationship between pass@1 and N. However, increasing N also increases computational costs. In our ablation study (Table <ref type="table">3</ref>.3), we find that increasing N from 6 to 12 leads to a significant performance boost, reflecting better coverage for complex problems. However, increasing N from 12 to 30 yields only minor improvements, suggesting that the benefits of larger N diminish quickly in vanilla rejection sampling. We expect that difficulty-aware sampling can lead to a better performance, while maintaining a moderate inference cost.</p><p>collection and model evaluation. The main experiment of this paper can be reproduced within 24 -48 hours with this setup. To improve the readability of this paper, we provide a notation table in Appendix A. The informal version of our main theoretical result is summarized in Theorem 1 is re-stated in Theorem 2 and its proof is provided in Appendix D. Xinyu Zhu, Junjie Wang, Lin Zhang, Yuxiang Zhang, Yongfeng Huang, Ruyi Gan, Jiaxing Zhang, and Yujiu Yang. Solving math word problems via cooperative reasoning induced language models. arXiv preprint arXiv:2210.16257, 2022. Brian D Ziebart. Modeling purposeful adaptive behavior with the principle of maximum causal entropy. Carnegie Mellon University, 2010. A NOTATION TABLE, RELATED WORK, AND MISSING DETAILS A.1 NOTATION TABLE Notation Description x, X</p><p>The prompt and the prompt space. d0</p><p>The distribution of initial state (prompt).</p><p>The state, action, and observation.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>H</head><p>Episode length, e.g., the maximal number of tool calls.</p><p>The true observation kernel. &#1009; = (x, y)</p><p>&#1009; is a trajectory and y is the completion part, i.e., we exclude x from &#1009; . u &#8594;</p><p>The true utility function associated with the BT model defined in Definition 1.</p><p>The true model with observation kernel P &#8594; and utility function</p><p>The policy, which is parameterized by the LLM. M = (S, A, H, P, d0, u)</p><p>One arbitrary environment with observation kernel P and utility function u.</p><p>One arbitrary reference policy. J(&#969;; M, &#969; ref )</p><p>The KL-regularized target (equation 2) with environment M and reference &#969; ref .</p><p>The coefficient of KL penalty, defined in equation 2.</p><p>The optimal Q-values associated with J(&#969;; M, &#969; ref ), defined in equation 3.</p><p>The optimal V -values associated with J(&#969;; M, &#969; ref ), defined in equation 4.</p><p>The optimal policy associated with J(&#969;; M, &#969; ref ), defined in equation 4.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>LM-DPO(&#8226;)</head><p>M-DPO loss, defined in equation 10.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>LM-KTO(&#8226;)</head><p>M-KTO loss, defined in equation 13.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>J(&#969;)</head><p>The abbreviation of J(&#969;; M &#8594; , &#969;0), defined in equation 14.</p><p>The optimal policy associated with J(&#969;).</p><p>The main and exploration policy at round t Reg(T )</p><p>Regret over horizon T , defined in equation 15.</p><p>U, P Known sets such that u &#8594; &#8658; U and P &#8594; &#8658; P B Assuming u &#8594; (x, y) &#8658; [0, B], &#8657;(x, y). &#251;t, Pt MLE of u &#8594; and P &#8594; at round t, defined in equation 16 and equation 17. Ut, Pt Confidences sets of u &#8594; and P &#8594; at round t, defined in equation 19. c1, c2, c Absolute constants. &#966; 1/(2 + exp(&#8593;B) + exp(B)). dU Eluder coefficient from Definition 3. dP , &#8636;(&#8226;) Generalized Eluder-type condition from Definition 4. TV(&#8226;, &#8226;) Total variation distance between two distributions.</p><p>Table 4: The table of notations used in this paper.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>A.2 RELATED WORK</head><p>LLMs for Mathematical Problem Solving. A line of works proposes to prompt LLMs to solve the complex reasoning task in a step-by-step manner, known as the Chain-of-Thought (CoT) prompting <ref type="bibr">(Wei et al., 2022;</ref><ref type="bibr">Zhou et al., 2022;</ref><ref type="bibr">Zhu et al., 2022;</ref><ref type="bibr">Tong et al., 2024)</ref>, which has been a standard practice in reasoning task. However, LLMs often struggle with basic arithmetic and symbolic manipulations when relying solely on internal knowledge and natural language reasoning, as measured by standard benchmarks <ref type="bibr">(Cobbe et al., 2021a;</ref><ref type="bibr">Hendrycks et al., 2021)</ref>. To overcome these limitations, several studies have explored the use of external tools to enhance the LLMs' problem-solving abilities. This includes calculators <ref type="bibr">(Cobbe et al., 2021b;</ref><ref type="bibr">Shao et al., 2022)</ref>, symbolic solvers <ref type="bibr">(Zhang, 2023)</ref>, and code interpreters <ref type="bibr">(Mishra et al., 2022;</ref><ref type="bibr">OpenAI, 2023)</ref>. A particularly effective approach is the Program-based method (PoT), which performs CoT reasoning by writing code and using the output of the written code as the final answer <ref type="bibr">(Gao et al., 2023;</ref><ref type="bibr">Chen et al., 2022)</ref>. This method significantly outperforms traditional CoT-based techniques in mathematical problem solving. However, PoT also faces challenges in planning and error handling, where natural language reasoning is more suitable <ref type="bibr">(Gou et al., 2023a)</ref>. In view of this, tool-integrated reasoning is proposed to combine the natural-language-based intrinsic reasoning with the external tools <ref type="bibr">(Gou et al., 2023b)</ref> and has achieved great progresses in recent studies <ref type="bibr">(Gou et al., 2023b;</ref><ref type="bibr">Yue et al., 2023;</ref><ref type="bibr">Yu et al., 2023;</ref><ref type="bibr">Shao et al., 2024;</ref><ref type="bibr">Toshniwal et al., 2024)</ref>. While these efforts have primarily focused on synthetic data generation for tool-integrated reasoning, our work aims to further boost the performance of tool-integrated LLMs by RLHF.</p><p>RLHF and RLHF Algorithms. The predominant approach in RLHF is the deep RL method, Proximal Policy Optimization Algorithms (PPO) <ref type="bibr">(Schulman et al., 2017)</ref>, which leads to the great successes in Chat-GPT (OpenAI, 2023), Gemini <ref type="bibr">(Gemini et al., 2023)</ref>, and Claude <ref type="bibr">(Anthropic, 2023)</ref>. However, applying PPO requires extensive efforts and resources <ref type="bibr">(Choshen et al., 2019;</ref><ref type="bibr">Engstrom et al., 2020)</ref>, often beyond the scope of open-source capabilities. In view of this, alternative approaches have been developed. The rejection sampling fine-tuning was first proposed with the name RAFT (reward ranked fine-tuning) in RLHF <ref type="bibr">(Dong et al., 2023)</ref> and was later extended to machine translation <ref type="bibr">(Gulcehre et al., 2023)</ref> and mathematical problem solving <ref type="bibr">(Yuan et al., 2023a)</ref>.</p><p>Its theoretical advantage was explored in <ref type="bibr">Gui et al. (2024)</ref>. Subsequently, another long line of works proposes direct preference learning algorithms, including SLiC <ref type="bibr">(Zhao et al., 2023)</ref>, DPO <ref type="bibr">(Rafailov et al., 2023)</ref>, <ref type="bibr">IPO (Azar et al., 2023)</ref>, KTO <ref type="bibr">(Ethayarajh et 2024)</ref>, and GPO <ref type="bibr">(Tang et al., 2024)</ref>. These algorithms bypass the reward modeling step and optimize carefully designed loss objectives directly on the preference dataset, hence the name direct preference learning. There are also some works focusing on more general preference structure</p><p>Munos et al. (2023); Swamy et al. (2024); et al. (2024); Rosset et al. ( <ref type="formula">2024</ref>) beyond the reward-based framework or post-processing of the model <ref type="bibr">(Lin et al., 2023;</ref><ref type="bibr">Zheng et al., 2024)</ref>.</p><p>The newly proposed direct preference learning algorithms have largely advanced the RLHF area, particularly the post-training of open-source models, with the Zephyr project as a notable example <ref type="bibr">(Tunstall et al., 2023)</ref>. After this, a long line of work (e.g., <ref type="bibr">Liu et al., 2023b;</ref><ref type="bibr">Xiong et al., 2024;</ref><ref type="bibr">Guo et al., 2024b;</ref><ref type="bibr">Xu et al., 2023;</ref><ref type="bibr">Tajwar et al., 2024;</ref><ref type="bibr">Xie et al., 2024a;</ref><ref type="bibr">Zhang et al., 2024b;</ref><ref type="bibr">Liu et al., 2024a;</ref><ref type="bibr">b;</ref><ref type="bibr">Meng et al., 2024)</ref> demonstrates the effectiveness of on-policy sampling (the samples are generated by the policy to be trained) and online exploration in enhancing direct preference learning.</p><p>In particular, the online iterative DPO <ref type="bibr">(Xiong et al., 2024;</ref><ref type="bibr">Xu et al., 2023;</ref><ref type="bibr">Hoang Tran, 2024)</ref> and its variants (e.g., <ref type="bibr">Chen et al., 2024b;</ref><ref type="bibr">Rosset et al., 2024;</ref><ref type="bibr">Cen et al., 2024;</ref><ref type="bibr">Zhang et al., 2024c)</ref> have made state-of-the-art open-source models <ref type="bibr">(Dong et al., 2024)</ref>, or even the industry models (qwe, 2024; Meta, 2024). Despite these advancements, most algorithms are proposed and designed for single-turn interactions and chat. The scenarios beyond single-turn chat remain largely unexplored in the existing literature. One exception is the very recent work by <ref type="bibr">Shani et al. (2024)</ref>, which studies multi-turn chat task under general preferences. In contrast, in this paper, we aim to explore the use of RLHF in multi-turn tasks that incorporate interactions with external tools. Meanwhile, they derive a mirror-descent-based policy optimization algorithm, which is also different from ours.</p><p>RLHF for Math Problem Solving. Algorithms traditionally used in general chatbot applications have been adapted to enhance the reasoning capabilities of LLMs in mathematical contexts. For instance, RAFT (Reward-rAnked Fine-Tuning) <ref type="bibr">(Dong et al., 2023;</ref><ref type="bibr">Yuan et al., 2023b;</ref><ref type="bibr">Touvron et al., 2023)</ref> is extensively employed for synthetic data generation, whether through on-policy (selfimproving) <ref type="bibr">(Yuan et al., 2023a)</ref> or off-policy (knowledge distillation) methods <ref type="bibr">(Gou et al., 2023b;</ref><ref type="bibr">Yu et al., 2023;</ref><ref type="bibr">Toshniwal et al., 2024;</ref><ref type="bibr">Singh et al., 2023;</ref><ref type="bibr">Tong et al., 2024)</ref>. The reward signal in these scenarios is typically derived from either final result checking or Outcome-supervised Reward Models (ORMs) <ref type="bibr">(Uesato et al., 2022;</ref><ref type="bibr">Zelikman et al., 2022)</ref>. A novel approach by Lightman et al.</p><p>(2023) introduces Process-supervised Reward Models (PRMs), which provide feedback at each step of the Chain-of-Thought, demonstrating significant improvements over ORMs when combined with rejection sampling <ref type="bibr">(Lightman et al., 2023;</ref><ref type="bibr">Wang et al., 2023a)</ref>.</p><p>In addition to the RAFT, the GRPO algorithm proposed in <ref type="bibr">Shao et al. (2024)</ref> studies multi-turn math problem solving but focuses on the CoT format without external inputs and the resulting model achieves the state-of-the-art performance in its class. The GRPO is a variant of Reinforce (Williams, 1992) thus falling into the scope of deep RL methods. Further advancements include adapting direct preference learning algorithms to mathematical problem solving. For instance, Jiao et al. (2024); Yuan et al. (2024) have applied the original DPO or KTO by taking the trajectory completion as a "meta" action. Xie et al. (2024b); Pang et al. (2024) further adapt the online iterative DPO originally designed for chat (Xiong et al., 2024; Xu et al., 2023; Hoang Tran, 2024) and achieve better performance for CoT reasoning. Inspired by the success of PRMs, recent studies have explored generating proxy step-wise labels for the intermediate steps of the reasoning trajectories. For instance, Xie et al. (2024b); Chen et al. (2024a); Lai et al. (2024) leverage Monte Carlo Tree Search (MCTS) and use the estimated Q value to generate the proxy labels for the intermediate steps. Lai et al. (2024) proposes to use AI feedback like GPT-4 (Lai et al., 2024) to find the first error step in the trajectory. Meanwhile, Lu et al. ( <ref type="formula">2024</ref>) identifies a trajectory with the correct final answer and no errors as preferable, and prompts the SFT model with a high temperature, starting from some intermediate step to collect a rejected trajectory with errors <ref type="bibr">(Pi et al., 2024)</ref>. Finally, a very recent study by <ref type="bibr">Chen et al. (2024a)</ref> proposes to use MCTS with a backward iteration from the final leaf node to compute the proxy unregularized value of each node. Preference pairs are then extracted from the tree by fixing the prefix and comparing the next single reasoning step. Then, they run the original DPO on these intermediate actions with the proxy labels from MCTS. To summarize, these works present different ways of preference data collection and apply the original DPO algorithm (with some additional marginal loss and regularization adapted from the literature), thereby differing from our work in both algorithmic concepts and application scope. In contrast, we study preference learning in the context of trajectory-level comparison, where we derive the optimality condition and introduce a multi-turn DPO within an online iterative framework, specifically for tool-integrated mathematical problem solving. However, we remark that while we focus on the trajectory-level comparison, the preference signal itself can be generated in a stepby-step supervision (see Section 2.1 for the detailed examples). When preference signals for partial trajectories with shared prefixes are available, our method can also adapt to learn these step-level signals (see the optimality condition in equation 9). In particular, the algorithmic design presented in this paper can be readily combined with the MCTS-based data collection strategy outlined in recent literature, which we leave for future work.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>A.3 MISSING DETAILS</head><p>Multi-turn KTO. With equation 9 implying that with term (C) = 0, the implicit reward is given by</p><p>, a multi-turn version of KTO <ref type="bibr">(Ethayarajh et al., 2024)</ref>, denoted as M-KTO, can also be naturally derived:</p><p>where</p><p>Here &#1009; + and &#1009; &#8593; are two hyper-parameters. We notice that <ref type="bibr">Mitra et al. (2024)</ref> developed an online iterative version of KTO for the CoT format reasoning task. Here we extend it to build the toolintegrated reasoning agent.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>B IMPLEMENTATION DETAILS</head><p>Supervised fine-tuning (SFT). We first fine-tune the model for the tool-integrated reasoning task <ref type="bibr">(Gou et al., 2023b)</ref>, using a subset of the Open-MathInstruct dataset, which was generated by the permissively licensed Mixtral-8x7B model through in-context learning. The problems are from the training sets of MATH and GSM8K datasets. We restrict the number of samples for each question to be 50 and remove the nearly duplicate responses. Eventually we get 510K samples in the SFT dataset. We train the models for 4 epochs at most with a learning rate of 5e-6 for Gemma instruct models <ref type="bibr">(Team et al., 2024)</ref> and a learning rate of 1e-5 for <ref type="bibr">Mistral-v0.3 model (Jiang et al., 2023)</ref>.</p><p>The learning rates are determined by searching {2e-6, 5e-6, 1e-5}. We use a cosine learning rate scheduler and set the warm-up steps as 100. The samples are packed into blocks with length 4096 to accelerate training and a global batch size of 64 is used. We also mask all the user messages (i.e., the Figure <ref type="figure">4</ref>: An example of multi-turn mathematical reasoning with Python interpreter. The action is in a ReAct style <ref type="bibr">(Yao et al., 2022)</ref> where it consists of a reasoning step f h and an execution step e h .</p><p>prompt and the messages returned by the Python interpreter) in the training. The checkpoint at the end of the third epoch is used for Gemma and the checkpoint of the end of the second epoch is used for Mistral as the starting point for RLHF. This is because these models outperform the last-iteration one with considerable margin and is very close to the next one. An ablation study on the SFT epochs is also included.</p><p>Data format and generation. We format the data into a multi-turn chat where the user asks the LLMs a question, and provide the messages returned by the Python interpreter in the subsequent user rounds of chat. For all the data generation process, we adopt the following constraints: (1) for each turn, the model can generate up to 512 tokens; (2) the maximal number of steps is H=6; (3) the maximal number of token for each trajectory is 2048. Following <ref type="bibr">Gou et al. (2023b)</ref>; <ref type="bibr">Toshniwal et al. (2024)</ref>, the LLM agent is allowed to call the python interpreter when it decodes a python code starting with python and ending with . For each step h, to generate the observation o h , we leverage the python package IPython, and run all the codes in the history one by one and treat each code snippet as a Jupyter cell. We only return the standard output or the error message from the last snippet. When there exists some bug in the code, we only return the error message which is typically less than 20 tokens as in <ref type="bibr">Toshniwal et al. (2024)</ref>. We notice that some works (e.g. <ref type="bibr">Shao et al. (2024)</ref>) also returns the first and the last 50 tokens of the trackback information.</p><p>Evaluation Configuration. All the models are evaluated in the zero-shot setting. For all the data generation process, we adopt the following constraints: (1) for each turn, the model can generate up to 512 tokens; (2) the maximal number of steps is H=6; (3) the maximal number of generated token for each trajectory is 2048. When collecting new data for online iterative M-DPO, we set temperature to be 1.0 and decode without top-K or top-p sampling. For evaluation, greedy decoding is employed so that the results are generally comparable with previous works <ref type="bibr">Gou et al. (2023b)</ref>; <ref type="bibr">Toshniwal et al. (2024)</ref>. For evaluating the models with pass@n rate, we follow <ref type="bibr">Toshniwal et al. (2024)</ref> to adopt a temperature of 0.7.</p><p>Python Experiment Environment. We find that the evaluation can be influenced by the python environment, the precision (especially for the Gemma-1.1 models), and even the virtual machine we use. This does not affect the overall trend and conclusion because the magnitude of oscillation is relatively small compared to the overall improvement. For completeness, however, we specify some of the key package versions here. We use transformers 4.42.4, torch 2.3.0, sympy 1.2, antlr4-python3-runtime 4.11.0, IPython 8.26.0 for all models. We evaluate the models using torch.float and use vllm 0.5.0.post1 for most the experiments except for Gemma-2 where vllm 0.5.1 is required. The inconsistency of vllm version is because Gemma-2 model was not released when we performed the main experiments of this project. We fix the python environment and machine for our evaluation throughout the experiment. For SFT, we use the open-source axolotl project with version 0.4.1 and for online iterative preference learning and RAFT, we use the code base from RLHF Workflow <ref type="bibr">(Dong et al., 2024)</ref>.</p><p>RAFT implementation. RAFT first collects N trajectories per prompt, filters the low-quality data (by reward function), and fine-tune on the selected trajectories. The data generation step is similar to the online iterative M-DPO training, except that we only keep the trajectories with correct final answer. For each prompt, we sample at most k trajectories where we search k &#8594; {1, 3, 8} and use k = 1 eventually because we do not see improvement by leveraging more data. We run the algorithm for three iterations in total. The training parameters are similar to the SFT stage, but we use a smaller batch size of 32 so that there are enough optimization steps. For Gemma models, we use a learning rate of 5e-6. For each training stage, we train the models for two epochs in total according to our parameter search. For Mistral model, we find that a smaller learning rate of 1e-6 and training for 1 epoch give us much better performance.</p><p>Prompt template. We do not tune the prompt though we do observe that the prompt engineering can further improve the performance. For all the experiments, we simply adopt the chat template of the models to form a multi-turn chat as in Figure <ref type="figure">4</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>C ADDITIONAL EXPERIMENTAL RESULTS</head><p>We include additional ablation studies in this section for a more comprehensive understanding of the proposed algorithm.</p><p>The best model is obtained with starting checkpoint fine-tuned with more than 1 epochs. <ref type="bibr">Tunstall et al. (2023)</ref> finds that if the SFT model is trained for more than one epoch, the subsequent DPO training will lead to performance regression with longer training in terms of instruction-following ability and benchmark for a general chatbot. In other words, there exists a trade-off between the SFT training epochs and the DPO training steps. Moreover, the best model is obtained by SFT for one epoch in their practice. We also conduct an ablation study on the impact of the SFT epoch and summarize the results in Table <ref type="table">5</ref>. Consistently across all tested scenarios, the subsequent iterative M-DPO training leads to considerable model improvement compared to the SFT model. Meanwhile, we also observe a similar trade-off between SFT and RLHF training because with more SFT epochs, the gains from the RLHF stage decrease. However, in our case, the strongest model is obtained with three epochs of SFT, followed by fine-tuning through iterative M-DPO, which is different from the offline DPO training <ref type="bibr">(Tunstall et al., 2023)</ref> or the iterative DPO for general chatbot <ref type="bibr">(Dong et al., 2024)</ref> with only one epoch of SFT.</p><p>Table <ref type="table">5</ref>: Ablation study of the impact of SFT epoch. Mixture sampling is adopted for the iterative M-DPO training and we run for three iterations in total. The gains relative to their starting SFT checkpoints are marked by &#8656;.</p><p>Model Method GSM8K MATH</p><p>NLL loss helps when the SFT model is substantially underfitting. The recent work Pang et al.</p><p>(2024) has introduced iterative RPO, specifically aimed at enhancing Chain of Thought (CoT) capabilities for solving mathematical problems. A key feature of this approach is the inclusion of an additional negative log-likelihood (NLL) loss for the preferred response. The main intuition for adding the NLL loss is that the original DPO algorithm <ref type="bibr">(Rafailov et al., 2023)</ref> tends to reduce the likelihood of the preferred responses, and this is believed to hurt the reasoning ability <ref type="bibr">(Wang et al., 2024)</ref>. Motivated by their results, we explored the applicability of this idea to our setup. We conduct an ablation study by adding the NLL loss into the iterative M-DPO training and observe performance regression as reported in Table <ref type="table">6</ref>. We observe that the best model is obtained in the second iteration if we add the additional NLL loss even though we use the mixture sampling to increase the diversity of the collected data. With time-weighted exponential moving average for smoothing training record, we observe that the log probability of the chosen responses and rejected responses are <ref type="bibr">(-126, -222)</ref> at the 200th step of the third iteration training when we add the NLL loss, as compared to <ref type="bibr">(-166, -350)</ref> in the case without the NLL loss. This is consistent with the result of <ref type="bibr">Pang et al. (2024)</ref> where with the additional NLL loss, both the log probability of chosen responses and that of rejected responses increase. These evidences indicate that the NLL loss further contributes to the model distribution collapse and eventually hurt the overall performance of online iterative learning. Finally, we notice that the additional NLL loss can be viewed as an implementation of the pessimistic principle <ref type="bibr">(Liu et al., 2024b)</ref>. This also explains its inferior in-domain performance though it may be helpful to stable the training, which requires more in-depth studies.</p><p>However, one distinct feature between our setup and Pang et al. ( <ref type="formula">2024</ref>) is whether we first fine-tune the initialized SFT model with in-domain data. To further understand the phenomena, we fine-tune the Gemma-1.1-it-7B with only 100 steps (so that the model knows to leverage Python code to solve the problem) as the starting checkpoint of preference learning and conduct an ablation study with the NLL loss using this model. We observe when the SFT model is substantially underfitting, the addition of NLL loss actually enhances performance. This scenario mirrors the findings of Pang et al. ( <ref type="formula">2024</ref>), who utilized a general LLaMA2-70B-chat model <ref type="bibr">(Touvron et al., 2023)</ref> without firstly fine-tuning on the in-domain data. Our observations align with prior research in the context of developing general chatbots <ref type="bibr">(Lin et al., 2023)</ref>, which suggests that RLHF is less effective without preliminary SFT. Table <ref type="table">6</ref>: Other ablation studies. Mixture sampling is adopted for the iterative M-DPO training and we run for three iterations in total. The gains relative to the iterative M-DPO are marked by &#8656;.</p><p>Model Method GSM8K MATH</p><p>Iterative M-DPO with NLL loss 81.7 &#8659;2.2 49.5 &#8659;1.7</p><p>Gemma-1.1-it-7B SFT 100 steps 50.8 23.7 Gemma-1.1-it-7B + M-DPO Iteration 1 57.8 27.9 Gemma-1.1-it-7B + M-DPO and NLL loss Iteration 1 61.0 &#8656;3.2 30.1 &#8656;2.2</p><p>On-policy sampling and small learning rate mitigate the probability drops in preferred responses. In the literature, the Direct Preference Optimization (DPO) algorithm is often reported to diminish reasoning capabilities by reducing the likelihood of preferred responses <ref type="bibr">(Yuan et al., 2024;</ref><ref type="bibr">Hong et al., 2024;</ref><ref type="bibr">Meng et al., 2024)</ref>. In our preliminary experiments, we also observe similar phenomena with a large learning rate (1e-6), where the model's reasoning ability collapses after only a few training steps, preventing convergence to good reasoning performance. In contrast, we find that using on-policy sampling within our online iterative training framework, coupled with a smaller learning rate (2e-7 or 4e-7), the DPO algorithm enhances the model's reasoning abilities. To interpret our observation, we can first write down the gradient of the DPO as follows:</p><p>where r &#977; (x, y) = &#982; log &#969; &#969; (x,y) &#969; ref (x,y) is the implicit reward and we use the single-turn one for simplicity. In practice, the probability of the rejected responses typically decrease, and their gradient quickly dominates when &#969; &#977; (y l |x) &lt;&lt; &#969; &#977; (y w |x) and the optimization becomes unlearning of the rejected responses. In this case, the probability of the chosen responses cannot increase. This phenomenon was also discussed in the blog <ref type="bibr">Guo et al. (2024a)</ref>. When we adopt on-policy sampling, it leads to a relatively large probability for both rejected and chosen responses at the initial stage, ensuring that both gradients remain valid and effective. Moreover, a small learning rate prevents the model from deviating too significantly, maintaining the effectiveness of both gradients. We also notice that for the KTO algorithm, the preferred responses and the rejected responses do not appear in pairs. We suspect that the probability of the preferred response increases because the gradients of the rejected response do not dominate in every mini-batch of data. A more comprehensive understanding of the training dynamic of the direct preference learning algorithms remains largely open and we leave a more detailed study of this phenomena to future study.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>D THEORETICAL PROOFS D.1 THEORETICAL RESULTS</head><p>In this following, we show that the multi-turn RLHF problem can be solved in a statistically efficient manner under standard assumptions in learning theory literature. In particular, for generality, we target the most challenging scenario with stochastic and unknown transitions, while as aforementioned, multi-turn mathematical reasoning with external tools falls into a relatively easier regime with deterministic transitions. As mentioned in the main paper, we mostly study the KL-regularized target due to the lack of theoretical research on it. The other target of optimizing the rewards has been theoretically studied in <ref type="bibr">Wang et al. (2023b)</ref> while the techniques of analyzing mirror-descent-style algorithm and corresponding guarantees have also been developed in <ref type="bibr">Cai et al. (2020)</ref>, which can be migrated to considering preference feedbacks. Also, to ease the presentation, we consider the scenario with batch size m = 1, while the results can be easily generalized to large batches.</p><p>First, to measure the online learning process, we define the optimal policy as</p><p>and introduce the standard notion of regret as</p><p>which represents the cumulative performance loss over T steps comparing the learned policies [&#969; 1 t ] T t=1 against the optimal policy &#969; &#8594; . In addition, we consider that a bounded u &#8594; (x, y) &#8594; [0, B] for all (x, y) to maintain a reasonable utillity regime. Also, it is assumed that we have accesses to the following policy improvement oracle, that is analogue to the one considered in <ref type="bibr">Xiong et al. (2024)</ref>. Definition 2 (Policy Improvement Oracle). For any model M = (S, A, H, P, d 0 , u) and a reference function &#969; ref , we can compute the optimal policy associated with the model [&#969; M,h ] H h=1 iteratively as in equation 4.</p><p>The overall algorithm, i.e., the theoretical version of online iterative M-GSHF, is also summarized in Algorithm 1. At each round t, with D = &#8656; t&#8593;1 i=1 D i as the aggregated dataset, it starts with performing a maximum likelihood estimation (MLE) of the reward function u &#8594; over a set U , whose elements are bounded in [0, B], as</p><p>and also an MLE of the transition kernel P &#8594; over a set P as Pt = arg max</p><p>where P &#969; (&#949; ) denotes the probability of trajectory &#949; under policy &#969; and transition kernel P. With the obtained model Mt = (&#251; t , Pt ), the Oracle defined in Definition 2 is called with the reference policy &#969; ref set as the initial policy &#969; 0 , whose output is adopted as the main policy &#969; 1 t . Then, we specify how to choose a theoretically sound exploration policy &#969; 2 t . The previous work of <ref type="bibr">Xiong et al. (2024)</ref> on single-turn RLHF has demonstrated the intuition that the exploration policy should be in charge of collecting information of the uncertain parts of the environment M, which is thus often selected to maximize one uncertainty measurement. In the multi-turn RLHF setup considered in this work, the following proposition serves as the cornerstone to find a suitable uncertainty measurement to decide the exploration policy. In particular, we can observe that the optimal policy is parameterized by the optimal Q-function. If a different set of Q-function is adopted for policy parameterization, we can bound its performance as follows.</p><p>Proposition 2 (Value Decomposition Lemma for KL-regularized MDP). If considering a set of Q-functions [ Qh ] H h=1 and a reference policy &#969; ref with the induced policy &#969; as &#969;h (a h |s h ) &#8658; &#969; ref,h (a h |s h ) &#8226; exp Qh (s h , a h )/&#982; , and the corresponding set of V -functions [ Vh ] H h=1 as Vh</p><p>for any comparator policy &#969;, it holds that</p><p>where the expectation E d0,&#969;,P &#8593; is with respect to the prompt and response (i.e., the trajectory) generated following d 0 , P &#8594; and &#969;.</p><p>Based on Proposition 2, the exploration policy &#969; 2 t is selected as</p><p>where U t and P t are two confidence sets defined as</p><p>with c 1 denoting an absolute constant here. Note that for the theoretical convenience, we have assumed U and P are finite here, which can be extended to the infinite case using standard discretization techniques. It can be observed that &#969; 2 t is selected to maximize a combination of uncertainty from estimations of both rewards and transitions. If considering known transitions (i.e., without the need to estimate P), the uncertainty from the estimation of transitions dimimishes, which leads to a similar uncertainty measurement adopted in <ref type="bibr">Xiong et al. (2024)</ref>.</p><p>The following theorem establishes a rigorous guarantee for the regret incurred.</p><p>Theorem 2. Assuming u &#8594; &#8594; U and P &#8594; &#8594; P, with probability at least 1 &#8593; &#966;, we have that</p><p>where &#8636; := 1/(2 + exp(&#8593;B) + exp(B)), c 2 is an absolute constant, d U is the Eluder coefficient defined in Definition 3 while d P and &#8637;(&#8226;) are from the generalized Eluder-type condition defined in Definition 4.</p><p>We note that the Eluder coefficient and the generalized Eluder-type condition are standard and welladopted conditions in the theoretical studies on RL <ref type="bibr">(Zhang, 2023;</ref><ref type="bibr">Zhong et al., 2022;</ref><ref type="bibr">Liu et al., 2023a;</ref><ref type="bibr">Xie et al., 2022;</ref><ref type="bibr">Agarwal et al., 2023)</ref> and also RLHF <ref type="bibr">(Zhan et al., 2023;</ref><ref type="bibr">Wang et al., 2023b;</ref><ref type="bibr">Ye et al., 2024)</ref>. Moreover, for a board class of RL problems (see <ref type="bibr">Zhang (2023)</ref>; <ref type="bibr">Liu et al. (2023a)</ref> for more details), the Eluder coefficient d U is small and the condition is satisfied with &#8637;(d P , T, c 2 log(|P|HT /&#966;)) &#8621; d P T log(|P|HT /&#966;), which implies that the regret of theoretical version of Algorithm 1 is sublinear in T , further evidencing its statistical efficiency.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>D.2 PROOF OF PROPOSITION 2</head><p>Proof of Proposition 2. For one policy &#969;, starting with V &#969; M,H+1 = 0, we recursively define its Vvalue and Q-value functions on one model M = (S, A, H, P, d 0 , u) and the reference policy &#969; ref as</p><p>In the following discussions, we exclusively focus on the model</p><p>In the above derivation, equation (a) is from the definitions of Q &#969; and V &#969; , and the relationship between Q and V . The equation (b) is because</p><p>where the second equation is from the relationship that</p><p>Furthermore, if h = H, we can obtain that</p><p>where the first inequality is from Proposition B.2 from <ref type="bibr">Liu et al. (2023a)</ref> and the second inequality uses Lemma 1. The result for &#251;t can be similarly established.</p><p>Then, following similar steps, for P t , we can obtain that with probability at least 1 &#8593; &#966;, there exists an absolute constant c such that for all t &#8594; [T ],</p><p>j&#8596;{1,2} h&#8596;[H] i&lt;t TV {d 0 , &#969; j i , [P &#8594; 1:h&#8593;1 , P t,h , P &#8594; h+1:H ]}, {d 0 , &#969; j i , P &#8594; 1:H } 2 &#8599; j&#8596;{1,2} h&#8596;[H] c &#8226; &#63727; i&lt;t log P &#8594; h (s j i,h+1 |s j i,h , a j i,h ) P t,h (s j i,h+1 |s j i,h , a j i,h ) + log(|P h |HT /&#966;) &#63738; = c &#8226; &#63729; &#63740; j&#8596;{1,2} i&lt;t log P &#8594;,&#969; j i (&#949; j i ) P The result for Pt can also be similarly established.</p><p>Proof of Theorem 2. In the following proofs, we omit the KL term in the decomposition to ease the presentation. Then, with probability at least 1 &#8593; &#966;, for all t &#8594; [T ], we can obtain that</p><p>&#969; 1 t ,P &#8593; [u &#8594; (sH , aH )] &#8593; E d 0 ,&#969; &#8593; ,P &#8593; [&#251;t(sH , aH )] &#8593; E d 0 ,&#969; 1 t ,P &#8593; [&#251;t(sH , aH )] + h&#8599;[H] E d 0 ,&#969; &#8593; ,P &#8593; Vt,h+1 (s h+1 ) &#8593; Pt,h Vt,h+1 (s h , a h ) &#8593; h&#8599;[H] E d 0 ,&#969; 1 t ,P &#8593; Vt,h+1 (s h+1 ) &#8593; Pt,h Vt,h+1 (s h , a h ) &#8596; E d 0 ,&#969; 2 t , P t [ ut(sH , aH )] &#8593; E d 0 ,&#969; 1 t , P t [ ut(sH , aH )] &#8593; E d 0 ,&#969; 2 t , P t [&#251;t(sH , aH )] &#8593; E d 0 ,&#969; 1 t , P t [&#251;t(sH , aH )] term (I) t + h&#8599;[H] E d 0 ,&#969; 2 t , P t Vt,h+1 (s h+1 ) &#8593; Pt,h Vt,h+1 (s h , a h ) + h&#8599;[H] E d 0 ,&#969; 1 t ,P &#8593; Pt,h Vt,h+1 (s h , a h ) &#8593; Vt,h+1 (s h+1 ) term (II) t , where the inequality is from the definition of &#969; 2 t and the fact that (u &#8594; , P &#8594; ) &#8594; U t &#8659; P t from Lemma 1. We define the following terms: term (A) t := E d 0 ,&#969; 2 t ,P &#8593; [ ut(sH , aH )] &#8593; E d 0 ,&#969; 1 t ,P &#8593; [ ut(sH , aH )] &#8593; E d 0 ,&#969; 2 t ,P &#8593; [u &#8594; (sH , aH )] &#8593; E d 0 ,&#969; 1 t ,P &#8593; [u &#8594; (sH , aH )] , term (B) t := E d 0 ,&#969; 2 t ,P &#8593; [u &#8594; (sH , aH )] &#8593; E d 0 ,&#969; 1 t ,P &#8593; [u &#8594; (sH , aH )] &#8593; E d 0 ,&#969; 2 t ,P &#8593; [&#251;t(sH , aH )] &#8593; E d 0 ,&#969; 1 t ,P &#8593; [&#251;t(sH , aH )] , term (C) t := j&#8599;{1,2} h&#8599;[H] E d 0 ,&#969; j t ,P &#8593; TV P t,h (&#8226;|s h , a h ), P &#8594; h (&#8226;|s h , a h ) , term (D) t := j&#8599;{1,2} h&#8599;[H] E d 0 ,&#969; j t ,P &#8593; TV Pt,h (&#8226;|s h , a h ), P &#8594; h (&#8226;|s h , a h ) . term (A) t + E d 0 ,&#969; 2 t ,P &#8593; [u &#8594; t (sH , aH )] &#8593; E d 0 ,&#969; 1 t ,P &#8593; [u &#8594; t (sH , aH )] &#8593; E d 0 ,&#969; 2 t ,P &#8593; [&#251;t(sH , aH )] &#8593; E d 0 ,&#969; 1 t ,P &#8593; [&#251;t(sH , aH )] term (B) t + 4B &#8226; j&#8599;{1,2} h&#8599;[H] E d 0 E &#969; j t ,P &#8593; TV P t,h (&#8226;|s h , a h ), P &#8594; h (&#8226;|s h , a h ) term (C) t . For term (II) t , we have that term (II) t = h&#8596;[H] E d0,&#969; 2 t , Pt Vt,h+1 (s h+1 ) &#8593; Pt,h Vt,h+1 (s h , a h ) + h&#8596;[H] E d0,&#969; 1 t ,P &#8593; Pt,h Vt,h+1 (s h , a h ) &#8593; Vt,h+1 (s h+1 ) = h&#8596;[H] E d0,&#969; 2 t ,P &#8593; Vt,h+1 (s h+1 ) &#8593; Pt,h Vt,h+1 (s h , a h ) + h&#8596;[H] E d0,&#969; 2 t , Pt Vt,h+1 (s h+1 ) &#8593; Pt,h Vt,h+1 (s h , a h ) &#8593; h&#8596;[H] E d0,&#969; 2 t ,P &#8593; Vt,h+1 (s h+1 ) &#8593; Pt,h Vt,h+1 (s h , a h ) + h&#8596;[H] E d0,&#969; 1 t ,P &#8593; Pt,h Vt,h+1 (s h , a h ) &#8593; Vt,h+1 (s h+1 ) &#8599; 2B &#8226; j&#8596;{1,2} h&#8596;[H] E d0,&#969; j t ,P &#8593; TV( Pt,h (&#8226;|s h , a h )), P &#8594; h (&#8226;|s h , a h ) + 2BH &#8226; TV({d 0 , &#969; 2 t , P t }, {d 0 , &#969; 2 t , P &#8594; }) &#8599; 2B &#8226; j&#8596;{1,2} h&#8596;[H] E d0,&#969; j t ,P &#8593; TV( Pt,h (&#8226;|s h , a h )), P &#8594; h (&#8226;|s h , a h ) &#63723;&#63734; &#63726; term (D) t + 2BH &#8226; j&#8596;{1,2} h&#8596;[H] E d0,&#969; j t ,P &#8593; TV( P t,h (&#8226;|s h , a h )), P &#8594; h (&#8226;|s h , a h ) &#63723;&#63734; &#63726; term (C) t . In the above derivations, we have repeatedly used similar relationships as follows: TV({d 0 , &#969; 2 t , P t }, {d 0 , &#969; 2 t , P &#8594; }) &#8599; h&#8596;[H] E d0,&#969; 2 t ,P &#8593; TV P t,h (&#8226;|s h , a h ), P &#8594; h (&#8226;|s h , a h ) , which can be derived as TV({d 0 , &#969; 2 t , P t }, {d 0 , &#969; 2 t , P &#8594; }) &#8599; h&#8596;[H] TV {d 0 , &#969; 2 t , P &#8594; 1:h&#8593;1 , P t,h:H }, {d 0 , &#969; 2 t , P &#8594; 1:h , P t,h+1:H } = h&#8596;[H] E d0,&#969; 2 t ,P &#8593; TV P t,h (&#8226;|s h , a h ), P &#8594; h (&#8226;|s h , a h )} . Then, we can obtain that t&#8596;[T ] J(&#969; &#8594; ) &#8593; J(&#969; 1 t ) &#8599; t&#8596;[T ] term (A) t + t&#8596;[T ] term (B) t + (4B + 2BH) t&#8596;[T ] term (C) t + 2B t&#8596;[T ] term (D) t . Then, we control the sum of each individual term in the following. First, for term (A) t , with probability at least 1 &#8593; &#966;, we have that t&#8599;[T ] term (A) t = t&#8599;[T ] E d 0 ,&#969; 2 t ,P &#8593; [ ut(sH , aH )] &#8593; E d 0 ,&#969; 1 t ,P &#8593; [ ut(sH , aH )] &#8593; E d 0 ,&#969; 2 t ,P &#8593; [u &#8594; (sH , aH )] &#8593; E d 0 ,&#969; 1 t ,P &#8593; [u &#8594; (sH , aH )] &#8596; t&#8599;[T ] ut(s 2 t,H , a 2 t,H ) &#8593; ut(s 1 t,H , a 1 t,H ) &#8593; u &#8594; (s 2 t,H , a 2 t,H ) &#8593; u &#8594; (s 1 t,H , a 1 t,H ) + O(B &#63734; T log(1/&#8637;)) &#8596; &#63726; &#63737; &#63737; &#63728; dU T t=2 &#63739; 1 + t&#8596;1 i=1 ut(s 2 i,H , a 2 i,H ) &#8593; ut(s 1 i,H , a 1 i,H ) &#8593; u &#8594; (s 2 i,H , a 2 i,H ) &#8593; u &#8594; (s 1 i,H , a 1 i,H ) 2 &#63727; + O(B &#63734; T log(1/&#8637;)) &#8596; &#63726; &#63737; &#63737; &#63728; dU T t=2 &#63739; 1 + &#966; &#8596;2 t&#8596;1 i=1 &#982; ut(s 2 i,H , a 2 i,H ) &#8593; ut(s 1 i,H , a 1 i,H ) &#8593; &#982; u &#8594; (s 2 i,H , a 2 i,H ) &#8593; u &#8594; (s 1 i,H , a 1 i,H ) 2 &#63727; + O(B &#63734; T log(1/&#8637;)) &#8621; &#966; &#8596;1 B &#63734; dU T log(|U |T /&#8637;), where the first inequality is from the Hoeffding inequality, the second inequality uses the Eluder coefficient d U := EC(1, U &#8593; U, T ) from Definition 3, the third inequality leverages the mean value theorem with &#8636; := 1/(2 + exp(&#8593;B) + exp(B)) representing the minimum derivative of &#977;(&#8226;) in the regime of [0, B], and the last inequality incorporates Lemma 2. A similar result can be obtained for term (B) t . For term (C) t , we have that t&#8596;[T ] term (C) t = j&#8596;{1,2} t&#8596;[T ] h&#8596;[H] E d0,&#969; j t ,P &#8593; TV P t,h (&#8226;|s h , a h ), P &#8594; h (&#8226;|s h , a h ) = j&#8596;{1,2} t&#8596;[T ] h&#8596;[H] TV {d 0 , &#969; j t , [P &#8594; 1:h&#8593;1 , P t,h , P &#8594; h+1:H ]}, {d 0 , &#969; j t , P &#8594; 1:H } &#8599; 2H &#8226; &#8637;(d P , T, c 2 log(|P|HT /&#966;)), where the last step is from the generalized Eluder-type condition in Definition 4 and Lemma 2. A similar result can be obtained for term (D) t . Finally, we obtain that Reg(T ) &#8621;&#8636; &#8593;1 B d U T log(|U|T /&#966;) + B 2 H&#8637;(d P , T, c 2 log(|P|HT /&#966;)</p></div><note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="1" xml:id="foot_0"><p>When there is no ambiguity, the abbreviation s h+1 &#8594; P &#8594; h (&#8226;|s h , a h ) is also adopted.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="2" xml:id="foot_1"><p>We use the pre-trained version because the chat template of its instruct model from huggingface is not consistent with their own codebase.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="4" xml:id="foot_2"><p>CONCLUSION, LIMITATION, AND FUTURE RESEARCH DIRECTIONIn this paper, we demonstrate that preference learning, as an alternative to supervised fine-tuning, further enhances the performance of tool-integrated reasoning LLMs after SFT. We introduce an online iterative multi-turn direct preference optimization algorithm, validated through extensive experiments across multiple base models. Results show significant improvements in pass@1 over the SFT policy, particularly on benchmarks like GSM8K and MATH. Ablation studies highlight the importance of balancing per-iteration improvement with exploration, which is achieved by moderate levels of KL regularization and strategic exploration choices.Several avenues for improvement remain unexplored. Our current approach only uses final result checks as preference signals, limiting the comparison between trajectories with correct or incorrect answers. One may use step-wise reward signal<ref type="bibr">(Lightman et al., 2023)</ref> in the data ranking stage. Meanwhile, the fine-grained reward signals could enable the use of advanced exploration strategies like west-of-n sampling<ref type="bibr">(Pace et al., 2024)</ref>, or MCTS(Xie et al., 2024b)  in our heuristic exploration implementation. Finally, while the direct preference learning algorithms show promising gains for the mathematical reasoning tasks with code interpreter, it is not directly applicable to the general agent learning with more complex and stochastic external environments or against dynamic opponents. In particular, it requires to construct a value network for involving an adaptive margin in the optimization target and take the randomness of the external environment into consideration. We leave the study of this more involved algorithm to the future work.</p></note>
		</body>
		</text>
</TEI>
