Exploratory Preference Optimization: Harnessing Implicit Q*-Approximation for Sample-Efficient RLHF
Tengyang Xie, Dylan J. Foster, Akshay Krishnamurthy, Corby Rosset, Ahmed Awadallah, Alexander Rakhlin
Introduction
Reinforcement learning from human feedback (RLHF) is a central tool to align language models to human values and elicit useful behavior (Christiano et al., 2017; Bai et al., 2022; Ouyang et al., 2022). Using human-labeled preference data, RLHF achieves enhanced capabilities using a modest amount of data compared to unsupervised pre-training (on the order of tens of millions versus trillions of tokens) by treating the language model as a “policy” and optimizing it with reinforcement learning techniques.
Even though RLHF is typically only applied with preference data from humans or other language models, one might hope that it has potential to produce super-human capabilities because recognizing novel behavior and insights is typically easier than generating novel behavior. Indeed, it is often much easier to verify correctness of a given proof or program than it is to produce one from scratch. By repeatedly generating new proposals and labeling them with human feedback, a language model could gradually push beyond the boundary of human capabilities. Unfortunately, even with the great disparity in difficulty between generation and verification, a major barrier to achieving enhanced capabilities via RLHF is the volume of human feedback, i.e., sample complexity, required by existing methods. Thus, a promising research direction is to develop sample-efficient methods for RLHF.
A natural way to address the sample efficiency problem for RLHF is to augment algorithms with online exploration. Online exploration exploits interactive access to human or AI feedback by deliberately encouraging the model to produce diverse, novel responses. RLHF algorithms that exploit online feedback have received limited investigation, and in spite of encouraging initial results, existing approaches either do not update the language model (Dwaracherla et al., 2024), or engage in purely passive exploration (Guo et al., 2024; Gao et al., 2024), with no mechanism to encourage novelty or diversity. Passive exploration is intuitively insufficient, as we are unlikely to generate novel and correct proofs by chance; we make this precise in Proposition 2.1. Thus, the full potential of online exploration as a new paradigm for language model training has yet to be realized.
The central challenge in equipping language models with deliberate exploration is to efficiently navigate the vast, combinatorially large space of token sequences to find responses for which feedback will be maximally informative. The contemporary theory of reinforcement learning offers—at a conceptual level—solutions to this problem, providing algorithm design principles for exploration that can optimally take advantage of problem structure and achieve sample efficiency to the best extent one can hope for (Jiang et al., 2017; Agarwal et al., 2019; Foster and Rakhlin, 2023). However, the most powerful approaches in this space are computationally intractable in the general reinforcement learning setting (Jiang et al., 2017; Jin et al., 2021; Foster et al., 2021), and prior attempts to adapt them to RLHF either make unrealistic modeling assumptions (i.e., do not allow for general function approximation) (Xu et al., 2020; Novoseller et al., 2020; Pacchiano et al., 2021; Wu and Sun, 2023; Zhan et al., 2023b; Du et al., 2024; Das et al., 2024), or are computationally inefficient and not feasible to faithfully implement (Chen et al., 2022; Wang et al., 2023; Ye et al., 2024). Can we, perhaps by specializing to language modeling, develop practical, provable, and empirically efficient online exploration methods for RLHF?
We propose a new algorithm for online exploration in RLHF, Exploratory Preference Optimization (XPO), which is simple and practical—a one-line change to (online) Direct Preference Optimization (DPO; Rafailov et al. (2023); Guo et al. (2024))—yet enjoys the strongest known provable guarantees and promising empirical performance. XPO augments the DPO objective with a novel and principled exploration bonus, empowering the algorithm to explore outside the support of the initial model. We show that XPO is provably sample-efficient, and converges to a near-optimal language model policy under natural exploration conditions (Jin et al., 2021; Xie et al., 2023; Zhong et al., 2022). Critically, and in contrast to prior work, our theory holds irrespective of whether the initial model is sufficiently exploratory on its own. To summarize:
XPO offers the first practical and provably sample-efficient online exploration algorithm for RLHF with general function approximation.
Our design and analysis of XPO uses previously disparate techniques from language modeling and theoretical reinforcement learning, combining them in a serendipitous fashion through the perspective of KL-regularized Markov decision processes (Neu et al., 2017).
First, generalizing Rafailov et al. (2024), we observe that DPO can be viewed as implicitly performing Bellman error minimization (Xie and Jiang, 2020) to approximate the optimal value function in a KL-regularized MDP. We use this to provide a novel KL-regularized regret decomposition.
Then, we show that global optimism (Jiang et al., 2017; Jin et al., 2021; Xie et al., 2023), a powerful RL exploration technique that has classically been viewed as computationally intractable (Dann et al., 2018; Kane et al., 2022; Golowich et al., 2024), can be implemented in any KL-regularized MDP with deterministic transitions (generalizing language modeling) by adding a surprisingly simple exploration bonus to the DPO objective. This yields the XPO objective.
We expect our analysis techniques and perspective to be useful more broadly. In particular, the guarantees for XPO hold not just for language models, but for any reinforcement learning problem with a stochastic starting state and (potentially unknown) deterministic transition dynamics (“Deterministic Contextual MDP”).
In Section 3.4, we perform a proof-of-concept experiment to validate our theory, and find that XPO can match the performance of DPO variants (Xu et al., 2023; Tran et al., 2024; Dong et al., 2024) based on passive or heuristic exploration using significantly less preference data. These initial findings suggest that augmenting language models with online exploration may indeed lead to benefits over passive exploration.
Two concurrent and independent works posted to arXiv just before this preprint, Cen et al. (2024); Zhang et al. (2024), propose algorithms that equip DPO with exploration bonuses similar to XPO. On the theoretical side, both works are restricted to the contextual bandit formulation of RLHF, and do not consider the general reinforcement learning framework in this work or make the connection to -approximation and KL-regularized MDPs. Compared to our results, which give provable sample complexity guarantees with general function approximation, Zhang et al. (2024) do not provide sample complexity guarantees, while Cen et al. (2024) provide guarantees only for linear contextual bandits. In addition, and importantly, the sample complexity guarantees in Cen et al. (2024) have exponential dependence on the KL regularization parameter, which our results avoid. Empirically, both works find benefits from exploration.
2 Paper Organization
Section 2 presents background on RLHF, online feedback, and the necessity of exploration. Section 3 presents our algorithm and main theoretical guarantees, including motivation behind the algorithm design and a proof sketch. Section 3.4 presents experimental results, and we conclude with discussion in Section 4. Proofs and additional results are deferred to the appendix.
Background
This section contains necessary background to present our main results. We begin by recalling the standard formulation of reinforcement learning from human feedback from offline data (Section 2.1), then introduce the online feedback model and highlight the need for systematic exploration (Section 2.2).
We study RLHF in a general reinforcement learning formulation which subsumes the token-level MDP formulation considered in prior work (Rafailov et al., 2024), but is somewhat broader.
In the context of language modeling, the main object of interest is the token-level MDP (Rafailov et al., 2024). Here, represents a prompt, each action represents a token (with representing the vocabulary), and the state is the prompt and sequence of tokens so far. The language model is represented by a policy , which maps the current context to a distribution over the next token . The trajectory produced by this process can be interpreted as the language model’s response to the prompt ; we will occasionally use the terms “trajectory” and “response” synonymously in this context.
Our main results apply to any Deterministic Contextual MDP (DCMDP) for which the initial state is stochastic, but the subsequent transition dynamics are deterministic and potentially unknown. This formulation encompasses but strictly generalizes the token-level MDP.
Based on the preference dataset , the goal is to learn a policy with high reward. Following prior theoretical works on RLHF, we consider a KL-regularized reward objective (Xiong et al., 2023; Ye et al., 2024), defined for a regularization parameter , via
We aim to compute a policy such that
for some small . Such a guarantee means that near-optimally maximizes reward, yet stays relatively close to (as a function of ). The choice of , which is important for safety and reliability, is typically viewed as a domain specific hyperparameter (Tang et al., 2024). Our main focus in this paper is the small- regime, which allows to meaningfully deviate from and generate potentially novel responses. Notably, by taking sufficiently small, it is possible to translate suboptimality bounds for the regularized reward into bounds for the unregularized reward (e.g., Zhu et al., 2023; Zhan et al., 2023a).
We refer to this setting as offline RLHF because the algorithm relies only on the offline dataset for training, and does not perform any active data collection.
Initial approaches to offline RLHF (Christiano et al., 2017; Ouyang et al., 2022) proceed by first estimating a reward function from using the Bradley-Terry model, then optimizing an estimated version of the KL-regularized objective in Eq. 2 using policy optimization methods like PPO, i.e.,
The starting point for our work is an alternative approach introduced by Rafailov et al. (2023), Direct Preference Optimization (DPO). DPO is motivated by a closed-form solution for the policy that optimizes the KL-regularized objective in Eq. 2, and condenses the two-step process above into a single policy optimization objective, removing the need for reward function estimation. Concretely, DPO solvesWe adopt the convention that the value of the DPO objective is if does not satisfy .
for a user-specified policy class , where is the sigmoid function.
2 Online Feedback and Exploration in RLHF
DPO and other offline RLHF methods have achieved great success in language model alignment, but are fundamentally limited to behaviors that are well-supported by the initial model and preference data . RLHF with online feedback offers a promising approach to move beyond this limitation by collecting feedback from responses sampled from the model during training (Guo et al., 2024).
3 The Necessity of Deliberate Exploration
Existing approaches to online RLHF adapt offline techniques by applying them iteratively. As an example, Online DPO (Guo et al., 2024) proceeds as follows:The closely related Iterative DPO approach (Xu et al., 2023; Tran et al., 2024) proceeds in the same fashion, but samples a large batch of preference pairs from each policy instead of a single pair, and performs fewer updates.
Compute by solving the DPO objective in Eq. 4 with the current preference dataset .
Sample , then label as and update .
We refer to such an approach as passive exploration, as the responses are sampled directly from the policy without an explicit mechanism to encourage diversity. The following proposition shows that passive exploration is insufficient to discover novel behavior: Unless the initial policy has good coverage, Online DPO can fail to learn a near-optimal policy.
Fix , and consider the bandit setting (, , and ). There exists a reference policy such that for all , with constant probability, all of the policies produced by Online DPO satisfy
That is, the sample complexity required by Online DPO is exponential in , which is unacceptable in the small- regime; inspecting the proof, it is straightforward to see that the same conclusion holds for Iterative DPO and purely offline DPO. The idea behind Proposition 2.1 is simple: If places small probability mass on the optimal action, Online DPO may fail to ever explore this action until the number of iterations is exponentially large. This reflects the intuition that in the small- regime, more deliberate exploration is required to discover behaviors or capabilities not already covered by .
Various empirical works have suggested that offline DPO can under-perform relative to vanilla RLHF with PPO due to a lack of on-policy sampling (Xiong et al., 2023; Guo et al., 2024; Dong et al., 2024; Tang et al., 2024). Proposition 2.1 highlights a conceptually distinct phenomenon, where both of the aforementioned algorithms (as well as online variants of DPO) fail due to poor coverage from , in spite of on-policy sampling.
Exploratory Preference Optimization
We now present our main algorithm XPO, which addresses the limitations of existing alignment methods by augmenting DPO with active exploration. We first describe the algorithm and motivation (Section 3.1), then present theoretical guarantees (Section 3.2), and sketch the analysis (Section 3.3).
XPO (Exploratory Preference Optimization) is displayed in Algorithm 1. The algorithm takes as input a user-specified policy class and proceeds in almost the same fashion as Online DPO. For each step , given the current policy and an initial state , the algorithm begins by sampling a pair of trajectories and , which are labeled as based on the preference feedback and used to update the preference dataset via . The most important step is 7, which updates the policy to via the following optimistic variant of the DPO objective:
Here, is an optimism parameter; for , the algorithm nearly equivalent to Online DPO, except that we sample and instead of sampling at each iteration. As we will see now, for , the term
in Eq. 6 encourages the policy to behave optimistically, and produce diverse responses .
Optimism in the face of uncertainty is a widely used technique in reinforcement learning theory (Agarwal et al., 2019; Lattimore and Szepesvári, 2020; Foster and Rakhlin, 2023). In its most standard form, the optimism principle is usually stated as follows: One should explore by choosing their actions according to the most optimistic view of the world, given all of the data that has already been observed. The idea is that if we choose a decision according to this principle, one of two good things can happen: (i) the optimistic view is correct, and we receive large reward; or (ii) the optimistic view is incorrect, but we receive useful information that will help to better estimate the state of the world in subsequent iterations.
In other words, implements an accurate internal reward model. From this viewpoint:
The standard DPO term in Eq. 6 encourages the policy to build an accurate internal model for rewards under the Bradley-Terry model; this can be viewed as a form of implicit -approximation, since we are implicitly minimizing the Bellman errors in Eq. 8.
In light of Equation 9 it is natural to approximate , the regularized value function for , by . Using this approximation, the first term in Equation 6 biases the policy toward a large value function such that , implementing implicit (global) optimism in the face of uncertainty (up to an inconsequential difference in on-policy rewards). The fact that this suffices to drive exploration is quite subtle, and leverages non-trivial properties of the KL-regularized MDP, including the fact that Eq. 8 holds on a per-trajectory basis.
As remarked above, another difference between XPO and online/iterative DPO is that instead of sampling the preference pairs via , we sample and . This small change is important: it is possible to show that in general, sampling can lead to degenerate behavior in which the algorithm fails to adequately explore in the small- regime, even when itself has good coverage.
While we use in Algorithm 1, XPO is significantly more general, and leads to provable guarantees for any fixed sampling policy , as well as certain data-dependent sampling schemes (e.g., sampling ); different choices may have different tradeoffs and benefits in practice. A general version of XPO which leaves the sampling distribution for as a free parameter is given in Section C.1 (Algorithm 2).
XPO is highly practical, and can easily be incorporated into existing language modeling and RLHF pipelines as a drop-in replacement for Online DPO (a one-line change to existing code). The theoretical guarantees for the algorithm continue to hold under standard modifications such as (i) incorporating additional preference data from or another reference policy; and (ii) performing a smaller number of iterations, but collecting a larger batch of preference data from (as in Iterative DPO).
2 Theoretical Guarantees
To provide sample complexity guarantees for XPO, we make some standard statistical assumptions. The first assumption asserts that the policy class is powerful enough to represent the optimal KL-regularized policy.
The policy class satisfies .
Policy realizability is a minimal assumption for sample-efficient reinforcement learning (Agarwal et al., 2019; Lattimore and Szepesvári, 2020; Foster and Rakhlin, 2023); through Eq. 9, it is equivalent to a form of reward/value realizability. For language modeling, will typically correspond to a class of language models with fixed architecture but variable weights. Next, we make a regularity assumption on the policies in (Rosset et al., 2024).
For all and trajectories ,
Note that is measurable and controllable in practice; our guarantees scale polynomially with this parameter. For log-linear policies where , we expect .
The trajectory-level coverability coefficient is given by
Assumption 3.2 implies a trivial bound of C_{\mathsf{cov}}(\Pi)\lesssim{}\exp\big{(}\frac{V_{\mathsf{max}}}{\beta}\big{)}. Indeed, measures coverage with respect to the best possible distribution , while the bound implied by Assumption 3.2 takes , so we expect when does not provide adequate coverage on its own (e.g., the example in Proposition 2.1). This is precisely the setting where we expect deliberate exploration to be helpful. We also note that there is a trivial bound , but because coverability depends on the structure of the (restricted) class , the value can be significantly smaller in general (e.g., if policies are highly correlated or stochastic).
The main sample complexity guarantee for XPO is as follows.
Let us discuss some key features of this result.
Theorem 3.1 shows that XPO converges to a near-optimal policy with sample complexity polynomial in the coverability coefficient ; in particular, to learn an -optimal policy episodes are required.We state the result for finite classes () to simplify presentation, following the standard in RL theory (Agarwal et al., 2019; Foster and Rakhlin, 2023); the result readily extends to infinite classes through standard arguments. By scaling with , Theorem 3.1 can be viewed as a strict improvement over offline RLHF (Zhu et al., 2023; Zhan et al., 2023a), as well as prior works on online RLHF that rely on passive exploration (Xiong et al., 2023; Gao et al., 2024; Chang et al., 2024). In particular, these works scale with coverage parameters for , the simplest of which take the form . Under Assumption 3.2, we have that which, as discussed above, upper bounds but can be much larger when has poor coverage. The dependence on in Theorem 3.1 reflects the fact that XPO can explore responses not covered by . Many works consider more general notions of coverage that account for reward function structure, in the same vein as SEC, as well as single-policy variants; both can be problematic for similar reasons.
In Appendix C, we give a generalization of Theorem 3.1 (Theorem 3.1′) which scales with a more comprehensive exploration parameter, the Sequential Extrapolation Coefficient (SEC), matching (for DCMDPs) the most general results in prior work on exploration in RLHF, but with a significantly simpler algorithm (Chen et al., 2022; Wang et al., 2023; Ye et al., 2024). The SEC also leads to polynomial sample complexity for tabular and linear MDPs, a common setting considered in prior work (Xu et al., 2020; Novoseller et al., 2020; Pacchiano et al., 2021; Wu and Sun, 2023; Zhan et al., 2023b; Das et al., 2024). See Appendix A for a detailed comparison. We emphasize that Theorem 3.1 applies to any DCMDP (including but not limited to the token-level MDP), even if the dynamics are unknown; as such, the result meaningfully extends beyond the contextual bandit formulation of RLHF found in many prior works (Zhu et al., 2023; Xiong et al., 2023; Das et al., 2024; Ye et al., 2024).
By avoiding explicit dependence on , XPO provably improves upon Online DPO when is small; per Proposition 2.1, the latter must pay even when . This improvement stems from the fact that KL-regularization does not automatically lead to exploration or grant meaningful control of coverability in the small- regime.
Most prior approaches to RL with general function approximation that incorporate global forms of optimism similar to Eq. 7 (Jiang et al., 2017; Sun et al., 2019; Du et al., 2021; Jin et al., 2021; Xie et al., 2023; Liu et al., 2024) are known to be computationally intractable to implement in general (Dann et al., 2018), and involve solving non-convex, non-differentiable constrained optimization problems. Thus, it is natural to ask why our result is not too good to be true. The answer is that even though the objective in Eq. 6 is simple, it is still non-convex in general, even if one employs log-linear policies of the form
Separately, we mention in passing that we believe it should be possible to derive tighter sample complexity bounds for large , in the vein of Tiapkin et al. (2023a).
Our results are limited to MDPs with deterministic dynamics and stochastic start state (DCMDPs). We believe that without further modifications, the DPO objective is not suitable for stochastic dynamics, as Eq. 9 no longer holds on a per-trajectory basis.
A related point concerns trajectory coverability. In the standard (as opposed to preference-based) RL setting, it is possible to achieve guarantees that scale with state-action coverability (Xie et al., 2023), defined via:
3 Proof Sketch for \crtcrefthm:main
Our starting point for the proof of Theorem 3.1 is the following regret decomposition, which is proven as a consequence of the implicit -approximation result in Eq. 9.
For any pair of policies and , it holds that
This result decomposes the error of any policy into two pairs of terms: The first pair in Eq. 13 measures the extent to which the policy’s internal reward model overestimates the optimal value, and directly informs the notion of optimism in XPO, while the second pair in Eq. 14 measures the reward model’s predictive accuracy. Critically, as a consequence of the fact that Eq. 9 holds uniformly for all trajectories, the regret decomposition measures error under (i) the policy itself (on-policy error), and (ii) an arbitrary reference policy , which we will instantiate as the historical data distribution.
Let denote the policy that, given , samples for and samples , with the convention that is arbitrary. Observe that . For each step , applying Lemma 3.1 with and gives
The reward estimation error term in Eq. 15 samples and (on-policy). To relate this to the purely off-policy objective in 7 of XPO, we use a potential argument based on coverability (Xie et al., 2023) which, for any , allows us to bound the above expression by
The XPO objective in 7 minimizes an empirical analogue of this quantity (up to a standard translation between log-loss and square loss under the Bradley-Terry model), so a concentration argument (Lemma D.5) allows us to conclude that the iterates of XPO satisfy with high probability. Plugging this bound into Eq. 16 yields
4 Empirical Validation
To close this section, we provide a preliminary empirical evaluation of XPO in real-world RLHF experiments. To implement XPO, we use the iterative DPO (Xu et al., 2023; Tran et al., 2024; Dong et al., 2024) pipeline from Dong et al. (2024) with 3 total iterations (that is, we set , but draw a large batch of pairs from ), and augment the DPO objective with the optimism term in XPO. We use the same base model (which we refer to as Llama-3-8B-Flow-SFT),https://huggingface.co/RLHFlow/LLaMA3-SFT. prompt sets for each iteration,https://huggingface.co/datasets/RLHFlow/iterative-prompt-v1-iter1-20K, https://huggingface.co/datasets/RLHFlow/iterative-prompt-v1-iter2-20K, https://huggingface.co/datasets/RLHFlow/iterative-prompt-v1-iter3-20K. and preference model (to generate preference feedback),https://huggingface.co/RLHFlow/pair-preference-model-LLaMA3-8B. as Dong et al. (2024), which makes our results generally comparable to theirs. Over all three iterations, we fix to be the base model, Llama-3-8B-Flow-SFT.
In Table 1, we compare XPO with the following baselines: 1) iterative DPO with the same setup (i.e., XPO with ), 2) Llama-3-8B-Flow-Final, the final model from Dong et al. (2024), and 3) the industry-level instruction-tuned model Llama-3-8B-it,https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct on various academic and chat benchmarks (Zhong et al., 2023; Nie et al., 2020; Hendrycks et al., 2021; Rein et al., 2023; Cobbe et al., 2021; Dubois et al., 2024; Li et al., 2024; Clark et al., 2018; Lin et al., 2022; Zellers et al., 2019; Sakaguchi et al., 2021). We compute all baseline numbers ourselves with the same configuration for a fair comparison. A key distinction between our experimental setup and that of Dong et al. (2024) is that we construct preference pairs from only two responses, whereas Dong et al. (2024) use best/worst-over-8-responses for preference pair construction as a heuristic exploration strategy. In other words, the final models we obtain (XPO-iter3, and a baseline, DPO-iter3 in Table 1) use only the number of generated responses compared the final model (Llama-3-8B-Flow-Final)https://huggingface.co/RLHFlow/LLaMA3-iterative-DPO-final from Dong et al. (2024).
We find that the model obtained by XPO improves over the non-exploratory baseline (DPO-iter) on the chat benchmarks (which offer roughly 90% agreement and/or Spearman correlation to Chatbot Arena (Chiang et al., 2024)), and attains performance comparable to the industry-level (Llama-3-8B-it) or 4data-usage (Llama-3-8B-Flow-Final) models. At the same time, XPO also improves over the non-exploratory baseline on most of the academic benchmarks, again achieving comparable performance with the industry-level and 4data-usage models, and does not introduce significant performance regression in any benchmark. In contrast, we observe that the iterative DPO baseline (without exploration) causes obvious regression in the math (GSM8K) benchmark. However, we caution that conducting separate training runs with different random seeds can yield results with relatively high variance (e.g., the difference in win rates can be up to ) for both chat benchmarks; due to resource limitations, we defer a more comprehensive evaluation to future work. See Appendix F for additional results.
Discussion
Our work provides the first practical and provably sample-efficient online exploration algorithm for RLHF with general function approximation, a step toward fully realizing the potential of online exploration for aligning language models. Our results also show that viewing DPO as a form of implicit -approximation can directly inform new algorithmic interventions (e.g., implicit optimism), and offer an example of fruitful interplay between language modeling and theoretical reinforcement learning. Building on this viewpoint, an exciting direction for future work is to import the broader set of tools from the literature on reinforcement learning theory (e.g., more powerful exploration principles (Foster et al., 2021)) and harness them for language modeling and alignment; in this context, we expect our analysis techniques based on the KL-regularized MDP to find broader use.
From a reinforcement learning perspective, interesting technical directions for future work include (i) providing instance-dependent sample complexity bounds for XPO; and (ii) supporting RL settings beyond deterministic contextual MDPs. On the practical side, immediate followup directions include extending XPO to support general preference models (Munos et al., 2023; Swamy et al., 2024) or more general feedback modalities (Ethayarajh et al., 2024).
References
Appendix A Related Work
Theoretical analysis of algorithms for RLHF is becoming an active area of research. Much of this research focuses on purely offline RLHF (Zhu et al., 2023; Zhan et al., 2023a), which is complementary to our work. Many works also consider a so-called hybrid RLHF setting, where the algorithm has access to online feedback, but requires the initial policy to have good coverage (e.g., bounded concentrability or related quantities) (Xiong et al., 2023; Gao et al., 2024; Chang et al., 2024).To our knowledge, all prior works in this space require uniform notions of concentrability as opposed to single-policy concentrability. Gao et al. (2024) state guarantees in terms of single-policy concentrability under the assumption that certain regression errors can be bounded, but this cannot be achieved in general without further coverage or exploration-like conditions. These hybrid algorithms do not engage in systematic exploration (i.e., they explore passively), and hence cannot provide meaningful guarantees if does not adequately cover the optimal policy (e.g., for the setting in Proposition 2.1).
For online RLHF, the most relevant related work can be summarized as follows:
Most prior work (Xu et al., 2020; Novoseller et al., 2020; Pacchiano et al., 2021; Wu and Sun, 2023; Zhan et al., 2023b; Du et al., 2024; Das et al., 2024) gives algorithms and sample complexity guarantees for the special case of tabular or linear MDPs; these algorithms use exploration bonuses that are tailored to linear models, and are not suitable for the general function approximation setting we consider (e.g., for LLMs). Nonetheless, we obtain polynomial sample complexity guarantees for tabular and linear MDPs (Examples D.1 and D.2), though our results are restricted to deterministic dynamics (we believe that moving beyond the DPO objective is likely required to handle stochastic dynamics).
More relevant to our work is Ye et al. (2024), who give algorithms and sample complexity guarantees for online RLHF with general function approximation for the special case of contextual bandits (). For contextual bandits, their sample complexity guarantees scale with a complexity measure, the eluder coefficient, which is equivalent to the Sequential Extrapolation Coefficient in our most general result, Theorem 3.1′. However, their exploration algorithm requires solving a rather complicated optimization problem, and it is unclear whether it is possible to implement it faithfully for language models (in particular, their experiments use an alternative, heuristic approach to exploration which is only loosely inspired by the theory).
Lastly, Chen et al. (2022); Wang et al. (2023) give guarantees for RLHF with general function approximation based on eluder dimension-like complexity measures which are incomparable to, but in some cases more general than Theorem 3.1′. However, these works require model-based function approximation (as opposed to the model-free setup we consider), and do not lead to efficient or practical algorithms when specialized to language modeling.
A difference worth highlighting between our work and some (but not all) of the works above (Zhu et al., 2023; Xiong et al., 2023; Das et al., 2024; Ye et al., 2024) is that we model RLHF as a general reinforcement learning problem as opposed to a contextual bandit problem. The problem of autoregressive sequence prediction can equivalently be formulated as RL in the token-level MDP, or as a contextual bandit problem (RL with horizon ) in which the “action space” consists of all possible token sequences. However, because our work supports general deterministic contextual MDPs (DCMDPs) with unknown dynamics and not just the token-level MDP, it is strictly more general than the contextual bandit formulation.
Recent work of Rafailov et al. (2024) shows that DPO, when applied to the token-level MDP can be viewed as estimating the KL-regularized value function ; their work does not consider sample complexity or online exploration. Our results extend their observation to any deterministic contextual MDP and—more importantly—show that it is possible to harness this perspective to provide provable end-to-end sample complexity guarantees.
Online exploration in RLHF has received limited exploration so far, with notable examples including Online DPO (Guo et al., 2024) and Iterative DPO (Xu et al., 2023; Tran et al., 2024; Pang et al., 2024; Mitra et al., 2024; Dong et al., 2024). As discussed in Section 2, these methods engage in purely passive exploration, meaning that sample from the current model without an explicit mechanism to encourage diverse, exploratory responses.
Dwaracherla et al. (2024) perform a dedicated empirical evaluation of active exploration for language models. However, this work does not actually train the language model, and thus cannot be viewed as a form of RLHF; instead the authors train a reward model iteratively, and use this in tandem with various active sampling schemes to accept or reject responses proposed by . Nevertheless, the positive results achieved by Dwaracherla et al. (2024) in this limited setting are suggestive of the potential power of online exploration in RLHF. Similarly, Ye et al. (2024) perform a limited evaluation of empirical exploration schemes inspired by theoretical RL, but only report results for reward modeling benchmarks, not language modeling.
Most closely related, Xiong et al. (2023); Dong et al. (2024) perform an extensive empirical evaluation of Iterative DPO variants, and find that Iterative DPO with passive exploration can already have significant benefits over offline DPO. These works also incorporate a “best/worst-over-” trick for preference pair construction, which can be viewed as a heuristic to promote exploration, but does not have provable guarantees. See Section 3.4 for further discussion.
Outside the context of language models, an active line of research provides structural complexity measures and algorithms that enable sample-efficient exploration in reinforcement learning in general settings (Russo and Van Roy, 2013; Jiang et al., 2017; Sun et al., 2019; Wang et al., 2020; Du et al., 2021; Jin et al., 2021; Foster et al., 2021; Xie et al., 2023; Foster et al., 2023; Liu et al., 2024). The techniques from this line of research that support general function approximation, while sample-efficient, are computationally intractable to implement in general (Dann et al., 2018), involving non-convex and non-differentiable constrained optimization problems. We use the unique structure of the KL-regularized MDP formulation and deterministic contextual MDP (DCMDP) to derive the exploration objective in XPO which—while still non-convex—is differentiable and directly amenable to a practical implementation with language models.
First introduced in Ziebart et al. (2008); Ziebart (2010), a number of recent works provide sample complexity guarantees for reinforcement learning in KL-regularized or entropy-regularized MDPs (Kozuno et al., 2022; Tiapkin et al., 2023b, a), mainly focusing on the special case of tabular (finite-state/action) MDPs. To the best of our knowledge, the optimistic objective in XPO is novel in this context.
Appendix B Technical Tools
Let be a sequence of real-valued random variables adapted to a filtration . If almost surely, then with probability at least ,
For any sequence of real-valued random variables adapted to a filtration , it holds that with probability at least , for all ,
Appendix C Proof of \crtcrefthm:main
This section is organized as follows. First, in Section C.2, we present a more general version of XPO, which makes use of an arbitrary, user-specified sampling policy for the second response . Then, in Section C.2, we state a more general version of Theorem 3.1 (Theorem 3.1′), and show how it implies Theorem 3.1. Examples are then given in Section D.3.
In the remainder of the section, we prove Theorem 3.1′. We first prove a number of intermediate results:
In Section D.4, we state preliminaries regarding the KL-regularized MDP, and use them to prove the implicit -approximation lemma (Lemma D.3).
In Section D.5, we prove the central regret decomposition lemma (Lemma 3.1).
In Section D.6, we prove a key concentration result used within Theorem 3.1′.
Finally, in Section D.7, we prove Theorem 3.1′, with proofs for supporting lemmas deferred to Section D.8.
Algorithm 2 presents a general version of XPO. The algorithm is identical to Algorithm 1, except that it makes use of an arbitrary, user-specified user-specified sampling policy for the second response .
In more detail, the algorithm takes as input a sampling strategy which, at step , computes a sampling policy via . The algorithm then samples the response pair via and . Algorithm 1 is a special case of this scheme in which for all .
A secondary difference from Algorithm 1 is that Algorithm 2 assumes access to a dataset consisting of responses sampled from , which are used to compute the optimistic term in 9. In Algorithm 1, because is static, we can simply re-use the responses for this task, setting . However, for general time-varying sampling scheme, it may be necessary to draw a fresh dataset of responses from to compute .
As a practical example, Algorithm 3—displayed below—instantiates the general scheme in Algorithm 2 by setting to sample from the historical data distribution at step . For this scheme, it suffices to set , re-using the responses sampled from .
C.2 General Version of \crtcrefthm:main
Our most general sample complexity guarantee for XPO (Algorithm 1 and Algorithm 2), Theorem 3.1′, is stated in terms of the following preference-based analogue of the Sequential Extrapolation Coefficient (SEC) from Xie et al. (2023) (also known as an eluder coefficient or decoupling coefficient (Zhong et al., 2022; Ye et al., 2024)). Recall that for a trajectory , we define
For a pair of policies and , we define as the joint policy that, given , samples and . We write as shorthand for this process.
For a policy class , sampling strategy , and entropy regularization parameter , we define the Sequential Extrapolation Coefficient via
where , and where we define , with the convention that is arbitrary.
Note that for Algorithm 1, which sets for all , we can simplify the definition above to
where .
Our general sample complexity guarantee is as follows.
As a special case, if we set for an absolute constant , then Algorithm 1 ensures that with probability at least ,
The following result shows that the SEC is always bounded by the coverability coefficient in Definition 3.1.
Theorem 3.1 follows immediately by combining Theorem 3.1′ with Lemma D.1.
D.3 Additional Examples for \crtcrefthm:main_general
for a given value function class . Note that for such a class, we can take , and that implies that .
The following lemma bounds the SEC for log-linear policy classes in terms of a preference-based analogue of the value function SEC in Xie et al. (2023).
For any value function class , we have that , where
where , , and (with the convention that is arbitrary), and where is the KL-regularized Bellman operator defined in Section D.4.
Proof of Lemma D.2. This is an immediate corollary of Lemma D.4. ∎
We first apply this bound to give a polynomial bound on the SEC in tabular DCMDPs where and are finite.
Suppose that sets for all for some fixed policy . When consists of all functions over tabular state and action spaces with , we have and . It follows that XPO (Algorithm 1) achieves
Example D.1 is a corollary of the following more general result.
In a Linear MDP (Jin et al., 2020), we have
for and , then , satisfying Assumption 3.1. For this setting, when sets for all for some fixed policy , we have and . It follows that XPO (Algorithm 1) achieves
In this section, we give some basic background on value functions and dynamic programming for the KL-regularized MDP (Ziebart et al., 2008; Ziebart, 2010), then use these properties to prove Lemmas D.3 and D.4, which show that the optimal KL-regularized policy implicitly performs models rewards and performs -approximation.
and that the policy that obtains the maximum above is
From here, beginning with , , and for , for each , we can inductively define for each :
The following lemma, generalizing Rafailov et al. (2024), shows that the optimal KL-regularized policy can be viewed as implicitly modeling rewards.
For any DCMDP, it holds that for all admissibleWe use “admissible” to a refer to a trajectory generated by executing an arbitrary policy in the MDP. trajectories ,
where is the KL-regularized value function defined in Eq. 26.
Proof of Lemma D.3. Let , and recall that for any DCMDP, all state transitions except for are deterministic. Then we have
where the second equality uses that for any admissible trajectory in a deterministic MDP, and the third equality uses the explicit form for in terms of and given in Equation 25. Rearranging yields the result. ∎
We can also prove the following, more general version of Lemma D.4.
Proof of Lemma D.4. Let . Then we have
where the first equality uses the definition of , the second equality uses that for any admissible trajectory in a deterministic MDP, and the third equality uses that . Rearranging yields the result. ∎
D.5 Regret Decomposition
In this section we prove the central regret decomposition for XPO, restated below.
Proof of Lemma 3.1. It follows immediately from the definition of the KL-regularized reward that
However, since for all admissible trajectories by Lemma D.3, we have that
for all policies , as the initial state does not depend on the policy under consideration. The result now follows by rearranging
D.6 Concentration Lemmas
Recall that we define . For a given policy , define
The following lemma is our central concentration guarantee for Algorithm 1.
Suppose that Assumptions 3.2 and 3.1 hold. Then Algorithm 1 guarantees that with probability at least , for all steps ,
for .
Proof of Lemma D.5. Let be fixed.
and . Then we can equivalently write
For a given policy , recall that we define
Then, in light of Lemma D.3, under the Bradley-Terry model (Eq. 1), we have that for all ,
For any fixed , with probability at least , all satisfy
Rearranging Lemma D.6, with probability at least , all satisfy
Hence, as long as (Assumption 3.1), the definition of in Algorithm 2 implies that
We next appeal to another basic concentration result.
For any fixed , with probability at least , all satisfy
Combining Lemma D.7 with Eq. 32, we conclude that with probability at least ,
To conclude, we further simplify the expression via
where the last inequality uses that for , .
Finally, using Lemma D.3, we have almost surely, while by Assumption 3.2. We appeal to the following lemma.
If and for , , then
This proves the result after taking a union bound over all steps .
Next, using Eq. 30 and a somewhat standard argument from van de Geer (2000); Zhang (2006), we calculate that
Since and for , we conclude that
Proof of Lemma D.7. Let denote the trajectories in . Let , and let
which implies that . From here, the result follows immediately by applying Lemma B.1 with the sequence and taking a union bound over . ∎
Proof of Lemma D.8. We consider three cases. First, if , then
for some . In this regime, we have . Next, if , we can directly bound
where the last line holds whenever . We conclude in this case that
Finally, we consider the case where . In this case, we can similarly lower bound
as long as . From here, proceeding in the same fashion as the second case yields the result. ∎
D.7 Proof of \crtcrefthm:main_general
Proof of Theorem 3.1′. Before diving into the proof, we re-state two central technical lemmas. The first lemma, generalizing Rafailov et al. (2024), shows that the optimal KL-regularized policy can be viewed as implicitly modeling rewards.
This lemma allows us to view the DPO objective as a form of implicit -approximation. Building on this lemma, we prove the following regret decomposition.
This result shows that the (regularized) regret of any policy can be decomposed into two terms. The term in Eq. 14 measures the extent to which (implicitly) models the reward; by Lemma D.3, this term is zero when . Meanwhile, the term in Eq. 13 measures the extent to which the policy over-estimates the internal reward; we will control this term using optimism. Importantly, the regret decomposition in Lemma 3.1 holds for an arbitrary roll-in policy . This will facilitate minimizing the terms in the regret decomposition in a data-driven fashion. Before proceeding, we remark that Lemma D.3 and Lemma 3.1 together imply that
For each step , we apply Lemma 3.1 with and , which gives
Next, recall that we define Consider a fixed step , and define
Then, using the AM-GM inequality, for any we can bound
Note that by definition, we have that . Hence, by plugging Eq. 36 into Eq. 35 and summing, we conclude that
above. Let . By Lemma D.3, we have that for any pair of admissible trajectories that share the initial state , , so we can rewrite Eq. 38 as
We now recall the central concentration lemma for XPO (Lemma D.5).
It follows that if we set , then with probability at least , for all ,
Plugging this bound back into Eq. 37, we have that
where the last line uses that . It follows that by choosing
Finally, we note that .
D.8 Proofs for SEC Bounds
be the distribution that achieves the value of the coverability coefficient in Definition 3.1. Let us abbreviate . For a trajectory , let
Letting , we can further bound this by
so that .
where the last inequality is by Cauchy-Schwarz. We conclude that
To proceed, we restrict our attention to the case where for all for some fixed . We observe that in this case, for all ,
since and are conditionally independent given , and since if do not share the same . It follows that
Finally, by Lemma 4 of Xie et al. (2023), we have that for all , , which yields . This proves the result.
Proof for Example D.2. We claim for any pair of trajectories and function , we can write
With this definition, we observe that in the case where for all , we can write the value of for a sequence of policies as
Appendix E Additional Proofs
This section contains proofs for supporting results found throughout Section 2 and Section 3.
Proof of Proposition 2.1. Consider the bandit setting where , , and . Let be given. We consider the reward function given by and . We choose the reference model to set and for a parameter , where is an absolute constant whose value will be chosen at the end of the proof. We choose , which we note satisfies Assumption 3.1 and Assumption 3.2 with .
Specialized to the bandit setting, Online DPO takes the following simplified form:
Sample pair of actions .
Label the actions as according the Bradley-Terry model:
and update .
Compute via
Our construction uses the fact that depending on the preference dataset , the minimizer in Eq. 45 may not be uniquely defined. Let denote the event that at iteration , . We appeal to a technical lemma.
Suppose we initialize with . As long as , , the following properties hold:
Whenever hold, we can choose the policy to satisfy , which has
By Lemma E.1 and the union bound, we have that
as long as . It follows that whenever this occurs, for all .
Note that since online DPO selects for all in our counterexample above, this also immediately implies a lower bound for offline DPO (interpreting as the policy returned by offline DPO).
Proof of Lemma E.1. We prove this claim inductively. Let be fixed, and suppose the claim holds for . If we assume hold, then we have inductively. In this case,
Now, for the second part of the claim, suppose that hold. Then for all , , which implies that
for all such that . It follows that is a valid minimizer for Eq. 45.
Finally, we compute that as long as and
Appendix F Experiments: Additional Results and Details
Table 2 displays the performance of XPO and the comparator models described in Section 3.4 on additional reasoning tasks. We observe that the XPO model outperforms Llama-3-8B-it, and still comparable to Llama-3-8B-Flow-Final, which uses 4x more data than XPO. The average over all academic benchmarks is 59.94 for Llama-3-8B-Flow-Final vs. 59.61 for XPO-iter3, in addition to the performance gain from XPO-iter3 in the chat benchmarks (Table 1).
The experiments were conducted on 8 x Nvidia H100 GPUs. In our implementation, we mainly follow the general version of XPO (Algorithm 2), and we pick and . In each iteration, we fix the base model (Llama-3-8B-Flow-SFT) as , set , use a global batch size of , and use a learning rate of with cosine scheduling. The parameter follows the schedule for the three iterations. We clip the term for both positive and negative trajectories to $$, but only for the exploration term, in order to enhance stability. This is motivated by Assumption 3.2. The number of training epochs for each iteration is 2, and the warmup ratio is 0.03.