Sam Babichenko

Reading notes / Bandits and exploration

In-context exploration by language models

Krishnamurthy et al., 2024; Nie et al., 2025; Schmied et al., 2026

Bandit
KKnumber of arms
aaan arm
a⋆a^\starbest arm, the one with the highest mean reward μ⋆\mu^\star
TThorizon: the number of rounds in a run
tta round, t=1,…,Tt=1,\dots,T
ata_tarm pulled at round tt
rtr_treward seen at round tt, drawn independently with mean μat\mu_{a_t}
μa\mu_amean reward of arm aa, unknown to the agent
μ⋆\mu^\starmean reward of the best arm; 0.5+Δ/20.5+\Delta/2 in Krishnamurthy et al.'s instances
Δ\Deltagap between the best arm's mean and every other arm's mean; the other arms sit at 0.5−Δ/20.5-\Delta/2 in Krishnamurthy et al.'s instances
Nt(a)N_t(a)number of pulls of arm aa in rounds 1 to tt
μ^t(a)\hat\mu_t(a)average reward of arm aa over its pulls up to round tt
RegT\mathrm{Reg}_Tregret after TT rounds, RegT=E∑t≤T(μ⋆−μat)\mathrm{Reg}_T=\mathbb E\sum_{t\le T}(\mu^\star-\mu_{a_t}): the reward lost against always pulling the best arm
Failure statistics
SuffFailFreq(t)\mathrm{SuffFailFreq}(t)fraction of replicates with a suffix failure at round tt: the best arm a⋆a^\star is never pulled in rounds tt to TT
MinFrac(t)\mathrm{MinFrac}(t)replicate average of the share of rounds 1 to tt spent on the least-pulled arm; at most 1/K1/K, plotted as K⋅MinFracK\cdot\mathrm{MinFrac}
Algorithm help
VtexploitV^{\rm exploit}_tUCB's exploitation term for arm aa at round tt, Vtexploit(a)=μ^t(a)V^{\rm exploit}_t(a)=\hat\mu_t(a)
VtexploreV^{\rm explore}_tUCB's exploration bonus for arm aa at round tt, Vtexplore(a)=αlog⁡t/Nt(a)V^{\rm explore}_t(a)=\alpha\sqrt{\log t/N_t(a)}
α\alphaUCB's weight on the exploration bonus αlog⁡t/Nt(a)\alpha\sqrt{\log t/N_t(a)}
Constants
K=5,K=5, Δ=0.2\Delta=0.2Krishnamurthy et al.'s hard instance: five Bernoulli arms, the best at mean 0.6 and the rest at 0.4; the easy instance has K=4, Δ=0.5K=4,\ \Delta=0.5
T=100T=100main horizon in Krishnamurthy et al. (200 and 500 in checks)
T=50T=50horizon in Schmied et al.

Context. Language models now sit in feedback loops where they act, observe an outcome, and act again, such as recommending items or picking the next experiment. Learning from that feedback requires exploration, trying an option that looks worse now to check whether it is actually better. The multi-armed bandit isolates that requirement. Three papers pose bandits to language models in text, putting the task and history in the prompt. Krishnamurthy et al. (2024) test pretrained models through prompting alone. Nie et al. (2025) pass a bandit algorithm's behavior through prompts or fine-tuning, and Schmied et al. (2026) measure why models fall short and train them with RL.

Given the raw history of past rounds, pretrained models fail in two ways. Most commit to one arm early and never return to the best arm; a few keep pulling every arm nearly equally. They explore well only when the prompt summarizes each arm's pull count and average reward, or after fine-tuning or RL. Across GPT-3.5, GPT-4, and Llama 2, GPT-4 with that summary was the only prompted configuration in Krishnamurthy et al. to explore about as well as a bandit algorithm that keeps a posterior over each arm's mean (here Beta, from a uniform prior), draws one value from each, and pulls the arm with the largest draw. Reading note: UCB and Thompson sampling. The same prompt failed with the raw list. In Nie et al., a smaller model fine-tuned on upper confidence bound: pull the arm with the largest average reward plus a bonus that shrinks as the arm is pulled more. Reading note: UCB and Thompson sampling's choices beat a larger prompted one, though neither reached UCB.

Schmied et al. trace early commitment to two distinct habits and show that RL fine-tuning on bandit rewards pushes models to explore more. Small models repeat whichever action fills their context. Large models compute UCB's rule accurately in most steps, yet still act greedily in most of them. In practice, a system that must explore should compute the summary statistics, or run the whole decision rule, in code rather than asking the model to track a raw history. Evaluation also needs hard instances, because greedy play already does well on easy ones and hides the failure.

Setting. A bandit has KK arms; each arm aa has an unknown mean reward arm aa's mean reward, unknown to the agent. At round t=1,…,Tt=1,\dots,T, the agent pulls an arm the arm pulled at round tt and sees an independent reward the reward of round tt, drawn independently with mean μat\mu_{a_t} with mean μat\mu_{a_t}, learning nothing about the other arms. Write the arm with the highest mean for the best arm, the best arm's mean reward for its mean, and the number of times arm aa was pulled in rounds 1 to tt for arm aa's pull count in the first tt rounds. the expected reward lost against always pulling the best arm, summed over rounds. Reading note: UCB and Thompson sampling measures the expected reward lost relative to always pulling a⋆a^\star:RegT=E∑t=1T(μ⋆−μat).\mathrm{Reg}_T=\mathbb E\sum_{t=1}^T\big(\mu^\star-\mu_{a_t}\big).On the instances below, UCB and Thompson sampling achieve regret of order (K/Δ)log⁡T(K/\Delta)\log T, where the gap between the best arm's mean and every other arm's mean is the mean gap between the best arm and every suboptimal arm.

Prompting alone (Krishnamurthy et al.). The authors use Bernoulli rewards with μ⋆=0.5+Δ/2\mu^\star=0.5+\Delta/2 and every other arm at 0.5−Δ/20.5-\Delta/2. The hard instance has K=5K=5 and Δ=0.2\Delta=0.2; the easy one has K=4K=4 and Δ=0.5\Delta=0.5. Each round, the model reads the task and history and names an arm. Prompt configurations vary five choices plus an option for step-by-step reasoning (text in which the model reasons before giving its answer; here asked for in zero-shot form, with no worked examples. Reading note: Depth, width and expressivity). The scenario uses buttons or ads, and the framing either stays neutral or hints to balance exploration and exploitation. The history is either the raw list of past rounds or per-arm pull counts and average rewards. Output is one arm or a distribution to sample from, at temperature 0 or 1 (distribution answers run only at 0). GPT-4 wrote chain-of-thought reasoning reliably only with a second reminder, called reinforced chain of thought. Runs last T=100T=100 rounds with 10 or 20 replicates per configuration, benchmarked against UCB, Thompson sampling, and after one pull of each arm, always pull the arm with the best average reward so far.

Two failure statistics detect what total reward cannot at this scale. A a replicate in which the best arm is never pulled from some round tt to the end at round tt means a replicate never pulls a⋆a^\star in rounds tt to TT, and the fraction of replicates with a suffix failure at round tt is the fraction of replicates with one. Once unlucky early draws push a⋆a^\star's average below what another arm settles at, Greedy never tries a⋆a^\star again. Total reward hides this failure at T=100T=100. On the hard instance (simulated here), Greedy averages about 11 short of always pulling a⋆a^\star, matching what Thompson sampling spends on exploration, with a standard deviation near 10 per replicate. Separating the two by mean reward would take thousands of replicates. Their SuffFailFreq(T/2)\mathrm{SuffFailFreq}(T/2), 0.48 versus 0.01 in the paper, already differs by about three standard errors at 10 replicates. The second statistic, the average over replicates of the share of rounds 1 to tt spent on the least-pulled arm; at most 1/K1/K, averages over replicates the share of rounds 1 to tt spent on the least-pulled arm. A rescaled K⋅MinFrac(t)∈[0,1]K\cdot\mathrm{MinFrac}(t)\in[0,1] that stays high as tt grows flags a pulls spread nearly evenly over the arms to the end, with no shift toward the better ones.

The first statistic bounds regret directly. In these instances, every pull of an arm other than a⋆a^\star loses exactly Δ\Delta in expectation (in general, μ⋆−μa\mu^\star-\mu_a). A replicate with a suffix failure at round tt misses a⋆a^\star on all T−t+1T-t+1 remaining rounds, so regret satisfies (computed here)RegT=Δ E[T−NT(a⋆)]≥Δ (T−t+1)×Pr⁡[suffix failure at t].\begin{aligned}\mathrm{Reg}_T&=\Delta\,\mathbb E\big[T-N_T(a^\star)\big]\\&\ge\Delta\,(T-t+1)\\&\quad\times\Pr[\text{suffix failure at }t].\end{aligned}A suffix-failure rate bounded above zero as TT grows therefore forces linear regret in TT, against (K/Δ)log⁡T(K/\Delta)\log T for UCB and Thompson sampling. A replicate in a suffix failure gathers no new data on a⋆a^\star, so longer horizons cannot repair it.

On the hard instance at T=100T=100, all but five configurations across the three models have SuffFailFreq(T/2)≥0.15\mathrm{SuffFailFreq}(T/2)\ge0.15. The basic GPT-4 prompt (buttons, neutral framing, raw history, one arm, no reasoning, temperature 0) reaches 0.50, near Greedy's rate and far above UCB's 0.02. Many of its replicates pull the best arm only a handful of times while the rest lock onto it right away, so lucky runs mask the failure in average reward. Extended to T=500T=500 with 20 replicates, it suffers suffix failures in more than 60% of replicates and earns clearly less reward than UCB and Thompson sampling. Four of the five configurations below 0.15 fail the opposite way. Two GPT-4 configurations requesting a distribution over arms end with K⋅MinFrac(T)K\cdot\mathrm{MinFrac}(T) of 0.41 and 0.49, against 0.28 for Thompson sampling and 0.18 for UCB. Over 200 rounds, the one with raw history keeps that fraction flat and earns clearly less reward. Two GPT-3.5 configurations at temperature 1 likewise keep pulls nearly uniform.

The fifth is the one configuration that explores well, and it depends on the summarized history. It pairs GPT-4 with the buttons scenario, exploration-exploitation framing, the summary, reinforced chain of thought, and temperature 0. That setup ends with K⋅MinFrac(T)K\cdot\mathrm{MinFrac}(T) of 0.33, and its share of pulls on a⋆a^\star climbs steadily toward 1, much like Thompson sampling. Rerun at T=200T=200 with 40 replicates, it holds SuffFailFreq(T/2)\mathrm{SuffFailFreq}(T/2) at 0.03, against 0.12 for the same prompt with raw history, 0.00 for Thompson sampling, and 0.47 for Greedy. The authors suggest the summary helps because the model cannot reliably count and average a raw list itself. With many arms or contexts, however, each arm or context-arm pair appears only a few times, turning summarization into an algorithm design problem of its own.

Easy instances do not reveal the failure. On the easy instance, with 3 replicates per configuration, most GPT-4 setups avoid suffix failures and earn high reward while picking the best-looking arm in most rounds. Greedy also does well there, even though it provably fails with constant probability and 19% of its replicates suffer suffix failures. When rewards separate the arms quickly, little exploration is needed, so easy instances cannot test whether a model truly explores.

Algorithmic prompts and fine-tuning (Nie et al.). Nie et al. introduce Nie et al.'s suite of bandit tasks posed in text: 16 multi-armed configurations and a contextual task built from movie ratings to test whether handing a model more of a bandit algorithm's computation closes the gap. Its multi-armed suite uses K=5K=5 or 20 arms with Bernoulli rewards (gap 0.2 or 0.5) or Gaussian rewards. Its contextual task sets expected reward linear in feature vectors shown in the prompt, with the UCB rule for contextual bandits with rewards linear in the features: play the arm with the largest x⊤θ^+αx⊤A−1xx^\top\hat\theta+\alpha\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 pulls with rewards rr; the square root is the estimate's standard deviation at xx (Li et al., 2010). Reading note: Contextual bandits as the reference algorithm. Methods are ranked by the share of significant wins (t-test, p<0.05p\lt0.05, 30 runs each) against all other methods over all configurations, which depends on the pool of compared methods. Alongside Krishnamurthy et al.'s summary, the prompt can supply UCB's two terms for each arm. Writing arm aa's average reward over its pulls up to round tt for arm aa's average reward so far and UCB's weight on the exploration bonus for the exploration weight, they areVtexploit(a)=μ^t(a),Vtexplore(a)=αlog⁡tNt(a).\begin{aligned}V^{\rm exploit}_t(a)&=\hat\mu_t(a),\\V^{\rm explore}_t(a)&=\alpha\sqrt{\frac{\log t}{\htmlData{gr=g8}{N_t(a)}}}.\end{aligned}UCB picks the arm with the largest sum, leaving the model only an addition and a maximum. On the contextual task, the prompt supplies LinUCB's two terms. As an alternative, OFT: fine-tuning the model to predict UCB's next arm from the history, by maximum likelihood on UCB trajectories (OFT) trains Gemini 1.5 Flash by maximum likelihood to predict UCB's next arm from text histories.

Fine-tuning helps more than any prompt, and neither reaches the algorithm. On the multi-armed tasks, adding the summary or UCB's terms lifts the larger Gemini 1.5 Pro's win rate from 45.5% with raw history to 60.0% and 59.6%. OFT lifts Flash to 65.6%, beating Pro under every prompt, while UCB stands at 90.6%. On the contextual task, raw history is nearly useless to both models (0.0% and 7.1%), and LinUCB's terms lift Pro to 64.3%. Flash fine-tuned with those terms in its training and test prompts reaches 89.3%, against 96.4% for LinUCB.

Why models commit early, and RL fine-tuning (Schmied et al.). The authors test Gemma2 models at 2B, 9B, and 27B on BanditBench's Gaussian bandits, letting each write up to 256 tokens of reasoning before each action. Episodes run T=50T=50 steps over K∈{5,10,20}K\in\{5,10,20\} arms labeled as colored buttons. covt=∣{a∈A:Nt(a)>0}∣/∣A∣\mathrm{cov}_t=|\{a\in\mathcal A:N_t(a)\gt0\}|/|\mathcal A|, the fraction of arms tried at least once by step tt, the fraction of arms tried at least once, climbs for about 10 steps and stalls at 40% (2B) and 65% (9B, 27B) on 10 arms. As soon as an action returns a reward, the models put very high probability on it and keep choosing it, so an untried arm, possibly the best one, is never sampled.

To separate repetition from reward-chasing, the authors take short random-policy histories, repeat the last action 0 to 100 times, and inspect each model's next-action distribution. For 2B, entropy falls as repetitions grow, and 96% of choices go to the most frequent action in the history. For 27B, entropy rises, only 14% of choices go to that action, and most go to the highest-reward arm tried so far. The authors link the small model's habit to the an imitation-trained policy's tendency to repeat its own previous action, because in recorded data the last action predicts the next one well (Wen et al., 2020). Reading note: xLSTM for fast inference of behavior cloning, reading it as an artifact of supervised pretraining.

The 27B model computes the right action and does not take it. Prompted to calculate UCB's counts, means, and bonuses before acting, it gives its highest computed value to the true UCB-optimal arm in 90.3% of steps. Yet 58.1% of all steps pair a correct calculation with the greedy action (the tried arm with the highest UCB value, when that is not optimal). Only 21.6% pair a correct calculation with the optimal arm. Among steps where its math is right, the model still acts greedily about 64% of the time and follows UCB in 24% (computed here), a the gap between what a model can state or compute about a task and what it actually does when acting.

RL on the model's own reasoning makes it explore more and copy less. RL fine-tuning (reinforcement learning fine-tuning, the paper's name for RL on the model's own reasoning and actions with rewards from the environment: PPO's clipped objective with a KL penalty to the starting model, and a penalty of −5-5 when no valid action can be read from the output) runs for 30k updates over a pool of 512 bandits and lowers cumulative regret for 2B and 9B on 5, 10, and 20 arms. Coverage finishes 12% higher on 10 arms and 13% higher on 20. At 0 to 10 repetitions, choices of the most frequent action drop from 70% to 35%, though it still dominates at high repetition. On contextual bandits built from MovieLens, where the prompted model performs near random, the RL-tuned 2B model approaches LinUCB.

Of seven exploration mechanisms compared on 10-arm bandits, with and without RLFT, trying every arm once at the start gives the largest improvement. The other six are epsilon-greedy, shuffling action labels, a summary of counts and mean rewards, a self-correction pass, a majority vote over samples, and a +1 reward for each untried arm during RLFT. With try-all, the 27B model nearly matches UCB, showing that it chooses well once every arm has an estimate. For 2B and 27B, the summary leaves regret well above try-all, though at 9B it gives the lowest regret of the mechanisms tested. Self-correction gives the highest regret at every size (both read approximately from Figure 8; the text discusses neither).

RLFT lowers regret under each of these mechanisms. Adding the +1 exploration bonus rewards trying a new arm immediately instead of relying only on delayed returns over a 50-step episode. That bonus lifts coverage from 50% to 70% and lowers regret further. Supervised fine-tuning on 32k UCB rollouts also reaches UCB's regret over these 50-step episodes.

Consequences and limits. Language models choose well once every arm has an estimate, while summarizing the history in the prompt helps only unevenly. A summary produced GPT-4's single working prompt and lifted Gemini 1.5 Pro. Among Schmied et al.'s Gemma2 models, however, it gave the lowest regret only at 9B and left 2B and 27B well behind try-all. Even when the prompt supplies UCB's terms, leaving only an addition and a maximum, Pro still wins far less often than UCB. The safer engineering choice keeps the decision rule itself in code.

Krishnamurthy et al. measure both failure statistics on every configuration they run, and Schmied et al. observe the same early commitment in another model family under a different metric. Krishnamurthy et al. use few replicates (10 for most GPT-4 setups), horizons of at most 500 rounds, and mid-2023 models, and their results depend sensitively on interacting prompt changes. Nie et al.'s win rates depend on the pool of compared methods. Schmied et al. test one model family up to 27B, run RL only at 2B and 9B, and use three seeds per result. Their 50-step episodes are too short for 20 arms, where UCB is still exploring and some models fall below its regret. Arm labels also matter. Numbering arms instead of using colors lifts 27B's coverage to nearly 90% on 10 arms.

Terms

Suffix failure
best arm never pulled from some round on; Greedy's failure, and most prompted configurations'
Uniform-like failure
pulls stay nearly even to the end; high K⋅MinFrac(T)K\cdot\mathrm{MinFrac}(T)
Regret from suffix failures
RegT≥Δ(T−t+1)Pr⁡[suffix failure at t]\mathrm{Reg}_T\ge\Delta(T-t+1)\Pr[\text{suffix failure at }t] on these instances
Summary versus raw history
GPT-4's one success needs per-arm counts and averages in the prompt; suffix failures at T = 200: 3% with the summary, 12% with the raw list
Easy instances
greedy play does well, so they cannot show exploration
UCB terms in the prompt
UCB's average and bonus per arm in the prompt; the model only adds and maximizes
OFT
fine-tuning on UCB's next arm; Flash 65.6% against Pro's best 60.0% and UCB's 90.6%
Copying the frequent action
choosing the action that fills the context; 96% of choices for 2B, 14% for 27B
Knowing-doing gap
27B computes UCB's choice correctly in 90.3% of steps but acts greedily in about 64% of those
RLFT and try-all
RL on the bandit's rewards: coverage +12%, frequent-action choices 70% to 35%; pulling every arm once gives the largest gain; +1 per untried arm: coverage 50% to 70%

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