| Bandit | |
|---|---|
| number of arms (Agrawal and Goyal write ) | |
| an arm, one of | |
| a best arm, one whose mean is the largest, | |
| horizon: the total number of rounds played | |
| a round, | |
| mean reward of arm , unknown to the learner | |
| largest mean, | |
| gap of arm , : the expected reward lost by one play of arm | |
| arm played at round | |
| plays of arm in rounds (the papers write , ) | |
| regret after rounds, : expected reward lost against always playing a best arm | |
| KL divergence between Bernoulli distributions with means and , ; at least | |
| UCB1 | |
| average of the first rewards of arm | |
| average of the first rewards of the best arm | |
| UCB1's bonus at round for an arm with plays, | |
| Thompson sampling | |
| successes of arm : the number of its rewards equal to 1 | |
| failures of arm : the number of its rewards equal to 0 | |
| arm 's posterior draw at round , , the posterior of under a uniform prior | |
| binomial random variable: the number of successes in independent trials that each succeed with probability | |
| threshold in Step 3: after plays arm 2's draws stay below it, so arm 1 is played once its draw exceeds it | |
| number of plays of the best arm (arm 1) so far, in Step 3 | |
| in Step 4, the best saturated arm, the one with the smallest gap among worse arms with at least plays | |
| in Step 4, an unsaturated worse arm, one with fewer than plays | |
| Constants | |
| UCB1's leading constant in Theorem (a): the bound charges to each worse arm | |
| UCB1's constant term in Theorem (a), multiplying : the rounds in which a confidence bound fails (Step 1) | |
| for two arms with gap : plays of arm 2 after which its draws stay below , Step 3 | |
| : plays after which worse arm counts as saturated, its draws within of , Step 4 | |
| exploration probability of -greedy at round , , with tuning constant and a known lower bound on the gap between the best and second-best means | |
| Chapelle and Li's narrowing factor: Beta parameters divided by in the simulations, standard deviations multiplied by in the ad experiments | |
Context. A multi-armed bandit is the simplest model of learning while acting. Pulling a potentially worse arm costs immediate reward, while sticking to the apparent leader risks missing a better arm. Regretthe expected reward lost over rounds against always playing the arm with the highest mean measures the expected reward lost over rounds against always playing the best arm. Lai and Robbins (1985) proved that regret must grow at least like and gave asymptotically optimal rules, though those rules are hard to compute and carry no finite-horizon bound. Auer et al. (2002) showed that a one-line index rule, UCB1upper confidence bound rule 1: after one play of each arm, play the arm with the largest average reward plus a bonus , with the arm's plays and the rounds so far, achieves logarithmic regret at every horizon. Thompson samplinga randomized rule from Thompson (1933): draw a mean for every arm from its posterior given the rewards seen so far, and play the arm whose draw is largest is older, just as simple, and worked well in practice long before it had a proof. Agrawal and Goyal (2012) gave its first logarithmic regret bound, and Chapelle and Li (2011) tested it on simulations, display ads, and news recommendation.
Both rules keep pulling an arm while its estimate remains uncertain, and uncertainty shrinks with its play count. Distinguishing a worse arm whose mean sits below the best takes about plays, which yields regret of order . UCB1 adds uncertainty as a deterministic bonus. Thompson sampling instead draws a candidate mean from each arm's posterior. In Chapelle and Li's experiments, random sampling matches or beats UCB and holds up better under delayed or batched feedback. While rewards are pending, UCB's indices barely move, so it repeats one arm. Thompson sampling redraws each round, playing each arm with its posterior probability of being best.
Setting. There are arms. Each play of arm returns a reward in , drawn independently from a fixed distribution with unknown mean the mean reward of arm , unknown to the learner. Write the largest mean, ; a star marks the best arm throughout for the largest mean, for an arm that attains it, and the gap of arm : the expected cost of one play of it for the gap of arm . Let the arm played at round be the arm played at round , and the number of rounds among in which arm was played its play count through round . Grouping rounds by arm rewrites the expected regret the expected regret after rounds, against always playing as a sum over worse arms:Bounding regret reduces to bounding how often the rule plays each worse arm.
No broadly good rule can abandon a worse arm too quickly. For Bernoulli rewards, Lai and Robbins proved that any rule that is good on every instancewhy: a rule that always plays arm 1 has zero regret whenever arm 1 is best; the bound is for rules whose regret is for every on every instance must play each worse arm at least times asymptotically:Here the Kullback-Leibler divergence between Bernoulli rewards with means and ; it is at least is the Kullback-Leibler divergence between Bernoulli distributions with means and . Suppose a rule stopped playing arm after plays. On an alternate instance where arm 's mean sits just above , its first rewards still look like draws from with probability about . When that happens, the rule misses the best arm and loses order . Keeping that loss forces , orStatistical evidence against arm arrives at nats per play and must reach .
UCB1 adds an optimism bonus that grows slowly with the round number and shrinks with each arm's play count. It plays every arm once, then at each round picks the arm with the largest indexHere the average of the first rewards of arm ; for the best arm is the average of arm 's first rewards and UCB1's bonus at round for an arm with plays is the bonus. By Hoeffding's inequalityfor independent rewards in with mean , , and the same bound for (Hoeffding, 1963), the true mean exceeds with probability at most . The index therefore acts as an upper confidence bound whose failure probability drops rapidly with .
Thompson sampling for Bernoulli rewards in tracks each arm's counts the numbers of rewards equal to 1 (successes) and 0 (failures) that arm has returned of successes and failures. Under a uniform prior, the posterior of is . Each round the rule draws arm 's posterior draw at round , from : the posterior of under a uniform prior after successes and failures for every arm and plays the arm with the largest draw. Agrawal and Goyal extend the rule to any reward by flipping a coin that lands 1 with probability and recording that outcome. The flip lands 1 with marginal probability , so the counts evolve just like a Bernoulli arm with the same mean, and the Bernoulli proof covers both cases. Chapelle and Li apply the general Bayesian form: draw a parameter from the posterior of any reward model and take the action that is optimal under that draw.
Main results. Each paper bounds regret at every finite horizon , with the gaps setting the leading constants. (a) UCB1 (Auer et al., Theorem 1). For any and any reward distributions on ,The first term charges about plays of each worse arm at cost per play. The second covers the rare rounds in which a confidence bound fails (Step 1). Since , the Lai-Robbins optimal play count is at most , one sixteenth of UCB1's . In the same paper, UCB2 holds each chosen arm for epochs of geometrically growing length and pulls the leading constant arbitrarily close to .
(b) Thompson sampling (Agrawal and Goyal, Theorems 1 and 2). With two arms and gap , the proof givesand with arms,The growth is optimal, but the gap dependence is loose. When all worse arms share gap , the bound scales like against UCB1's , a byproduct of the worst-case step in Step 4. Later analyses (Kaufmann et al., 2012; Agrawal and Goyal, 2013) proved that Bernoulli Thompson sampling attains the exact Lai-Robbins constant , showing that the looseness lies in this first proof.
What it means. Both rules achieve logarithmic regret in without knowing the gaps or the horizon. A worse arm with a small gap hurts most. Distinguishing it takes about plays at cost each. Its regret therefore grows like as shrinks, until the gap gets so small that playing the arm every round costs less. In practice, Thompson sampling adapts more easily to rich models because it needs only a draw from a posterior or an approximation to one. A confidence bonus has to be derived anew for each model. Chapelle and Li's logistic click models draw from a Gaussian approximation, and Agrawal and Goyal note that Bing's search-ad click-through predictor (Graepel et al., 2010) explores the same way. Both guarantees assume rewards drawn independently from fixed distributions and say nothing when rewards drift or are chosen by an adversary.
Auer et al. also analyze two related baselines. -greedyplay the arm with the best average, except that at round , with probability , play a uniformly random arm; is a tuning constant (the logarithmic bound needs it large enough, for example ) and a known lower bound on the gap between the best and second-best means decays its exploration probability like and achieves logarithmic regret, but it requires a known lower bound on the smallest gap. UCB1-NORMAL handles Gaussian rewards with unknown variances, though its proof relies on two tail bounds for the and Student distributions that the authors checked only numerically.
UCB1 plays a worse arm about times. Fix a worse arm and count its plays beyond the first . Because the play counts at round are random, playing arm at round after prior plays requires for some and . That inequality forces at least one of three events:If all three failed, then . Set , which is at most . Every forces for all , ruling out the third event. Hoeffding's inequality bounds each of the first two events by . A union bound over at most pairs summed over all rounds adds . Counting the initial plays yieldsMultiplying by and summing over worse arms gives (a). The factor makes bound failures decay fast enough to sum finitely while still dropping worse arms after order plays.
In Auer et al.'s experiments, a variance-aware UCB needed no tuning while -greedy was fragile. Auer et al. test three two-arm and four ten-arm Bernoulli problems over 100,000 plays, averaged across 100 runs. Their plots omit UCB1 because UCB1-TUNEDUCB1 with the bonus , where is the arm's sample variance plus and is the largest variance of a reward in , which substitutes a sample variance estimate for the worst-case variance, did substantially better than UCB1 in essentially all experiments. Among UCB2, -greedy, and UCB1-TUNED, a well-tuned -greedy was almost always best. Yet no single constant worked across problems, and regret rose quickly away from the best constant on every problem except one. It also lost on two ten-arm problems, which the authors attribute to uniform exploration across many worse arms. In most cases UCB1-TUNED matched a well-tuned -greedy without tuning and was not very sensitive to arm variances. UCB2 behaved similarly but always trailed slightly. UCB1-TUNED carries no proof.
With two arms, Thompson sampling's regret comes down to the wait between plays of the best arm. Randomized sampling creates a proof difficulty that UCB1 avoids. UCB1 rarely picks a well-sampled worse arm no matter how few plays the best arm has, because a little-played arm carries a large bonus. Under Thompson sampling, a little-played best arm has a wide posterior draw. With zero plays that draw is uniform on , so it loses to a well-estimated worse arm with probability about . The analysis must track how often the rule has played the best arm, arm 1.
Set the play threshold , for two arms whose means differ by : the number of plays of the worse arm (arm 2) after which its draws stay below , except with probability per round and the midpoint . The first plays of arm 2 cost at most . Afterward, arm 2's posterior draws stay below except with probability per round. Arm 1 then wins as soon as its own draw exceeds , and every round of waiting adds one play of arm 2. After plays of arm 1 with successes, its draw follows and is redrawn independently until arm 1 wins. That wait is geometric, and the Beta-binomial identity writes its mean in terms of a binomial random variable: the number of successes in independent trials that each succeed with probability , the success count in trials with success probability :
Order statistics explain that identity. The -th smallest of independent uniform draws on follows . It exceeds exactly when at most of those draws fall below . Next, split the sum over arm 1's play count at . Once , Hoeffding's inequality keeps close to , and the expected wait drops to at most . For smaller , can come out unluckily low. Averaging the expected wait over the binomial distribution of and summing over early adds . Adding the initial plays of arm 2 and the waits across both regimes yields . Multiplying by gives (b) for two arms.
With arms, rounds won by little-played arms multiply the cost. Call a worse arm saturated once it reaches : the number of plays after which worse arm counts as saturated, meaning its draws stay within of except with small probability per round plays. Its draws then stay within of , except with probability at most per round across all saturated arms. Plays of unsaturated arms cost at most in total. Between two plays of the best arm, let be the best saturated arm, the one with the smallest gap . Saturated arms can win while the best arm's draw stays below , forming a geometric wait as in Step 3. Any saturated arm that wins must beat arm , so . That forces , capping each such round's cost at .
The wait restarts whenever an unsaturated arm wins a round in which the best arm's draw already exceeded , stealing a play from the best arm. Each interruption uses one play of an unsaturated arm, capping their count at , which is of order . Placing those restarts in the worst way multiplies that count by the expected cost of a wait, of order . Their product gives the bound in (b), and the authors point to this worst-case placement as the source of the high power of the gaps.
In simulation, Thompson sampling's regret tracks the optimal slope and stays below UCB's. Chapelle and Li test Bernoulli arms with best mean 0.5 and the other arms at or , for and , averaged over 100 runs. Against , Thompson sampling's regret traces a straight line whose slope stays close to the Lai-Robbins constant . UCB incurs larger regret in every setting. Their UCB baseline uses a tight Chernoff-type bounda confidence bound from the Chernoff tail inequality, with the Bernoulli divergence; tighter than Hoeffding's when the mean is near 0 or 1 (Chernoff, 1952) from Langford's tutorial with confidence parameter , which beat UCB1's bonus in their tests. Thompson sampling also beats UCB when the uniform prior mismatches the arm means, with best mean 0.1 and nine arms at 0.08, though the paper does not plot those runs.
Narrowing the posterior by dividing both Beta parameters by cuts exploration. That often lowers regret, though some runs then suffer very large regret. On average it beats at moderate horizons and loses at long horizons. An optimistic variant that floors each arm's draw at its posterior mean gains only marginally.
Thompson sampling degrades less than UCB when feedback is delayed. To mimic news recommendation, Chapelle and Li simulate 10 items whose click rates are drawn from . With probability each round, one item is retired and replaced. Rewards arrive in batches every 1 to 1,000 rounds, and Chapelle and Li measure regret at , averaged over 100 runs. With immediate feedback, UCB's regret is 2.65 times Thompson sampling's, at 24,145 against 9,105. When feedback arrives every 1,000 rounds, that ratio widens to 3.82, at 226,220 against 59,256, climbing steadily across intermediate delays.
On display advertising and news recommendation, Thompson sampling matches or beats tuned alternatives. On display ads, Thompson sampling with halved posterior standard deviations holds click-through-rate regret to 3.72%. The best LinUCBa UCB rule for a reward model linear in the features: play the arm whose predicted reward plus a tuned multiple of its standard deviation is largest; in Li et al.'s ridge version that is plus a multiple of , for the arm's feature vector , the ridge-regression estimate , and , summed over past plays with rewards ; the square root is the prediction's standard deviation (Li et al., 2010). Reading note: Contextual bandits scores 4.14%, -greedy scores 4.98% to 5.22%, exploit-only scores 5.00%, and random choice scores 31.95%. Changing contexts already force exploit-only to explore. The underlying model is logistic regression on hashedmapped by a hash function to one of a fixed number of indices (here ), so no feature dictionary is kept and rare collisions are tolerated sparse features with a diagonal Gaussian Laplace approximationa Gaussian fitted to the posterior at its mode, with covariance the inverse Hessian of the negative log-posterior there; here only its diagonal is kept updated hourly. Its 95% intervals cover the true click rate 95.1% of the time. Contexts and eligible ads come from real traffic, with up to 5,910 eligible ads per context. Clicks are simulated from a perturbed learned weight vector because replay over so many arms leaves too few usable events.
The Yahoo! front page benchmark tracks a pool of about 20 articles, with one logistic model per article on 21 user features. Chapelle and Li evaluate policies by unbiased replayLi et al.'s offline method: step through visits whose article was chosen uniformly at random and keep only those where the policy picks the logged article; the kept visits are distributed as live ones (Li et al., 2011). Reading note: Contextual bandits over 34 million randomly served visits. Across update delays of 10, 30, and 60 minutes, Thompson sampling stays competitive. UCB performs well at 10 minutes but falls off as the delay grows. At one hour, Thompson sampling and its optimistic variant are significantly better than the rest (read from a figure).
Terms
- Regret
- : gaps times expected plays
- Lower bound (Lai and Robbins)
- for rules good on every instance
- UCB1 index
- ; the bound fails with probability at most
- UCB1 regret
- at every
- Thompson sampling
- draw for every arm, play the largest; general form: draw a parameter from the posterior, act greedily for it
- Rewards in [0,1]
- flip a coin with success probability equal to the reward and count the flip
- Beta-binomial identity
- Thompson sampling regret
- two arms: ; arms:
- Delayed feedback
- UCB's regret over Thompson sampling's: 2.65 with immediate feedback, 3.82 with feedback every 1,000 rounds
- Display ads
- regret in click-through rate (%): Thompson sampling 3.72, best LinUCB 4.14, exploit-only 5.00
- Posterior narrowing
- less exploration: often lower regret and better on average at moderate horizons, a few very bad runs
Sources
- Peter Auer, Nicolò Cesa-Bianchi, and Paul Fischer. Finite-time Analysis of the Multiarmed Bandit Problem. Machine Learning, 2002.
- Shipra Agrawal and Navin Goyal. Analysis of Thompson Sampling for the Multi-armed Bandit Problem. COLT, 2012.
- Olivier Chapelle and Lihong Li. An Empirical Evaluation of Thompson Sampling. NeurIPS, 2011.
- Emilie Kaufmann, Nathaniel Korda, and Rémi Munos. Thompson Sampling: An Asymptotically Optimal Finite-Time Analysis. ALT, 2012.
- Shipra Agrawal and Navin Goyal. Further Optimal Regret Bounds for Thompson Sampling. AISTATS, 2013.
- Lihong Li, Wei Chu, John Langford, and Robert E. Schapire. A Contextual-Bandit Approach to Personalized News Article Recommendation. WWW, 2010.
- Wassily Hoeffding. Probability Inequalities for Sums of Bounded Random Variables. Journal of the American Statistical Association, 1963.
- Herman Chernoff. A Measure of Asymptotic Efficiency for Tests of a Hypothesis Based on the Sum of Observations. Annals of Mathematical Statistics, 1952.
- William R. Thompson. On the Likelihood that One Unknown Probability Exceeds Another in View of the Evidence of Two Samples. Biometrika, 1933.
- Lihong Li, Wei Chu, John Langford, and Xuanhui Wang. Unbiased Offline Evaluation of Contextual-bandit-based News Article Recommendation Algorithms. WSDM, 2011.
Connected notes
- Reward model overoptimizationLearning from human preferences · Feedback between a model and its data
Optimizing against a learned reward raises gold score up to a KL that moves out smoothly with the log of the reward model's size and then lowers it, so early stopping or a KL target has a real effect on the gold score.
- Stein's paradox and the James-Stein estimatorBenign overfitting · Comparing noisy runs is an estimation problem
With effects spread around a common mean, the posterior mean pulls each raw estimate toward that mean, and Lindley's version of James-Stein estimates both the mean and the amount of pulling from the spread of the estimates themselves. It beats the raw estimates in total squared error for every configuration of the once there are four or more, and in Efron's batting example it cuts the total prediction error to 0.28 of that of the raw batting averages.
- PPO and RLOO for language modelsReinforcement learning for reasoning · Feedback between a model and its data
Labelers were told to penalize inaccuracy but not copying, so summarization policies learned to copy whole sentences, and collecting labels on the current policy's samples during training mattered for summarization, where labelers preferred the online model 64% and 65% of the time.
- Learned KV-cache evictionEfficient sequence models · Comparing noisy runs is an estimation problem
By the note's rough estimate the difference between two average pass@1 scores, over about 120 problems with 16 samples each, has a standard deviation of at most about 0.016 before any training-seed variation, so gaps of 0.01 to 0.02 between eviction methods are not resolved.