Sam Babichenko

Reading notes / Bandits and exploration

UCB and Thompson sampling

Auer et al., 2002; Agrawal and Goyal, 2012; Chapelle and Li, 2011

Bandit
KKnumber of arms (Agrawal and Goyal write NN)
iian arm, one of 1,…,K1,\dots,K
i∗i^*a best arm, one whose mean is the largest, μ∗\mu^*
TThorizon: the total number of rounds played
tta round, t=1,…,Tt=1,\dots,T
μi\mu_imean reward of arm ii, unknown to the learner
μ∗\mu^*largest mean, μ∗=max⁡iμi\mu^*=\max_i\mu_i
Δi\Delta_igap of arm ii, Δi=μ∗−μi\Delta_i=\mu^*-\mu_i: the expected reward lost by one play of arm ii
iti_tarm played at round tt
Ni(t)N_i(t)plays of arm ii in rounds 1..t1..t (the papers write Ti(n)T_i(n), ki(t)k_i(t))
RTR_Tregret after TT rounds, RT=Tμ∗−E∑t≤Tμit=∑iΔi ENi(T)R_T=T\mu^*-\mathbb E\sum_{t\le T}\mu_{i_t}=\sum_i\Delta_i\,\mathbb E N_i(T): expected reward lost against always playing a best arm
d(μi,μ∗)d(\mu_i,\mu^*)KL divergence between Bernoulli distributions with means μi\mu_i and μ∗\mu^*, μiln⁡μiμ∗+(1−μi)ln⁡1−μi1−μ∗\mu_i\ln\frac{\mu_i}{\mu^*}+(1-\mu_i)\ln\frac{1-\mu_i}{1-\mu^*}; at least 2Δi22\Delta_i^2
UCB1
μ^i,s\hat\mu_{i,s}average of the first ss rewards of arm ii
μ^s∗\hat\mu^*_saverage of the first ss rewards of the best arm i∗i^*
ct,sc_{t,s}UCB1's bonus at round tt for an arm with ss plays, ct,s=2ln⁡t/sc_{t,s}=\sqrt{2\ln t/s}
Thompson sampling
SiS_isuccesses of arm ii: the number of its rewards equal to 1
FiF_ifailures of arm ii: the number of its rewards equal to 0
θi(t)\theta_i(t)arm ii's posterior draw at round tt, θi(t)∼Beta(Si+1,Fi+1)\theta_i(t)\sim\mathrm{Beta}(S_i+1,F_i+1), the posterior of μi\mu_i under a uniform prior
Bin(n,y)\mathrm{Bin}(n,y)binomial random variable: the number of successes in nn independent trials that each succeed with probability yy
yythreshold y=μ2+Δ/2y=\mu_2+\Delta/2 in Step 3: after LL plays arm 2's draws stay below it, so arm 1 is played once its draw exceeds it
jjnumber of plays of the best arm (arm 1) so far, in Step 3
aain Step 4, the best saturated arm, the one with the smallest gap among worse arms with at least 24ln⁡T/Δi224\ln T/\Delta_i^2 plays
uuin Step 4, an unsaturated worse arm, one with fewer than 24ln⁡T/Δu224\ln T/\Delta_u^2 plays
Constants
88UCB1's leading constant in Theorem (a): the bound charges 8ln⁡T/Δi8\ln T/\Delta_i to each worse arm ii
1+π2/31+\pi^2/3UCB1's constant term in Theorem (a), multiplying ∑iΔi\sum_i\Delta_i: the rounds in which a confidence bound fails (Step 1)
LLL=24ln⁡T/Δ2L=24\ln T/\Delta^2 for two arms with gap Δ\Delta: plays of arm 2 after which its draws stay below μ2+Δ/2\mu_2+\Delta/2, Step 3
LiL_iLi=24ln⁡T/Δi2L_i=24\ln T/\Delta_i^2: plays after which worse arm ii counts as saturated, its draws within Δi/2\Delta_i/2 of μi\mu_i, Step 4
εn\varepsilon_nexploration probability of εn\varepsilon_n-greedy at round nn, εn=min⁡{1,cK/(δ02n)}\varepsilon_n=\min\{1,cK/(\delta_0^2n)\}, with tuning constant c>0c\gt 0 and δ0\delta_0 a known lower bound on the gap between the best and second-best means
α\alphaChapelle and Li's narrowing factor: Beta parameters divided by α\alpha in the simulations, standard deviations multiplied by α\alpha 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. the expected reward lost over TT rounds against always playing the arm with the highest mean measures the expected reward lost over TT rounds against always playing the best arm. Lai and Robbins (1985) proved that regret must grow at least like ln⁡T\ln T 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, upper confidence bound rule 1: after one play of each arm, play the arm with the largest average reward plus a bonus 2ln⁡t/s\sqrt{2\ln t/s}, with ss the arm's plays and tt the rounds so far, achieves logarithmic regret at every horizon. a 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 Δi\Delta_i below the best takes about ln⁡T/Δi2\ln T/\Delta_i^2 plays, which yields regret of order ∑iln⁡T/Δi\sum_i\ln T/\Delta_i. 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 KK arms. Each play of arm ii returns a reward in [0,1][0,1], drawn independently from a fixed distribution with unknown mean the mean reward of arm ii, unknown to the learner. Write μ∗\mu^*=max⁡iμi{}=\max_i\mu_i for the largest mean, i∗i^* for an arm that attains it, and Δi\Delta_i=μ∗−μi{}=\mu^*-\mu_i for the gap of arm ii. Let the arm played at round tt be the arm played at round tt, and the number of rounds among 1,…,t1,\dots,t in which arm ii was played its play count through round tt. Grouping rounds by arm rewrites the expected regret the expected regret after TT rounds, Tμ∗−E∑t≤TμitT\mu^*-\mathbb E\sum_{t\le T}\mu_{i_t} against always playing i∗i^* as a sum over worse arms:RT=Tμ∗−E∑t=1Tμit=∑i=1KΔi ENi(T).\begin{aligned}R_T&=T\mu^*-\mathbb E\sum_{t=1}^T\mu_{i_t}\\&=\sum_{i=1}^K\Delta_i\,\mathbb E N_i(T).\end{aligned}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 why: a rule that always plays arm 1 has zero regret whenever arm 1 is best; the bound is for rules whose regret is o(Tβ)o(T^\beta) for every β>0\beta\gt 0 on every instance must play each worse arm at least ln⁡T/d(μi,μ∗)\ln T/d(\mu_i,\mu^*) times asymptotically:lim inf⁡T→∞ENi(T)ln⁡T≥1d(μi,μ∗).\liminf_{T\to\infty}\frac{\mathbb E N_i(T)}{\ln T}\ge\frac{1}{d(\mu_i,\mu^*)}.Here the Kullback-Leibler divergence μiln⁡μiμ∗+(1−μi)ln⁡1−μi1−μ∗\mu_i\ln\frac{\mu_i}{\mu^*}+(1-\mu_i)\ln\frac{1-\mu_i}{1-\mu^*} between Bernoulli rewards with means μi\mu_i and μ∗\mu^*; it is at least 2Δi22\Delta_i^2 is the Kullback-Leibler divergence between Bernoulli distributions with means μi\mu_i and μ∗\mu^*. Suppose a rule stopped playing arm ii after ss plays. On an alternate instance where arm ii's mean sits just above μ∗\mu^*, its first ss rewards still look like draws from μi\mu_i with probability about e−s d(μi,μ∗)e^{-s\,d(\mu_i,\mu^*)}. When that happens, the rule misses the best arm and loses order TT. Keeping that loss o(Tβ)o(T^\beta) forces Te−s d(μi,μ∗)≲TβTe^{-s\,d(\mu_i,\mu^*)}\lesssim T^\beta, ors≳(1−β)ln⁡Td(μi,μ∗).s\gtrsim(1-\beta)\frac{\ln T}{d(\mu_i,\mu^*)}.Statistical evidence against arm ii arrives at d(μi,μ∗)d(\mu_i,\mu^*) nats per play and must reach ln⁡T\ln T.

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 t+1t+1 picks the arm with the largest indexμ^i,Ni(t)+ct,Ni(t),ct,s=2ln⁡ts.\begin{aligned}&\hat\mu_{i,N_i(t)}+c_{t,N_i(t)},\\&c_{t,s}=\sqrt{\frac{2\ln t}{s}}.\end{aligned}Here the average of the first ss rewards of arm ii; μ^s∗\hat\mu^*_s for the best arm is the average of arm ii's first ss rewards and UCB1's bonus 2ln⁡t/s\sqrt{2\ln t/s} at round tt for an arm with ss plays is the bonus. By for ss independent rewards in [0,1][0,1] with mean μ\mu, Pr⁡(μ^≥μ+c)≤e−2sc2\Pr(\hat\mu\ge\mu+c)\le e^{-2sc^2}, and the same bound for μ^≤μ−c\hat\mu\le\mu-c (Hoeffding, 1963), the true mean exceeds μ^i,s+ct,s\hat\mu_{i,s}+c_{t,s} with probability at most e−2s ct,s2=t−4e^{-2s\,c_{t,s}^2}=t^{-4}. The index therefore acts as an upper confidence bound whose failure probability drops rapidly with tt.

Thompson sampling for Bernoulli rewards in {0,1}\{0,1\} tracks each arm's counts the numbers of rewards equal to 1 (successes) and 0 (failures) that arm ii has returned of successes and failures. Under a uniform prior, the posterior of μi\mu_i is Beta(Si+1,Fi+1)\mathrm{Beta}(S_i+1,F_i+1). Each round the rule draws arm ii's posterior draw at round tt, from Beta(Si+1,Fi+1)\mathrm{Beta}(S_i+1,F_i+1): the posterior of μi\mu_i under a uniform prior after SiS_i successes and FiF_i failures∼Beta(Si+1,Fi+1){}\sim\mathrm{Beta}(S_i+1,F_i+1) for every arm and plays the arm with the largest draw. Agrawal and Goyal extend the rule to any reward x∈[0,1]x\in[0,1] by flipping a coin that lands 1 with probability xx and recording that outcome. The flip lands 1 with marginal probability μi\mu_i, 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 TT, with the gaps setting the leading constants. (a) UCB1 (Auer et al., Theorem 1). For any K>1K\gt 1 and any reward distributions on [0,1][0,1],RT≤∑i:Δi>08ln⁡TΔi+(1+π23)∑i=1KΔi.\begin{aligned}R_T\le{}&\sum_{i:\Delta_i\gt 0}\frac{8\ln T}{\Delta_i}\\&+\Big(1+\frac{\pi^2}{3}\Big)\sum_{i=1}^K\Delta_i.\end{aligned}The first term charges about 8ln⁡T/Δi28\ln T/\Delta_i^2 plays of each worse arm at cost Δi\Delta_i per play. The second covers the rare rounds in which a confidence bound fails (Step 1). Since d(μi,μ∗)≥2Δi2d(\mu_i,\mu^*)\ge2\Delta_i^2, the Lai-Robbins optimal play count ln⁡T/d(μi,μ∗)\ln T/d(\mu_i,\mu^*) is at most ln⁡T/(2Δi2)\ln T/(2\Delta_i^2), one sixteenth of UCB1's 8ln⁡T/Δi28\ln T/\Delta_i^2. In the same paper, UCB2 holds each chosen arm for epochs of geometrically growing length and pulls the leading constant arbitrarily close to 1/(2Δi2)1/(2\Delta_i^2).

(b) Thompson sampling (Agrawal and Goyal, Theorems 1 and 2). With two arms and gap Δ\Delta, the proof givesRT≤40ln⁡TΔ+48Δ3+18Δ,R_T\le\frac{40\ln T}{\Delta}+\frac{48}{\Delta^3}+18\Delta,and with KK arms,RT=O((∑i≠i∗1Δi2)2ln⁡T).R_T=O\bigg(\Big(\sum_{i\ne i^*}\frac{1}{\Delta_i^2}\Big)^2\ln T\bigg).The ln⁡T\ln T growth is optimal, but the gap dependence is loose. When all K−1K-1 worse arms share gap Δ\Delta, the bound scales like 1/Δ41/\Delta^4 against UCB1's 1/Δ1/\Delta, 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 1/d(μi,μ∗)1/d(\mu_i,\mu^*), showing that the looseness lies in this first proof.

What it means. Both rules achieve logarithmic regret in TT without knowing the gaps or the horizon. A worse arm with a small gap hurts most. Distinguishing it takes about ln⁡T/Δi2\ln T/\Delta_i^2 plays at cost Δi\Delta_i each. Its regret therefore grows like ln⁡T/Δi\ln T/\Delta_i as Δi\Delta_i 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. play the arm with the best average, except that at round nn, with probability εn=min⁡{1,cK/(δ02n)}\varepsilon_n=\min\{1,cK/(\delta_0^2n)\}, play a uniformly random arm; c>0c\gt 0 is a tuning constant (the logarithmic bound needs it large enough, for example c>5c\gt 5) and δ0\delta_0 a known lower bound on the gap between the best and second-best means decays its exploration probability like 1/n1/n 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 χ2\chi^2 and Student distributions that the authors checked only numerically.

Step 1

UCB1 plays a worse arm about 8ln⁡T/Δi28\ln T/\Delta_i^2 times. Fix a worse arm ii and count its plays beyond the first ℓ\ell. Because the play counts at round tt are random, playing arm ii at round t+1t+1 after ℓ\ell prior plays requires μ^s∗+ct,s≤μ^i,si+ct,si\hat\mu^*_s+c_{t,s}\le\hat\mu_{i,s_i}+c_{t,s_i} for some 1≤s≤t1\le s\le t and ℓ≤si≤t\ell\le s_i\le t. That inequality forces at least one of three events:μ^s∗≤μ∗−ct,s,μ^i,si≥μi+ct,si,μ∗<μi+2ct,si.\begin{aligned}&\hat\mu^*_s\le\mu^*-c_{t,s},\\&\hat\mu_{i,s_i}\ge\mu_i+c_{t,s_i},\\&\mu^*\lt \mu_i+2c_{t,s_i}.\end{aligned}If all three failed, then μ^s∗+ct,s>μ∗≥μi+2ct,si>μ^i,si+ct,si\hat\mu^*_s+c_{t,s}\gt \mu^*\ge\mu_i+2c_{t,s_i}\gt \hat\mu_{i,s_i}+c_{t,s_i}. Set ℓ=⌈8ln⁡T/Δi2⌉\ell=\lceil8\ln T/\Delta_i^2\rceil, which is at most 8ln⁡T/Δi2+18\ln T/\Delta_i^2+1. Every si≥8ln⁡T/Δi2s_i\ge8\ln T/\Delta_i^2 forces 2ct,si≤Δi2c_{t,s_i}\le\Delta_i for all t≤Tt\le T, ruling out the third event. Hoeffding's inequality bounds each of the first two events by t−4t^{-4}. A union bound over at most t2t^2 pairs (s,si)(s,s_i) summed over all rounds adds ∑t=1∞2t−2=π2/3\sum_{t=1}^\infty 2t^{-2}=\pi^2/3. Counting the initial ℓ\ell plays yieldsENi(T)≤8ln⁡TΔi2+1+π23.\mathbb E N_i(T)\le\frac{8\ln T}{\Delta_i^2}+1+\frac{\pi^2}{3}.Multiplying by Δi\Delta_i and summing over worse arms gives (a). The ln⁡t\ln t factor makes bound failures decay fast enough to sum finitely while still dropping worse arms after order ln⁡T/Δi2\ln T/\Delta_i^2 plays.

Step 2

In Auer et al.'s experiments, a variance-aware UCB needed no tuning while εn\varepsilon_n-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 with the bonus (ln⁡t/s)min⁡{1/4,V}\sqrt{(\ln t/s)\min\{1/4,V\}}, where VV is the arm's sample variance plus 2ln⁡t/s\sqrt{2\ln t/s} and 1/41/4 is the largest variance of a reward in [0,1][0,1], which substitutes a sample variance estimate for the worst-case variance, did substantially better than UCB1 in essentially all experiments. Among UCB2, εn\varepsilon_n-greedy, and UCB1-TUNED, a well-tuned εn\varepsilon_n-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 εn\varepsilon_n-greedy without tuning and was not very sensitive to arm variances. UCB2 behaved similarly but always trailed slightly. UCB1-TUNED carries no proof.

Step 3

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 [0,1][0,1], so it loses to a well-estimated worse arm with probability about μ2\mu_2. The analysis must track how often the rule has played the best arm, arm 1.

Set the play threshold LL=24ln⁡T/Δ2{}=24\ln T/\Delta^2 and the midpoint y=μ2+Δ/2=μ1−Δ/2y=\mu_2+\Delta/2=\mu_1-\Delta/2. The first LL plays of arm 2 cost at most 24ln⁡T/Δ24\ln T/\Delta. Afterward, arm 2's posterior draws stay below yy except with probability 2/T22/T^2 per round. Arm 1 then wins as soon as its own draw exceeds yy, and every round of waiting adds one play of arm 2. After jj plays of arm 1 with S1S_1 successes, its draw follows Beta(S1+1,j−S1+1)\mathrm{Beta}(S_1+1,j-S_1+1) 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 nn independent trials that each succeed with probability yy, the success count in nn trials with success probability yy:Pr⁡(θ1>y)=Pr⁡(Bin(j+1,y)≤S1),E[wait]=1Pr⁡(θ1>y)−1.\begin{aligned}&\Pr(\theta_1\gt y)\\&\quad=\Pr\big(\mathrm{Bin}(j+1,y)\le S_1\big),\\&\mathbb E[\text{wait}]=\frac{1}{\Pr(\theta_1\gt y)}-1.\end{aligned}

Order statistics explain that identity. The (S1+1)(S_1+1)-th smallest of j+1j+1 independent uniform draws on [0,1][0,1] follows Beta(S1+1,j−S1+1)\mathrm{Beta}(S_1+1,j-S_1+1). It exceeds yy exactly when at most S1S_1 of those j+1j+1 draws fall below yy. Next, split the sum over arm 1's play count jj at 16ln⁡T/Δ216\ln T/\Delta^2. Once j≥16ln⁡T/Δ2j\ge16\ln T/\Delta^2, Hoeffding's inequality keeps S1/jS_1/j close to μ1\mu_1, and the expected wait drops to at most 16/T16/T. For smaller jj, S1S_1 can come out unluckily low. Averaging the expected wait over the binomial distribution of S1S_1 and summing over early jj adds 16ln⁡T/Δ2+48/Δ416\ln T/\Delta^2+48/\Delta^4. Adding the initial L=24ln⁡T/Δ2L=24\ln T/\Delta^2 plays of arm 2 and the waits across both regimes yields EN2(T)≤40ln⁡T/Δ2+48/Δ4+18\mathbb E N_2(T)\le40\ln T/\Delta^2+48/\Delta^4+18. Multiplying by Δ\Delta gives (b) for two arms.

Step 4

With KK arms, rounds won by little-played arms multiply the cost. Call a worse arm ii saturated once it reaches LiL_i=24ln⁡T/Δi2{}=24\ln T/\Delta_i^2 plays. Its draws then stay within Δi/2\Delta_i/2 of μi\mu_i, except with probability at most 4(K−1)/T24(K-1)/T^2 per round across all saturated arms. Plays of unsaturated arms cost at most ∑iLiΔi=24ln⁡T∑i1/Δi\sum_iL_i\Delta_i=24\ln T\sum_i1/\Delta_i in total. Between two plays of the best arm, let aa be the best saturated arm, the one with the smallest gap Δa\Delta_a. Saturated arms can win while the best arm's draw stays below μa+Δa/2\mu_a+\Delta_a/2, forming a geometric wait as in Step 3. Any saturated arm ii that wins must beat arm aa, so μi+Δi/2≥μa−Δa/2\mu_i+\Delta_i/2\ge\mu_a-\Delta_a/2. That forces Δi≤3Δa\Delta_i\le3\Delta_a, capping each such round's cost at 3Δa3\Delta_a.

The wait restarts whenever an unsaturated arm uu wins a round in which the best arm's draw already exceeded μa+Δa/2\mu_a+\Delta_a/2, stealing a play from the best arm. Each interruption uses one play of an unsaturated arm, capping their count at ∑uLu\sum_uL_u, which is of order ln⁡T∑u1/Δu2\ln T\sum_u1/\Delta_u^2. Placing those restarts in the worst way multiplies that count by the expected cost of a wait, of order ∑a1/Δa2\sum_a1/\Delta_a^2. Their product gives the (∑i1/Δi2)2ln⁡T(\sum_i1/\Delta_i^2)^2\ln T bound in (b), and the authors point to this worst-case placement as the source of the high power of the gaps.

Step 5

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 K−1K-1 arms at 0.5−0.020.5-0.02 or 0.5−0.10.5-0.1, for K=10K=10 and K=100K=100, averaged over 100 runs. Against ln⁡T\ln T, Thompson sampling's regret traces a straight line whose slope stays close to the Lai-Robbins constant ∑iΔi/d(μi,μ∗)\sum_i\Delta_i/d(\mu_i,\mu^*). UCB incurs larger regret in every setting. Their UCB baseline uses a tight a confidence bound from the Chernoff tail inequality, Pr⁡(μ^≥μ+c)≤e−s d(μ+c,μ)\Pr(\hat\mu\ge\mu+c)\le e^{-s\,d(\mu+c,\mu)} with dd the Bernoulli divergence; tighter than Hoeffding's when the mean is near 0 or 1 (Chernoff, 1952) from Langford's tutorial with confidence parameter 1/t1/\sqrt{t}, 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 α<1\alpha\lt 1 cuts exploration. That often lowers regret, though some runs then suffer very large regret. On average it beats α=1\alpha=1 at moderate horizons and loses at long horizons. An optimistic variant that floors each arm's draw at its posterior mean gains only marginally.

Step 6

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 Beta(4,4)\mathrm{Beta}(4,4). With probability 10−310^{-3} 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 T=106T=10^6, 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.

Step 7

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 a 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 x⊤θ^x^\top\hat\theta plus a multiple of x⊤A−1x\sqrt{x^\top A^{-1}x}, for the arm's feature vector xx, the ridge-regression estimate θ^=A−1b\hat\theta=A^{-1}b, and A=I+∑xx⊤A=I+\sum xx^\top, b=∑r xb=\sum r\,x summed over past plays with rewards rr; the square root is the prediction's standard deviation (Li et al., 2010). Reading note: Contextual bandits scores 4.14%, ε\varepsilon-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 2242^{24} mapped by a hash function to one of a fixed number of indices (here 2242^{24}), so no feature dictionary is kept and rare collisions are tolerated sparse features with a diagonal Gaussian a 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 Li 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
RT=Tμ∗−E∑tμit=∑iΔi ENi(T)R_T=T\mu^*-\mathbb E\sum_t\mu_{i_t}=\sum_i\Delta_i\,\mathbb E N_i(T): gaps times expected plays
Lower bound (Lai and Robbins)
ENi(T)≥(1−o(1))ln⁡T/d(μi,μ∗)\mathbb E N_i(T)\ge(1-o(1))\ln T/d(\mu_i,\mu^*) for rules good on every instance
UCB1 index
μ^i,Ni(t)+2ln⁡t/Ni(t)\hat\mu_{i,N_i(t)}+\sqrt{2\ln t/N_i(t)}; the bound fails with probability at most t−4t^{-4}
UCB1 regret
∑i:Δi>08ln⁡T/Δi+(1+π2/3)∑iΔi\sum_{i:\Delta_i\gt 0}8\ln T/\Delta_i+(1+\pi^2/3)\sum_i\Delta_i at every TT
Thompson sampling
draw θi∼Beta(Si+1,Fi+1)\theta_i\sim\mathrm{Beta}(S_i+1,F_i+1) 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
Pr⁡(Beta(S1+1,j−S1+1)>y)=Pr⁡(Bin(j+1,y)≤S1)\Pr(\mathrm{Beta}(S_1+1,j-S_1+1)\gt y)=\Pr(\mathrm{Bin}(j+1,y)\le S_1)
Thompson sampling regret
two arms: 40ln⁡T/Δ+48/Δ3+18Δ40\ln T/\Delta+48/\Delta^3+18\Delta; KK arms: O((∑i1/Δi2)2ln⁡T)O((\sum_i1/\Delta_i^2)^2\ln T)
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

Connected notes

  • 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.

  • With effects θi\theta_i 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 θi\theta_i 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.

  • 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.

  • 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.

Threads