Adversarial Bandits & EXP3
Regret against an adversary: exponential weights with importance-weighted estimates.
Drop the assumption that rewards come from fixed distributions. Let an adversary choose them: a market, a competitor, or just a world too nonstationary to model. You can no longer hope to learn the arms' means, because there are none, but you can still promise to do nearly as well as the best single arm in hindsight. Keeping that promise requires randomization, and one idea, following the regularized leader, yields Hedge, EXP3, their high-probability versions and the algorithms that are optimal against adversaries and random arms at once.
What you’ll learn
- Define the oblivious adversarial bandit and its regret, and prove that every deterministic algorithm can be forced into linear regret.
- Prove a regret bound for Hedge in the full-information setting through follow-the-regularized-leader: a penalty term plus a stability term.
- Derive EXP3 from Hedge with importance-weighted loss estimates, prove their unbiasedness and second-moment bound, and obtain regret .
- Explain why EXP3's guarantee holds only in expectation, and how implicit exploration (EXP3-IX) gives high-probability bounds.
- Connect no-regret learning to equilibria in games and to best-of-both-worlds algorithms such as Tsallis-INF.
Rewards without a model
In an adversarial bandit it is convenient to work with losses. Before the game, an oblivious adversary fixes loss vectors ; it may know the learner's algorithm, but not its future coin flips. In round the learner picks a distribution over arms, draws , and observes only (bandit feedback); with full information it would see the whole vector . Regret compares with the best fixed arm in hindsight:
Against an oblivious adversary the comparator is not random, so this expected regret and the pseudo-regret coincide. A stochastic bandit is the special case of i.i.d. losses, so the lower bound of Regret Lower Bounds applies here too.
A deterministic algorithm's choice is a function of the losses it has seen, and an adversary that knows the algorithm can compute it in advance. Let the adversary put loss 1 on that arm and 0 elsewhere:
The arms' total losses add up to , so the best arm has total loss at most :
A randomized learner escapes: the adversary can compute but not the draw , so whatever it fixes, the learner's expected loss is , and spreading over arms that have done well denies the adversary a sure target.
Two remarks bound the model's scope. If the adversary may react to the learner's past actions, an adaptive adversary, the same algorithms keep their guarantees against the best fixed arm, but that comparator can become meaningless when the losses themselves depend on what was played; policy regret asks for more, and Lattimore and Szepesvári (ch. 11) show that even against constant action sequences it cannot be sublinear in general. And losses and rewards are interchangeable via , but estimators built from losses behave better, as the next steps show.
Full information: Hedge as follow the regularized leader
Hedge, or exponential weights (Littlestone & Warmuth, 1994; Freund & Schapire, 1997), plays , where is arm 's cumulative loss. It is an instance of follow the regularized leader (FTRL): play the distribution that minimizes the past losses plus a regularizer, here the negative entropy . Minimizing over the simplex with a Lagrange multiplier gives exactly the softmax of . The regularizer keeps the learner from jumping to the current leader, which is what an adversary would exploit.
Be-the-leader. Let minimize . By induction on , the hypothetical player who already knows the current loss does at least as well as any fixed : the case holds since minimizes , and adding to the case with gives :
Decompose. The real player uses , not . Add and subtract, then apply the previous line:
Penalty. The negative entropy ranges from at the uniform to at a corner, so for every comparator .
Stability for nonnegative losses. One step of exponential weights gives with , so and, using :
With losses in the stability term is at most . Balance the two terms at :
A sharper inequality (Hoeffding's lemma) improves Hedge's constant to (Cesa-Bianchi & Lugosi, 2006). The point of this cruder route is that its stability step used only , never , so it survives when the losses are replaced by unbounded estimates. FTRL with the entropy is also mirror descent with the KL divergence as its geometry (mirror descent), and changing the regularizer changes the algorithm, as the last step of this lesson shows.
Bandit feedback: EXP3
With bandit feedback only is seen, so Hedge cannot be run directly. EXP3 (Auer, Cesa-Bianchi, Freund & Schapire, 2002) runs Hedge on estimates of the whole loss vector built from that single number, the importance-weighted estimator : zero for the arms not played, and the observed loss scaled up by for the arm that was.
Unbiased. Write for the expectation given the past, which fixes . Arm is played with probability :
Second moment. The stability term of FTRL needs , whose conditional expectation is small even though single estimates can be huge:
Apply FTRL to the estimates. They are nonnegative, so the bound of the previous step holds for them, for any fixed arm as comparator:
Take expectations. and , so for every arm , and with :
The factor in the second moment is the price of seeing one coordinate instead of . A slightly sharper inequality gives (Lattimore & Szepesvári, Theorem 11.2), and changing the regularizer removes the altogether, matching the lower bound (Audibert & Bubeck, 2009). The original EXP3 worked with rewards and mixed in uniform exploration to keep its estimates in check; the loss-based version needs no mixing, because loss estimates are never negative.
With arms and the same horizon, by what factor is the EXP3 bound larger than the Hedge bound obtained by the same argument?
Show the answer
4
The ratio is . Full information reveals all 16 losses each round; bandit feedback reveals one, and the importance weights pay for the other 15 with variance. The gap is real: the minimax regret is of order with full information and with bandit feedback.
import numpy as np
def exp3_ix(loss, eta, gamma, seed=0):
"""loss: T x K array in [0, 1], fixed in advance (oblivious adversary).
gamma = 0 gives loss-based EXP3; gamma = eta / 2 gives EXP3-IX."""
rng = np.random.default_rng(seed)
T, K = loss.shape
L_hat = np.zeros(K) # estimated cumulative losses
incurred = 0.0
for t in range(T):
w = np.exp(-eta * (L_hat - L_hat.min())) # shift for numerical stability
p = w / w.sum()
a = rng.choice(K, p=p)
incurred += loss[t, a] # the only entry observed
L_hat[a] += loss[t, a] / (p[a] + gamma) # importance-weighted estimate
return incurred - loss.sum(axis=0).min() # realized regret vs best fixed armEXP3 and EXP3-IX differ in one character: the in the denominator of the estimate. The returned value is the realized regret of one run, a random variable whose spread is the subject of the next step.
From expectation to high probability
EXP3's bound holds in expectation, and the expectation hides a wide spread. The estimator's variance, , explodes on arms the algorithm has nearly abandoned. Lattimore and Szepesvári (ch. 11) exhibit loss sequences on which, for large , EXP3's realized regret exceeds with probability above . This does not contradict the expected regret, because the realized regret also takes large negative values. Implicit exploration (Kocák, Neu, Valko & Munos, 2014; Neu, 2015) fixes the problem with a one-character change.
Add to the denominator. The estimate is capped at and biased downward, more so for rarely played arms, which therefore look a little better than they are:
The downward bias buys concentration: a single exponential-moment argument shows that the cumulative estimates cannot exceed the true cumulative losses by much, simultaneously for all arms (Neu, 2015, Corollary 1). With probability at least :
Combining this with the FTRL bound, whose stability term is now controlled almost surely through the cap, gives a bound on the realized regret (Neu, 2015, Theorem 1). With , with probability at least :
Earlier high-probability algorithms, such as EXP3.P, forced uniform exploration with probability of order per round. Implicit exploration achieves the same effect, keeping rarely played arms from being written off on the strength of a few huge estimates, without ever pulling an arm just to explore it.
Think first What would it take to track the switch, and what does it cost?
A comparator that may switch, and an algorithm that forgets. Auer et al. (2002) introduced EXP3.S, which keeps every weight from collapsing (mixing in a little uniform weight each round) and competes with action sequences that switch a bounded number of times, at a cost that grows with the number of switches; sliding-window and discounted UCB do the same for stochastic arms (Garivier & Moulines, 2011). Forgetting has a price on stationary problems: a policy with logarithmic regret on fixed arms must suffer regret of order on some two-armed problem with two switches (Lattimore & Szepesvári, Theorem 31.2).
Games, and the best of both worlds
A regret bound holds against every loss sequence, including one produced by another learner. That makes no-regret learning a way to solve games. In a zero-sum matrix game the row player picks a mixed strategy to maximize and the column player picks to minimize it, payoffs in .
Let both players run algorithms with regret at most against the opponent's sequence (full information: each sees the other's mixed strategy). For the row player and the column player respectively:
Add the two inequalities, divide by , and write , for the time averages. The payoffs are linear in each strategy, so averages pass inside:
The left side is the sum of what each player could gain by deviating from the average profile, its exploitability. With Hedge, , so is an -Nash equilibrium; as this even proves von Neumann's minimax theorem.
In general-sum games, the empirical distribution of joint play of no-regret learners approaches the set of coarse correlated equilibria, a weaker notion than Nash. Counterfactual regret minimization (Zinkevich, Johanson, Bowling & Piccione, 2007) decomposes the regret of an extensive-form game into regrets at each information set and minimizes each locally, which is how poker was solved (Counterfactual Regret Minimization). Why last iterates cycle, and how optimistic variants make them converge, is the subject of Learning Dynamics in Games.
Key takeaways
- Against an oblivious adversary, regret compares with the best fixed arm in hindsight; deterministic learners can be forced to regret , so the learner must randomize.
- Follow-the-regularized-leader splits regret into a penalty ( for the entropy) and a stability term ( for nonnegative losses); for Hedge this gives .
- EXP3 runs Hedge on importance-weighted estimates , which are unbiased with , giving regret : a factor for bandit feedback.
- EXP3's realized regret has a wide spread; implicit exploration (EXP3-IX) biases the estimates downward and obtains regret with high probability.
- Time-averaged no-regret play converges to equilibria in zero-sum games, the basis of CFR; Tsallis-INF is optimal against adversaries and stochastic arms at once.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
An oblivious adversary knows a deterministic bandit algorithm. How much regret can it force on arms over rounds?
- About
- About
- At least
- None, since the adversary must fix the losses in advance
Show the answer
C. At least
Fixing the losses in advance is no obstacle: the adversary simulates the algorithm and puts loss 1 on each arm it will choose. The learner loses , the best arm at most . Randomization is what restores sublinear regret.
Why does EXP3 divide the observed loss by ?
- So that every arm's loss estimate is unbiased, although only one loss is observed
- To keep the estimates below 1
- To give rarely played arms an optimistic bonus
- To normalize the weights into a probability distribution
Show the answer
A. So that every arm's loss estimate is unbiased, although only one loss is observed
Given the past, arm is played with probability , so for played and unplayed arms alike. Unbiasedness is paid for in variance: the stability term involves , and that is what turns Hedge's into EXP3's .
What does EXP3-IX gain by estimating instead of dividing by alone?
- An unbiased estimate with lower variance
- Faster computation of the weights
- Exploration through forced uniform pulls
- Estimates capped at and biased slightly downward, which makes the cumulative estimates concentrate and yields a high-probability regret bound
Show the answer
D. Estimates capped at and biased slightly downward, which makes the cumulative estimates concentrate and yields a high-probability regret bound
The cap tames the variance, and the downward bias makes the cumulative estimates, with high probability, lower confidence bounds on the true losses up to . That is what turns an in-expectation guarantee into one that holds with probability .
Two players repeatedly play a zero-sum matrix game, both using Hedge. What is guaranteed to approach a Nash equilibrium?
- The current (last-iterate) strategies
- The time-averaged strategies, whose exploitability is at most
- Nothing, because each player's losses are generated by an adaptive opponent
- Only the strategy of the player with the smaller learning rate
Show the answer
B. The time-averaged strategies, whose exploitability is at most
Adding the two regret bounds shows that the average profile is a -equilibrium. The current strategies can keep cycling around the equilibrium; making the last iterate converge needs other methods, such as optimistic Hedge.
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).
- Y. Freund & R. E. Schapire, "A decision-theoretic generalization of on-line learning and an application to boosting," Journal of Computer and System Sciences 55(1), 119–139 (1997).
- G. Neu, "Explore no more: Improved high-probability regret bounds for non-stochastic bandits," Advances in Neural Information Processing Systems (2015).
- J. Zimmert & Y. Seldin, "Tsallis-INF: An optimal algorithm for stochastic and adversarial bandits," Journal of Machine Learning Research (2021); conference version at AISTATS (2019).
- T. Lattimore & C. Szepesvári, Bandit Algorithms, ch. 11, 12 and 28 (Cambridge University Press, 2020).