| Contextual bandit | |
|---|---|
| a round, | |
| number of rounds, or of logged rounds | |
| context of round : what the learner knows when it decides, such as features of the user | |
| number of actions | |
| action chosen in round | |
| reward of action in round , in ; the learner sees only | |
| a policy: a rule that maps each context to an action | |
| finite class of policies the learner competes with | |
| number of policies in | |
| expected reward of policy per round | |
| best policy in the class, | |
| regret of policy , | |
| probability that the learner picks action in round , given the history and | |
| propensity of round , , recorded with the action | |
| IPS estimate of from the first rounds | |
| smallest probability any action gets; under ε-greedy; the papers write (2014) and (2016) | |
| ε-greedy's exploration rate: the probability of a uniformly random action in a round | |
| failure probability: the guarantees hold with probability at least | |
| small constant in the bound for many policies on one log | |
| Agarwal et al. (2014) | |
| weight on policy ; nonnegative, summing to at most 1, nonzero for few policies | |
| probability of action in context after mixing with uniform exploration, | |
| the leader: the policy with the largest IPS estimate after rounds | |
| estimated regret, | |
| average over the logged contexts of ; it bounds the variance of 's IPS estimate | |
| constant scaling the estimated regret in the variance condition; in the paper | |
| , the logarithmic factor in | |
| absolute constant in the factor-2 comparison of true and estimated regret | |
| IPS reward vector of round : at the logged action, 0 elsewhere | |
| reward vector given to the argmax oracle, | |
| Regression oracles (2020, 2022) | |
| predicted reward of action in the current context | |
| largest predicted reward, that of the greedy action | |
| how sharply probability falls with an action's predicted gap | |
| class of reward models the regression learner fits | |
| LinUCB (Li et al., 2010) | |
| feature vector of article for the user of round , with entries | |
| ridge estimate of article 's coefficients, | |
| over the past rounds in which article was shown | |
| over the same rounds, the reward (1 for a click) | |
| multiplier of LinUCB's bonus, tuned on a separate day of data | |
Context. A news page chooses a featured story, an ad server picks an ad, and a cloud controller decides how long to wait before rebooting a machine. Each sees information about the current request, takes one action, and observes the outcome only for that action. A system that always serves its current best guess never sees what the other actions would have done. Its logs cannot tell whether a different rule would have worked better, and a model retrained on them reinforces the system's own past choices. The contextual bandita repeated decision in which each round shows a context, the learner picks one of finitely many actions, and only the chosen action's reward is revealed; the target is the best rule from contexts to actions models this problem. Li et al. (2010) guide exploration with the uncertainty of a linear model on Yahoo!'s front page. Agarwal et al. (2014) give an algorithm with optimal regret for any policy class a supervised learner can search. Agarwal et al. (2016) build that exploration-and-logging loop into a production system called the Decision Service.
Exploration is a data-collection design problem. Suppose a system randomizes its choices and logs the chosen action's probability at decision time. Those logs can then evaluate any policya rule that maps each context to an action, including one that never ran. In round , a context arrives and the learner picks an action from choices with probability , called the propensitythe probability with which the logged action was chosen, recorded when the decision is made. Reading note: Doubly robust policy evaluation. It observes only that action's reward . To estimate a policy's expected reward , inverse propensity scoringIPS: estimating a policy's reward from logged rounds by dividing each logged reward by its propensity and counting it only where the policy would have taken the logged action. Reading note: Doubly robust policy evaluation (IPS) uses the Horvitz-Thompson estimator from survey sampling:Write for the probability the learner assigned to 's action. The indicator equals 1 with that probability, canceling the denominator. Each term therefore has mean and second moment at most . The estimate is unbiased whenever 's actions had positive probability, and those probabilities govern its variance.
Every logged round informs every policy that agrees with the logged action, so one exploration log evaluates an entire policy class at once. Suppose every action receives probability at least the smallest probability that any action gets, in each round or in the logged data; under ε-greedy over logged rounds. With probability at least , one log estimates every policy in simultaneously within the first error below, while separate A/B tests splitting traffic across policies incur the second (Agarwal et al., 2016):Here is a small constant. Collecting that log costs the reward given up on randomized rounds. The design problem is choosing how much probability each action gets.
Uniform exploration pays too much for actions that already look bad. The learner competes with the best policy in a finite class , judged by regretthe reward lost against the best policy in the class: per round for a single policy, , and summed over rounds for a learner. Under ε-greedy, exploring uniformly at rate forfeits about reward while leaving every IPS estimate with variance about . The greedy policy played between explorations then errs by about per round. Balancing against stalls regret at order . Agarwal et al. (2014) budget exploration by the stakes and reach the optimal rate. They keep each policy's estimate only as precise as its estimated regret requires.
The leader is the policy with the largest IPS estimate after rounds. To set the exploration budget, the learner places nonnegative weights the weight on policy ; the weights are nonnegative, sum to at most 1, and are nonzero for few policies on a few policies and puts any leftover mass on . It then mixes the sampled policy's action with uniform exploration at floor probability . The average inverse probability of 's action over logged contexts, , with the probability that the weights and the uniform mixing give action ; the paper writes for , bounds policy 's IPS variance. Write for estimated regret, and fix a constant , set to 100 in the paper. For every , the weights must satisfyThe first condition keeps played policies close to the leader. The second lets bad policies carry higher variance. Any policy with still gets variance bound , within a factor of 4 of uniform exploration. The algorithm recomputes the weights at doubling epoch ends with and , shrinking exploration as estimates sharpen.
That precision keeps true and estimated regret aligned. Each IPS term is at most . Freedman's inequalitya Bernstein-type bound for martingales: a sum of martingale differences, each at most and with summed conditional variances , exceeds about with probability at most , so the deviation is set by the variance more than by the range (Beygelzimer et al., 2011) and a union bound over therefore limit to about . With , both and equal . Plugging in the variance bound for givesThe last line applies AM-GM in the form and uses .
The leader has estimated regret 0, and 's estimate cannot exceed the leader's. Applying the deviation bound to , the leader, and then pins true and estimated regret within a factor of 2 of each other, up to a floor proportional to :Here is an absolute constant, and the paper makes this comparison exact by induction over epochs. Because a policy's estimation error is a fixed fraction of its distance from the leader, a clearly bad policy cannot masquerade as the best. It is estimated only well enough to stay ruled out. By the first weight condition, played policies have average estimated regret , so each round costs in expectation. Summing over rounds gives . On i.i.d. rounds, regret after rounds is with probability at least , the optimal order against for uniform exploration.
Checking the variance condition directly for every policy in a large class is intractable. Instead, the algorithm finds the weights by calling a supervised learner as an argmax oraclea routine that, given contexts with nonnegative reward vectors, returns ; this is cost-sensitive classification, which supervised learners solve, which acts as a separation oracle. Write the IPS reward vector of round : at the logged action and 0 at the others, so that averages for round 's IPS reward vector, and define modified rewards . Policy 's variance violation, , equals the average of over the logged rounds plus terms independent of . Because is large for actions the current weights rarely play and for actions with high estimated reward, a single oracle call returns the most violated policy.
Raising that violated policy's weight is a coordinate-descent step on a potential that drops by a fixed amount at each update. Each solve therefore finishes in at most such steps, one oracle call each. Over rounds, the algorithm makes big-O up to logarithmic factors in and oracle calls in total. Earlier, Randomized UCB, the monster of the paper's title, required calls per round. The algorithm's total call count is close to tight. Each call adds at most one policy to 's support, and on some problems any distribution meeting the variance conditions after rounds needs at least on the order of policies. An oracle-based method therefore cannot make substantially fewer calls.
Later work replaces the classification oracle and iterative weight solve with a regression model and a closed-form sampling rule. Let be the predicted reward of action in the current context, and write for the largest prediction. SquareCB (Foster and Rakhlin, 2020) and FALCON (Simchi-Levi and Xu, 2022) give every non-greedy action probabilityand put the remaining mass on the greedy action. The inverse probability enforces the 2014 variance budget action by action. Each action's expected predicted cost, , stays below however bad the action looks. Simchi-Levi and Xu make this link explicit. The policy distribution induced by their rule satisfies two conditions of the 2014 form, with replacing and predicted regret replacing IPS regret. Their proof then follows the same factor-2 comparison.
Both methods match the 2014 optimal regret order. Paired with an online regression learner, SquareCB attains regret for a finite reward-model class , even when contexts are chosen adversarially. On i.i.d. contexts, FALCON reaches using only offline least-squares fits. Both require realizabilitythe true mean reward of every context and action is one of the models in ; the 2014 algorithm competes with the best policy in without any such assumption, which the 2014 algorithm does not need. Vowpal Wabbitan open-source online learning library that reduces contextual bandit learning to cost-sensitive classification or regression; the Decision Service is built on it implements the rule as --cb_explore_adf --squarecb, with growing like by default. It also provides --cover, an online variant of the 2014 algorithm.
LinUCB (Li et al., 2010) is a cheap parametric special case that replaces randomization with an optimism bonus from a linear model. It models article 's click rate as linear in a -dimensional user-article feature vector . From past rounds where article was shown, it forms , summed over the feature vectors of the past rounds in which article was shown, with features (six in the experiments) and , fits the ridge estimate , and servesUnder a standard normal prior on the coefficients and unit-variance Gaussian click noise, the square root equals the posterior standard deviation of the predicted click rate. It stays large when a user's features point in directions the article's past viewers have not covered, aiming exploration at the user-article pairs the model knows least about.
Because LinUCB is deterministic given the history, its own logs carry no propensities for IPS. Li et al. evaluate it offline by replaying uniformly logged traffic, keeping a logged event only when the algorithm picks the logged article. Uniform logging keeps each event with probability exactly , independent of the history. The kept stream therefore matches live traffic in distribution and evaluates even algorithms that learn online. Replay requires uniform logs and roughly times as much data. User features lifted the served policy's click-through rate by around 10% over context-free ε-greedy across about 36 million visits to Yahoo!'s front page during one week of May 2009. Using the same per-article linear models, LinUCB earned 26% more clicks than ε-greedy while learning, because ε-greedy explores by showing random articles.
The Decision Service (Agarwal et al., 2016) builds randomization and logging directly into serving, splitting exploring, logging, learning, and deploying into separate components. A client library inside the application turns the context and current model into an action distribution and samples an action with a seeded generator. It logs at decision time so the recorded propensity matches what actually ran. The log component waits a fixed interval before joining each reward to its decision, supplying a default reward of 0 if none arrives. Waiting keeps the learner from favoring actions with fast feedback. The learner trains online in Vowpal Wabbit, evaluates candidate policies with real-time IPS, and logs a model ID with every decision so runs can be reproduced offline.
In production, even small logging errors distort the estimates sharply. To measure the damage, the authors injected real deployment bugs into a day of MSN data. They then took the ratio of a policy's IPS estimate on its training data to its IPS estimate on held-out data. On clean logs, those two estimates agree within 5%. Every injected bug inflated the training estimate, by factors of 1.2 to 8.7. The largest jump, 8.7 times, came from a feature marking the chosen action that exists only after the decision. Next came editors overriding 10% of actions, leaving the logged probability attached to a different action and inflating the estimate 3.0 times.
Deployed in production, the service beat each site's prior policy. At MSN, a two-week A/B test using ε-greedy with outperformed the editors' ordering on two homepage blocks. Click-through rose by more than 25% on one block and by 5.3% on another with ten times the traffic, and the service became the default for logged-in users. Complex gained more than 30% over its editors, and TrackRevenue raised revenue by 18% over a context-free ε-greedy bandit. At Azure Compute, the default policy waits 10 minutes before rebooting an unresponsive virtual machine. Its logs directly reveal what any shorter wait would have done, yielding an offline estimate of 19% less wasted time. To learn from its own traffic, a system should randomize decisions it may later change and log the chosen action's probability at decision time. It should join rewards after a fixed wait and evaluate candidates offline before deploying. Running ε-greedy around the existing production policy is enough to make the logs usable.
Limits. IPS requires positive probability on every action a policy takes, and its variance explodes when there are many actions. Doubly robustIPS applied only to the residual of a reward model : each term becomes ; unbiased when either the propensities or the reward model are right, and with less variance than IPS when is accurate (Dudík et al., 2011). Reading note: Doubly robust policy evaluation estimates (Dudík, Langford, and Li, 2011) apply IPS only to a reward model's residual, cutting variance when the model is accurate. The theory also assumes a fixed distribution. At MSN, a policy trained on one day achieved only 73% of a freshly trained policy's click rate the next day, so the service keeps learning and resets its learning rate daily. LinUCB was tested on one site over one week with one run per setting. The 2014 guarantees assume i.i.d. rounds, a finite class, and an exact oracle. That paper's experiment instead runs Online Cover, an online variant with doubly robust estimates that sits outside the theory. Each production deployment compares against editorial orderings or a context-free bandit, with no competing contextual learner in the test.
Terms
- Contextual bandit
- each round: see a context, pick one of actions, see only that action's reward; compete with the best policy in a class
- Exploration as data collection
- randomize and log the chosen action's probability at decision time, and the logs value any policy
- IPS estimate
- ; unbiased, second moment at most
- One log, many policies
- error for all policies at once, against for A/B tests
- Budget by the stakes
- : near-uniform precision for policies that might be best, less for bad ones
- Factor 2
- true and estimated regret within a factor of 2 plus ; summing gives
- Argmax oracle
- cost-sensitive classification; one call finds the most violated variance condition
- Regret and calls (2014)
- regret with oracle calls in all
- Inverse-gap rule
- : the same budget per action from a regression model, under realizability
- LinUCB
- show ; the bonus is the posterior standard deviation
- Replay evaluation
- keep a uniformly logged event only when the algorithm agrees with it; kept events are distributed as live ones, at times the data
- Log at the decision
- record when the action is chosen; injected logging errors inflated estimates 1.2 to 8.7 times
- Fixed wait
- join each reward to its decision after the same wait, so fast-feedback actions are not favored
Sources
- Lihong Li, Wei Chu, John Langford, and Robert E. Schapire. A Contextual-Bandit Approach to Personalized News Article Recommendation. WWW, 2010.
- Alekh Agarwal, Daniel Hsu, Satyen Kale, John Langford, Lihong Li, and Robert E. Schapire. Taming the Monster: A Fast and Simple Algorithm for Contextual Bandits. ICML, 2014.
- Alekh Agarwal, Sarah Bird, Markus Cozowicz, Luong Hoang, John Langford, Stephen Lee, Jiaji Li, Dan Melamed, Gal Oshri, Oswaldo Ribas, Siddhartha Sen, and Alex Slivkins. Making Contextual Decisions with Low Technical Debt. arXiv preprint, 2016.
- Dylan J. Foster and Alexander Rakhlin. Beyond UCB: Optimal and Efficient Contextual Bandits with Regression Oracles. ICML, 2020.
- David Simchi-Levi and Yunzong Xu. Bypassing the Monster: A Faster and Simpler Optimal Algorithm for Contextual Bandits under Realizability. Mathematics of Operations Research, 2022.
- Alina Beygelzimer, John Langford, Lihong Li, Lev Reyzin, and Robert E. Schapire. Contextual Bandit Algorithms with Supervised Learning Guarantees. AISTATS, 2011.
- Miroslav Dudik, John Langford, and Lihong Li. Doubly Robust Policy Evaluation and Learning. ICML, 2011.
- Miroslav Dudik, Daniel Hsu, Satyen Kale, Nikos Karampatziakis, John Langford, Lev Reyzin, and Tong Zhang. Efficient Optimal Learning for Contextual Bandits. UAI, 2011.
- Daniel G. Horvitz and Donovan J. Thompson. A Generalization of Sampling Without Replacement from a Finite Universe. Journal of the American Statistical Association, 1952.
Connected notes
- Scaling RL computeRunning RL at scale · Importance weighting for distribution shift
Each token's gradient carries the ratio of its probability under the trained copy to that under the copy that sampled it; CISPO caps that weight at where DAPO's clip drops the gradient of a token whose ratio has moved past the clipping range in the direction its advantage favors, which raises the fitted ceiling from 0.52 to 0.595; computing the output layer in FP32, which shrinks the kernel mismatch inside every ratio, raises the base recipe's ceiling from 0.52 to 0.61 on its own.
- 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.
- Single Deep CFR and DREAMReinforcement learning for reasoning · Importance weighting for distribution shift
Sampling one action per decision divides each payoff by the probability of reaching it, and exploring at rate keeps that weight at most , so the regret bound still holds but grows exponentially with the number of decisions.
Penalizing a model through a linear probe on its own activations creates an adversarial feedback loop in which the model shifts the concept onto a new direction entangled with core features or into a nonlinear ReLU product code, so monitoring breaks unless the score is detached or read from a frozen model and periodically refit.