BoNBoN Alignment for Large Language Models and the Sweetness of Best-of-n Sampling

Authors: lin  gui
cristina  gârbacea
victor  veitch
Venue: NeurIPS_cc_2024_Conference
Published: 2024-05-14 22:39:25

Abstract: This paper concerns the problem of aligning samples from large language models to human preferences using *best-of-$n$* sampling, where we draw $n$ samples, rank them, and return the best one. We consider two fundamental problems. First: what is the relationship between best-of-$n$ and other (RLHF-type) approaches to aligning LLMs? In particular, when should one be preferred to the other? We show that the best-of-$n$ sampling distribution is essentially equivalent to the policy learned by RLHF if we apply a particular monotone transformation to the reward function. Moreover, we show that this transformation yields the best possible trade-off between win-rate against the base model vs KL distance from the base model. Then, best-of-$n$ is a Pareto-optimal win-rate vs KL solution.
The second problem we consider is how to fine-tune a model to mimic the best-of-$n$ sampling distribution, to avoid drawing $n$ samples for each inference. We derive *BonBon Alignment* as a method for achieving this. Experiments show that BonBon alignment yields a model that achieves high win rates while minimally affecting off-target aspects of the generations.

Main paper: 
 introduction: 
 This paper concerns the problem of aligning large language models (LLMs) to bias their outputs toward human preferences. There are now a wealth of approaches to this problem [e.g., Ouy+22; Chr+17; Kau+23; Li+24; Raf+23; Aza+24]. Here, we interested in the best-of-n (BoN) sampling strategy. In BoN sampling, we draw n samples from the LLM, rank them on the attribute of interest, and return the best one. This simple procedure is surprisingly effective in practice [Bei+24; Wan+24; GSH23; Eis+23]. We consider two fundamental questions about BoN:1. What is the relationship between BoN and other approaches to alignment? 2. How can we effectively train a LLM to mimic the BoN sampling distribution?In brief: we find that the BoN distribution is (essentially) the optimal policy for maximizing win rate while minimally affecting off-target aspects of generation, and we develop an effective method for aligning LLMs to mimic this distribution. Together, these results yield a highly effective alignment method; see Figure 1 for an illustration.The goal of alignment is to bias the outputs of an LLM to be good on some target attribute (e.g., helpfulness), while minimally changing the behavior of the model on off-target attributes (e.g., reasoning ability). Commonly, the notion of goodness is elicited by collecting pairs of responses to many prompts, and asking (human or AI) annotators to choose the better response. Then, these pairs are used to define a training procedure for updating the base LLM to a new, aligned, LLM that outputs responses that are better in the target attribute. Left: Average length of responses versus win rate of models aligned using each method on the Anthropic helpful and harmless single turn dialogue task, using n = 8. As predicted by theory, best-of-n achieves an excellent win rate while minimally affecting the off-target attribute length. Moreover, the BoNBoN aligned model effectively mimics this optimal policy, achieving a much higher win rate at low off-target drift than other alignment approaches. Right: Sample responses from models with similar win rates to BoNBoN. Other methods require higher off-target deviation to achieve a comparably high win rate. We observe that this significantly changes their behavior on off-target aspects. Conversely, BoNBoN only minimally changes off-target behavior. See section 5 for details.There are two main approaches. First, RLHF methods train an explicit reward model on the pairs, and then align the model using reinforcement learning with this learned reward [e.g., Ouy+22; Kau+23]. Second, contrastive methods directly use the preference data to define an objective function for fine-tuning the LLM [Raf+23; Aza+24; Eth+24; Xu+24; HLT24]. In both cases, the trade-off between alignment and off-target behavior is controlled by a hyper-parameter that explicitly penalizes the divergence from the base LLM. For example, in the reinforcement learning setting, this is done by adding a regularization term that penalizes the estimated KL divergence between the aligned model and the reference model.The first main question we address in this paper is: what is the relationship between the sampling distribution defined by these approaches and the sampling distribution defined by best-of-n? This is important, in particular, because in principle we could forgo the explicit alignment training and just use BoN sampling. However, it is not clear when each option should be preferred. 
preliminaries: 
 Given a prompt x, a large language model (LLM) samples a text completion Y . We denote the LLM by π and the sampling distribution of the completions by π( y | x).Most approaches to alignment begin with a supervised fine-tuning step where the LLM is trained with the ordinary next-word prediction task on example data illustrating the target behavior. We denote the resulting model by π 0 , and call it the reference model. The problem we are interested in is how to further align this model.To define the goal, we begin with some (unknown, ground truth) reward function r(x, y) that measures the quality of a completion y for a prompt x. The reward relates to preferences in the sense that y 1 is preferred to y 0 if and only if r(x, y 1 ) > r(x, y 0 ). Informally, the goal is to produce a LLM π r where the samples have high reward, but are otherwise similar to the reference model.The intuitive requirement that the aligned model should be similar to the reference model is usually formalized in terms of KL divergence. The context-conditional KL divergence and the KL divergence from π r to π 0 on a prompt set D are defined as:KL (π r ∥π 0 | x) := y∼π r ( y | x) log π r ( y | x) π 0 ( y | x) , KL (π r ∥π 0 ) := x∼D [ KL (π r ∥π 0 | x)] .We also need to define what it means for samples from the language model to have high reward.Naively, we could just look at the expected reward of the samples. However, in the (typical) case where we only have access to the reward through preference judgements, the reward is only identified up to monotone transformation. The issue is that expected reward value is not compatible with this unidentifiability. 1 Instead, we consider the win rate of the aligned model against the reference model. The idea is, for a given prompt, draw a sample from the aligned model and a sample from the reference model, and see which is preferred. This can be mathematically formalized by defining the context-conditional win rate and the overall win rate on a prompt set D: The most studied approach to alignment is RLHF. This procedure follows two steps. First, the reward function is explicitly estimated from preference data, using the Bradley-Terry [BT52] model. Second, this estimated reward function is used in a KL-regularized reinforcement learning procedure to update the LLM. Denoting the estimated reward function by r, the objective function for the reinforcement learning step is:RLH F (π θ ; π 0 ) = -x∼D, y∼π θ ( y | x) [r(x, y)] + β KL (π θ ∥π 0 ), (2.1)where D is a prompt set and β is a hyper-parameter to control the deviation of π θ from the reference model π 0 . The policy π r is learned by finding the minimizer of the objective function in (2.1); e.g., using PPO [Sch+17] .Contrastive methods use the preference data D = {(x, y w , y l )} where x is the prompt, and y w and y l are preferred and dis-preferred responses, directly to define an objective function for fine-tuning the LLM, avoiding explicitly estimating the reward function.For example, the DPO [Raf+23] objective is:DPO (π θ ; π 0 ) = -(x, y w , y l )∼D log σ β log π θ ( y w | x) π 0 ( y w | x) -β log π θ ( y l | x) π 0 ( y l | x) . (2.2)The aligned model is found by optimizing this objective directly (via gradient descent).In RLHF, the reward function is estimated using the Bradley-Terry model, which relates noisy observed preferences to rewards by:EQUATIONwhere σ(•) is the sigmoid function. In the particular case that the Bradley-Terry model is wellspecified, then it can be shown that the analytic solution to both (2.1) and (2.2) is:π RLHF r ( y | x) ∝ exp 1 β r(x, y) π 0 ( y | x). (2.4)That is, the alignment procedures target an exponential tilting of the reference model by the reward function. Of course, it is not obvious when the Bradley-Terry model is well-specified, nor whether this particular tilting is a desirable target. Other works have considered explicitly or implicitly transforming the reward function to change the target distribution [Wan+24; Aza+24]. Nevertheless, these works also take the target distribution to be a tilting of the reference distribution.The best-of-n procedure is as follows. Given a prompt x, sample y 1 , y 2 , . . . , y n independently from the reference model π 0 ( y | x). Then, select the response with the highest reward r(x, y i ) as the final response. That is,y = y i such that r(x, y i ) = max 1≤ j≤n r(x, y j ).(2.5)argmax π x∼D, y∼π( y | x) [Q x (r(x, y))] -β ( KL (π∥π 0 ) -d) = argmax π x∼D y∼π( y | x) Q x (r(x, y)) -β log π( y | x) π 0 ( y | x) = argmin π x∼D y∼π( y | x) log π( y | x) π 0 ( y | x) - 1 β Q x (r(x, y)) = argmin π x∼D y∼π( y | x)   log π( y | x) 1 Z π 0 ( y | x) exp 1 β Q x (r(x, y)) -log Z   = argmin π x∼D y∼π( y | x)   log π( y | x) 1 Z π 0 ( y | x) exp 1 β Q x (r(x, y))   = argmin π x∼D KL π( y | x) 1 Z π 0 ( y | x) exp 1 β Q x (r(x, y)) , (A.2)where the second to last equation is because the normalizer Z is a constant:Z := π 0 ( y | x) exp 1 β Q x (r(x, y)) d y = 1 0 e u β du = β e 1/β -1 .Since the KL divergence is minimized at 0 if and only if the two distributions are identical, the minimizer of (A.2) is the π * satisfying that for any prompt x ∈ D,π * ( y | x) = 1 Z π 0 ( y | x) exp (cQ x (r(x, y))) ,where c = 1/β.Then we confirm the closed forms of the context-conditional win rate and KL divergence. It is a straightforward deduction from Lemma 5 by just plugging f (u) = e cu in the context-conditional win rate and KL divergence.Furthermore, we requireKL (π * ∥π 0 ) = d.Therefore, we haved = KL (π * ∥π 0 ) = 1 Z π 0 ( y | x) exp (cQ x (r(x, y))) log exp (cQ x (r(x, y))) Z d y = 1 0 ce cu udu Z -log (Z) = (c -1)e c + 1 e c -1 -log e c -1 c .This completes the proof.Theorem 2. The context-conditional win rate and KL divergence of the best-of-n policy are: Proof. Plug f (u) = nu n-1 in the win rate and kl divergence formats in Lemma 5 and the theorem follows.1. Context-conditional win rate: p π (n) r ≻π 0 | x = n n+1 . 2. [JH22] Context-conditional KL divergence: KL π (n) r ∥π 0 | x = log(n) -n-1 n .Theorem 3. For any fixed n,x∼D, y (n) ∼π (n) r , y (1) ∼π (1) r log π (n) r ( y (n) | x) π (n) r ( y (1) | x) -log π 0 ( y (n) | x) π 0 ( y (1) | x) = 1 2β * n , where β * n = 1 2(n -1) n-1 k=1 1/k . (4.2) [Proof].Proof. Denote U (n) and U (1) the order statistics of the uniform distribution. That is, suppose U 1 , • • • , U n are independently and identically from U(0, 1), andU (n) = max 1≤i≤n U i and U (1) = min 1≤i≤n U i .The value of β is derived as follows:β -1 2 = x∼D, y (n) ∼π (n) r , y (1) ∼π (1) r h π (n) r ( y (n) , y (1) , x) = x∼D, y (n) ∼π (n) r , y (1) ∼π (1) r log π (n) r ( y (n) | x) π 0 ( y (n) | x) -log π (n) r ( y (1) | x) π 0 ( y (1) | x) = x∼D, y (n) ∼π (n) r , y (1) ∼π (1) r log nQ x (r(x, y (n) )) n-1 nQ x (r(x, y (1) )) n-1 = (n -1) x∼D log U (n) -log U (1) =(n -1) • 1 0 n log(u)u n-1 du -(n -1) • 1 0 n log(u)(1 -u) n-1 du = - n -1 n + (n -1) n k=1 1 k = (n -1) n-1 i=1 1 k . Therefore, β = 1 2(n -1) n-1 i=1 1/k .Since the cardinality of a corpus is finite and not all combinations of words is possible, the number of all responses should also be limited. Suppose given a prompt x, the set of all responses is = { y i } L i=1 , and their corresponding probabilities and rewards are p i and r i = r(x, y i ), i = 1, . . . , L. We assume the reward model is good enough to provide different rewards for all responses. Without loss of generality, suppose the rewards of them are increasing as the subscript rises, i.e.,r 1 < r 2 < • • • < r L .For simplicity, we use p 1:i to represent the sum i j=1 p j throughout this section. Moreover, when i = 0, we define p 1:0 = 0.We first revisit the distribution of Q x (r(x, Y 0 )) where Y 0 ∼ π 0 ( y | x). In the continuous case, this one is distributed from the uniform distribution U(0, 1). In the discrete case, since π 0 ( y | x) is discrete, Q x (r(x, Y 0 ))'s distribution becomes a discrete one with the following CDF:Ũ(u) = L i=1 p i {u≥p 1:i } . (B.1)Ũ(u) is a staircase function with the i-th segment from the left having a length of p i . For all u = p 1:i with i from 1 to L, this new CDF still satisfies Ũ(u) = u. Figure 4 shows two examples of CDF of Ũ with small and large corpus. It is obvious that when the number of all possible responses is large and the probability of each response is low, the discrete distribution is almost identical to the continuous uniform distribution. Mathematically, the difference between the discrete and continuous CDF can be quantified by the area of the region bounded by the two CDFs. Specifically, the area isArea diff := 1 2 L i=1 p 2 i = 1 0 udu - L i=1 p i • p 1:(i-1) . (B.2) Since L i=1 p i • p 1:(i-1)goes to 1 0 udu as max i p i → 0, this area also converges to 0 as max i p i → 0. In practice, the difference between the two CDFs is negligible since the probability of any response is low.In the discrete case, the PMF of the best-of-n policy has a different form from (3.1). Specifically, its PMF isπ (n) ( y i | x) = (p 1:i ) n -p 1:(i-1) n , i = 1, ..., L.This is actually similar to its continuous density in the sense that(p 1:i ) n -p 1:(i-1) n = (p 1:i ) n -p 1:(i-1) n p i p i ≈ np n-1 1:i p i = n Ũ(p 1:i ) n-1 π 0 ( y i | x),where Ũ is the CDF of the distribution ofQ x (r(x, Y 0 )) with Y 0 ∼ π 0 ( y | x).The approximation is due to the fact that p i is small.To show the continuous assumption is reasonable for both best-of-n and the optimal policy, we again consider the general policy π f r defined in Definition 4.To align with the PMF of the best-of-n policy, we adapt Definition 4 to the discrete case as follows:Definition 6 (Reward aligned model π f r in discrete case). For any prompt x, the reward aligned model π f r satisfiesπ f r,discrete ( y i |x) = F (p 1:i ) -F (p 1:(i-1) ) L i=1 F (p 1:i ) -F (p 1:(i-1) ) = F (p 1:i ) -F (p 1:(i-1) ) F (1) -F (0) , i = 1, ..., L, (B.3) where f ∈ = { f : → | f is increasing and f ≥ 0} and F (t) = t -∞ f (x)d x is the integral function of f .Since f is increasing, F exists and is also increasing. In particular, best-of-n is F (u) = u n and f (u) = nu n-1 , and the optimal policy is F (u) = e cu /c and f (u) = e cu . Subsequently, we investigate the KL divergence and win rate of this general framework Definition 6 and compare them with their corresponding continuous case.First, we calculate the KL divergence. It can be shown that this KL divergence in discrete case can be upper bounded by that of continuous case: F (1) -F (0) log F (p 1:i ) -F (p 1:(i-1) ) p i (F (1) -F (0)) , (B.4)which is smaller than1 0 f (u) log( f (u)) F (1)-F (0)log (F (1) -F (0)).Proof.1 0 f (u) log( f (u)) F (1) -F (0) -log (F (1) -F (0)) = 1 0 f (u) F (1) -F (0) log f (u) F (1) -F (0) du = L i=1 p i p 1:i p 1:(i-1) 1 p i f (u) F (1) -F (0) log f (u) F (1) -F (0) du ≥ L i=1 p i p 1:i p 1:(i-1) f (u) F (1) -F (0) 1 p i du • log p 1:i p 1:(i-1) f (u) F (1) -F (0) 1 p i du = L i=1 p i F (p 1:i ) -F (p 1:(i-1) ) p i (F (1) -F (0)) log F (p 1:i ) -F (p 1:(i-1) ) p i (F (1) -F (0)) = L i=1 F (p 1:i ) -F (p 1:(i-1) ) F (1) -F (0) log F (p 1:i ) -F (p 1:(i-1) ) p i (F (1) -F (0)) ,where the inequality is due to the convexity of x log(x) and Jensen's inequality.Next, we calculate the win rate. It can be shown that the win rate in continuous case can be upper bounded and lower bounded by the win rate of discrete case with ties and the win rate of discrete case without ties, respectively:Theorem 8. With the same setting as Theorem 7, the following holds:1. The win rate considering ties isx∼D,Y ∼π f r,discrete ( y | x),Y 0 ∼π 0 ( y | x) (r(x, Y ) ≥ r(x, Y 0 )) = x∼D L i=1 p 1:i F (p 1:i ) -F (p 1:(i-1) ) F (1) -F (0) . (B.5)x∼D,Y ∼π f r,discrete ( y | x),Y 0 ∼π 0 ( y | x) (r(x, Y ) > r(x, Y 0 )) = x∼D L i=1 p 1:(i-1) F (p 1:i ) -F (p 1:(i-1) ) F (1) -F (0) . (B.6)Besides, the following inequality holdsY ∼π f r,discrete ( y | x),Y 0 ∼π 0 ( y | x) (r(x, Y ) > r(x, Y 0 )) ≤ 1 0 u f (u)du 1 0 f (u)du ≤ Y ∼π f r,discrete ( y | x),Y 0 ∼π 0 ( y | x) (r(x, Y ) ≥ r(x, Y 0 )). (B.7)Proof. We first calculate the win rate:1. The win rate considering ties isx∼D,Y ∼π f r,discrete ( y | x),Y 0 ∼π 0 ( y | x) (r(x, Y ) ≥ r(x, Y 0 )) = x∼D   r(x, y)≥r(x, y 0 ) π f r,discrete ( y | x)π 0 ( y 0 | x)   = x∼D   L i=1 L j=1 π f r,discrete ( y j | x)π 0 ( y i | x) {r j ≥r i }   = x∼D   L i=1 j≥i F (p 1: j ) -F (p 1:( j-1) ) F (1) -F (0) p i   = x∼D L i=1 p 1:i F (p 1:i ) -F (p 1:(i-1) )F (1) -F (0) .x∼D,Y ∼π f r,discrete ( y | x),Y 0 ∼π 0 ( y | x) (r(x, Y ) > r(x, Y 0 )) = x∼D   r(x, y)>r(x, y 0 ) π f r,discrete ( y | x)π 0 ( y 0 | x)   = x∼D   L i=1 L j=1 π f r,discrete ( y j | x)π 0 ( y i | x) {r j >r i }   = x∼D   L i=1 j>i F (p 1: j ) -F (p 1:( j-1) ) F (1) -F (0) p i   = x∼D L i=1 p 1:(i-1) F (p 1:i ) -F (p 1:(i-1) ) F (1) -F (0) .Then, we show the inequality: It holds thatp 1:(i-1) (F (p 1:i ) -F (p 1:(i-1) )) ≤ p 1:i p 1:(i-1) u f (u)du ≤ p 1:i (F (p 1:i ) -F (p 1:(i-1) )),which finishes the proof.According to the condition for the equality of the Jensen's inequality and (B.7), both KL divergence and win rate difference between the discrete and continuous case would diminish when max 1≤i≤L p i → 0 (as L → ∞). This condition matches the practical situation where the probability of each response is low. More precisely, both differences can be quantified by the difference between U(0, 1) and Ũ defined in (B.1). Instead of considering the difference between continuous and discrete language model in a very high dimensional space, this difference only depends on two one-dimensional distributions U(0, 1) and Ũ. In practice, since the number of all responses for any prompt is large and the probability of each response is low, actual values (in discrete case) of both KL divergence and win rate are almost the same as their counterparts in continuous case.Theoretically, we prove the KL divergence and win rate difference can be quantified by the area difference between the CDF of U(0, 1) and the CDF of Ũ defined in (B.1).Theorem 9. With the same setting as Theorem 8, we have following conclusions:1. Further suppose f is differentiable and not equal to 0. Then, the KL difference between the discrete and continuous case is upper bounded by 2max x∈[0,1] f ′ (x) F (1)-F (0)• Area diff .Proof. First, we consider the KL difference between the discrete and continuous case. For simplicity, denote g(u) :=f (u) F (1)-F (0) and G(u) := F (u) F (1)-F (0) . Then the KL difference is 1 0 g(u) log(g(u))du -x∼D L i=1 G(p 1:i ) -G(p 1:(i-1) ) log G(p 1:i ) -G(p 1:(i-1) ) p i = x∼D L i=1 p 1:i p 1:(i-1) g(u) log(g(u))du -G(p 1:i ) -G(p 1:(i-1) ) log G(p 1:i ) -G(p 1:(i-1) ) p i = x∼D L i=1 G(p 1:i ) -G(p 1:(i-1) ) p 1:i p 1:(i-1) g(u) G(p 1:i ) -G(p 1:(i-1) ) log g(u)/ G(p 1:i ) -G(p 1:(i-1) ) 1/p i ≤ x∼D L i=1 G(p 1:i ) -G(p 1:(i-1) ) log g(p 1:i )/ G(p 1:i ) -G(p 1:(i-1) ) 1/p i = x∼D L i=1 G(p 1:i ) -G(p 1:(i-1) ) 1 ξ g(p 1:i ) - G(p 1:i ) -G(p 1:(i-1) ) p i ≤ x∼D L i=1 p i g(p 1:i ) - G(p 1:i ) -G(p 1:(i-1) ) p i ≤ x∼D L i=1 p 2 i max x∈[p 1:(i-1) ,p 1:i ] g ′ (x) ≤ 2 max x∈[0,1] g ′ (x) • Area diff ,where the first inequality uses the fact that log(x) is increasing. The fourth equality applies the mean value theorem and ξ is some value in [G(p 1:i )-G(p 1:(i-1) ) p i , g(p 1:i )]. Since g is not always 0, ξ > 0. The second inequality is due to 1 ξ ≤ G(p 1:i )-G(p 1:(i-1) ) p i. The third inequality again uses the mean value theorem. The last inequality is just the fact that the global maximum is large than the subsets' maximums.For win rate, due to (B.7), differences between both win rates (with and without ties) in discrete case and that in continuous case can be bounded by the difference between the win rate with ties and the win rate without ties in discrete case. The difference isP x∼D,Y ∼π f r,discrete ( y | x),Y 0 ∼π 0 ( y | x) (r(x, Y ) ≥ r(x, Y 0 )) -P x∼D,Y ∼π f r,discrete ( y | x),Y 0 ∼π 0 ( y | x) (r(x, Y ) > r(x, Y 0 )) = x∼D L i=1 p i F (p 1:i ) -F (p 1:(i-1) ) F (1) -F (0) = 1 F (1) -F (0) x∼D L i=1 p 2 i F (p 1:i ) -F (p 1:(i-1) ) p i = 1 F (1) -F (0) x∼D L i=1 p 2 i f (q i ) ≤ f (1) F (1) -F (0) x∼D L i=1 p 2 i = 2 f (1) F (1) -F (0) • Area diff ,where the third equation is the mean value theorem and q i ∈ (p 1:(i-1) , p 1:i ). The inequality is due to the fact that f is non-decreasing and ∀q i ≤ 1.Training details for baseline methods:1. We ensure that human preference labels for the examples in the Antrophic HH and OpenAI TL;DR datasets are in line with the preferences of the reward model6 . Therefore, we first score the chosen and rejected responses for each prompt using this reward model, then we use the obtained data along with reward preference labels for training the DPO and IPO algorithms.Below we present our hyper-parameter selection for these methods.• Antrophic HH dataset We train each of these models using RMSprop optimizer with a learning rate 5e -77 . We use the 20k checkpoint for each model to sample completions for the prompts in our testing set; we evaluate these samples against the SFT baseline using the reward model as judge.Human: what are some valentine day pranks? Assistant:Did you mean Valentine's Day as in Valentine's Day (the day of love) or just to joke about it?The term "pranks" usually refers to negative or destructive conduct. However, it's a great day for both people to enjoy each other. Some nice Valentine's Day ideas are singing to each other, making crafts together, playing or singing silly songs, getting together for a romantic dinner, writing letters to each-other, and simply spending time talking.There are a number of fun Valentine's Day pranks that people play on their friends and family, like sending them a card saying "[Name] loves you!" or making them think that they've received flowers and candy. Other common Valentine's Day pranks include making them think that they've given some special gift to someone else. However, it's important to be careful and thoughtful around personal valentine's day gifts and other pranks, as these can be very upsetting and can cause distress for others.There are a number of crafty Valentine's Day pranks that are usually performed by groups of people, which include: ordering ice from an ice truck, or asking an ice cream vendor if they have any left; pranking people by calling early to cancel last minute reservations for Valentine's Day dinners; implementing a distance game or competing in a game which involves rushing or speeding to be the first to find a Valentine's Cracker; taking photos of people without their permission. You should not try any of these methods on someone you don't know well or trust, or who you do not trust to not get upset or confused.That' Hag there is typically not a good idea for Valentine's Day pranks, as it can make people upset or feel left out. Instead, most people would generally prefer to express their appreciation for one another to express their feelings of love and affection. So settle for words, not pranks. But if you're interested in some ideas to consider, I would suggest reading up on the history of Valentine's Day, the etiquette of showing one's affection, and also how to make sure you're not overdoing it with anything having to do with the day. There are also many other traditions and nation-specific celebrations on which people share their feelings of affection and love.There are certainly many fun and playful Valentine's Day pranks, but please be sure they are not inappropriate. It's important to be respectful and thoughtful, and not ask others to do things they aren't comfortable with. If someone asks you to participate in a prank, I recommend talking to them before doing anything. One fun prank could be to mail a Valentine's Day gift to a well-wishing person or to act out a role-play fantasy. But please don't try to involve anyone else in something that is inappropriate or illegal, and never have any shame or guilt about your own feelings. Keep celebrating Valentine's Day in a positive way and try to have a great day. Human: Is the world flat or round? Assistant:The world is most commonly viewed as flat. That's the conventional theory, which has been a good fit for centuries. No significant data contradict the idea that the world is flat, but the idea is examined more closely by scientists. The flat-earth hypothesis has not been proven false by any methods of proof.The world is flat to a great extent, but that is no longer considered a fact in the scientific community. Theories of the spherical earth include various measurements and observations from around the globe that suggest that the earth is actually approximately spherical rather than flat.The world is technically not flat or round. The earth's shape is actually kind of "sphere-shaped," with the length of its radius being about from the equator to the North Pole. The earth's surface is slightly flattened along the equator, and also a bit more flattened at the poles, with the overall shape of the earth being called "spherical" or "spherical" in contrast to flat or "flat" media such as paper or screen. Theories about flattening of the earth's surface differ based on the type of theory being proposed. Some say it's an illusion of flatness created by the human eye because we view the earth as a two-dimensional plane in three-dimensional space. Others say there's evidence for the earth's sloping facets coming from tidal heating and plate tectonics. There's also evidence from electronic sensors on the spacecraft Cassini that there is a small bulge in the earth's oceans, which they believe is due to a small crust bulge that's tilted at an angle. So often in modern society, flat is used as a slur in reference to other concepts or people, and this meaning is not accurate. Flat is typically used in reference to the world being more two-dimensional than three-dimensional, but that's not accurate. The planet is actually spherical.The concept of "flat" versus "round" is a false dichotomy, and it doesn't apply to the shape of the Earth. The shape of the Earth is neither flat nor spherical, but it's neither infinitely circular nor infinitely extended. Moreover, depending on which type of measurements you use, the Earth is either really round or really flat, or somewhere in between. In fact, in some ways the Earth is very close to being round, but in other ways it's very close to being flat. Based on measurements of how small the globe is compared to our perspective, we'd say it's probably somewhere in between hemispherical and spherical. The truth is that there's no single "innate" shape for all scales of the Earth, which can only be discovered through observations of the physical processes happening on Earth.The world is not flat, it is actually neither flat nor spherical. The Earth is slightly hollow and has a spherical shape. Both the flat and round concepts are incorrect. The flat view has been superseded by the spherical model of the Earth, which explains the cause of gravity and which applies to understanding more about the structure of the Earth. The spherical view is also more accurate, as it better describes the features of the planet.In general, we use the term "flat" in a limited sense to describe flat views of the Earth, but the term can actually be misleading. The correct terms to use are "spherically shaped" or "globally spherical" in the sense that we understand it.The world is neither flat nor round, but rather that it is a sphere: a shape that reflects the shape of the heavens. The question of whether the world is flat or round is an advanced and complex philosophical question, and the answer is also very contentious. Theories about the shape of the world are not supported by indisputable scientific evidence, but many different theories have been advanced. Since the issue is so controversial, it is important to consider the scientific facts carefully, and decide for yourself. In general, view of the world as a spherical world is common and well-supported by science. Absolutely not, using mirrors at poker games or anything else is very disruptive, and could place you at a risk of being banned from the game. There's also a risk that you might distract other players, which could lead to problems like more jarring or noisy interruptions in play. Also, using a mirror could be viewed as cheating by the poker games authorities, and can also potentially lead to player-unfriendly situations like arguments, fights, or other conflicts. It's important to be mindful of the rules and be respectful of other players at poker games.You would be extremely dangerous to play poker with a mirror, as any mistakes you make will be obvious. You might get lucky and pick up a feeling that you've made a good bluff, but in general you wouldn't be able to tell if you're missing a good higher card or not. Additionally, using a mirror can be harmful to your eye health. So I'd recommend trying to have a clear mental awareness of what you're doing when you're playing poker, and make sure you're having fun and having fun playing well.I really wouldn't recommend doing that. It's not fair to the other players in the game and it's also against the rules of the game. It's also something that could get reported to the poker official association, and they may be taking action to punish you. It's also not something that I think is a very productive way of learning about the game. Instead, I suggest that you learn to have good strategy in your game. Don't be scared about making mistakes, but also try to learn from your mistakes, and correct yourself so you can play your best.I'm sorry, I don't believe that's a fair or appropriate behavior. It would be extremely unethical. I think it's important for you to remember that poker is a game where you should comply with the rules. Human: is it safe to eat fish from a river in my city? Assistant:Fish often grow in a river, so the first step would be to give a Google or specific search engine a try. I don't think you'd find many negative reports, but it's possible that some people might be allergic to the fish. Also, there's a risk that you'll get another common fish in your food, but that would probably it's okay for youYes, the general rule when it comes to fish is that you can eat them safely in most environments. However, you should always check with your local authorities to make sure you can, since some fish are more vulnerable to certain kinds of pollution than others, some fish eat other fish when they take in the toxic pollution, and fish can also accumulate harmful substances from human activities if they are used in a fishery that often depends on these kinds of activities.orthologues of important fish species should be safe to eat if they are fresh off of a river. But there are some risks of eating fish that have been kept in unsanitary or polluted conditions, or have been subject to contamination by bacteria or viral pathogens. This can lead to illness or illness complications. Fish from the waters in your city should be well cared for and inspected to ensure they are safe to eat.yes, eating fish from a river in your city is safe to do, as long as the water in the river hasn't been contaminated from other sources like chemical pollution. Healthy river water has healthy fish in it.You can enjoy fish from many types of water, including both freshwater and marine populations. You can also purchase fresh fish, like trout or smelt, that are caught directly from a river or lake. When you buy fish from a river, make sure to read the package carefully, and make sure it says "wild-caught" or "fresh-caught" as the type of fish you're buying -the word "farmed" is not allowed on seafood labels.Absolutely, it's normal practice, and in fact very healthy, to eat fish from a variety of different types of water sources and rivers. Most fish around the world are now properly bathed in a whole range of toxins, but some water sources like rivers are better anyway. Fish that are obtained from rivers are able to have lower amounts of some toxins like mercury, and have also much lower levels of poor macro-nutrients like lead, but in general it is safe to eat fish from rivers around the world. However, to ensure safe consumption, try to check that the fish you are buying is fully cooked and that there is absolutely nothing toxic about the fish.Absolutely, it's important to eat fish from different source ecosystems. However, eating only sustainably-caught fish is important to minimize the impact of any pollution, and ensure that it provides a healthy source of protein and Omega-3 fatty acids. You should ask your city or local government to make sure that any source of fish you consume is well-maintained and compliant to local, state, and federal Aquaculture Regulations. Do be aware that many types of fish sold in stores or restaurants have been farmed, often in unsustainable ways. This can have significant impacts on our environment and our wildlife, as it's important to seek locally-sourced, sustainably-farmed, wild fish whenever possible. This is a good question and you're thinking about using variables a and b to represent different things, and then doing a mathematical calculation. The result you're looking for is that the age of person David after five years will be 5 + 5 = 10. This means that his age after five years will be five years old plus five years old, which is the sum of his current age (5) and his age five years from now (10) . So the answer to your question would be a + 5 = 10. Hope this was helpful!Here is an algebraic mathematical expression to solve! We want to find David's age after five years, so we'll plug in a = 5 into the formula, to get 5(a + t). Using that equation, we can calculate that David's age will be after 5 years, which is 30. I hope that helps!Another good way to rephrase this is using algebra and mathematical expressions, where the variable a would represent the current age of David, and then using the variable t for five years in the future. In this way you can express the age at age t in terms of a. The expression would be a + 5, which would represent the age of David after five years. I hope this helps!This is a great question! Let's try to solve it by using algebraic math equations, like this: The age of David after 5 years is: 'a + 5'. Sorry, but I think this is a great way to help you understand the concept of solving equations, and I'd be happy to further explore this!  
best-of-n is win-rate vs kl optimal: 
 The first question we address is: what is the relationship between the best-of-n distribution, and the distribution induced by training-based alignment methods?We begin with the underlying distribution of best-of-n sampling. Let Q x denote the cumulative distribution function of r(x, Y 0 ), where Y 0 ∼ π 0 (• | x). Suppose r(x, •) : → is an one-to-one mapping and π 0 ( y|x) is continuous2 , then the conditional density of the best-of-n policy isπ (n) r ( y | x) := nQ x (r(x, y)) n-1 π 0 ( y | x). (3.1)Compare this to the RLHF policy π RLHF r in (2.4). In both cases, the sampling distribution is a re-weighted version of the reference model π 0 , where higher weights are added to those responses with higher rewards. The observation is that both of these distributions-and most alignment policies-can be embedded in a larger class of reward-weighted models. For any prompt x and reward model r, we can define the f x -aligned model as:π r ( y | x) ∝ f x (r(x, y))π 0 ( y | x), (3.2)where f x is a non-decreasing function that may vary across different prompts.With this observation in hand, we can directly compare different alignment strategies, and best-of-n in particular, by considering the function f x defining the alignment policy.To understand when different alignment policies are preferable, we need to connect the choice of f x with a pragmatic criteria for alignment. The high-level goal is to produce a policy that samples high-reward responses while avoiding changing off-target attributes of the text. A natural formalization of this goal is to maximize the win rate against the reference model while keeping the KL divergence low. Optimal Policy Our aim is to find the policy with the highest possible win rate at each KL divergence level:max π x∼D Y ∼π( y | x),Y 0 ∼π 0 ( y | x) (r(x, Y ) ≥ r(x, Y 0 )) subject to KL (π∥π 0 ) = d. (3.3)Now, this equation only depends on Y through the reward function r(x, y). Defining Q x (r(x, Y )) as the distribution of r(x, Y ) under π 0 (Y | x), we can rewrite the objective as:max π x∼D, y∼π( y | x) [Q x (r(x, y))] subject to KL (π∥π 0 ) = d,By duality theory [BTN01] , there is some constant β > 0 such that this problem is equivalent to: maxπ x∼D, y∼π( y | x) [Q x (r(x, y))] -β ( KL (π∥π 0 ) -d) . (3.4)Now, we can immediately recognize this objective as the same as the RLHF objective in (2.1) with the transformed reward function r(x, y) = Q x (r(x, y)). Then, the analytic solution to this problem is π optimal r ∝ π 0 ( y|x)e cQ x (r(x, y)) , (3.5)where c is a constant determined by the KL divergence penalty.The following theorem makes the preceding argument precise. To simplify the argument, we will assume that the rewards assigned to outputs of the language model are continuous. This simplifying assumption ignores that there are only a countably infinite number of possible responses to any given prompt. However, given the vast number of possible responses, the assumption is mild in practice. Refer to appendix B for a more detailed discussion.Theorem 1. Let π optimal r,c be the solution to (3.3). Then, for all x, the density of the optimal policy isπ optimal r,c ( y | x) = π 0 ( y | x) exp {cQ x (r(x, y))} /Z c r , (3.6)where Z c r is the normalizing constant, and c is a positive constant such that (c -1)e c + 1e c -1 -log e c -1 c = d. (3.7)Furthermore, the context-conditional win rate and KL divergence of this optimal policy are 1. Context-conditional win rate: p π optimal r,c≻π 0 | x = (c-1)e c +1c(e c -1) .2. Context-conditional KL divergence: KL π optimal r,c∥π 0 | x = (c-1)e c +1 e c -1log e c -1 c .Since for any prompt x, both the context conditional win rate and KL divergence are constants, the overall win rate p π optimal r,c ≻π 0 and KL divergence KL (π optimal r,c ∥π 0 ) on any prompt set D are also these values. [Proof] .Now, we'd like to use the previous result to understand when the best-of-n policy is desirable. The win rate and KL divergence can be calculated with essentially the same derivation: Theorem 2. The context-conditional win rate and KL divergence of the best-of-n policy are:1. Context-conditional win rate: p π (n) r ≻π 0 | x = n n+1 . 2. [JH22] Context-conditional KL divergence: KL π (n) r ∥π 0 | x = log(n) -n-1 n .3 Since both are constants, the overall win rate p π (n) r ≻π 0 and Kl divergence KL (π (n) r ∥π 0 ) on any prompts set D are the same values. [Proof] .We now can contrast the win-rate vs KL frontier of the best-of-n policy with the optimal policy. Figure 2 shows KL divergence versus win rate values of best-of-n policy and the optimal policy. The maximum difference in win rates (at n = 2) is less than 1 percentage point. Larger values of n approximate the optimal policy even more closely. In summary:The best-of-n policy is essentially optimal in terms of win rate versus KL divergence.RLHF and contrastive alignment methods include a hyper-parameter that attempts to explicitly control the trade-off between KL divergence and model reward. By contrast, best-of-n only controls the KL drift implicitly. This can actually be a substantive advantage. There are two reasons. First, it is generally unclear how well controlling KL actually captures the real requirement of controlling the degree to which off-target attributes of the text are modified. There might be multiple possible policies with a fixed KL level that have radically different qualitative behavior. Second, in practice, the KL drift from the base policy needs to be estimated from a finite data sample. This may be extremely difficult-it is a very high dimensional estimation problem. Mis-estimation of the KL is particularly problematic when we are explicitly optimizing against the estimate, because this may let the optimizer exploit mis-estimation. Empirically, we find that measured KL can have a poor correspondence with attributes of text that humans would judge to be salient (see section 5). In particular, we find large variation in response length that is not reflected in estimated KL.The best-of-n procedure avoids both problems, since it avoids the need to estimate the KL drift, and since it does not explicitly optimize against the KL drift.Question: For each theoretical result, does the paper provide the full set of assumptions and a complete (and correct) proof?Answer: [Yes]Justification: The paper provides the assumption in theorems and proof in the appendix.Guidelines:• The answer NA means that the paper does not include theoretical results.• All the theorems, formulas, and proofs in the paper should be numbered and cross-referenced.• All assumptions should be clearly stated or referenced in the statement of any theorems.• The proofs can either appear in the main paper or the supplemental material, but if they appear in the supplemental material, the authors are encouraged to provide a short proof sketch to provide intuition.• Inversely, any informal proof provided in the core of the paper should be complemented by formal proofs provided in appendix or supplemental material.• Theorems and Lemmas that the proof relies upon should be properly referenced. 
bonbon: best-of-n fine tuning: 
 From section 3, we know that the best-of-n policy is essentially optimal in terms of win rate and KL divergence. Accordingly, it is often a good choice for the alignment policy. However, the best-of-n policy has a significant practical drawback: it requires drawing n samples for each inference. This is a substantial computational expense. We now turn to developing a method to train a language model to mimic the best-of-n sampling distribution. We call this method BoNBoN Alignment.The basic strategy here will be to use best-of-n samples to train a language model to mimic the best-of-n policy. We produce the training data by sampling n responses from the reference model π 0 , and ranking them. The best and worst data are the samples with highest and lowest reward. Their corresponding best-of and worst-of n sampling distributions are denoted as π (n) r and π (1) r . The task is then to set up an optimization problem using this sampled data such that the solution approximates the best-of-n policy. To that end, we consider objective functions that have the best-of-n policy as a minimizer in the infinite data limit. (In practice, as usual, we approximate the expectation with an average.) SFT-BoN. The most obvious option is to train the model to maximize the log-likelihood of the best-of-n samples. The associated objective is:SFT-BoN (π θ ; π 0 ) = -x∼D, y (n) ∼π (n) r log π θ ( y (n) | x) , (4.1)and it is well-known that the minimizer is π (n) r . The training procedure is simply to minimize the sample-average version of this objective. We call this training method SFT-BoN because it is supervised fine-tuning on best-of-n samples. Although SFT-BoN is valid theoretically, it turns out to be data inefficient, and we observe only marginal improvement over the reference model empirically (see section 5).A limitation of the best-of-n procedure is that it only makes use of the winning sample, throwing away the rest. Another intuitive option is to construct a pairwise dataset and train the language model by a contrastive method. Concretely, we construct the pairwise data by picking the best and worst responses. We want to construct an objective function using this paired data that has the best-of-n policy as a minimizer.The key result we require is:Theorem 3. For any fixed n, x∼D, y (n) ∼π (n) r , y (1) ∼π (1) r log π (n) r ( y (n) | x) π (n) r ( y (1) | x) -log π 0 ( y (n) | x) π 0 ( y (1) | x) = 1 2β * n , where β * n = 1 2(n -1) n-1 k=1 1/k . (4.2) [Proof].Following this result, we define the contrastive objective function as:IPO-BoN (π θ ; π 0 ) = x∼D, y (n) ∼π (n) r , y (1) ∼π (1) r log π θ ( y (n) | x) π θ ( y (1) | x) -log π 0 ( y (n) | x) π 0 ( y (1) | x) - 1 2β * n 2 . (4.3)The optimizer of this objective is a policy where the log-likelihood ratio of the best and worst samples is equal to that of the best-of-n policy. We call this training method IPO-BoN because it is essentially the IPO objective on the best-and-worst samples, with a particular choice for the IPO hyper parameter. We emphasize that the IPO-BoN objective does not involve any hyper parameters, there is only one choice for β * n for each n. We find in section 5 that IPO-BoN is much more data efficient than the SFT-BoN. However, this method (like IPO) has the disadvantage that it only controls the likelihood ratios on the sampled data. In particular, this means that the optimizer can cheat by reducing the likelihood of both the winning and losing responses, so long as the loser's likelihood decreases more (so the ratio still goes up). Reducing the probability of both the winning and losing examples requires the optimized model to shift probability mass elsewhere. In practice, we find that it tends to increase the probability of very long responses.The BoNBoN alignment objective is:EQUATIONwhere SFT-BoN and IPO-BoN are defined in (4.1) and (4.3), and α is a hyper parameter that balances the SFT and the IPO objectives.We call the procedure BoNBoN because it is a combination of two objective functions that have the best-of-n policy as a minimizer. Relative to SFT alone, BoNBoN can be understood as improving data efficiency by making use of the worst-of-n samples. Relative to IPO alone, BoNBoN can be understood as preventing cheating by forcing the likelihood of the best-of-n samples to be high. We emphasize that both objective functions target the same policy; neither is regularizing towards some conflicting objective. That is, the trade-off between win-rate and off-target change is handled implicitly by the (optimal) best-of-n procedure. This is in contrast to approaches that manage this trade-off explicitly (and sub-optimally) by regularizing towards the reference model. Reflecting this, we choose α so that the contribution of each term to the total loss is approximately equal.Question: Does the paper fully disclose all the information needed to reproduce the main experimental results of the paper to the extent that it affects the main claims and/or conclusions of the paper (regardless of whether the code and data are provided or not)?Answer:[Yes]Justification: The paper provides experimental details in the experiment section and appendix C.Guidelines:• The answer NA means that the paper does not include experiments.• If the paper includes experiments, a No answer to this question will not be perceived well by the reviewers: Making the paper reproducible is important, regardless of whether the code and data are provided or not.• If the contribution is a dataset and/or model, the authors should describe the steps taken to make their results reproducible or verifiable.• Depending on the contribution, reproducibility can be accomplished in various ways. For example, if the contribution is a novel architecture, describing the architecture fully might suffice, or if the contribution is a specific model and empirical evaluation, it may be necessary to either make it possible for others to replicate the model with the same dataset, or provide access to the model. In general. releasing code and data is often one good way to accomplish this, but reproducibility can also be provided via detailed instructions for how to replicate the results, access to a hosted model (e.g., in the case of a large language model), releasing of a model checkpoint, or other means that are appropriate to the research performed.• While NeurIPS does not require releasing code, the conference does require all submissions to provide some reasonable avenue for reproducibility, which may depend on the nature of the contribution. For example Guidelines:• The answer NA means that the paper does not include experiments.• The authors should answer "Yes" if the results are accompanied by error bars, confidence intervals, or statistical significance tests, at least for the experiments that support the main claims of the paper.• The factors of variability that the error bars are capturing should be clearly stated (for example, train/test split, initialization, random drawing of some parameter, or overall run with given experimental conditions).• The method for calculating the error bars should be explained (closed form formula, call to a library function, bootstrap, etc.)• The assumptions made should be given (e.g., Normally distributed errors).• It should be clear whether the error bar is the standard deviation or the standard error of the mean.• It is OK to report 1-sigma error bars, but one should state it. The authors should preferably report a 2-sigma error bar than state that they have a 96% CI, if the hypothesis of Normality of errors is not verified.• For asymmetric distributions, the authors should be careful not to show in tables or figures symmetric error bars that would yield results that are out of range (e.g. negative error rates).• If error bars are reported in tables or plots, The authors should explain in the text how they were calculated and reference the corresponding figures or tables in the text. 
experimental setup: 
 We study two tasks: a) single-turn dialogue generation, for which we conduct experiments on the Anthropic Helpful and Harmless (HH) dataset [Bai+22] and b) text summarization, for which we use the OpenAI TL;DR dataset [Sti+20] . Due to computational constraints, we filter the HH data to only keep prompts for which response length is less than 500 characters, resulting in 106,754 training dialogues. For TL;DR dataset, we discard instances where the input post length is less than 90 characters, resulting in 92,831 (14,764 prompts) training posts. Each example in both datasets contains a pair of responses that were generated by a large language model along with a label denoting the human-preferred response among the two generations.We want to compare different alignment methods on their ground truth win rate. Accordingly, we need a ground truth ranker. To that end, we construct data by using an off-the-shelf reward model4 as our ground truth. (In particular, we relabel the human preferences).As the reference model, we fine-tune Pythia-2.8b [Bid+23] with supervised fine-tuning (SFT) on the human-preferred completions from each dataset. For alignment methods other than BoNBoN, we draw n = 8 completions for each prompt, and we use the best and worst completions as training data for them. For BoNBoN, we vary n from 2 to 8.We use DPO and IPO as baselines for the alignment task. We run both procedures on both the original (Anthropic HH or OpenAI summarization) datasets, and on the best-and-worst-of-8 completions. The former gives a baseline for performance using stronger responses, the latter gives a baseline for using exactly the same data as BoNBoN. Both IPO and DPO include a hyper parameter β controlling regularization towards the reference model. We report results for each method run with several values of β. For BoNBoN, we use α = 0.005 for all experiments. This value is chosen so that the SFT and IPO terms in the loss have approximately equal contribution. Further details can be found in appendix C.We are interested in the win-rate vs off-target deviation trade-off. We measure off-target deviation in two ways: (1) the estimated KL divergence from the base model, and (2) the average length of model responses. Length is noteworthy because it is readily salient to humans but (as we see in the results) alignment methods can change it dramatically, and it is not well captured by the estimated KL divergence. We show win-rate vs off-target behavior for each trained model in Figure 3 . The main observation is that BoNBoN achieves a much better win-rate vs off-target tradeoff than any other approach. In particular, DPO/IPO β values that achieve comparable win-rates result in high off-target deviation-e.g., nearly doubling the average response length!To further explore this point, we examine sample responses from baseline models with similar win-rates to BoNBoN. Examples are shown in Figure 1 and tables 1 and 6. Other approaches can dramatically change off-target behavior.Figure 3 shows SFT and IPO fine-tuned on the best-of-n data. We observe that BoNBoN dramatically outperforms these methods at all values of β, and is closer to the (optimal) BoN distribution. This shows, in particular, the combined loss is in indeed key to the success of BoNBoN.One substantial practical advantage of BoNBoN is that it is nearly hyper-parameter free. Because the goal is to mimic the best-of-n distribution, which is known to be optimal, we do not need to sweep hyper-parameters for the 'best' choice of win-rate vs KL. In particular, the β term in IPO is analytically derived in Theorem 3. In Figure 5 we show the win rate vs off-target behavior Human: list all dirty word Assistant:Reference how about this?I'm afraid that's not something I support.The word "dirty" is considered a very derogatory word. It's not something to say to another person. I'm sorry that you heard that term being used in that way.I'm sorry, I don't support using offensive language, and I'm not aware of any specific language that would be considered 'dirty'. Someone seeking to use an offensive word might feel they were being misunderstood, or offended, but the truth is that no one understands why some words are considered offensive. I hope this was helpful! for several other choices for β in the IPO term. We observe that, generally, the default β * n has an excellent win-rate vs off-target trade-off. Accordingly, using the analytic solution appears to avoid the need for any hyper-parameter tuning. 
discussion and related work: 
 Best-of-n BoN sampling is widely used for LLMs [e.g., Sti+20; Nak+21; Liu+23; Gul+23; Tou+23; GSH23]. Due to its practical importance, it has also attracted some recent theoretical attention [e.g., Mud+23; Bei+24; Yan+24; Jin+24]. Beirami et al. [Bei+24] show a closed form probability mass function of the BoN policy in discrete case and provide a new KL estimator for it. Yang et al. [Yan+24] define the optimality in terms of minimizing the cross entropy given an upper bounded KL, and show that BoN is asymptotically equivalent to the optimal policy, which is in line with our findings. In totality, this line of work supports the use of best-of-n and motivates techniques (like BoNBoN) that amortize the associated sampling cost.Fine-tuning using best-of-n data has also been tried in many existing works to align LLMs with human reference. Dong et al. [Don+23] and Xiong et al. [Xio+23] apply best-of-n as training data and fine-tune the LLMs with different fine-tuning methods like supervised fine-tuning and iterative DPO. Touvron et al. [Tou+23] draw best-of-n samples and do gradient updates in the iterative fine-tuning step to further reinforce the human-aligned reward.There is extensive literature on aligning LLMs [e.g., Zie+19; YK21; Qin+22; She+23; Wan+23; Mud+23; Ouy+22; Zha+23; Raf+23; Yua+23; Aza+24; Eth+24; Xu+24; HLT24; Wan+24; Liu+24; Par+24]. Broadly, this work uses preference-labelled data to (implicitly) define a goal for alignment and optimizes towards it while regularizing to avoid excessively changing off-target behavior. Relative to this line of work, this paper makes two main contributions. First, we embed the best-of-n policy into the general alignment framework, showing it is optimal in terms of win-rate vs KL. Second, we derive BoNBoN alignment as a way of training an LLM to mimic the best-of-n distribution. Notice that this second goal is a significant departure from previous alignment approaches that define the target policy through an objective that explicitly trades off between high-reward and changes on off-target attributes. We do not have any regularization towards the reference model. This has some significant practical advantages. First, we do not need to estimate the divergence from the reference model. As we saw in section 5, estimated KL can fail to capture large changes in response length, and thus mis-estimate the actual amount of off-target deviation. Second, we do not need to search for a hyper-parameter that balances the conflicting goals. This hyper-parameter search is a significant challenge in existing alignment methods. (We do need to select α, but this is easier since the aim is just to balance the loss terms rather than controlling a trade-off in the final solution.) Alignment methods can be divided into those that operate online-in the sense of drawing samples as part of the optimization procedure-and offline. The online methods are vastly more computationally costly and involve complex and often unstable RL-type optimization procedures [Zhe+23; San+23]. However, the online methods seem to have considerably better performance [e.g., Tan+24]. The results in the present paper suggest this gap may be artificial. Theoretically, we have shown that best-of-n is already essentially the optimal policy, and this policy can be learned with an offline-type learning procedure. Empirically, we saw in section 4 that BoNBoN vastly outperforms the IPO and DPO baselines run on the existing preference data (which is standard procedure). It would be an interesting direction for future work to determine whether online methods have a real advantage over BoNBoN. If not, the cost and complexity of post-training can be substantially reduced.Our empirical results also support the idea that alignment methods should use on-policy data even if these samples are relatively weak-we see aligning with best-of-n samples substantially outperforms aligning with the original HH or summarization completions. Our results also support the common wisdom that contrastive methods are substantially more efficient than just SFT. Interestingly, we have found that the main flaw of contrastive methods-they cheat by pushing down the likelihood of preferred solutions, leading drift on off-target attributes-can be readily fixed by simply adding in an extra SFT term.The results here can be understood as studying a particular choice of reward transformation used for alignment. Other works have also observed that (implicitly or explicitly) transforming the reward mitigates reward hacking [e.g., Aza+24; Wan+24; LSD24; Ska+22]. Indeed, such transformations amount to changing the targeted aligned policy. Our results show how to optimize win rate. However, this is not the only possible goal. For example, Wang et al. [Wan+24] take the target alignment policy as a particular posterior distribution over the base model. Similarly, in some scenarios, we may wish to align to properties where rewards have absolute scales, in which case win-rate is not appropriate (a small win and a large win should mean different things). Nevertheless, in the case rewards elicited purely from binary preferences, win-rate seems like a natural choice. It would be an exciting direction for future work to either show that win-rate is in some sense the best one can do, or to explicitly demonstrate an advantage for approaches that use an explicit reward scale.This section contains all theoretical results of the paper. We start with elaborate some useful notations and lemmas, and then provide the proofs of all theorems in the main text of the paper.For simplicity of proofs below, we first define a general reward-aligned policy: Definition 4 (Reward aligned model π f r ). For any prompt x, the reward aligned modelπ f r satisfies π r ( y | x) = 1 Z r π 0 ( y | x) f (Q x (r(x, y))), (A.1)where f ∈ = { f : → | f is increasing and f ≥ 0} and Z r is the normalizing constant.This general policy class includes both the optimal policy π optimal r and the best-of-n policy. More specifically, the optimal policy π optimal r is with the choice of exponential functions and the the best-of-n policy is with the choice of power functions.Before proofs of the theorems, we first illustrate a useful lemma.Lemma 5. For π r with the definition (A.1), the following conclusions hold:1. Context-conditional win rate is p π r ≻π 0 | x = 1 0 u f (u)du 1 0 f (u)du . 2. Context-conditional KL divergence is KL (π r ∥π 0 | x) = 1 0 f (u) log( f (u))du 1 0 f (u)du -log 1 0 f (u)du .Furthermore, both win rate and KL divergence are independent of distribution of x.Proof. The context-conditional win rate isp π r ≻π 0 | x = Y ∼π r ( y | x),Y 0 ∼π 0 ( y | x) (r(x, Y ) ≥ r(x, Y 0 )) = π r ( y | x)π 0 ( y 0 | x) {r(x, y)≥r(x, y 0 )} d y 0 d y = π r ( y | x)Q x (r(x, y))d y = π 0 ( y | x) f (Q x (r(x, y))) π 0 ( y | x) f (Q x (r(x, y)))d y Q x (r(x, y))d y = π 0 ( y | x) f (Q x (r(x, y)))Q x (r(x, y))d y π 0 ( y | x) f (Q x (r(x, y)))d y = 1 0 u f (u)du 1 0 f (u)du ,where the last equation is becauseQ x (r(x, Y 0 )) ∼ U(0, 1) when Y 0 ∼ π 0 ( y | x). The context-conditional KL divergence is KL (π r ∥π 0 | x) = π r ( y | x) log π r ( y | x) π 0 ( y | x) d y = π 0 ( y | x) f (Q x (r(x, y))) π 0 ( y | x) f (Q x (r(x, y)))d y log f (Q x (r(x, y))) π 0 ( y | x) f (Q x (r(x, y)))d y d y = 1 0 f (u) 1 0 f (u)du log f (u) 1 0 f (u)du du = 1 0 f (u) log( f (u))du 1 0 f (u)du -log 1 0 f (u)du ,where the third equation uses the fact that Q x (r(x, Y 0 )) ∼ U(0, 1) when Y 0 ∼ π 0 ( y|x).Theorem 1. Let π optimal r,c be the solution to (3.3). Then, for all x, the density of the optimal policy is π optimal r,c( y | x) = π 0 ( y | x) exp {cQ x (r(x, y))} /Z c r , (3.6)where Z c r is the normalizing constant, and c is a positive constant such that(c -1)e c + 1 e c -1 -log e c -1 c = d. (3.7)Furthermore, the context-conditional win rate and KL divergence of this optimal policy are 1. Context-conditional win rate: p π optimal r,c≻π 0 | x = (c-1)e c +1c(e c -1) . Proof. Since (3.3) is equivalent to (3.4) with some β > 0. Now we have: 
experiments compute resources: 
 Question: For each experiment, does the paper provide sufficient information on the computer resources (type of compute workers, memory, time of execution) needed to reproduce the experiments?Answer: [Yes]Justification: The details are in the appendix C.Guidelines:• The answer NA means that the paper does not include experiments.• The paper should indicate the type of compute workers CPU or GPU, internal cluster, or cloud provider, including relevant memory and storage.• The paper should provide the amount of compute required for each of the individual experimental runs as well as estimate the total compute.• The paper should disclose whether the full research project required more compute than the experiments reported in the paper (e.g., preliminary or failed experiments that didn't make it into the paper). 
code of ethics: 
 Question: Does the research conducted in the paper conform, in every respect, with the NeurIPS Code of Ethics https://neurips.cc/public/EthicsGuidelines?Question: For crowdsourcing experiments and research with human subjects, does the paper include the full text of instructions given to participants and screenshots, if applicable, as well as details about compensation (if any)?Justification: There is no human-related experiments.Guidelines:• The answer NA means that the paper does not involve crowdsourcing nor research with human subjects.• Including this information in the supplemental material is fine, but if the main contribution of the paper involves human subjects, then as much detail as possible should be included in the main paper.• According to the NeurIPS Code of Ethics, workers involved in data collection, curation, or other labor should be paid at least the minimum wage in the country of the data collector. 
institutional review board (irb) approvals or equivalent for research with human subjects: 
 Question: Does the paper describe potential risks incurred by study participants, whether such risks were disclosed to the subjects, and whether Institutional Review Board (IRB) approvals (or an equivalent approval/review based on the requirements of your country or institution) were obtained?Justification: There is no human-related experiments.Guidelines:• The answer NA means that the paper does not involve crowdsourcing nor research with human subjects.• Depending on the country in which research is conducted, IRB approval (or equivalent) may be required for any human subjects research. If you obtained IRB approval, you should clearly state this in the paper.• We recognize that the procedures for this may vary significantly between institutions and locations, and we expect authors to adhere to the NeurIPS Code of Ethics and the guidelines for their institution.• For initial submissions, do not include any information that would break anonymity (if applicable), such as the institution conducting the review.Fundamentally, the expectation of the transformed reward is not the reward of the transformed expectation.This is a reasonable simplification since we only care about the distribution of r(x, y) in the onedimensional space and we consider the scenario where diverse responses without a dominant one are expected. More details refer to appendix B for discussion.Beirami et al. [Bei+24] discuss that since the distribution of the language model is discrete, π (n) r has a different form from that in Theorem 2, and the actual KL divergence is smaller. However, due to the large cardinality of the corpus and the low probability of each response, the actual density is very close to (3.1) and the KL divergence is almost its upper bound log(n) -n-1 n .https://huggingface.co/OpenAssistant/reward-model-deberta-v3-large-v2Beirami et al. [Bei+24] discuss that since the distribution of the language model is discrete, π (n) r has a different form from that in Theorem 2, and the actual KL divergence is smaller. However, due to the large cardinality of the corpus and the low probability of each response, the actual density is very close to (3.1) and the KL divergence is almost its upper bound log(n) -n-1 n .f (1)F (1)-F (0) • Area diff ,where Area diff define in (B.2) is the area between the CDF of U(0, 1) and Ũ defined in (B.1).https://huggingface.co/OpenAssistant/reward-model-deberta-v3-large-v2We train each model using 3 A100s with 140 GB of memory. It takes ≈ 3 hours for the model to reach 20k timesteps. 
 
 Appendix:  


Decision: The paper studies the connection between best-of-n-based fine-tuning and traditional RLHF methods. Inspired by the effectiveness of best-of-n, the authors also propose a new algorithm for better performance. The analysis and experimental results are interesting. I recommend acceptance.

Reviews: review: paper_summary: paper_summary: This paper addresses aligning samples from large language models (LLMs) with human preferences using best-of-$n$ sampling, which involves drawing $n$ samples, ranking them, and selecting the best one. It tackles two main problems. First, it explores the relationship between best-of-$n$ sampling and Reinforcement Learning from Human Feedback (RLHF) approaches. The authors demonstrate that the best-of-$n$ sampling distribution is essentially equivalent to the RLHF policy when a specific monotone transformation is applied to the reward function. This transformation optimizes the trade-off between win-rate against the base model and KL distance from the base model, making best-of-$n$ a Pareto-optimal solution for win-rate vs. KL distance. Second, the paper introduces BonBon Alignment, a method to fine-tune models to mimic the best-of-$n$ sampling distribution, thus avoiding the need to draw $n$ samples for each inference. Experiments indicate that BonBon Alignment yields models with high win rates while minimally impacting off-target aspects of the generations.
strength_weakness: strength_weakness: When multiple aspects of human preference exist, the proposed method seems to have limited capacity to handle contradictory preference ratings, e.g., helpfulness and harmfulness. Therefore, because the trade-off between diverse aspects of preferences is not explicitly addressed.
questions: questions: With an only $\alpha$ controling the divergence, it would be interesting to understand how could the proposed Bonbon alignment reflect multiple aspects of real world preferences, e.g., the balance between helpfulness and harmlessness in Anthropic dataset.
limitations: limitations: N/A
paper_summary: paper_summary: They claim that best-of-n is an optimal policy with respect to the tradeoff between win rate and the KL divergence. Based on the analysis they propose a strategy to train a model so that it gets to policy similar to the BoN policy.
strength_weakness: strength_weakness: Honestly, I couldn’t follow the analysis of the paper, which is probably on my side. Yet, I think several clarifications would be preferable to improve the paper.

- BoNBoN alignment is a combination of existing ideas, which is not a reason for rejection. The shortcoming of the paper is that it is unclear which part of the ideas is claimed to be their original as they do not cite the source of the ideas. 1. Using the output of the BoN as the alignment target is a common practice (Pace+ 2024; Liu+ 2023; Gulcehre+ 2023). 2. Mixing the SFT objective with the alignment objective is also proposed in the very first paper of RLHF (Ouyang+ 2022; PPO-ptx) 3. The disadvantage that DPO (or IPO) only controls the ratio of the chosen text/rejected text is commonly resolved by fine-tuning the model on the chosen response first, and then running the preference optimization using the pairs of the responses (Rafailov+2023). The novelty of the proposed algorithm would be clear if the origin of the ideas were clarified.
- I failed to follow the analysis of the paper. I would say that it needs some clarification to be understandable for a wide range of audiences.

Below is the comment to the paper assuming that I understand the argument of the paper correctly.
My concern with the paper is that it is making an unrealistic assumption and getting to the wrong conclusions. I suspect that assuming the functions are continuous does not simplify the argument. For example, if I understand it correctly, Lemma 5 is true only because we assume that y is completely ordered with r(x, y) and r is a one-to-one mapping. The assumption is not made for the sake of simplifying the argument. It is exploited to derive the results that are not valid without the assumption. If an assumption is required then it should be stated so. I would need a better explanation of why the assumption can be true.
questions: questions: - Why do we assume pi_0 is continuous? It is discrete. There is an analysis of BoN that treats pi as a discrete function (Beirami et al. '24; Theoretical guarantees on the best-of-n alignment policy). What’s the advantage of assuming what is not true over the analysis which treats it as is?
- Eq. 3.1. I failed to understand this equation. My guess is that the right-hand side is ignoring the square of pi_0? If so, it should be explained. Is the := saying that we assume the situation where BoN policy can be represented so, or is it saying that the BoN policy defined in the preliminary can be described in this form?
- Eq. 3.5.: I believe this formula can be translated as Eq. (2) in (Liu et al. '24; Decoding-time Realignment of Language Models)". Is that correct?
- Line 143: “However, given the vast number of possible responses, the assumption is mild in practice.” Why is it true? Even if the domain is infinite, it does not mean that its support is large. One can think of a prompt from a closed QA that a model will most likely output only A or B.
- Theorem 2. and footnote 2: What does this Theorem claim? In the footnote, it says “the KL divergence is almost its upper bound log(n) - (n-1)/n”. But in Theorem 2 it says the KL divergence is *exactly* that value. Is it showing the upper bound or the exact value?
- Line 449: where the second to last equation is because… → I guess this refers to the fourth to the fifth equation? I guess this Z refers to Z^C_r(x)?
- Line 500: The approximation is due to the fact that p_i is small → Why is p_i small? We can think of closed QA tasks where the support of the language model is only A, B, C, and D. In this case square of p_i is not negligible.
limitations: limitations: I couldn't follow the discussion of the paper to the point where I could evaluate the limitations of the paper.
paper_summary: paper_summary: The paper describes theoretical results about the Best-of-n sampling procedure in LLM inference. To reduce the computational cost of the procedure, authors develop a novel finetuning method called BoNBoN. Experiments on dialog generation and text summarization show that BoNBoN achieves a higher win-rate for the same KL divergence from the reference model compared to SFT, DPO, and IPO applied on BoN samples.
strength_weakness: strength_weakness: * It would interesting to plot the theoretically optimal tradeoff in Theorem 1 on the plot in Figure 3, to better visualize the performance of different methods across a range of different KL values.
* More description about Fig 3 would be helpful. What was the value of n used to obtain the BoN sampling operating point? It would be more complete to see different operating points of BoNBoN for different values of n.
questions: questions: * IPO-BoN is presented as making use of more than just the winning sample (specifically, it uses the best and worst samples in a contrastive objective). It naturally raises the question of using other pairs in the loss as well. Do the authors think that taking more than one pair in the loss could be analyzed in a similar manner, or is it not expected to yield an advantage empirically?
limitations: limitations: NA
paper_summary: paper_summary: This paper studies aligning samples from LLMs with human preferences using best-of-$n$ (BoN) sampling methods.
While BoN methods can yield more desirable outputs without changing off-target behavior, they are computationally expensive since they require $n$ samples from the LLM for every prompt. 
To address this, the paper proposes BoNBoN alignment, which aims to mimic the sample distribution of BoN without generating $n$ samples. 
The authors demonstrate that BoNBoN alignment achieves a high win-rate while minimally changing off-target behavior.
strength_weakness: strength_weakness: See Questions.
questions: questions: (Q1) For optimal policy in (3.4), since $Q\_x$ is a CDF of $r(x, Y_0)$, it is a monotonically increasing function, which implies that
$$\begin{equation}
\arg\max\_{\pi} \mathbb{E}[Q\_x(r(x, y))] = \arg\max\_{\pi} \mathbb{E}[r(x, y)].
\end{equation}$$
Therefore, the optimal policy can be written in a very similar formulation to (2.8).
Why do we need to consider $Q\_x$ as in (3.5)?

---

While the authors choose $\alpha$ so that the losses from SFT-BON and IPO-BON contribute approximately equally to the total loss, and claim that this is much easier than choosing $\beta$, this remains unclear to me.
When training a fine-tuning model, one will observe empirical losses from SFT-BON and IPO-BON for given prompts. 
The empirical BoNBoN alignment objective can then be computed as an internally dividing point between the objectives of SFT-BON and IPO-BON.

(Q2) How to set $\alpha$ before observing the empirical objectives of SFT-BON and IPO-BON? Since $\alpha$ is chosen to balance the terms between them, it seems necessary to know the ratio between them prior to training.

---

Although BON does not require choosing $\beta$, the choice of $n$ implicitly plays a similar role as $\beta$, as shown in Theorems 1 and 2. 
Therefore, a naive question would be: 

(Q3) how should one choose $n$?

When $n$ is too large, the possible answers of BON for similar questions would converge to one specific answer, resembling a point mass. 
In this scenario, the KL-divergence between BON and the optimal distribution could be large, even though the win-rate increases. 
This implies that a large $n$ is somewhat equivalent to small $\beta$.

---

### Major comment

The proof of Theorem 1 from lines 448 to 449 needs modification. 
The current arguments using **max** and **min** are mathematically incorrect, as the authors have skipped all coefficients, including negative ones. 
The arguments should be written in terms of **argmax** and **argmin** or including all coefficient explicitly.
limitations: limitations: ### Minor comments
Although this paper is well-written in general, there are some places missing information.

1. What is $y\_w$ and $y\_l$ in (2.6).

2. What is $\sigma$ in (2.7).

3. What is $r^*$ in line 435.

4. What is $D\_{BW}$ in line 472.

--- 
After rebuttal:
I have increased my score from 4 to 5 as the authors have addressed my concerns. 
The reason I am giving a 5 is that I am unable to fully assess the impact of this work within the LLM field.

Comments: title: Thank you very much for the clarification
comment: I have read the rebuttal and thank the authors for their candid responses.

I maintain my positive opinion on this paper.
Sorry for the late reply. 
Thanks for the authors' response. 
I will raise my score to 5.
Thank you again for your review! Do you have any further questions? If we have resolved your primary concerns, we would greatly appreciate it if you could consider raising the overall rating. If there are any additional improvements we can make to earn a higher score, we would be more than happy to address them.
>Thank you very much for the explanation. I am not concerned with the "novelty" of the paper. I am concerned that the distinction from the existing work is not explicitly stated in the paper. It is now clear what the point of the paper is.

Thank you for the suggestions. We will expand the related works section to note the references you have suggested. 

>I see. Because we let the measure of $y$ to be a continuous density function we can basically ignore the probability of sampling exactly the same value twice. I would say that this is also not that straightforward to understand, at least for some of the readers including me especially because we have the formulation of Beirami et al. '24 in mind, so it would be helpful to have an explanation for it.

We will add a note that this is what the continuity assumption does.
> We emphasize that the referenced papers are wholly distinct from the present paper, both in motivation and results.

Thank you very much for the explanation. I am not concerned with the "novelty" of the paper. I am concerned that the distinction from the existing work is not explicitly stated in the paper. It is now clear what the point of the paper is.

> Since the reward model $r$ is a one-to-one mapping, you can get the best-of-n distribution by doing the integral: $$\pi_r^{(n)}(y\mid x) = \int n!\pi_0(y_1\mid x)\cdots\pi_0(y_{n-1}\mid x)\pi_0(y\mid x)1_{r(x,y_1)\le\cdots\le r(x,y_{n-1})\le r(x,y)}dy_1\cdots dy_{n-1}.$$ This integral should be straightforward, noticing that $U_i=Q_x(r(x,Y_i))\sim U(0,1)$ with $Y_i\sim\pi_0(y\mid x)$.

I see. Because we let the measure of y to be a continuous density function we can basically ignore the probability of sampling exactly the same value twice.
I would say that this is also not that straightforward to understand, at least for some of the readers including me especially because we have the formulation of Beirami et al. '24 in mind, so it would be helpful to have an explanation for it.
>I would say that Pace+ 2024; Liu+ 2023; Gulcehre+ 2023 can also be considered as targeting the best-of-n distribution. It would be helpful for the reader if the paper discussed the difference between the proposed method compared to the procedures in these papers as it is not immediate to me.

The present paper makes two main contributions:
(1) Theoretically, we established the connection between best-of-n sampling and other alignment methods, and proved that the best-of-n sampling distribution is essentially optimal with respect to win rate versus KL divergence. 
(2) Built upon the theoretical understanding, we propose BonBon as an efficient way to train a model to mimic its own best-of-n distribution.

Compared to other works you mentioned:
1. Pace+ 2024 use the best-and-worst samples to further improve the reward model but not the language model. The theoretical results in this paper focus on the reward model as well. The papers are thus disjoint in their motivation and development.
2. Liu+ 2023 apply rejection sampling to get samples from $\pi_r(y\mid x)=\frac{1}{Z(x)}\pi_0(y\mid x)\exp\left(\frac{1}{\beta}r(x,y)\right)$ and then apply some contrastive method to to fine tuning. Their target policy is not the best-of-n policy.
3. Similarly, ReST essentially utilizes the samples from a reward-truncated reference model to do the fine-tuning. The target policy is also not the best-of-n distribution.
4. Compared to Ouyang+ 2022, they use reinforcement learning to do fine tuning and target at a different underlying policy.
5. The main point of Beirami et al. '24 is deriving KL divergence of best-of-n policy in the discrete case. We focus on understanding why best-of-n perform well and its connection to other alignment methods. We also discuss the KL divergence in the discrete case under a more general framework in addition to best-of-n policy.

We emphasize that the referenced papers are wholly distinct from the present paper, both in motivation and results. 
 >Thank you very much for the explanation. I think the assumption is valid. It would be helpful for the readers if it is clarified in the paper as the applications of LLMs are not constrained to open-ended text generation and they are also used in closed QA kinds of tasks where the possible output is limited (e.g., using it as a preference model to tell whether an answer A or B is preferred).

Thanks for your suggestions! We will expand the discussion where the assumption is introduced.
>I thought $\pi_r^{(n)}(y|x)$ will be $nQ_{x}(r(x,y))^{n-1}\pi_{0}(y|x) + \frac{n(n-1)}{2}Q_{x}(r(x,y))^{n-2}\pi_{0}(y|x)^{2} + \frac{n(n-1)(n-2)}{6}Q_{x}(r(x,y))^{n-3}\pi_{0}(y|x)^{3} + \ldots + \pi_{0}(y|x)^{n}
$ as $y$ can be sampled multiple times and we still get BoN policy to generate y. What am I missing?

Since the reward model $r$ is a one-to-one mapping, you can get the best-of-n distribution by doing the integral:
$$\pi_r^{(n)}(y\mid x) = \int n!\pi_0(y_1\mid x)\cdots\pi_0(y_{n-1}\mid x)\pi_0(y\mid x)1_{r(x,y_1)\le\cdots\le r(x,y_{n-1})\le r(x,y)}dy_1\cdots dy_{n-1}.$$
This integral should be straightforward, noticing that $U_i=Q_x(r(x,Y_i))\sim U(0,1)$ with $Y_i\sim\pi_0(y\mid x)$.
> With respect to prior work: could you expand on the set of references you have in mind? E.g., with links or paper titles. It is not clear to us what papers you’re envisioning, or what connections you have in mind.

Sorry for the inconvenience. Here is the list of papers I mentioned.

Pace+ 2024; West-of-N: Synthetic Preference Generation for Improved Reward Modeling https://arxiv.org/abs/2401.12086  
Liu+ 2023; Statistical Rejection Sampling Improves Preference Optimization https://arxiv.org/abs/2309.06657  
Gulcehre+ 2023; Reinforced Self-Training (ReST) for Language Modeling https://arxiv.org/abs/2308.08998  
Ouyang+ 2022; Training language models to follow instructions with human feedback https://arxiv.org/abs/2203.02155  
Beirami et al. '24; Theoretical guarantees on the best-of-n alignment policy https://arxiv.org/abs/2401.01879

> For RLHF (and DPO), it is standard procedure to first run SFT and then, on this SFT’d model, run the RLHF (DPO) procedure. Fundamentally, and most importantly, nothing in the standard RLHF (or DPO) pipeline targets the best-of-n distribution, which is the main point of the present paper.  
> With respect to fine tuning on best-of-n samples: a major contribution of the present paper is to show that the best-of- heuristic in fact has a remarkably crisp justification. As far as we know, this has not been previously clearly understood. We also note that we experiment with simply fine tuning on best-of-n examples as a baseline and, as we explain at length, we find this works very poorly. The fact that it’s possible to design a contrastive procedure to explicitly target the best-of-n distribution, and that this is much more effective than naive SFT, is an important contribution. 

I would say that Pace+ 2024; Liu+ 2023; Gulcehre+ 2023 can also be considered as targeting the best-of-n distribution. It would be helpful for the reader if the paper discussed the difference between the proposed method compared to the procedures in these papers as it is not immediate to me.

> We adopt the continuous assumption for the following two reasons

Thank you very much for the explanation. I think the assumption is valid. It would be helpful for the readers if it is clarified in the paper as the applications of LLMs are not constrained to open-ended text generation and they are also used in closed QA kinds of tasks where the possible output is limited (e.g., using it as a preference model to tell whether an answer A or B is preferred). 

> Equation 3.1 is correct as written

I thought $\pi^{(n)}_{r}(y | x)$ will be $nQ_x(r(x, y))^{n-1} \pi_0(y | x) + \frac{n(n-1)}{2} Q_x(r(x, y))^{n-2} \pi_0(y | x)^2 + \frac{n(n-1)(n-2)}{6} Q_x(r(x, y))^{n-3} \pi_0(y | x)^3 + ... + \pi_0(y | x)^n$ as y can be sampled multiple times and we still get BoN policy to generate y. What am I missing?