Recommender systems
Exploration, Contextual Bandits, and Online Learning
Understand exploration-exploitation, contextual bandits, logging probabilities, regret, safety constraints, and deployment discipline.
By the end you can
- Explain exploration-exploitation and the contextual-bandit feedback loop
- Compare epsilon-greedy, UCB, and Thompson-style exploration
- Identify support, propensity, safety, reward, and experiment-interaction risks
- Design bounded exploration with logging and stop rules
Example
The system never learned whether tail items were good
High-confidence head articles took almost all of the exposure a news recommender had to give. Offline data showed little evidence about niche sources, so every new model stayed uncertain about them and went on avoiding them. The loop closes on itself. A bandit receives feedback only for the action it chose, and the policy chose the head. In the logs, an item that genuinely performs badly and an item nobody tried look identical. The only thing that tells them apart is exposure. And exposure is spent out of a real user's session. That is what the rest of this lesson is about: what that exposure costs, who has paid it in public, and what has to be recorded while it is being spent.
- Exploitation: The policy chose items with the highest current estimate.
- Exploration: The system allocated some exposure to uncertain alternatives.
- Data value: Exploration created information for future decisions, and it is the only thing that does.
- User cost: Poor or repetitive exploratory choices could degrade experience, so the cost is charged to sessions rather than to a compute budget.
- Logging requirement: Counterfactual analysis depended on known action probabilities and support — a probability that was never recorded, or recorded wrongly, cannot be reconstructed afterwards.
Visual
A safe exploration loop
Exploration is bounded before it starts. The loop runs in five stages, and four of them are decisions taken in advance. Context and eligible actions defines which candidates can be responsibly explored. Policy and probability chooses actions with known or reconstructable probabilities. Outcome and delay observes reward, guardrails and mature consequences. That stage's name matters: how long feedback takes to arrive changes which exploration method wins. Estimator and update learns from chosen actions while accounting for policy selection. Budget and stop rule limits regret, exposure, risk and experiment duration. Without that last stage, all four run until somebody notices.
Context and eligible actions
Define which candidates can be responsibly explored.
Policy and probability
Choose actions with known or reconstructable probabilities.
Outcome and delay
Observe reward, guardrails, and mature consequences.
Estimator and update
Learn from chosen actions while accounting for policy selection.
Budget and stop rule
Limit regret, exposure, risk, and experiment duration.
Comparison
Epsilon-greedy, UCB and Thompson-style methods express uncertainty differently — and the difference has been measured
The difference is where the uncertainty lives. Epsilon-greedy holds none. It randomizes a fixed share of decisions anyway, which is what makes its propensities so easy to write down and its behaviour easy to audit. The price is that it explores weak actions indiscriminately, so the eligible action set has to do the protecting.
Upper confidence bound adds a bonus for what the model does not know. The size of that bonus is not a metaphor. Auer and two co-authors proved it in 2002. UCB1 is the average reward plus a one-sided confidence bonus, and their Theorem 1 bounds its expected regret after n plays at 8·Σ_{i:μi<μ*}(ln n / Δi) + (1 + π²/3)·Σ_j Δj, for arbitrary reward distributions supported in [0,1]. What was new was not that regret grows logarithmically. It was when the guarantee applies. The abstract says it in one line: “In this work we show that the optimal logarithmic regret is also achievable uniformly over time, with simple and efficient policies, and for all reward distributions with bounded support.” Uniformly over time, not only asymptotically — the bound holds at the horizon you actually stop at. The cost of that guarantee is calibrated uncertainty. The bonus is only as good as the confidence interval underneath it.
Thompson sampling draws one plausible world and acts as though it were true. The case for it is empirical rather than a guarantee. Chapelle and Li ran both methods to T = 10^6 in 2011. The pool held 10 items, and at any given time one of them retired with probability 10^-3 and was replaced by a new one. Results were averaged over 100 repetitions. Then they varied how often feedback came back. With feedback at every step (δ=1), regret was 24,145 for UCB against 9,105 for Thompson — a ratio of 2.65. With feedback arriving only every 1,000 steps (δ=1,000), it was 226,220 against 59,256, a ratio of 3.82. “It appears that Thompson sampling is more robust than UCB when the delay is long,” they wrote. That is the map's outcome-and-delay stage with a price on it. A deterministic rule keeps picking the same arm while it waits. Here the wait cost it 3.82 times the regret.
Epsilon-greedy
Randomizes a fixed share of decisions.
- Simple and auditable
- Explores weak actions indiscriminately
- Easy propensity calculation
- Useful as a controlled baseline
Upper confidence bound
Adds an uncertainty bonus to estimated value.
- Targets uncertain promising actions
- Needs calibrated uncertainty
- Can overexplore sparse or noisy estimates
- Useful with structured models
Thompson sampling
Samples a plausible model or reward and acts optimally under it.
- Probability matching intuition
- Depends on posterior quality
- Harder in complex neural systems
- Useful with tractable uncertainty models
Analogy
A clinical trial with an enormous treatment menu
A trial that varies treatment learns what a trial handing everyone the current best guess never learns. It is bounded anyway. The rule that bounds it is written down, and it is worth reading rather than gesturing at. The FDA's 2019 guidance on adaptive designs sets the definition: “For the purposes of this guidance, an adaptive design is defined as a clinical trial design that allows for prospectively planned modifications to one or more aspects of the design based on accumulating data from subjects in the trial.”
Prospectively planned is the load-bearing phrase. The guidance recommends complete prespecification of the rules governing those adaptations — as nonbinding guidance, not a binding rule. It also records that response-adaptive randomization remains controversial. That is the technique that shifts assignment probabilities based on accumulating outcome data. It is precisely what a bandit does by construction.
Recommendation exploration sits under both pressures at once. The budget is declared in advance, the way a prespecified adaptation rule is. Action probabilities are logged the way randomization is recorded. And the proxy reward is named out loud, because it stands in for a benefit nobody measured directly.
The adaptation rules are prespecified before the data starts accumulating; a policy that sets its exposure budget after week one has the order backwards.
Bandit methods optimize decisions while learning from partial feedback — at a rate somebody has to choose
A contextual bandit observes a context, chooses an action, receives feedback for the chosen action, and updates a policy. Exploration balances current estimated value against information about uncertain alternatives. Recommendation action spaces are large and structured, so practical systems often explore within a retrieved candidate set, or use uncertainty and randomization at selected stages.
What an exploration budget looks like in production is on the record. On MSN, the Decision Service ran exploration as epsilon-greedy with ε = 33%, on a 10-minute experimental unit, with a new model deployed every 5 minutes. Twelve authors published that deployment in 2016. A third of decisions randomized, and the loop closed in five minutes. Measured against the editorial ordering it replaced: “Experiments on the Slate segment of the page showed a >25% CTR improvement over a two-week period; the Panel showed a 5.3% improvement, which is even more significant as it receives 10x more traffic than the Slate.” Long-term engagement metrics were maintained or improved. Note which number is the impressive one: the smaller improvement, on the surface carrying ten times the traffic. Exploration must still respect eligibility, safety, user controls and experience budgets. Those bounds are numbers someone wrote down before Monday, not a disposition.
Exploration is spent out of a real user's session, so eligibility, safety and experience budgets bound it rather than the learning objective alone — at MSN that bound was ε = 33%, chosen in advance.
Case
33 million Yahoo events, and a 12.5 percent lift from exploring
The canonical deployment is more than fifteen years old. In 2010, Li and three co-authors framed news article selection as a contextual bandit. On over 33 million events from the Yahoo! Front Page Today module, their LinUCB algorithm gave a 12.5 percent click lift over a context-free bandit. The comparator matters. That is contextual selection priced against selection that ignores context, not against whatever a given team serves today. The record gives a relative lift and no absolute click-through rate, so the figure cannot be read as a per-session click count. The authors add that the advantage grew as data became scarcer. That is the honest summary of exploration: it pays most where you know least.
Figure
Steps
Design a bounded exploration policy — and log what makes the last step possible
Exploration starts by restricting the action set to candidates that are eligible and plausibly useful. Then choose the uncertainty method and the budget: exposure limits, segments, stop conditions. Then log probabilities, preserving action probabilities, context, candidates and policy version. Then monitor regret and guardrails, tracking immediate and delayed user and provider outcomes. Then evaluate off-policy, checking overlap, weight variance and estimator sensitivity.
Steps three and five are one step separated in time, and there is a published receipt for what step three buys. A replay estimator is provably unbiased only under a randomized logging policy. Li and three colleagues showed that in 2011, and stated the condition in the paper itself: “In this section, we describe a sound technique for carrying out such an evaluation, assuming that the individual events are i.i.d., and that the logging policy chose each arm at each time step uniformly at random.” They validated it on about 40 million events from a Yahoo! Front Page “random bucket”, collected between 1 and 10 November 2009, with roughly 20 articles in the pool at any moment.
Read that as a price list. An unbiased offline estimate was not extracted from ordinary traffic by cleverness. It existed because uniformly random exposure had been served to real visitors for ten days, and recorded as such.
1. Restrict the action set
Explore only among eligible and plausibly useful candidates.
2. Choose uncertainty and budget
Define exposure limits, segments, and stop conditions.
3. Log probabilities
Preserve action probabilities, context, candidates, and policy version.
4. Monitor regret and guardrails
Track immediate and delayed user and provider outcomes.
5. Evaluate off-policy carefully
Check overlap, weight variance, and estimator sensitivity.
Example
Exploration failures, two of them with numbers attached
No support makes an estimate meaningless, because the new policy prefers actions the logs almost never exposed. A wrong propensity makes it confidently false, and the Decision Service team measured how false. On MSN exploration data, split 80/20 in time order, correctly logged data kept the train/test performance discrepancy within 5%. Overriding 10% of actions, so that the recorded probability was wrong, produced a 3.0x discrepancy. That is larger than reward-delay bias (1.3x), a modified feature (1.2x) or a deleted feature (2.4x), and second only to using the decision itself as a feature (8.7x). The failure is mundane rather than exotic: “A common error is when editors or business logic override the chosen action and record the override making the recorded probability incorrect.” An editor's veto on one decision in ten was enough.
Experiment contamination has a documented industrial fix. Google deployed overlapping experiment infrastructure in March 2007 and described it in 2010. System parameters are partitioned into layers, so a request sits in at most N experiments at once, one per layer. “Each experiment can only modify parameters associated with its layer (i.e., in that subset), and the same parameter cannot be associated with multiple layers.” Interaction is prevented by the parameter partition, not by coordination between teams. Google reports the arrangement enabled nearly an order of magnitude more experiments, launches and experimenters.
- No support: A new policy chooses actions that historical logs almost never exposed, and no reweighting can manufacture exposure that never happened.
- Unknown propensity: The logger cannot reconstruct selection probability — overriding 10% of actions so the recorded probability was wrong blew a within-5% train/test discrepancy out to 3.0x.
- Unsafe action space: Exploration includes items that violate policy or user boundaries.
- Reward myopia: Immediate click reward ignores long-term satisfaction or ecosystem effects.
- Experiment contamination: Multiple ranking and UI experiments interact without joint logging; Google's answer was structural, partitioning parameters into layers so that no parameter belongs to two of them.
Key idea
The exploration gate
Launch exploration only when action support, logging probabilities, risk budgets, user boundaries and rollback are operational. Four of those five are engineering. The fifth has failed in public, at scale, in an experiment whose statistics were never the problem.
An experiment manipulated the News Feed of 689,003 Facebook users, and three researchers published it in PNAS in 2014. Their own account of the consent basis was this: “As such, it was consistent with Facebook's Data Use Policy, to which all users agree prior to creating an account on Facebook, constituting informed consent for this research.” A month later, on 3 July 2014, PNAS published an Editorial Expression of Concern signed by its editor-in-chief. It noted that the data collection may not have been fully consistent with obtaining informed consent and allowing participants to opt out under the Common Rule.
Nothing in that record turns on a bad estimator, a missing propensity or an untested rollback. The user-boundary requirement is a separate item on the gate because it fails separately. A terms-of-service page does not satisfy it.
Missing logging probabilities or an untested rollback turn an experiment into an incident nobody can reconstruct afterwards — and 689,003 accounts show that an experiment can be fully reconstructable and still have crossed a boundary it had no permission to cross.
Key takeaways
- Learning online is valuable only when the information gained justifies the experience and risk spent to obtain it. On MSN that spend was named in advance: epsilon-greedy at ε = 33%, a 10-minute experimental unit, a new model every 5 minutes.
- A contextual bandit observes a context, chooses an action, receives feedback for the chosen action, and updates a policy; feedback for actions it did not choose never arrives.
- UCB1's expected regret after n plays is at most 8·Σ_{i:μi<μ*}(ln n / Δi) + (1 + π²/3)·Σ_j Δj, proved in 2002 — logarithmic regret uniformly over time, for reward distributions supported in [0,1]. The guarantee is only as good as the confidence bonus underneath it.
- Delay reorders the methods. At T = 10^6 with feedback every step, measured regret was 24,145 for UCB against 9,105 for Thompson; when feedback arrived only every 1,000 steps, 226,220 against 59,256.
- Exploration is a controlled allocation of uncertainty, not a license to serve arbitrary items. And a wrong propensity is worse than a missing one: overriding 10% of actions took a within-5% train/test discrepancy to 3.0x.
- Off-policy estimates deserve scrutiny of overlap, weight variance and estimator sensitivity before anyone treats them as evidence that a new policy is safe to serve. The provably unbiased Yahoo replay estimate existed only because a random bucket ran from 1 to 10 November 2009, and cost about 40 million events.