Oracle-Efficient Contextual Bandits
Reducing exploration to regression: from ε-greedy to SquareCB.
With a class of a billion policies, EXP4 achieves the optimal regret, of order , by keeping a weight for every policy, which no computer can do. A question shaped a decade of contextual bandit research: can exploration be reduced to the supervised learning we already do well, calling a classifier or a regression solver only a few times? This lesson follows the answer from epoch-greedy's , through the "monster" algorithm that reaches with a classification oracle, to SquareCB and FALCON, where inverse-gap weighting turns any regression method into an optimal contextual bandit, and to the decision-estimation coefficient that explains why it works.
What you’ll learn
- Define regret against a policy class and the oracle model of computation, and explain why EXP4 is statistically optimal but computationally infeasible.
- Explain epoch-greedy and the optimization problem of ILOVETOCONBANDITS, and why controlling the variance of importance-weighted estimates is the crux.
- Prove the per-round inequality of inverse-gap weighting, and derive SquareCB's regret bound in terms of the regression oracle's regret.
- Describe the decision-estimation coefficient as a general account of the statistical complexity of exploration.
A policy class and an oracle
Fix a class of policies, maps from contexts to actions: all depth-5 decision trees on some features, say, or all argmax rules of linear scores. The learner competes with the best policy in the class, in expectation, where is the reward action would have earned in round .
Two kinds of oracle stand in for supervised learning. A cost-sensitive classification oracle receives contexts with a cost for every action and returns the policy in with the lowest total cost, an empirical risk minimization that standard classifiers solve approximately and at scale. A regression oracle fits a reward model to data by least squares, either once on a batch (offline) or by updating after every example (online); regression-based methods assume realizability, for some . An algorithm is oracle-efficient if it runs in polynomial time and makes few oracle calls.
EXP4 (Auer, Cesa-Bianchi, Freund & Schapire, 2002) treats every policy as an expert: it keeps exponential weights over the policies, plays the mixture of actions they recommend with a little uniform exploration, and updates every policy with the importance-weighted estimate of its reward, as EXP3 does for arms (Adversarial Bandits & EXP3). Its regret is of order , even when contexts and rewards are chosen by an adversary, and Seldin and Lugosi (2016) showed that no algorithm can beat order . Chase, Ito and Mehalel (2026) closed the remaining gap with a lower bound matching an upper bound of Kale (2014): the minimax regret is of order . The logarithm makes huge classes statistically affordable, but the weights cost time proportional to in every round.
| Algorithm | Oracle | Oracle calls over rounds | Regret |
|---|---|---|---|
| EXP4 (Auer et al., 2002) | None: enumerates | Work proportional to per round | , even against adversaries |
| Epoch-greedy (Langford & Zhang, 2008) | Classification | About one per epoch | Order , up to factors in and |
| ILOVETOCONBANDITS (Agarwal et al., 2014) | Classification | Order , up to logarithms | |
| SquareCB (Foster & Rakhlin, 2020) | Online regression | One update per round | |
| FALCON (Simchi-Levi & Xu, 2022) | Offline regression | , or if is known | Optimal for the class, e.g. for finite classes |
From epoch-greedy to taming the monster
Epoch-greedy (Langford & Zhang, 2008) alternates a round of uniform exploration, whose importance-weighted data give unbiased value estimates for every policy at once, with an epoch of exploitation that follows the policy the oracle finds best on those data; epochs lengthen as the estimates sharpen. Like explore-then-commit, it cannot beat order : uniform exploration costs the same in every round, whether or not any policy that would choose the explored action is still in contention.
The fix is to explore only as much as needed to tell the remaining good policies apart. ILOVETOCONBANDITS (Agarwal, Hsu, Kale, Langford, Li & Schapire, 2014), building on a slower algorithm of Dudík et al. (2011), keeps a sparse distribution over policies, recomputed at a few epoch boundaries, that satisfies two kinds of constraint:
- Low empirical regret: playing from is cheap, being of the order of the statistical noise.
- Low variance for every policy: for each , the quantity , where is 's action distribution smoothed with a little uniform exploration, is at most of order plus a term that grows with 's empirical regret.
The constraints are met by a coordinate descent in which each step calls the classification oracle. Over rounds it needs calls, far fewer than , and attains regret of order up to logarithms, for i.i.d. contexts.
A distribution over policies plays some policy's actions with probability about in most contexts. What goes wrong if that policy is in fact the best?
- Nothing: its importance weights of about make its estimate unbiased
- Its estimated value is unbiased but so noisy, with variance of order per sample, that the learner cannot tell that it is the best
- Its value is biased downward, because it is rarely played
- The oracle cannot return it
Show the answer
B. Its estimated value is unbiased but so noisy, with variance of order per sample, that the learner cannot tell that it is the best
Unbiasedness holds, but the second moment of each IPS term is of order , so separating that policy from a slightly worse one takes an enormous number of rounds. The variance constraints exist to prevent exactly this for every policy with small empirical regret.
SquareCB: exploration by inverse-gap weighting
Assume realizability and an online regression oracle: after every round it updates its predictions , and its cumulative square loss exceeds that of the best by at most . For a finite class, Vovk's aggregating algorithm gives ; for linear functions in it is of order . SquareCB (Foster & Rakhlin, 2020) turns the predictions into an action distribution with a rule from Abe and Long (1999): put the most weight on the action predicted best, and give every other action a probability inversely proportional to its predicted gap.
import numpy as np
def inverse_gap_weighting(pred, gamma):
"""pred[a]: the regression oracle's predicted reward of action a in this context."""
K = len(pred)
best = int(np.argmax(pred))
p = 1.0 / (K + gamma * (pred[best] - pred)) # small predicted gap -> large probability
p[best] = 0.0
p[best] = 1.0 - p.sum() # the predicted best gets the rest, at least 1/K
return p
# SquareCB, one round: p = inverse_gap_weighting(oracle.predict(x), gamma)
# a = rng.choice(K, p=p); r = observe(a); oracle.update(x, a, r)The whole algorithm. It touches the function class only through the oracle's predictions and updates, so it inherits the oracle's runtime and memory, and of order tunes how fast exploration fades.
Fix a round. Write for the predicted reward of action , for its true mean, , and for the predicted gaps. Inverse-gap weighting plays
Claim (Foster & Rakhlin, 2020, Lemma 3, here in reward form). For every vector of true means , with , the round's expected regret is paid for by the oracle's squared error on the actions it plays:
Proof. For split . Each estimation error, set against its share of the squared errors, costs little by with : together the first and third pieces cost at most . The middle piece is , and . So the left side minus the squared-error term is at most
If , then and , giving . If , then , so , the cancels, and the bound is again . An action's probability falls exactly as fast as its predicted gap can be blamed on the oracle's error.
Summing over rounds. Under realizability the oracle's excess square loss controls its squared errors on the sampled actions, plus a deviation term. So , and of order balances the two:
actions, , and the oracle predicts rewards 0.50, 0.48, 0.30 and 0.10. With what probability does inverse-gap weighting play the 0.48 action?
Show the answer
0.17
. The 0.30 action gets , the 0.10 action , and the predicted best the remaining 0.769. The close runner-up keeps a large share because a gap of 0.02 could easily be the oracle's error; the clearly poor actions are still sampled now and then, in case the oracle is badly wrong about them.
Offline oracles: FALCON. Online regression oracles are rarer than offline ones, which fit a model to a batch. Simchi-Levi and Xu (2022) run inverse-gap weighting in epochs of growing length, refitting the model by least squares once per epoch on the previous epoch's data and raising as the fit improves. For i.i.d. contexts and realizability this attains the optimal regret with only oracle calls over rounds, or if is known in advance.
Why not optimism or posterior sampling? Foster and Rakhlin point out that for general function classes, generalized UCB and Thompson sampling adapt to gaps but, without strong structural assumptions on , can suffer regret growing with itself rather than its logarithm. Inverse-gap weighting never needs a confidence set over , only a good regressor. In a large empirical comparison on supervised datasets, an optimistic regression-oracle method (RegCB; Foster et al., 2018) did best overall, and a purely greedy baseline came a surprisingly close second (Bietti, Agarwal & Langford, 2021). SquareCB is among Vowpal Wabbit's exploration options.
A theory of exploration: the decision-estimation coefficient
The per-round inequality has a general form. Let be a class of models, each assigning to every decision a distribution of observations and an expected reward , with optimal decision , and let be a reference model, such as the current estimate. Foster, Kakade, Qian and Rakhlin (2021) define the decision-estimation coefficient:
Their Estimation-to-Decisions (E2D) algorithm plays, in each round, the minimizing distribution for the current estimate, and its regret is at most of order , with the cumulative error of an online estimator. They also prove lower bounds, governed by a localized version of the coefficient, that apply to every algorithm, so the coefficient characterizes the statistical complexity of interactive decision making from bandits to reinforcement learning, up to the estimation term; in RL it recovers essentially all known hardness results. Inverse-gap weighting is the -armed instance: with squared error in place of Hellinger distance, the per-round inequality says that the coefficient with weight on the information term is at most , and E2D becomes SquareCB.
Key takeaways
- Against a class of policies the optimal regret is of order , up to a logarithmic factor in . EXP4 attains it but enumerates the class, so the goal is oracle efficiency: few calls to a classifier or a regression solver.
- Uniform exploration, as in epoch-greedy, gives order . ILOVETOCONBANDITS reaches with classification calls by keeping importance-weighted variance small exactly for the policies that might still be best.
- Inverse-gap weighting, , satisfies a per-round inequality, regret at most times the squared error plus , so SquareCB's regret is : any online regression method becomes an optimal contextual bandit. FALCON achieves this with offline fits.
- The decision-estimation coefficient generalizes this trade-off between regret and information and characterizes the statistical complexity of interactive decision making, from bandits to RL, up to an estimation term.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
EXP4's regret is of order for a class of policies. Why is it not used for, say, all depth-5 decision trees on a hundred features?
- Because its regret bound holds only against adversaries
- Because is too large for such classes
- Because it keeps and updates a weight for every policy, and the class is astronomically large, so each round costs time proportional to
- Because it needs the horizon in advance
Show the answer
C. Because it keeps and updates a weight for every policy, and the class is astronomically large, so each round costs time proportional to
Statistically, for such a class is modest, so EXP4's regret would be fine. Computationally, every round updates weights. Oracle-efficient algorithms keep the statistics of while touching the class only through an optimization oracle.
What do the variance constraints of ILOVETOCONBANDITS guarantee?
- Every policy with small empirical regret has a precise importance-weighted value estimate, because the exploration distribution plays its actions with non-negligible probability
- Every policy is played equally often
- The regret is zero after the first epoch
- The oracle is called in every round
Show the answer
A. Every policy with small empirical regret has a precise importance-weighted value estimate, because the exploration distribution plays its actions with non-negligible probability
The constraint bounds , the quantity controlling each policy's IPS variance, by about plus a term proportional to the policy's empirical regret. Good policies get precise estimates; clearly bad ones may stay imprecise, which is what saves exploration.
In inverse-gap weighting, how does an action's probability depend on its predicted gap to the predicted best action?
- It is zero unless the gap is zero
- It is , whatever the gap
- It is proportional to
- It is : actions with small predicted gaps keep substantial probability, actions with large gaps are rarely played, and sets the trade-off
Show the answer
D. It is : actions with small predicted gaps keep substantial probability, actions with large gaps are rarely played, and sets the trade-off
The inverse dependence is what makes the per-round inequality work: an action played with probability has a gap , which the oracle's squared error on that action, weighted by , can pay for. Exponential weights would starve near-optimal actions too quickly, and uniform exploration would ignore the predictions.
What does a small decision-estimation coefficient mean?
- The class contains few models
- Some decision distribution, against every model in the class, has either small regret or observations that distinguish that model from the reference
- The reference model is close to the truth
- Exploration is unnecessary
Show the answer
B. Some decision distribution, against every model in the class, has either small regret or observations that distinguish that model from the reference
The coefficient is a minimax trade-off: regret under the worst model minus times the information the decision gathers about it. If it is small, every round either earns nearly optimal reward or learns something, which is why it bounds regret together with an estimation term.
Further reading
- P. Auer, N. Cesa-Bianchi, Y. Freund & R. E. Schapire, "The nonstochastic multiarmed bandit problem," SIAM Journal on Computing 32(1), 48–77 (2002).
- A. Agarwal, D. Hsu, S. Kale, J. Langford, L. Li & R. E. Schapire, "Taming the monster: A fast and simple algorithm for contextual bandits," International Conference on Machine Learning (2014).
- D. J. Foster & A. Rakhlin, "Beyond UCB: Optimal and efficient contextual bandits with regression oracles," International Conference on Machine Learning (2020).
- D. Simchi-Levi & Y. Xu, "Bypassing the monster: A faster and simpler optimal algorithm for contextual bandits under realizability," Mathematics of Operations Research 47(3) (2022).
- D. J. Foster, S. M. Kakade, J. Qian & A. Rakhlin, "The statistical complexity of interactive decision making," arXiv:2112.13487 (2021).