Sample Efficient Alignment for LLMs

## Abstract

Abstract We study methods for efficiently aligning large language models (LLMs) with human preferences given budgeted online feedback. We first formulate the LLM alignment problem in the frame of contextual dueling bandits. This formulation, subsuming recent paradigms such as online RLHF and online DPO, inherently quests for sample-efficient algorithms that incorporate online active exploration . Leveraging insights from bandit theory, we introduce a unified algorithm based on Thompson sampling and highlight its applications in two distinct LLM alignment scenarios. The practical agent that efficiently implements this algorithm, named SEA ( S ample- E fficient A lignment), is empirically validated through extensive experiments across three model scales (1B, 2.8B, 6.9B) and three preference learning algorithms (DPO, IPO, SLiC). The results demonstrate that SEA achieves highly sample-efficient alignment with oracle’s preferences, outperforming recent active exploration methods for LLMs. Additionally, we release the implementation of SEA together with an efficient codebase designed for o nline a lignmen t of LLMs, aiming to accelerate future research in this field. \faGithub https://github.com/sail-sg/oat

## 1 Introduction

Aligning LLMs with human preferences is a crucial step to elicit various desirable behaviors, e.g., helpfulness and harmlessness (Bai et al., ). Moreover, it holds the potential to create superhuman capabilities with only human-level feedback, as verifying is believed to be easier than synthesizing novel behaviors. By iteratively generating massive new candidates and asking for human feedback, LLMs could learn to reinforce good behaviors and may eventually surpass human capabilities.

Existing methods, either via reinforcement learning from human feedback (RLHF) (Stiennon et al., ; Ouyang et al., ) or direct alignment from preferences (DAP) (Rafailov et al., ; Azar et al., ), typically require a large amount of human annotations to achieve effective alignment. As a result, the volume of human feedback becomes a major bottleneck in practical alignment scenarios. This poses a challenging and under-explored research question:

How to align LLMs sample-efficiently?

To seek answers, in Section 2, we formalize LLM alignment as a contextual dueling bandit (CDB) (Yue et al., ; Dudík et al., ), where the agent (i.e., the learner and decision maker, in our case the LLM) interacts with the environment (i.e., human) to collect experience for improving its policy.
This formulation naturally calls for two key properties for alignment algorithms to be sample-efficient:

###### Property 1 (online interaction) .

Interacting and learning online allows the agent to act with the latest learned policy and then use that experience to immediately improve the policy.

###### Property 2 (active exploration) .

An actively exploring agent strategically selects actions such that the collected experience leads to maximal policy improvement.

Since the CDB formulation is general and almost subsumes all existing LLM alignment methods, it provides us a lens to scrutinize prior methods on the axes of Properties 1 and 2. In Section 3, we thoroughly discuss prior alignment approaches, ranging from offline learning (Rafailov et al., ; Azar et al., ) and passive learning with iterative (Christiano et al., ; Dong et al., ) or online interaction (Guo et al., ), to active exploration for learning preference models (Dwaracherla et al., ) or aligning LLMs (Muldrew et al., ; Zhang et al., ; Xie et al., ). As will be revealed, most prior methods (partially) fail to satisfy the two properties, resulting in inferior sample efficiency. Moreover, through the CDB formulation, we identify two LLM alignment scenarios, namely aligning from online users’ feedback (e.g., ChatGPT ()) and aligning from crowdsourcing (Christiano et al., ; Ouyang et al., ), and shed light on their correspondences to two bandit settings (explore & exploit and best arm identification). Understanding their differences is important for designing efficient alignment algorithms for respective scenarios. We detail these two settings in Section 2 and discuss how prior works approach them in Section 3.

Leveraging algorithmic insights from bandit theory, our answer to the research question above is a principled alignment algorithm based on Thompson sampling (TS) (Thompson, ). Our method fulfills Properties 1 and 2 to enhance sample efficiency, and it solves either of the two settings depending on practical scenarios (Section 4.1). We incorporate techniques including epistemic reward model, policy-guided search and mixed preference learning to implement the proposed TS algorithm (Section 4.2), yielding a practical agent which we call SEA (Sample-Efficient Alignment). In addition, we develop and open source a highly efficient, distributed learning system for studying online LLM alignment methods (Section 5), eliminating barriers to fair empirical comparisons of different alignment algorithms. Through extensive experiments (Section 6), SEA shows strong empirical results (see Figure 1), consistently achieving higher win rates and improved sample efficiency compared to baseline approaches across three model scales. We hope our open-sourced codebase and proposed algorithm could inspire future research in sample-efficient online LLM alignment.

###### Property 1 (online interaction) .

###### Property 2 (active exploration) .

## 2 LLM alignment as contextual dueling bandits

We first review the definitions and two typical objectives of Contextual Dueling Bandits (Section 2.1), then translate them into the language of LLM alignment (Section 2.2). The tight connection between them, as we will see, allows us to leverage insights from bandit algorithms to design efficient alignment algorithms for LLMs.

### 2.1 Contextual dueling bandits

Contextual dueling bandits (CDB) (Yue et al., ; Dudík et al., ) is proposed to study online learning problems where the feedback consists of relative pairwise comparisons. A CDB problem can be characterized by a tuple $({\mathcal{C}},{\mathcal{A}},{\mathbb{P}})$, where ${\mathcal{C}}$ is the context space, ${\mathcal{A}}$ is the action space, and ${\mathbb{P}}:{\mathcal{A}}\times{\mathcal{A}}\times{\mathcal{C}}\mapsto[0,1]$ denotes the unknown preference oracle. An agent learns by iteratively interacting with the environment (i.e., the preference oracle ${\mathbb{P}}$) as follows. At each round $t$ of the learning process, a context ${\bm{c}}_{t}\sim p_{\mathcal{C}}$ is presented to the agent, who needs to take two actions ${\bm{a}}_{t},{\bm{a}}_{t}^{\prime}\in\mathcal{A}$ for a “dueling” comparison. The agent then receives stochastic feedback in the form of a comparison result $z_{t}\sim\operatorname{Ber}\left(\mathbb{P}\left({\bm{a}}_{t}\succ{\bm{a}}_{t}
^{\prime}|{\bm{c}}_{t}\right)\right)$ from the environment, where $\operatorname{Ber}(\cdot)$ is the Bernoulli distribution and $\succ$ denotes that the first action is preferred.

Regret. The quality of the dueling actions selected by the agent is measured by the immediate regret: $R_{t}={\mathbb{P}}({\bm{a}}^{\star}_{t}\succ{\bm{a}}_{t}|{\bm{c}}_{t})+{
\mathbb{P}}({\bm{a}}^{\star}_{t}\succ{\bm{a}}_{t}^{\prime}|{\bm{c}}_{t})-1$, where ${\bm{a}}^{\star}_{t}$ is the best action(^1^11We assume that a best action ${\bm{a}}^{\star}$ in the sense that ${\mathbb{P}}({\bm{a}}^{\star}\succ{\bm{a}}|{\bm{c}})\geq\frac{1}{2},\forall{ \bm{a}}\in{\mathcal{A}}$ exists for all context ${\bm{c}}\in{\mathcal{C}}$.) the agent would take at round $t$ if it had complete knowledge of ${\mathbb{P}}$.
Intuitively, if the agent has learned how to act optimally from round $t$ onwards, it would no longer suffer any regret since its actions would be indistinguishable from the best action (${\mathbb{P}}({\bm{a}}_{\tau}^{\star}\succ{\bm{a}}_{\tau}|{\bm{c}}_{\tau})=
\frac{1}{2}$ hence $R_{\tau}=0$ for $\tau\geq t$).

Optimal policy.
A policy $\pi\in\Delta^{\mathcal{C}}_{\mathcal{A}}$(^2^22We denote by $\Delta^{\mathcal{C}}_{\mathcal{A}}$ the set of all mappings ${\mathcal{C}}\mapsto\Delta_{\mathcal{A}}$, where $\Delta_{\mathcal{A}}$ denotes the set of all probability distributions over ${\mathcal{A}}$.) associates each context ${\bm{c}}\in{\mathcal{C}}$ with a probability distribution $\pi(\cdot|{\bm{c}})\in\Delta_{\mathcal{A}}$ over the action space.
The total preference of policy $\pi$ over policy $\mu$ given a context sampling distribution $p_{\mathcal{C}}\in\Delta_{\mathcal{C}}$ and a preference oracle ${\mathbb{P}}$ is defined as

$$ $P_{p_{\mathcal{C}},{\mathbb{P}}}(\pi\succ\mu)={\mathbb{E}}_{{\bm{c}}\sim p_{ \mathcal{C}}}\left[{\mathbb{E}}_{{\bm{a}}\sim\pi(\cdot|{\bm{c}})}{\mathbb{E}}_ {{\bm{a}}^{\prime}\sim\mu(\cdot|{\bm{c}})}\left[{\mathbb{P}}({\bm{a}}\succ{\bm {a}}^{\prime}|{\bm{c}})\right]\right].$ (1) $$

We adopt the von Neumann winner (Dudík et al., ) as the solution concept, which requires the optimal policy $\pi^{\star}$ to satisfy that

$$ $\forall\pi^{\prime}\in\Delta^{\mathcal{C}}_{\mathcal{A}},\;P_{p_{\mathcal{C}}, {\mathbb{P}}}(\pi^{\star}\succ\pi^{\prime})\geq\frac{1}{2}.$ (2) $$

In words, the von Neumann winner policy should beat or tie with every policy (i.e., is zero-regret) on average.

Learning objectives. The goal of bandit agents is to learn an optimal policy through interactions with the environment. There are two subtypes of objectives that focus on different learning scenarios.
The first type considers the conventional explore and exploit (E&E) setting (Robbins, ; Auer et al., ), where the agent learns fully online and tries to minimize the cumulative regret over $T$ rounds: $\sum_{t=1}^{T}R_{t}$. The second type of objective concerns the best arm identification (BAI) setting (Bubeck et al., ; Audibert & Bubeck, ), where the agent is only evaluated offline on its average performance, possibly at any round (a.k.a., anytime regret), and tries to learn the optimal policy with minimum interaction. Both settings call for effective online exploration strategies that satisfy Properties 1 and 2. Their differences will be made clearer with real scenarios in Section 2.2.

### 2.2 Alignment as CDB

Figure: Figure 2: Illustrative comparison between CDB and LLM alignment.
Refer to caption: x3.png

LLM alignment can be framed as a CDB problem with their correspondences illustrated in Figure 2. Specifically, at time $t$ a text prompt (cf. context) ${\bm{x}}_{t}\in{\mathcal{X}}$ is sampled from a prompt distribution $p_{\mathcal{X}}$. Then, two distinct responses (cf. actions), ${\bm{y}}_{t},{\bm{y}}_{t}^{\prime}\in{\mathcal{Y}}$, are chosen by the agent, and presented to human annotators (cf. the environment) for preference ranking. The winning and losing responses are labeled as $({\bm{y}}_{t}^{+},{\bm{y}}_{t}^{-})$ based on a binary stochastic feedback $z_{t}$. The agent is expected to behave optimally by pursuing either E&E or BAI objectives, with knowledge learned from the experience accumulated so far: $\mathcal{D}_{t}=\{\bm{x}_{\tau},\bm{y}_{\tau}^{+},\bm{y}_{\tau}^{-}\}_{\tau=1}
^{t}$. A standard assumption is that human preferences follow the Bradley-Terry (BT) model (Bradley & Terry, ):

$$ $\mathbb{P}({\bm{y}}_{t}\succ{\bm{y}}_{t}^{\prime}|{\bm{x}}_{t})=\frac{\exp{(r^ {\star}({\bm{x}}_{t},{\bm{y}}_{t}))}}{\exp{(r^{\star}({\bm{x}}_{t},{\bm{y}}_{t }))}+\exp{(r^{\star}({\bm{x}}_{t},{\bm{y}}_{t}^{\prime}))}}=\sigma(r^{\star}({ \bm{x}}_{t},{\bm{y}}_{t})-r^{\star}({\bm{x}}_{t},{\bm{y}}_{t}^{\prime})),$ (3) $$

where $\sigma$ is the sigmoid function and $r^{\star}$ encodes human’s implicit reward. The immediate regret of LLM alignment can be rewritten as $R_{t}=r^{\star}({\bm{x}}_{t},{\bm{y}}_{t}^{\star})-\left({r^{\star}({\bm{x}}_{
t},{\bm{y}}_{t})+r^{\star}({\bm{x}}_{t},{\bm{y}}_{t}^{\prime})}\right)/{2}$ with the BT assumption (Saha, ; Li et al., ), where ${\bm{y}}_{t}^{\star}$ is the best response for prompt ${\bm{x}}_{t}$ given human’s implicit reward, i.e., $r^{\star}({\bm{x}}_{t},{\bm{y}}_{t}^{\star})\geq r^{\star}({\bm{x}}_{t},{\bm{y
}}),\forall{\bm{y}}\in{\mathcal{Y}}$. The von Neumann winner policy is also redefined as

$$ $\pi^{\star}\in\underset{\pi\in\Delta^{\mathcal{X}}_{\mathcal{Y}}}{\arg\max}~{} J(\pi),\text{ where }J(\pi)={\mathbb{E}}_{{\bm{x}}\sim p_{\mathcal{X}}}{ \mathbb{E}}_{{\bm{y}}\sim\pi(\cdot|{\bm{x}})}{\left[r^{\star}({\bm{x}},{\bm{y} })\right]}~{}\text{is the objective,}$ (4) $$

by substituting Eq. 3 into Eq. 1 and maximizing $P_{p_{\mathcal{X}},{\mathbb{P}}}(\pi\succ\pi^{\star})$ towards $1/2$.

The two settings in bandits have their respective applications in LLM alignment. (1) The E&E setting applies to the scenario of serving an LLM-based application online and aligning it continually with users’ preferences. In this setting, the agent needs to balance exploration with exploitation, thus the cumulative regret is of interest because the quality of every response matters. In fact, commercial systems like ChatGPT would strategically ask users to make a dueling comparison, while upholding the quality of both responses. Please see Figure 10 in Appendix E for an example. (2) The BAI setting corresponds to the other scenario where annotators are paid to provide human feedback (Christiano et al., ; Ouyang et al., ). The desideratum in this scenario is to align the LLM at the minimum labeling cost, while the quality of the dueling responses is not important as long as the experience helps sample-efficiently learn the von Neumann winner policy.

After formalizing LLM alignment in the framework of CDB and uncovering their tight connections, we next thoroughly discuss existing alignment methods in the CDB framework and reveal the sources of their sample inefficiencies.

## 3 How prior works (partially) solve LLM alignment as CDB

Figure: Figure 3: Different paradigms for solving the LLM alignment problem in the CDB framework. Note that although all paradigms follow the LLM alignment interface (Figure 2) with the interaction loop, some are actually offline or iteratively online (i.e., loop only once or a few times). Detailed comparisons will be made in Section 3. We use colors to denote learnable components, RL optimizer, direct optimizer, and active exploration. $r_{\phi}$ denotes a point estimate of human’s implicit reward, while ${\mathcal{R}}_{\Phi}$ refers to an uncertainty-aware reward model.
Refer to caption: x4.png

We first align the notations and terminology used in CDB with commonly referred ones in the LLM community. Previously, we used the term “agent” to denote the learner and decision maker, and referred to its overall behavior as the “policy” $\pi$ (as in Eq. 4), following the standard abstraction in RL (Sutton & Barto, ; Sutton et al., ).
However, in the LLM literature, “policy” typically refers to the generative language model alone, excluding components like reward models (RMs) that the agent might additionally build (see Figure 2). To avoid confusion, from now on we use $\pi_{\theta^{t}}$ to denote the generative language model (policy) and $r_{\phi^{t}}$ to denote the (optional) RM at time $t$, both of which are learned from preference data ${\mathcal{D}}_{t}$ collected up to time $t$. We will omit $t$ when the time-indexing is not applicable (i.e., no online interaction) or not important in the context.

RLHF and DAP. Commonly adopted RLHF pipelines (Christiano et al., ; Stiennon et al., ; Bai et al., ; Ouyang et al., ) first learn a proxy RM with a negative log-likelihood loss:

$$ ${\mathcal{L}}_{r}(\phi|\mathcal{D})=-\mathbb{E}_{\left({\bm{x}},{\bm{y}}^{+},{ \bm{y}}^{-}\right)\sim p_{\mathcal{D}}}\left[\log\sigma\left(r_{\phi}\left({ \bm{x}},{\bm{y}}^{+}\right)-r_{\phi}\left({\bm{x}},{\bm{y}}^{-}\right)\right) \right],$ (5) $$

where ${\mathcal{D}}$ is collected by querying human annotators using a behavior policy $\pi_{\mathrm{ref}}$ (typically the supervised fine-tuned policy $\pi_{\mathrm{sft}}$). Afterwards, offline RL (Lange et al., ; Levine et al., ) is conducted to learn $\pi_{\theta}$ with respect to the learned reward $r_{\phi}$ internally within the agent (Figure 3a). However, the learned model $\pi_{\theta}$ might be inaccurate at regions out of the distribution (o.o.d.) of $\pi_{\mathrm{ref}}$ because little training data can be collected. An effective remedy is to incorporate a pessimistic term to combat the distributional shift, leading to a reformulation of the von Neumann winner policy objective in Eq. 4 as

$$ $\displaystyle J(\pi_{\theta})$ $\displaystyle=\underset{{\bm{x}}\sim p_{\mathcal{X}}}{\mathbb{E}}~{}\underset{ {\bm{y}}\sim\pi_{\theta}(\cdot|{\bm{x}})}{\mathbb{E}}{\Biggr{[}\underbrace{ \biggr{.}r_{\phi}({\bm{x}},{\bm{y}})}_{\text{~{}~{}estimated $r^{\star}$}}- \underbrace{\beta\log\frac{\pi_{\theta}({\bm{y}}|{\bm{x}})}{\pi_{\mathrm{ref}} ({\bm{y}}|{\bm{x}})}\biggl{.}}_{\text{o.o.d.\ reward penalty~{}}}~{}\Biggl{]}}$ (6) $\displaystyle=\underset{{\bm{x}}\sim p_{\mathcal{X}}}{\mathbb{E}}\left[ \underset{{\bm{y}}\sim\pi_{\theta}(\cdot|{\bm{x}})}{\mathbb{E}}\left[r_{\phi}( {\bm{x}},{\bm{y}})\right]-\beta D_{\text{KL}}(\pi_{\theta}(\cdot|{\bm{x}})|| \pi_{\mathrm{ref}}(\cdot|{\bm{x}}))\right],$ (7) $$

which converts an online objective regarding the human’s implicit reward $r^{\star}$ to an offline objective regarding the proxy reward $r_{\phi}$. The KL penalty in Eq. 7 is widely used for language model fine-tuning (Jaques et al., ; Xiong et al., ), and PPO (Schulman et al., ) has become a default RL optimizer to maximize the KL-regularized reward. However, the performance of RLHF is guaranteed only if the preference data ${\mathcal{D}}$ induced by $\pi_{\mathrm{ref}}$ adequately covers $\pi^{\star}$ (Zhu et al., ), which is often approximated by updating $\pi_{\mathrm{ref}}$ with the latest (improved) $\pi_{\theta}$ for re-sampling a batch of online experience and repeating Eq. 5 and 7. Prior methods typically employ only a few iterations of online interaction with large batches (Xiong et al., ; Dong et al., ), which may compromise sample efficiency (Property 1).

Online RLHF is difficult due to the complexity and instability of RL optimizers. For example, Huang et al. () openly reproduces offline RLHF scaling behaviors but requires many implementation tricks for training, highlighting the difficulties of an online counterpart. Fortunately, the introduction of DAP (or direct optimizers) largely simplifies and stabilizes the alignment process by conducting contrastive supervised learning directly on ${\mathcal{D}}$ (Figure 3b). While most DAP works focus on learning from a fixed offline preference dataset (Zhao et al., ; Rafailov et al., ; Azar et al., ; Meng et al., ; Zhang et al., ), iterative DPO (Xu et al., ) observes improved results when allowing iterative online interaction. Guo et al. () further propose OAIF to make DAP faithfully online, satisfying Property 1, and demonstrate that online learning prevents over-fitting and yields continual performance improvement. Nevertheless, it still employs passive exploration strategies (directly using ${\bm{y}},{\bm{y}}^{\prime}\sim\pi_{\theta}$), hindering sample efficiency (Property 2).

Online exploration in LLMs. A line of recent works (Mehta et al., ; Das et al., ; Melo et al., ; Dwaracherla et al., ) adopts the fully online bandit formulation and incorporates active exploration with uncertainty-aware RMs for response selection (Figure 3c). In particular, Mehta et al. () consider the E&E setting and develop a UCB-style (Auer et al., ) algorithm; Das et al. () instead select the dueling responses with the most uncertain preference estimate, targeting the BAI setting in a pure exploration way; unlike the above, Melo et al. () view the problem from the angle of pool-based active learning and propose an acquisition function based on both entropy and epistemic uncertainty; finally, the work by Dwaracherla et al. () is the closest to ours in the sense that they apply double Thompson sampling (DTS) (Wu & Liu, ) for exploration, but DTS is designed for the E&E setting while they evaluate anytime average performance as in the BAI setting. We will show in Section 6.3 that pure exploration by Das et al. () is not the best choice for BAI, and the objective mismatch in Dwaracherla et al. () could lead to suboptimal performance in respective settings. Meanwhile, all these works primarily focus on learning uncertainty-aware RMs online without updating LLM policies. Therefore, all responses are sampled from a fixed proposal policy $\pi_{\beta}$ (or even a fixed dataset), making the data coverage a critical concern.

Another line of research updates LLMs online while incorporating exploration. Zhang et al. () and Xie et al. () independently propose to learn an optimistic RM to encourage exploration. They leverage the property of DPO (Rafailov et al., ) to reparameterize RM with policy and conclude with an extra optimistic term in the DPO loss function. Thus, their learning processes are like Figure 3b but with an optimistic direct optimizer. Muldrew et al. () adopt the vanilla DPO loss but utilize the implicit reward margin to actively select dueling responses. Yet, these methods are tightly coupled with DPO and not compatible to other direct optimizers. Their experiments are also limited to a few online iterations, possibly due to the implementation difficulty of a faithfully online learning system. Given their relevance to our approach, we will reproduce them in a fully online manner for fair comparisons in Section 6.1. We summarize prior works in Table 2 in Appendix E.

## 4 SEA : sample-efficient alignment for LLMs

In this section we present our online exploration agent SEA (Figure 3d). We first introduce a principled Thompson sampling algorithm inspired by bandit theory (Section 4.1), and then derive SEA as its practically efficient implementation (Section 4.2). Interestingly, SEA can also be viewed as an instantiation of a classical model-based RL architecture called Dyna (Sutton, ), for which we defer the discussion to Appendix B.

### 4.1 Thompson sampling for LLM alignment

Thompson sampling (TS) (Thompson, ) is widely adopted for solving bandit problems at scale due to its efficiency and strong empirical performance in general online learning problems (Chapelle & Li, ; Russo et al., ). A bandit agent using Thompson sampling typically maintains and incrementally updates a posterior distribution of the oracle reward $p(r|{\mathcal{D}})$. Meanwhile, the agent takes actions following a greedy policy with respect to a sampled RM: ${\bm{a}}_{t}=\arg\max_{{\bm{a}}}r({\bm{a}})$ with $r\sim p_{r}(\cdot|{\mathcal{D}})$. This simple yet effective algorithm naturally balances exploration and exploitation: when the agent has limited knowledge about the environment, the posterior estimate exhibits high uncertainty so that the sampled RM could guide the greedy policy to explore; after sufficient experience is gathered, the sampled RM approximates the oracle more closely, allowing the agent to exploit near-optimal policies.

In the context of LLM alignment, we leverage the BT assumption (Eq. 3) to replace the preference oracle ${\mathbb{P}}$ with the implicit reward $r^{\star}$. This substitution enables us to model the reward posterior $p(r|{\mathcal{D}})$ in the standard TS framework, preserving the probabilistic structure necessary for effective posterior sampling. Inspired by prior works (Wu & Liu, ; González et al., ) on non-contextual $K$-arm bandits and preferential Bayesian optimization problems, we generalize them for LLM alignment and develop a unified algorithm as shown in Algorithm 1. Note that we assume for now the LLM agent can be fully described by the posterior $p(r|{\mathcal{D}})$, and we defer practical reward ($r_{\phi}$) and policy ($\pi_{\theta}$) learning to Section 4.2.

Figure: Algorithm 1 Thompson sampling for LLM alignment (intractable).

As Algorithm 1 presents, the first response of the duel is always selected via standard TS (4). The selection of the second response varies across different settings. 6 will be used for scenarios where preference feedback is collected from online users (the E&E setting). The dueling responses selected in this case will both try to maximize a sampled RM, so that the online user experience is warranted with best effort. However, such algorithm can have poor asymptotic performance for BAI problems (Russo, ), because sub-optimal responses with confidently high rewards might be tried for a long time at the expense of not exploring other potentially better choices. In light of this, 10 provides an alternative for scenarios where we could hire annotators for feedback and low-quality but exploratory responses are safe to try. Specifically, 10 selects the second response as the one that maximizes the variance of the preference (Eq. 3) over the first response ${\bm{y}}$. This variance quantifies the epistemic uncertainty of the RM, pointing the agent to the maximally informative direction to explore for better sample efficiency.

However, Algorithm 1 is yet to be practical for LLM alignment for three main reasons. First, computing and sampling from a reward posterior is intractable for nearly all RMs at LLM scale, which are mostly based on large transformers (Lambert et al., ). Second, even if we managed to approximate the reward posterior, the $\arg\max$ operations for response selection are still intractable since the search space ${\mathcal{Y}}$ is discrete and massive for token sequences of arbitrary length. Last but not least, an LLM agent (Achiam et al., ; Touvron et al., ) typically consists in a generative model $\pi_{\theta}$ (e.g., a transformer (Vaswani et al., )), while the algorithm above is centered around a reward posterior $p(r|{\mathcal{D}})$ that cannot be easily converted into a generative model.

### 4.2 Practical implementation

#### 4.2.1 Epistemic reward model for posterior sampling

To implement active exploration with TS, we seek an efficient way to maintain and incrementally update the reward posterior $p(r|{\mathcal{D}})$. We consider deep ensemble for our purpose, due to its capability to model epistemic uncertainty (Lakshminarayanan et al., ) and provable results when applied to TS in linear bandits (Qin et al., ). Specifically, we update a set of plausible RMs independently and online, using the preference data and a regularized negative log-likelihood loss:

$$ $\displaystyle\mathcal{L}_{\mathcal{R}}(\Phi^{t}|{\mathcal{D}}_{t})=\sum_{k=1}^ {K}\left({\mathcal{L}}_{r}(\phi_{k}^{t}|\mathcal{D}_{t})-\lambda||\phi_{k}^{t} -\phi_{k}^{0}||\right),$ (8) $$

where ${\mathcal{L}}_{r}$ is defined in Eq. 5, $\Phi^{t}=\{\phi^{t}_{k}\}_{k=1}^{K}$ contains the weights of the ensemble of size $K$, and $\lambda$ controls the regularization towards individual initial weights $\phi_{k}^{0}$ to retain the diversity across ensemble members (Dwaracherla et al., ). In practice, we train $K$ MLP heads on top of a pretrained and frozen transformer. We refer to the ensemble as the Epistemic Reward Model (ERM, denoted as ${\mathcal{R}}_{\Phi}$), with which the posterior sampling ($r\sim p_{r}(\cdot|{\mathcal{D}}_{t})$) simply amounts to randomly picking a $\phi^{t}_{k}$ from $\Phi^{t}$.

#### 4.2.2 Policy-guided search to approximate arg ⁡ max \arg\max roman_arg roman_max

With the ERM approximating the reward posterior, we need to further approximate the response selection steps (4, 6 and 10) which generally take the form of ${\color[rgb]{0.6,0,0.4}\definecolor[named]{pgfstrokecolor}{rgb}{0.6,0,0.4}\arg
\max_{{\bm{b}}\in{\mathcal{Y}}}}U({\bm{b}})$, where $U$ absorbs the sampled prompt, the sampled RM, and optionally the selected first response (for BAI, 10). To obtain the maximum, bandit algorithms for large action spaces typically resort to an action optimization oracle (Katz-Samuels et al., ; Zhu et al., ), but they assume a linear structure of $U$ with respect to ${\bm{b}}$, which might be impractical for LLMs. Therefore, we instead replace the optimization over ${\mathcal{Y}}$ with sampling from a policy-guided distribution conditioned on $U$, $\pi_{\mathrm{prior}}(\cdot|{\bm{x}})\exp{(U(\cdot)/\eta)}$, which is appropriate since it favors responses ${\bm{y}}$ that approximately maximize $U({\bm{y}})$. In practice, for a given prompt ${\bm{x}}_{t}$, we sample $M$ candidate responses from the prior policy $\pi_{\mathrm{prior}}(\cdot|{\bm{x}}_{t})$ to construct a proposal set ${\mathcal{S}}_{t}=\{{\bm{y}}_{t}^{i}\}_{i=1}^{M}$. We then conduct a greedy search in ${\mathcal{S}}_{t}$ (taking $\eta\to 0$) to identify the response ${\bm{y}}_{t}$ (or ${\bm{y}}_{t}^{\prime}$) that locally maximizes the utility function $U$, which is subsequently used in the duel. We also reuse the same ${\mathcal{S}}_{t}$ for different $U$ functions at time $t$ to save computation. The choice of $\pi_{\mathrm{prior}}$ will be discussed in the next section.

#### 4.2.3 Online policy learning from mixed preferences

We finally resolve two remaining questions: (Q1) how to choose a sensible $\pi_{\mathrm{prior}}$ at each time $t$ and (Q2) how to get a good generative policy online. To this end, we propose a simple approach to approximately address both questions simultaneously. That is, we can utilize any direct optimizer to learn the policy $\pi_{\theta^{t}}$ online with the following loss and use the latest online policy as $\pi_{\mathrm{prior}}$:

$$ $\mathcal{L}_{\pi}(\theta^{t}|{\mathcal{B}}_{t},\pi_{\mathrm{ref}},F)=\mathbb{E }_{\left({\bm{x}},{\bm{y}}^{+},{\bm{y}}^{-}\right)\sim p_{{\mathcal{B}}^{t}}} \left[F_{\theta^{t}}({\bm{x}},{\bm{y}}^{+},{\bm{y}}^{-},\pi_{\mathrm{ref}}) \right],$ (9) $$

where ${\mathcal{B}}_{t}$ is a batch of preference data labeled by the oracle wherein the responses are proposed by $\pi_{\mathrm{prior}}$ and selected by ${\mathcal{R}}_{\Phi^{t}}$, $F$ could be any DAP loss (see Appendix A for some examples), and $\pi_{\mathrm{ref}}$ is chosen to be $\pi_{\mathrm{sft}}$. Note that we use $\pi_{\theta^{t}}$ as $\pi_{\mathrm{prior}}$ at any time $t$, thus ${\mathcal{B}}^{t}$ is a batch of on-policy data. By contrastive training on these on-policy data, we leverage their orthogonal benefits to achieve maximal policy improvement (Tajwar et al., ; Tang et al., ).

Now that optimizing Eq. 9 yields a good online policy $\pi_{\theta^{t}}$ (answering Q2), we need to assess whether $\pi_{\theta^{t}}$ can serve as a suitable $\pi_{\mathrm{prior}}$ for approximating the $\arg\max$ in TS (Q1). If we optimize $\pi_{\theta^{t}}$ with oracle preference data, ${\mathcal{S}}_{t}$ will be biased towards responses with high oracle reward $r^{\star}$. Bias towards high-$r^{\star}$ region is generally helpful because it aligns with ${\arg\max_{{\bm{b}}\in{\mathcal{Y}}}}r({\bm{x}},{\bm{b}})$ that seeks high-reward responses. However, optimizing $\pi_{\theta^{t}}$ only with oracle data can average out the epistemic uncertainty of ${\mathcal{R}}$, hindering the exploration efficiency. To mitigate this issue, we further align $\pi_{\theta^{t}}$ with ${\mathcal{R}}_{\Phi^{t}}$ using the same direct optimizer to encourage $\pi_{\theta^{t}}$ to propose high-$r_{\phi^{t}_{k}}$ responses for individual $r_{\phi^{t}_{k}}$, leading to better approximation of ${\arg\max_{{\bm{b}}\in{\mathcal{Y}}}}r({\bm{x}},{\bm{b}})$ for any sampled $r$. To implement, we optimize Eq. 9 over a mixture distribution $p_{{\mathcal{B}}_{t}^{\text{mix}}}=\gamma p_{{\mathcal{B}}_{t}}+(1-\gamma)p_{{
\mathcal{B}}_{t}^{\text{ERM}}}$, where $\gamma\in[0,1]$ controls the mixture ratio and ${\mathcal{B}}_{t}^{\text{ERM}}=\{{\bm{x}}_{i},\tilde{{\bm{y}}}^{+}_{i},\tilde{
{\bm{y}}}^{-}_{i}\}_{i=1}^{b}$ consists of preference data labeled by randomly sampled individual ensemble members $r_{\phi^{t}_{k}}$. Interestingly, learning from mixed preferences further boosts sample efficiency because it utilizes the internal ERM to get pseudo labels instead of querying humans. This relates closely to model-based RL, for which we discuss further in Appendix B. We summarize our practical algorithm (Algorithm 2) in Appendix A.

## 5 Experimental setup

In this section, we elaborate the experimental setup employed to validate our algorithm and ensure fair comparisons with other online alignment baselines. We start by introducing the distributed learning system designed for experimenting with online LLM alignment using simulated human preferences (Section 5.1). Then, we provide key experimental details in Section 5.2, with a full description available in Appendix D.

### 5.1 Distributed learning system

The interactive nature of LLM alignment necessitates an integrated online learning system that simulates the interface depicted on the right of Figure 2. The absence of a performant open-source online alignment system has restricted many existing works to only a few iterations of batch learning (Muldrew et al., ; Dong et al., ; Chen et al., ; Zhang et al., ; Xie et al., ), which creates a mismatch with their theories that typically require a large number of online interaction rounds. Even worse, such absence also makes the comparison between different LLM exploration methods difficult, often restricting evaluations to the simplest iterative DAP baselines (Zhang et al., ; Xie et al., ).

Figure: Figure 4: The learning system for experimenting online LLM alignment algorithms.
Refer to caption: x5.png

To fill this gap, we build a highly efficient learning system for experimenting with online LLM alignment algorithms. We notice that the computational bottleneck lies in online response sampling (i.e., autoregressive generation) and preference labeling (e.g., human, large RMs, or large LLMs), which mirrors the slow actor-environment interaction seen in RL systems. Inspired by distributed deep RL systems which spawn many actors or environments in parallel (Espeholt et al., ; Weng et al., ), we design an Actor-Learner-Oracle architecture for online LLM alignment, which is depicted in Figure 4. The three types of workloads (i.e., actor, learner and oracle) are heterogeneous and require different optimization. In particular, we adopt vLLM (Kwon et al., ) for the actor to accelerate the autoregressive response generation. We also use DeepSpeed’s ZeRO (Rasley et al., ; Rajbhandari et al., ) strategies to enhance the memory efficiency of the learner. The updated model weights are broadcasted from the learner master to all actors after every optimizer step efficiently via NCCL, similar to Hu et al. (). Furthermore, to improve the scalability, we wrap the oracle RM as a service using Mosec (Yang et al., ), which supports dynamic batching and parallel processing, to minimize preference query latency. Finally, we leverage DeepMind Launchpad (Yang et al., ) to compose all workloads into a distributed program and adopt Plasma (Philipp & Robert, ) to efficiently transfer data across process boundaries.

We benchmark our system’s efficiency against a concurrent implementation of online DPO by HuggingFace(^3^33[https://huggingface.co/docs/trl/main/en/online_dpo_trainer](https://huggingface.co/docs/trl/main/en/online_dpo_trainer).), which utilizes only DeepSpeed for memory optimization. Our system achieves up to $\textbf{2.5}\times$ latency reduction compared to this counterpart, demonstrating its computational efficiency. Due to space constraints, detailed benchmarking methods and results are presented in Appendix C. Our codebase, oat (online alignment), along with the implementation of SEA, is open-sourced at [https://github.com/sail-sg/oat](https://github.com/sail-sg/oat) to accelerate future research in online LLM alignment.

### 5.2 Experiment details

We adopt SFT models tuned on TL;DR (Stiennon et al., ) from Huang et al. (), which cover three scales (1B, 2.8B, 6.9B) of the Pythia family (Biderman et al., ), as starting points for our experiments. We choose Liu et al. () to be the oracle RM. To verify the effectiveness of SEA, we employ three direct optimizers: DPO (Rafailov et al., ), IPO (Azar et al., ), and SLiC (Zhao et al., ). Besides, two LLM exploration methods built on DPO, APL (Muldrew et al., ) and XPO (Xie et al., ), are fairly compared when using DPO as the optimizer. Our experiments primarily focus on the BAI setting (crowdsourcing labeling), and we use win rate against reference responses as the metric. We refer readers to Appendix D for more details.

## 6 Empirical results

In this section, we present our empirical results and analyses, organized into four parts: (1) an overall comparison between SEA and baselines across various direct optimizers and model scales; (2) an ablation analysis to study the effects of SEA’s key components; (3) a comparison of different exploration strategies under E&E and BAI settings; (4) additional results for alignment with a human oracle simulated by GPT4o-mini.

Figure: Figure 5: Win rate comparison of different algorithms against their initial SFT models across three scales and three direct optimizers.
Refer to caption: x6.png

### 6.1 Overall comparison

We first compare SEA with all baselines across three model scales and three direct optimizers. APL and XPO are only compared when DPO is used as the direct optimizer, because they are incompatible with IPO or SLiC. Figure 5 shows the win rate curves versus the number of query steps. Across all settings, Online agents consistently improve sample efficiency over their Offline counterparts, validating the necessity of Property 1 for alignment algorithms. Focusing on the first row, we observe that among prior active exploration methods, XPO gives a small improvement in final performance over Online (passive) at the 1B scale, but falls short for larger scales. On the other hand, APL shows a significant sample efficiency boost at the 1B scale, but this advantage diminishes when scaling up and it performs almost the same as Online at 6.9B scale. Our method, SEA, outperforms both offline and online passive methods across all scales and all direct optimizers, confirming the critical role that Property 2 plays for sample-efficient alignment. Meanwhile, in the special case of using DPO as the direct optimizer, SEA also shows superior performance to prior online active exploration methods including APL and XPO. We invite readers to revisit Figure 1, where we show that SEA not only attains significantly improved final performance (Left) but also achieves $2\text{-}5\times$ better sample efficiency (Right).

Additionally, we note that the choice of direct optimizer matters for both online learning and active exploration. When comparing different optimizers at 1B scale (the first column), all Offline agents demonstrate comparable learning efficiency and reach the same level of final performance (around $70\%$ win rate), but SLiC Online agent deliver slightly less improvement than DPO and IPO Online agents. Besides, when incorporating active exploration, the SEA agent using DPO shows much larger improvement than the other two. This suggests that selecting the most suitable policy optimizer coupled with active exploration would yield the best agent.

### 6.2 Ablation analysis

**Table 1: Decomposition of different driving factors of online active alignment algorithms.**
| Variant | Inference (Test) | Exploration | Learn | Remark |
| --- | --- | --- | --- | --- |
| 1 | $\pi_{\theta}$ | passive | $\pi_{\theta}$ | Online DAP (Guo et al., ) |
| 2 | $\pi_{\theta}$ | active | $(\pi_{\theta},{\mathcal{R}}_{\Phi})$ | SEA without ERM sync (Section 4.2.3) |
| 3 | $\pi_{\theta}$ | active | $(\pi_{\theta}\leftrightarrow{\mathcal{R}}_{\Phi})$ | SEA |
| 4 | $\operatorname{BoN}(\pi_{\theta},{\mathcal{R}}_{\Phi})$ | passive | $(\pi_{\theta},{\mathcal{R}}_{\Phi})$ | - |
| 5 | $\operatorname{BoN}(\pi_{\theta},{\mathcal{R}}_{\Phi})$ | active | $(\pi_{\theta},{\mathcal{R}}_{\Phi})$ | - |
| 6 | $\operatorname{BoN}(\pi_{\theta},{\mathcal{R}}_{\Phi})$ | active | $(\pi_{\theta}\leftrightarrow{\mathcal{R}}_{\Phi})$ | SEA with Best-of-N sampling |
| 7 | $\operatorname{BoN}(\pi_{\mathrm{ref}},{\mathcal{R}}_{\Phi})$ | active | ${\mathcal{R}}_{\Phi}$ | Not learn policy (Dwaracherla et al., ) |

Figure: Figure 6: Win rate comparison of different agent variants when using (Left) policy and (Right) Best-of-N sampling for inference.
Refer to caption: x7.png

Next, we decompose SEA into distinct components to evaluate their individual contributions. Table 1 shows the three axes we dissect SEA on, including inference methods, exploration strategies, and learning components. We construct seven agent variants from different combinations, which cover two closely related baselines (Guo et al., ; Dwaracherla et al., ). We show in Figure 6 the performance curves of each variant, all trained with DPO on 1B scale. The left plot compares variants that directly use the policy for inference. It clearly shows the benefits of learning ERM for active exploration (Variant-2) and aligning $\pi_{\theta^{t}}$ with ${\mathcal{R}}_{\Phi^{t}}$ (Variant-3). Since a reward model is learned within the agent, we can further incorporate inference-time alignment via Best-of-N (BoN) sampling (Nakano et al., ; Touvron et al., ). This also facilitates a direct comparison between SEA and Dwaracherla et al. (), which learns a similar ERM for both exploration and BoN but does not align the LLM policy. Results in the right plot of Figure 6 suggest a similar trend that Variant-6$~{}\succ~{}$Variant-5$~{}\succ~{}$Variant-4. The Variant-7 (Dwaracherla et al., ), however, ceases to improve after ERM converges due to the limited performance of its fixed policy.

### 6.3 Choice of exploration strategies

Recalling that different LLM alignment scenarios (online system or crowdsourcing) require different exploration strategies to meet their respective learning objectives (Section 2.2). We investigate three strategies based on posterior sampling and compare them on both online and offline performance. The first strategy (Uncertainty) focuses on pure exploration with information maximization. It seeks the pair of dueling responses that exhibits the largest epistemic uncertainty, which is implemented by selecting the pair whose logits difference has the largest variance across ensemble members. The second (E&E-TS) and the third (BAI-TS) strategies follow the principles in Algorithm 1, and their differences are between 6 and 10. The comparison results are shown in Figure 7 (Left and Middle). Focusing on the left plot, we observe that E&E-TS strategy achieves the best online performance, which is within our expectation. In contrast, Uncertainty shows the worst online performance because it tries to maximize the information gain but does not prioritize reward maximization. On the other hand, conclusions are interestingly different when taking the offline performance as the metric. In this case, BAI-TS and Uncertainty both exhibit more efficient offline performance improvement than E&E-TS. This can be attributed to that exploration for uncertainty minimizing helps to identify more informative responses to train the LLM policy. Moreover, BAI-TS $\succ$ Uncertainty indicates exploration with both reward and information maximization is better than exploration with only information maximization. E&E-TS, however, always chooses two responses with similarly high quality to exploit. This can not only lead to less efficient exploration, but also result in less efficient policy learning due to smaller DAP loss gradients.

Figure: Figure 7: (Left and Middle) Win rate comparison of different exploration strategies measured in E&E and BAI settings. (Right) Win rate comparison of different agents when using GPT4o-mini to simulate human feedback via LLM-as-a-judge.
Refer to caption: x8.png

### 6.4 Aligning LLMs with a human simulator

Results presented so far are based on experimenting LLM alignment with the preference oracle being a scalar reward model, which is deterministic and does not capture the potential randomness of the choice by real humans. To test different agents in a more realistic setting, we use generative models as human simulator in an LLM-as-a-judge (Bubeck et al., ; Zheng et al., ) manner. In particular, we directly query the OpenAI API and use the gpt-4o-mini-2024-07-18 model as the judge to provide preference feedback. We follow the prompt template of Li et al. (). The results are shown in Figure 7 (Right). We can observe the performance curves generally exhibit higher variance, possibly due to the randomness introduced in the feedback process, which puts more stringent requirements for learning algorithms. The two active exploration methods demonstrate opposite results to those in Section 6.1—APL learns fast initially but is eventually outperformed by Online, while XPO improves over Online after stabilizing its training and delivers a better final performance. Our agent, SEA, is shown to offer the best sample efficiency as well as asymptotic performance, further validating the importance of online learning and well-designed active exploration mechanism.

## 7 Conclusion

In this paper, we study the problem of LLM alignment through the lens of contextual dueling bandits and propose a Thompson sampling-based algorithm to achieve sample-efficient alignment. We incorporate three techniques, including epistemic reward model, policy-guided search and mixed preference learning to yield a practically efficient online alignment method. Extensive empirical evaluation demonstrates the superior sample efficiency of our method compared to existing baselines. To our knowledge, this is the first work to study active exploration for online LLM alignment with fully online experimental verification. We hope our positive empirical results, along with the open-sourced codebase, will encourage future research in this direction, ultimately enabling LLMs to achieve superhuman intelligence with an affordable amount of human feedback.

## Appendix A Algorithm details

While Algorithm 1 presents our Thompson sampling algorithm for LLM alignment, it is intractable and centered around the reward posterior modeling. We next present a practical sample-efficient alignment agent that learns both an LLM policy and an epistemic reward model online in Algorithm 2.

Figure: Algorithm 2 Sample-efficient alignment (SEA) for LLMs

In Algorithm 2, we describe an online setting where a single example is processed at each time $t$ (batch size $b=1$). This is mainly for notational convenience, while in implementation we set $b$ to be the training batch size (e.g., $128$). We instantiate the reward posterior with an epistemic reward model, which allows for efficient incremental update and sampling. We also replace the global optimization ($\arg\max_{{\bm{b}}\in{\mathcal{Y}}}$) with a policy-guided local search among proposals sampled from the latest online policy $\pi_{\theta^{t-1}}$. At each time $t$, we update ERM weights $\Phi$ with $m$ randomly sampled batches from the experience ${\mathcal{D}}_{t}$. We find setting $m=5$ suffices to achieve reasonable accuracy. The policy parameters $\theta$ are updated using mixed preference data, with proportion $\gamma$ being the real environment experience and $(1-\gamma)$ from the ERM’s synthetic experience. Note that the synthetic experience is not added into ${\mathcal{D}}_{t}$ to ensure reward learning always uses ground truth environment data.

We consider the following three direct optimizers in our experiments:

- •
DPO (Rafailov et al., ):
$F_{\theta}({\bm{x}},{\bm{y}}^{+},{\bm{y}}^{-},\pi_{\mathrm{ref}})=-\log\sigma
\left(\beta\log\frac{\pi_{{\theta}}\left(\bm{y}^{+}|\bm{x}\right)\pi_{\mathrm{
ref}}\left(\bm{y}^{-}|\bm{x}\right)}{\pi_{\mathrm{ref}}\left(\bm{y}^{+}|\bm{x}
\right)\pi_{{\theta}}\left(\bm{y}^{-}|\bm{x}\right)}\right)$
(10)
- •
IPO (Azar et al., ):
$F_{\theta}({\bm{x}},{\bm{y}}^{+},{\bm{y}}^{-},\pi_{\mathrm{ref}})=\left(\log
\left(\frac{\pi_{{\theta}}\left(\bm{y}^{+}|\bm{x}\right)\pi_{\mathrm{ref}}
\left(\bm{y}^{-}|\bm{x}\right)}{\pi_{\mathrm{ref}}\left(\bm{y}^{+}|\bm{x}
\right)\pi_{{\theta}}\left(\bm{y}^{-}|\bm{x}\right)}\right)-\frac{1}{2\beta}
\right)^{2}$
(11)
- •
SLiC (Zhao et al., ):
$F_{\theta}({\bm{x}},{\bm{y}}^{+},{\bm{y}}^{-},\pi_{\mathrm{ref}})=\max\left(0,
1-\beta\log\frac{\pi_{{\theta}}\left(\bm{y}^{+}|\bm{x}\right)\pi_{\mathrm{ref}
}\left(\bm{y}^{-}|\bm{x}\right)}{\pi_{\mathrm{ref}}\left(\bm{y}^{+}|\bm{x}
\right)\pi_{{\theta}}\left(\bm{y}^{-}|\bm{x}\right)}\right)$
(12)

where $\beta$ controls the rate of deviation of $\pi_{\theta}$ from $\pi_{\mathrm{ref}}$.

## Appendix B On connections with single-step RL

By viewing contextual dueling bandits as single-step preference-based RL (PbRL) (Busa-Fekete et al., ; Wirth et al., ) problems, we can interpret paradigms shown in Figure 3 from the RL perspective.

RLHF approaches (Figure 3a) are instances of offline model-based RL (Kidambi et al., ; Yu et al., ; Schrittwieser et al., ; Liu et al., ; Tajwar et al., ), where they learn a reward model (no need for a transition model since the prompt-response interaction is single-step) of the environment from a batch of offline collected data, and train a policy (i.e., LLM) to maximize the return (i.e., expected one-step reward) with respect to the learned reward.

In contrast, DAP methods (Figure 3b) are similar to policy-based model-free RL algorithms, e.g., REINFORCE (Williams, ) which conducts policy gradient update:

$$ $\mathbb{E}_{{\bm{x}}\sim{\mathcal{X}}}\mathbb{E}_{{\bm{y}}\sim\pi_{\theta}( \cdot|{\bm{x}})}\left[R({\bm{x}},{\bm{y}})\nabla_{\theta}\log\pi_{\theta}({\bm {y}}|{\bm{x}})\right],$ (13) $$

where $R({\bm{x}},{\bm{y}})$ is the return (i.e., cumulative reward) of the trajectory. To connect with DAP, we could set $R$ as arbitrary scalar values based on the binary preference outcomes, e.g., $R({\bm{x}},{\bm{y}}^{+})=\zeta$ and $R({\bm{x}},{\bm{y}}^{-})=-\zeta$ for preference triplet $\{{\bm{x}},{\bm{y}}^{+},{\bm{y}}^{-}\}$. In this way we could rewrite Eq. 13 as

$$ $\mathbb{E}_{{\bm{x}}\sim{\mathcal{X}}}\mathbb{E}_{{\bm{y}},{\bm{y}}^{\prime} \sim\pi_{\theta}(\cdot|{\bm{x}})}\mathbb{E}_{({\bm{y}}^{+}\succ{\bm{y}}^{-}) \sim{\mathbb{P}}}\left[\zeta\left(\nabla_{\theta}\log\pi_{\theta}({\bm{y}}^{+} |{\bm{x}})-\nabla_{\theta}\log\pi_{\theta}({\bm{y}}^{-}|{\bm{x}})\right)\right],$ (14) $$

by repeating action sampling twice and querying the oracle for preference labeling. This matches the gradient direction of contrastive DAP losses (e.g., see Section 4 of DPO (Rafailov et al., )) if we optimize them online (Guo et al., ).

Additionally, active reward learning from behavior policy’s data distribution (Figure 3c) can be regarded as inverse RL (Ng & Russell, ), which tries to recover environment’s reward function given expert trajectories. In the context of LLM alignment, the preference data $\{{\bm{x}},{\bm{y}}^{+},{\bm{y}}^{-}\}_{i=1}^{N}$ directly encodes human’s implicit reward $r^{\star}$, which can be inversely learned with assumptions such as the BT model (Bradley & Terry, ). However, existing methods belonging to this paradigm mostly rely on a fixed (and suboptimal) behavior policy for response sampling, whose coverage inherently limits the quality of the recovered reward function.

Last but not least, SEA depicted in Figure 3d resembles a class of online model-based RL algorithms, known as Dyna (Sutton, ; Janner et al., ), that learns a world model from environment experience and trains a base agent (consisting of reactive policies and value functions) from both environment experience and model experience. Compared to model-free methods, Dyna naturally enables more sample-efficient learning by planning with the learned world model to update the base agent. In SEA, we learn the reward model online and update the LLM (i.e., the reactive policy) with model-planing experience by mixed preference learning (Section 4.2.3). Online model-based RL algorithms could suffer from catastrophic forgetting in the face of nonstationary data (Liu et al., ), and we leave it for future work. Overall, this model-based RL formulation is powerful and explains popular LLM techniques, e.g., Best-of-N sampling (Touvron et al., ) can be viewed as planning for acting, which trades compute for performance. We believe it is a promising path leading us to unlock superhuman capabilities of LLMs.

## Appendix C System benchmarking

We conduct a rigorous benchmarking comparison on the efficiency of online DPO training using our learning system oat(^4^44[https://github.com/sail-sg/oat](https://github.com/sail-sg/oat).), alongside the trl’s implementation(^5^55[https://github.com/huggingface/trl/blob/main/trl/trainer/online_dpo_trainer.py](https://github.com/huggingface/trl/blob/main/trl/trainer/online_dpo_trainer.py).).

Settings. In alignment with the examples provided by trl, we use the TL;DR (Stiennon et al., ) dataset and evaluate training efficiency at three model scales: 1B, 2.8B and 6.9B parameters for both SFT-ed LLMs and exclusively trained RMs. This is similar to the settings in our experiments (see Appendix D) except that we fix the reward oracle to be a strong general-purpose RM.

Hardware & Software. All benchmarking experiments are conducted on a single machine with eight A100-40G GPUs and $96$ AMD EPYC 7352 CPUs. To ensure fair comparison, we align all key hyperparameters for both oat and trl. The DeepSpeed ZeRO-2 strategy is employed by default when GPU memory suffices; otherwise, ZeRO-3 or ZeRO-2-offload is utilized as applicable. Notably, the distributed architecture of oat provides flexibility in system configuration, enabling adjustments to accommodate memory and computational time constraints. Figure 8 illustrates two example configurations employed in our benchmarking experiments.

- •
Config 1 collocates all three workloads on each of the GPUs. Specifically, eight vLLM instances (for actors) and eight Mosec workers (for oracle RMs) are spawned to run independently on each GPU. After a batch of responses is generated (by actors) and labeled (by oracle RMs), it is sent to the learner, which runs on all eight GPUs coordinated through ZeRO strategies for policy learning. The updated policy weights are then broadcasted to all actors for on-policy response sampling on subsequent prompt batch. While this configuration maximizes GPU utilization, it requires substantial GPU memory to accommodate all workloads and is thus employed only for 1B scale experiments.
- •
Config 2 only collocates actor and oracle workloads on half of the GPUs, reserving the remaining four GPUs exclusively for the learner. This is suited for larger-scale experiments (e.g., 2.8B or 6.9B), where additional GPU memory is allocated to the learner. However, this setup incurs idle time on half of the GPUs due to data dependency, as the learner must await new preference data, and the actor must await updated policies. An alternative is to implement asynchronous data collection, where minor data staleness is allowed by using $\theta_{t-1}$ to generate data for updating $\theta_{t+1}$. Although this data would not be strictly on-policy, asynchronous training could reduce idle time and enhance GPU utilization. This approach has proven effective in large-scale RL systems (Berner et al., ), and we leave this optimization to future work.

We provide all benchmarking scripts in our codebase(^6^66[https://github.com/sail-sg/oat/tree/main/benchmark](https://github.com/sail-sg/oat/tree/main/benchmark).) for reproducibility.

Figure: Figure 8: Two example configurations of oat used in benchmarking experiments.
Refer to caption: x9.png

Results. Benchmarking results for the latency of training a batch of 128 samples are presented in Figure 9. Overall, training with oat config 2 demonstrates consistently greater efficiency than trl, achieving up to a 2.5$\times$ reduction in latency at the 2.8B scale.

Figure: Figure 9: Averaged training latency (over 10 batches, equivalent to 1280 samples) comparing sail-sg/oat against huggingface/trl.
Refer to caption: x10.png

We next analyze the time costs for individual stages: generate, oracle and learn. Across all scales and configurations, oat demonstrates significantly lower generate time than trl, due to distributed actors utilizing vLLM. Additionally, at the 6.9B scale, oat requires substantially less oracle time than trl, as trl employs ZeRO-3 to prevent GPU memory overflow, thereby slowing inference. In contrast, oat config 2 allows for flexible collocation, enabling oracle RMs hosted via Mosec to operate in parallel without sharding. However, oat config 2 incurs longer learn time compared to trl due to the use of only half the available GPUs. This limitation also explains why, at the 1B scale, config 2 has higher latency than config 1 across all stages.

The other category accounts for time costs associated with data loading, tokenization, and communication. Here, inter-process communication is the primary cost, with trl showing minimal overhead as all three stages operate within the same process on identical micro-batches, avoiding weight synchronization. By contrast, oat requires considerable time to transfer updated policy weights from the learner to all actors. While NCCL is recommended for synchronization over GLOO, it requires older vLLM packages (prior to version 0.4.3), which may lack support for newer LLM architectures. Moreover, NCCL is incompatible with config 1 due to its restriction on the learner master process establishing two separate process groups (one for DeepSpeed, the other for weight synchronization). In summary, we recommend future researchers prioritize oat config 2 and employ NCCL when feasible.

## Appendix D Full experimental details

Models. We experiment three model scales (1B, 2.8B, 6.9B) from the Pythia family (Biderman et al., ). We take pretrained SFT models from Huang et al. () as $\pi_{\mathrm{ref}}$ for the starting model in all experiments. Except in Section 6.1, we use 1B model for experiments to save computation.

Reward oracle. We simulate the process of human feedback with a strong scalar RM and refer it as reward oracle. We choose Skywork-Reward-Llama-3.1-8B(^7^77[https://huggingface.co/Skywork/Skywork-Reward-Llama-3.1-8B.](https://huggingface.co/Skywork/Skywork-Reward-Llama-3.1-8B.)) (Liu et al., ), which is top-ranked in RewardBench leaderboard (Lambert et al., ), as the reward oracle.

Epistemic reward model. We build ERM on top of a pretrained $0.4$B transformer (Jiang et al., ), by removing its head and adding an ensemble of MLPs. The size of ensemble is set to $K=20$, and all MLPs contain 2 hidden layers of 128 nodes. Note that the ERM is chosen to be much smaller than the reward oracle following Dwaracherla et al. (), which reflects the fact that human preferences can be more complex than what the agent can model. The regularization coefficient $\lambda$ is fixed to be $0.5$ after a coarse hyperparameter search.

Data. We employ the widely adopted TL;DR dataset (Stiennon et al., ) for our experiments. It consists of Reddit posts as prompts, and the agent is required to give summaries that align with human preferences. We fix $50$k prompts for training and limit the query budget to $50$k as well.

DAP methods. We adopt three DAP methods (direct optimizers) to thoroughly validate our algorithm, including DPO (Rafailov et al., ), IPO (Azar et al., ) and SLiC (Zhao et al., ).

Baselines. We include the offline and online variants of different DAP methods as baselines, which are studied by Guo et al. (). Additionally, we compare with two active exploration baselines built on online DPO: APL (Muldrew et al., ) and XPO (Xie et al., ). We omit the comparison with SELM (Zhang et al., ) since SELM and XPO share a very similar algorithmic design.

Metrics. We use the win rate of agent’s responses against reference responses judged by the reward oracle as the performance metric. This metric can reflect both the agent’s cumulative regret and anytime regret (i.e., average performance). In the E&E setting, we measure the “online” win rate of the agent’s dueling responses that are executed during experience collection and take the average. In the BAI setting, we measure the “offline” win rate by evaluating the latest agent’s responses given a fixed set of holdout prompts periodically. We mainly focus on the BAI setting because crowdsourcing seems a major scenario for most practitioners, and present one set of experiments for comparing different exploration strategies in both settings. When the comparison is only made within a model scale, we report the relative win rate against the initial STF models. When the comparison is across scales (Figure 1 Left), we report the absolute win rate against the ground truth responses in the dataset.

Hyperparameters. We set $\beta=0.1$ for DPO and $\beta=0.2$ for SLiC and find they are robust for all scales. We tune $\beta$ from $\{0.2,0.3,0.5,1.0\}$ for IPO across scales and report the best performing results. We sample $M=20$ on-policy responses with a temperature $\eta=0.7$ during training, and use greedy decoding for offline evaluation (BAI’s metric). We use the Adam optimizer with learning rate of $5e-7$ and cosine scheduling, and set the batch size to be $128$. We initialize the mixture ratio $\gamma$ of SEA to be $1$ and adjust it to $0.7$ after a burn-in period of $1$k samples. To reproduce baselines (APL and XPO), we follow the recommended hyperparameters from their papers.

Statistical significance. There are various factors to introduce randomness during online learning. We thus launch $3$ independent runs for every experiment with different random seeds. All the results are reported with mean and standard error to indicate their statistical significance.

Computational resources. Experiments at all scales are conducted on a single machine with 8 A100 GPUs to run the learner and actors. We additionally host a separate remote server with workers spawned on 16 A100 GPUs for the oracle RM(^8^88We utilize the Kubernetes service for routing requests to multiple Mosec (Yang et al., ) instances.), so that it can be queried by all concurrently running experiments. All experiments conducted for this research consume about 2 A100 GPU years.

## Appendix E Supplementary materials

We include a comparison of prior works (Table 2) and an example of ChatGPT’s active exploration (Figure 7) in this section.

**Table 2: A summary of prior work. $\pi_{\theta}$ denotes the proposal policy that is continuously updated based on newly collected preference data, while $\pi_{\beta}$ denotes a fixed proposal policy. Algorithms that encompass online interaction (Property 1), active exploration (Property 2), and learnable $\pi_{\theta}$ offer the best sample efficiency. Notably, only three methods (listed at the bottom of the table) satisfy these characteristics, and we include them for comparisons in our experiments.**
|  | Method | Exploration | Interaction | Proposal Policy |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|  | Active | Passive | Online | Iterative | Offline | $\pi_{\theta}$ | $\pi_{\beta}$ |  |
| RL<br>Optimizer | Christiano et al. () |  | ✓ |  | ✓ | ✓ | ✓ |  |
| Stiennon et al. () |  | ✓ |  | ✓ | ✓ | ✓ |  |  |
| Bai et al. () |  | ✓ |  | ✓ | ✓ | ✓ |  |  |
| Ouyang et al. () |  | ✓ |  | ✓ | ✓ | ✓ |  |  |
| Direct<br>Optimizer | Zhao et al. () |  | ✓ |  |  | ✓ | ✓ |  |
| Rafailov et al. () |  | ✓ |  |  | ✓ | ✓ |  |  |
| Azar et al. () |  | ✓ |  |  | ✓ | ✓ |  |  |
| Meng et al. () |  | ✓ |  |  | ✓ | ✓ |  |  |
| Xu et al. () |  | ✓ |  | ✓ |  | ✓ |  |  |
| Guo et al. () |  | ✓ | ✓ |  |  | ✓ |  |  |
| Mehta et al. () | ✓ |  | ✓ |  |  |  | ✓ |  |
| Das et al. () | ✓ |  | ✓ |  |  |  | ✓ |  |
| Melo et al. () | ✓ |  | ✓ |  |  |  | ✓ |  |
| Dwaracherla et al. () | ✓ |  | ✓ |  |  |  | ✓ |  |
| Zhang et al. () | ✓ |  | ✓ |  |  | ✓ |  |  |
| Xie et al. () | ✓ |  | ✓ |  |  | ✓ |  |  |
| Muldrew et al. () | ✓ |  | ✓ |  |  | ✓ |  |  |

Figure: Figure 10: ChatGPT system asks for users’ preference feedback to strategically explore better answers. In this case, algorithms should be designed around the objective of minimizing cumulative regret (i.e., the E&E setting), because the quality of both responses generated by the system affects user experience.
Refer to caption: extracted/5986906/assets/chat-gpt-online-feedback.jpg

## Peer Reviews

confidence: 4
contribution: 3
initial_rating: 5
presentation: 3
questions: - Do you have results that can showcase this method on a variety of tasks and many different datasets? How generalizable is this method (in terms of how well it works)?
soundness: 3
strengths: + The paper builds upon the direction of aligning LLMs that considers the epistemic uncertainty of the reward function and utilizing the variance to guide the model to collect preference data in directions that maximally obtains information.
+ The algorithm is sound and theoretically solid. They build upon well performing methods for uncertainty estimates using the ensemble reward model method.
+ The results shown are promising (although see weakness for caveats).
summary: The paper considers the problem of aligning LLMs to humans via online interaction and in a sample efficient manner that minimizes the overall human annotations consumed. It proposes a practical algorithm that can be implemented and using the tldr dataset shows that it can achieve extremely high win-rates when compared against the baseline alignment algorithm.
weaknesses: - The main weakenss of this paper is the lack of siginificant experimentation. The paper only considers the summarization task with the tldr dataset. It does not consider more diversity in tasks/datasets and does not utilize some of the most common tasks in the LLM literature (e.g., reasoning, code, general knowledge). Even within summarization, it does not consider > 1 datasets. Improvements in one dataset is typically very limiting.

---

confidence: 2
contribution: 3
initial_rating: 6
presentation: 3
questions: Please see the last part.
soundness: 3
strengths: 1.	The paper studies the LLM alignment problem from an online view. It is reasonable to formulate the problem as a contextual dueling bandit problem. 
2.	The paper is inspired by the classic Thompson sampling algorithm to actively explore the preference function and proposes a corresponding version suitable for real-world application.
3.	The paper builds a learning system for studying methods in online LLM alignment. This provides efficient tools for the community on this research line.
summary: This paper studies the online alignment for LLMs. It formulates the LLM alignment as a contextual dueling bandit problem. It proposes a Thompson sampling-like algorithm for both the regret minimization and best arm identification setting. For the challenge encountered when implementing this algorithm including the model constraints, the intractable operation to sample a posterior and argmax action, the paper proposes corresponding solutions to enable real-world application. Finally, the authors build a learning system for studying methods in online LLM alignment and compare the proposed method with available baselines in different scale levels of experiments. The proposed method shows superior sample efficiency compared with baselines.
weaknesses: 1.	In Line 383, the authors claim they omit a baseline SELM since it shares a very similar algorithmic design as XPO. This is generally not an acceptable reason for excluding a baseline comparison.

---

confidence: 4
contribution: 2
initial_rating: 6
presentation: 3
questions: see above.
soundness: 3
strengths: This paper is nicely written and well-executed. The details are well-presented.
summary: This paper considers explorations by approximate TS in LLM alignment.
weaknesses: This paper is a bit incremental and the idea is well expected. The contextual bandit formulation is well-known and the implementation of TS using ensemble is pretty straightforward.  

There are multiple key questions this paper fails to answer:

1. Why ensemble on the top of DPO makes sense and how good the uncertainty estimation is? This is not a standard supervise learning problem. This paper lacks a way to directly measure it. I do not think ensemble + X can quantify uncertainty in every problem.  

2. The reward model is too small (0.4B) and the base model Pythia family is outdated such that the empirical result may become useless in a practical setting. It is very common that the benefit of active exploration could disappear when the base model and reward model become much stronger. 

3. The baseline number is not comparable with other literatures since the author uses its own oracle reward model. There are tons of implementation details that could be hidden for other baselines. I think it would be good to have an apple-to-apple comparison with the same setting in the original DPO paper.

---

confidence: 3
contribution: 2
initial_rating: 3
presentation: 2
questions: Concretely, in what ways does SEA differ from APL? How do you explain the large increase in sample efficiency?
soundness: 2
strengths: - The contextual dueling perspective is interesting, insightful, and to the best of my knowledge, new.
- The paper does a good job of covering the most relevant related literature, and how it relates to the proposed approach.
- The description is very limited with no details in the supplementary material, but it is possible that the testbed they develop to evaluate different approaches is a valuable contribution in its own right
summary: This paper frames the problem of aligning LLMs with pairwise preferences as a contextual dueling bandit problem. The authors propose a method that adapts a well-know & effective bandit algorithm, Thompson sampling (TS), to LLMs. This is not trivial, because TS requires maintaining and sampling from a belief over reward functions. To address this, the authors provide tractable approximations. They evaluate their proposed approach empirically on LLMs of various sizes, and provide comparisons to related work.
weaknesses: - The writing could be improved significantly; parts of the paper are unclear, imprecise, and many details are omitted and should at least be present in the supplementary materials. A non-exhaustive list of examples:
    - line 144: "based on a binary stochastic feedback $z$" -> z is never referred to anywhere outside of this line as far as I see
    - line 196: "offline RL" -> I think the authors might be conflating offline RL with offline preference collection. RLHF typically uses online RL. PPO is an online algorithm.
    - I struggle to make sense of Figure 3, for example I fail to understand how (d) is meant to differ from (b).
- The posterior approximation scheme (Eq. 9) is not well motivated. I can see it is computationally attractive, but why do we believe this is a reasonable way to approximate the posterior? A cursory glance at the papers mentioned around Eq. 9 did not help. Since this is one of the central components of the proposed approach, I would expect a more rigorous justification here.
- The experiments are comprehensive, but I struggle to take them at face value. Unfortunately, few details are provided, neither in the main text, nor in the supplementary materials.
    - There are design decisions involved in setting up baselines, and these are not discussed.
    - I can't reconcile any of the curves in Figure 6 with the curves in Figure 5.
- Some of the metrics are problematic, as I see it. The "online win rate" (line 387) would make a model that deliberately samples poor responses look great.

Meta-review: This paper introduces Sample-Efficient Alignment (SEA), a novel algorithm to align large language models (LLMs) with human preferences sample-efficiently. The problem is formulated as a contextual dueling bandit framework, and the SEA algorithm leverages Thompson Sampling with deep ensembles for uncertainty estimation. The authors present extensive experiments across three LLM scales and three preference learning algorithms, demonstrating the proposed method's superior sample efficiency compared to baseline methods. The work also provides a practical learning system for online alignment research.

Reviewers raised concerns about limited task diversity, inadequate baseline comparisons, particularly the omission of SELM, and incremental novelty. While the authors added experiments (e.g., UltraFeedback and AlpacaEval 2.0) and improved writing, reviewers found these changes insufficient to address broader generalization, weak comparability, and lack of rigor. Presentation issues were also noted, although some partial improvements were made in the revisions. Based on the common consensus, therefore, I would recommend the authors submit to the next suitable venue addressing all the concerns once all the necessary modifications are incorporated.

Decision: Reject