SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Jon Schneider Google Research hnei@google.com
Julian Zimmert  
Google Research  
zimmert@gmail.com
We consider the problem of designing contextual bandit algorithms in the "cross-learning" setting of Balseiro et al., where the learner observes the loss for the action they play in all possible contexts, not just the context of the current round. We specifically consider the setting where losses are chosen adversarially and contexts are sampled i.i.d. from an unknown distribution. In this setting, we resolve an open problem of Balseiro et al. by providing an efficient algorithm with a nearly tight (up to logarithmic factors) regret bound of  $\widetilde{O}(\sqrt{TK})$ , independent of the number of contexts. As a consequence, we obtain the first nearly tight regret bounds for the problems of learning to bid in first-price auctions (under unknown value distributions) and sleeping bandits with a stochastic action set.
At the core of our algorithm is a novel technique for coordinating the execution of a learning algorithm over multiple epochs in such a way to remove correlations between estimation of the unknown distribution and the actions played by the algorithm. This technique may be of independent interest for other learning problems involving estimation of an unknown context distribution.
In the contextual bandits problem, a learner repeatedly observes a context, chooses an action, and observes a reward for the chosen action only. The goal is to learn a policy that maximizes the expected reward over time, while taking into account the fact that the context can change from one round to the next. Algorithms for the contextual bandits problem are extensively used across various domains, such as personalized recommendations in e-commerce, dynamic pricing, clinical trials, and adaptive routing in networks, among others.
Traditionally, in contextual bandits problems, the learner only observes the reward for the current action and the current context. However, in some applications, the learner may be able to deduce the reward they would have received from taking this action in other contexts and attempt to make use of this additional information. For example, if a learner is repeatedly bidding into an auction (where their context is their private value for the item, and their action is the bid), they can deduce their net utility under different counterfactual values for the item.
This form of "cross-learning" between contexts was first introduced by Balseiro et al. [2019], who showed that with this extra information it is possible to construct algorithms for this problem with regret guarantees (compared to the best fixed mapping from contexts to actions) that are independent of the total number of contexts  $C$  – in contrast, without this cross-learning information it is necessary to suffer at least  $\Omega(\sqrt{CKT})$  regret against such a benchmark. In particular, when contexts are drawn i.i.d. from a known distribution  $\nu$  and losses are chosen adversarially, Balseiro et al. [2019] present an efficient algorithm that achieves  $\widetilde{O}(\sqrt{KT})$  expected regret compared to the best fixed mapping from contexts to actions. However, this learning algorithm crucially requires knowledge of the distribution
$\nu$  over contexts (knowledge which is unrealistic to have in many of the desired applications). Balseiro et al. [2019] present an alternate algorithm in the case where  $\nu$  is unknown, albeit with a significantly worse regret bound of  $O(K^{1/3}T^{2/3})$ .
Our main contribution in this paper is to close this gap, providing an efficient algorithm (Algorithm 1) which does not require any prior knowledge of  $\nu$ , and attains  $\widetilde{O}(\sqrt{KT})$  regret (where the  $\widetilde{O}$  hides logarithmic factors in  $K$  and  $T$ , but not  $C$ ). Since there is an  $\Omega(\sqrt{KT})$  regret bound from ordinary (non-contextual) bandits, this bound is optimal up to logarithmic factors in  $K$  and  $T$ .
Techniques At first glance, it may seem misleadingly simple to migrate algorithms from the known context distribution setting to the unknown context distribution setting. After all, we are provided one sample from this context distribution every round, and these samples are unbiased and unaffected by the actions we take. This suggests the idea of just replacing any use of the true context distribution in the original algorithm by the current empirically estimated context distribution.
Unfortunately, this does not easily work as stated. We go into more detail about why this fails and the challenges of getting this to work in Section 2.1 after we have introduced some notation, but at a high level the algorithm of Balseiro et al. [2019] requires computing a certain expectation over  $\nu$  when computing low-variance unbiased loss estimates. In particular, this expectation appears in the denominator of these estimates, meaning tiny errors in evaluating it can lead to large changes in algorithm behavior. Even worse, the quantity we need to take the expectation of depends on the previous contexts and therefore can be correlated with our empirical estimate of  $\nu$ , preventing us from applying standard concentration bounds.
We develop new techniques to handle both of these challenges. First, we present a new method of analysis that sidesteps the necessity of proving high probability bounds on each of the denominators individually, instead bounding their expected sum in aggregate. Secondly, we present a method of scheduling the learning algorithm into different epochs in a way which largely disentangles the correlation between learning  $\nu$  and solving the bandit problem.
As a final note, we remark that dealing with unknown context distributions is a surprising challenge in many other contextual learning problems. For example, Neu and Olkhovskaya [2020] study a variant of linear contextual bandits where they can only prove their strongest regret bounds in the setting where they know the distribution over contexts. It would be interesting to see if the techniques we develop in this paper provide a general method for handling such issues – we leave this as an interesting future direction.
1.1 Applications
As an immediate consequence of our bounds for Algorithm 1, we obtain nearly tight regret bounds for a number of problems of interest. We focus on two such applications in this paper: bidding in first-price auctions, and sleeping bandits with stochastic action sets.
Learning to bid in first-price auctions [Balseiro et al., 2019, Han et al., 2020b,a, Zhang et al., 2021, 2022, Badanidiyuru et al., 2023]. In a first-price auction, an item is put up for sale. Simultaneously, several bidders each submit a hidden bid for the item. The bidder with the highest bid wins the item and pays the value of their bid. Over the last few years, first-price auctions have become an increasingly popular format for a variety of large-scale advertising auctions [Chen, 2017].
Unlike second-price auctions (where the winning bidder pays the second-highest bid), first-price auctions are non-truthful, meaning that it is not the incentive of the bidder to bid their true value for the item – indeed, doing so guarantees the bidder will gain no utility from winning the auction. Instead, the optimal bidding strategy in a first-price auction is complex and depends on the bidders estimation of the other players' values and bids. As such, it is a natural candidate for learning over time (especially since advertising platforms run these auctions millions of times a day).
This problem was a motivating application for Balseiro et al. [2019], who proved an  $O(T^{3/4})$  regret bound for bidders with an unknown (but stochastic iid and bounded) value distribution participating in adversarial first-price auctions with no feedback aside from whether they won the item. Later, several works studied variants of this problem under more relaxed feedback models (for example, Han et al. [2020b] introduced "winning-bid" feedback, where the bidder can always see the winning
Algorithm	Regret	Computation
Exp4 Auer et al. [2002]	K√T	2^K
Saha et al. [2020]	√2^dT (K^2√T)	KT
Algorithm 1	√KT	K
Table 1: Related works in the sleeping bandits framework ignoring all logarithmic terms. The improved regret bound of Saha et al. [2020] is restricted to problem instances where availability of all arms are independent.
bid, and Zhang et al. [2022] study this problem in the presence of machine-learned advice), but none improve over the  $O(T^{3/4})$  bound in the binary feedback setting.
In Section 4.1, we show that Algorithm 1 leads to an efficient  $\widetilde{O}(T^{2/3})$  regret algorithm for the setting of Balseiro et al. [2019]. This nearly (up to logarithmic factors) matches an  $\Omega(T^{2/3})$  lower bound proved by Balseiro et al. [2019].
Sleeping bandits [Kanade et al., 2009, Kleinberg et al., 2010, Neu and Valko, 2014, Kanade and Steinke, 2014, Kale et al., 2016, Saha et al., 2020]. Sleeping bandits are a variant of the classical multi-armed bandit problem, motivated by settings where some actions or experts might not be available in every round. For instance, some items in retail stores might be out of stock, or certain servers in load balancing might be under maintenance. When both losses and arm availabilities are adversarial, the problem is known to be NP-hard [Kleinberg et al., 2010] and EXP4 obtains the optimal  $\widetilde{O}(K\sqrt{T})$  regret. However, when losses are adversarial but availabilities are stochastic, it is unknown what the minimax optimal  $K$ -dependency is and whether it can be obtained by a computationally efficient algorithm. The state of the art for efficient algorithm is either  $O((KT)^{\frac{2}{3}})$  [Neu and Valko, 2014] or  $O(\sqrt{2KT})$  [Saha et al., 2020]. The latter work provides an improved algorithm with  $O(K^2\sqrt{T})$  regret when the arm availabilities are independent, however, in the general case, the computational complexity scales with  $T$ .
In Section 4.2, we show that Algorithm 1 leads to an efficient  $(O(K)$  time per round)  $\widetilde{O} (\sqrt{KT})$  regret algorithm for the sleeping bandits problem with arbitrary stochastic arm availabilities. Again, this nearly matches the  $\Omega (\sqrt{KT})$  lower bound inherited from standard bandits.
Other applications. Finally, we briefly point out that our algorithm extends to the other applications mentioned in Balseiro et al. [2019], including multi-armed bandits with exogenous costs, dynamic pricing with variable costs, and learning to play in Bayesian games. In all cases, applying Algorithm 1 allows us to get nearly the same regret bounds in the unknown context distribution setting as Balseiro et al. [2019] can obtain in the known distribution setting.
Notation For any natural number  $N$ , we use  $[N] = \{1,2,\dots,N\}$ .
We study a contextual  $K$ -armed bandit problem over  $T$  rounds, with contexts belonging to some set  $\mathcal{C}$ . At the start of the problem, an oblivious adversary selects a bounded loss function  $\ell_{tk} : \mathcal{C} \to [0,1]$  for every round  $t \in [T]$  and every arm  $k \in [K]$ . In each round  $t$ , then we begin by sampling a context  $c_t \sim \nu$  i.i.d. from an unknown distribution  $\nu$  over  $\mathcal{C}$ , and we reveal this context to the learner. Based on this context, the learner selects an arm  $A_t \in [K]$  to play. The adversary then reveals the function  $\ell_{t,A_t}$ , and the learner suffers loss  $\ell_{t,A_t}(c_t)$ . Notably, the learner observes the loss for every context  $c \in \mathcal{C}$ , but only for the arm  $A_t$  they actually played.
We would like to design learning algorithms that minimize the expected regret of the learner with respect to the best fixed mapping from contexts to actions. In particular, letting  $\Pi = \{\pi : [C] \to [K]\}$ , we define
$$
\operatorname {R e g} = \max  _ {\pi^ {*} \in \Pi} \mathbb {E} \left[ \sum_ {t = 1} ^ {T} \ell_ {t, A _ {t}} (c _ {t}) - \ell_ {t, \pi^ {*} (c _ {t})} (c _ {t}) \right].
$$
Note that here, the expectation is defined both over the randomness of the algorithm and the randomness of the contexts.
Non-uniform action sets For some applications (specifically, for sleeping bandits), we will find it useful to restrict the action set of the learner as a function of the context. To do so, we associate every context  $c \in \mathcal{C}$  with a fixed non-empty set of active arms  $\mathcal{A}_c \subseteq [K]$ . In round  $t$ , we then restrict the learner to playing an action  $A_t$  in  $\mathcal{A}_{c_t}$  and measure the regret with respect to policies in the restricted class  $\Pi = \{\pi : [K] \to [C] ; \pi(c) \in \mathcal{A}_c\}$ . All the analysis we present later in the paper will apply to the non-uniform action set case (which includes the full action set case above as a special case).
2.1 Challenges to extending existing algorithms
It is not a priori obvious that any learning algorithm in this setting can obtain regret independent of the size of  $\mathcal{C}$ . Indeed, without the ability to cross-learn between contexts (i.e., only observing the loss for the current action and the current context), one can easily prove a lower bound of  $\Omega (\sqrt{|\mathcal{C}|KT\log K})$  by choosing an independent hard bandits instance for each of the contexts in  $\mathcal{C}$ . With the ability to cross-learn between contexts, we side-step this lower bound by being able to gain a little bit of information about each context in each round – however, this information may not be equally useful for every context (e.g., it may be the case that arm 1 is a useful arm to explore for context  $c_{1}$ , but is already known to be very sub-optimal in context  $c_{2}$ ).
In Balseiro et al. [2019], the authors provide an  $\widetilde{O} (\sqrt{KT})$  regret algorithm for this problem in the setting where the learner is aware of the context distribution  $\nu$ . This algorithm essentially runs one copy of EXP3 per context using the following unbiased estimator of the loss (which takes advantage of the cross-learning between contexts):
$$
\widehat {\ell} _ {t k} (c) = \frac {\ell_ {t k} (c)}{\mathbb {E} _ {c \sim \nu} [ p _ {t k} (c) ]} \mathbb {I} \left(A _ {t} = k\right), \tag {1}
$$
where in this expression,  $p_{tk}(c)$  is the probability that the algorithm would choose arm  $k$  in round  $t$  if the context was  $c$ . A straightforward analysis of this algorithm (following the analysis of EXP3, but using the reduced variance of this estimator) shows that it obtains  $\widetilde{O}(\sqrt{KT})$  regret.
The only place knowledge of  $\nu$  is required in this algorithm is in computing the denominator  $f_{tk}(p) = \mathbb{E}_{c\sim \nu}[p_{tk}(c)]$  of our estimator. It is natural, then, to attempt to extend this algorithm to work in the unknown distribution setting by replacing the distribution  $\nu$  with the empirical observed distribution of contexts so far; that is, replacing  $f_{tk}(p)$  with  $\widehat{f_{tk}} (p) = \frac{1}{t}\sum_{s = 1}^{t}p_{sk}(c_s)$ . Unfortunately, this approach runs into the following two challenges.
First, since this quantity appears in the denominator, small differences between  $f_{tk}(p)$  and  $\widehat{f}_{tk}(p)$  can lead to big differences in the estimated losses. This can be partially handled by replacing the denominator with a high probability upper bound  $\widehat{f}_{tk}(p) + C_t$  for some confidence constant  $C_t$ . However, doing so also introduces a bias penalty of  $O(C_T T)$  into the analysis. Tuning this constant leads to another  $T^{2/3}$  algorithm.
Secondly, when we compute the estimator  $\widehat{f}_{tk}(p) = \frac{1}{t}\sum_{s=1}^{t} p_{sk}(c_s)$ , we have the issue that  $p_{tk}$  is not independent from the previous contexts  $c_t$ . This can cause the gap between  $\widehat{f}_{tk}(p)$  and  $f_{tk}(p)$  to be larger than what we would expect via concentration inequalities. Avoiding this issue via union bounds leads to a polynomial dependency on  $|\mathcal{C}|$ .
2.2 Our techniques
Avoiding high-probability bounds. While prior work ensured that  $\widehat{f}_{t,k}(p) + C_t \geq f_{t,k}(p)$  with high probability, the analysis only requires this to hold in expectation. The following lemma shows that this relaxation allows for smaller confidence intervals. While we don't use this specific lemma in our later proofs, we believe that this result might be of independent interest.
Lemma 1. Let  $X_{1},\ldots ,X_{t}$  be i.i.d. samples from a distribution  $\nu$  over [0,1] with mean  $\mu$ , and let  $\widehat{\mu} = \frac{1}{t}\sum_{s = 1}^{t}X_{s}$  denote the empirical mean. Then
$$
\mathbb {E} \left[ \frac {1}{\widehat {\mu} + 1 6 / t} \right] \leq \mathbb {E} \left[ \frac {1}{\mu} \right].
$$
This implies that we only need order  $\sqrt{T}$  many i.i.d. samples for estimating  $f_{t,k}(p)$  with sufficient precision.
Increasing the number of i.i.d. samples. In order for us to use samples from the context distribution in theorems like Lemma 1, these samples must be independent and must not have already been used by the algorithm to compute the current policy. We increase the number of independent samples via the idea of decoupling the estimation distribution from the playing distribution.
To elaborate, consider the setting of a slightly different environment that helps us in the following way: instead of observing the loss of the action we played from our distribution  $p_t$ , the environment instead reveals to us the loss of a fresh "exploration action" sampled from a snapshot  $s$  of our action distribution from a previous round. If the environment takes a new snapshot of our policy every  $L$  rounds (i.e.,  $s = p_{eL}$  for some integer  $e$ ) then this reduces the number of times we need to estimate the importance weighting factor in the denominator of (1) to once in every epoch, since the importance weighting factor stays the same throughout the epoch. At the same time, we have  $L$  fresh i.i.d. samples of the context distribution available at the start of every new epoch.
We present a technique to operate in the same way without such a change in the environment. Instead of the environment taking snapshots of our policy, the algorithm will be responsible for taking snapshots  $s$  itself. In order to generate unbiased samples from  $s$  (while actually playing  $p_t$  in round  $t$ ), we decompose the desired action distribution  $p_t$  into an equal mixture of the snapshot  $s$  and an exploitation policy  $q_t$ :  $p_t = \frac{1}{2} (s + q_t)$ . We implement this mixture by tossing a fair coin of whether to sample from  $s$  or  $q_t$ , and only create a loss estimation for when we sample from  $s$ . This approach fails when  $q_t$  is not a valid distribution over arms, but we show that this is a low probability failure event by ensuring stability in the policy  $p_t$ .
Equipped with these two high level ideas, we now drill down into the technical details of our algorithm.
3 Main result and analysis
3.1 The algorithm
We will now present an efficient algorithm for the unknown distribution setting which achieves  $\widetilde{O}(\sqrt{KT})$  regret. We begin by describing this algorithm, which is written out in Algorithm 1.
At the core of our algorithm is an instance of the Follow the Regularized Leader (FTRL) algorithm with entropy regularization (i.e., EXP3). In each each round  $t$ , we will generate a distribution over actions  $p_{t,c_t}$  for the current context  $c_t$  via
$$
p _ {t, c _ {t}} = \arg \min  _ {x \in \Delta ([ K ])} \left\langle x, \sum_ {s = 1} ^ {t - 1} \widehat {\ell_ {s}} (c _ {t}) \right\rangle - \eta^ {- 1} F (x),
$$
where  $F(x) = \sum_{i=1}^{K} x_i \log(x_i)$  is the unnormalized neg-entropy,  $\eta$  is a learning rate and the  $\widehat{\ell}$  are loss estimates to be defined later.
We will not sample the action  $A_{t}$  we play in round  $t$  directly from  $p_t$ . Instead, we will sample our action from a modified distribution  $q_{t}$  that we will construct in a such way so that the probability  $q_{t,i}$  of playing a specific action is not correlated with every single previous context  $c_s$  (for  $s < t$ ). This will then allow us to construct loss estimates in a way that bypasses the second obstacle in Section 2.1.
To do so, we will divide the time horizon into epochs of equal length  $L$  (where  $L = \widetilde{\Theta}(\sqrt{KT})$ , to be specified exactly later). Without loss of generality, we assume  $L$  is even and that  $T$  is an integer multiple of  $L$ . We let  $\mathcal{T}_e$  to denote the set of rounds in the  $e$ -th epoch.
Figure 1: Illustration of the timeline of Algorithm 1. At the end of epoch  $\mathcal{T}_e$ , the snapshot  $s_{e + 2}$  is fixed. The contexts within epoch  $\mathcal{T}_e$  are used to compute loss estimators for epoch  $\mathcal{T}_{e + 1}$ , which are fed to the FTRL sub-algorithm.
At the end of each epoch, we take a single snapshot of the underlying FTRL distribution  $p_t$  for each context and arm; that is, we let
$$
s _ {e + 2, c, k} = p _ {e L, c, k}  ,   \text {w h e r e}   s _ {1, c, k} = s _ {2, c, k} = \left\{ \begin{array}{l l} \frac {1}{| \mathcal {A} _ {c} |} & \text {i f} k \in \mathcal {A} _ {c} \\ 0 & \text {o t h e r w i s e .} \end{array} \right.
$$
During epoch  $e$ , the learner has two somewhat competing goals. First, they would like to play actions drawn from a distribution close to  $p_{t,c_t}$  (as this allows us to bound the learner's regret from the guarantees of FTRL). But secondly, the learner would also like to compute estimators of the true losses  $\ell_{t,k}$  with small variance and sufficiently small bias. To do this, the learner requires a good estimation of the probability of observing each loss (which in turn depends on both the context distribution and the distribution of actions they are playing).
We avoid the problems inherent in estimating a changing distribution by committing to observe the loss function of arm  $k$  with probability  $f_{ek} = \mathbb{E}_{c\sim \nu}[s_{eck} / 2]$  for any  $t\in \mathcal{T}_e$ . This is guaranteed by the following rejection sampling procedure: we first play an arm according to the distribution
$$
q _ {t, c _ {t}} = \left\{ \begin{array}{l l} p _ {t, c _ {t}} & \text {i f} \forall k \in [ K ]: p _ {t, c _ {t}, k} \geq s _ {e, c _ {t}, k} / 2 \\ s _ {e, c _ {t}} & \text {o t h e r w i s e .} \end{array} \right.
$$
After playing arm  $k$  according to  $q_{t,c_t}$ , the learner samples a Bernoulli random variable  $S_{t}$  probability  $\frac{s_{ectk}}{2q_{tc_k}k}$ . If  $S_{t} = 0$ , they ignore the feedback from this round; otherwise, they use this loss. This subsampling ensures that the probability of observing the loss for a given arm is constant over each epoch. To address the first goal and avoid paying large regret due to the mismatch of  $p_t$  and  $q_{t}$ , we tune the FTRL algorithm to satisfy  $p_t = q_t$  with high probability at all times.
To actually construct these loss estimates, we need accurate estimates of the  $f_{ek}$ . To do this we use contexts from epoch  $e - 1$  that were not used to compute  $s_{ec}$ , and are thus free of potential correlations. For similar technical reasons, we will also want to use different sets of rounds for computing estimators  $\widehat{f}_{ek}$  of  $f_{ek}$  and estimators  $\widehat{\ell}_{tk}$  of the losses  $\ell_{tk}$ . To achieve this, we group all timesteps into consecutive pairs. In each pair of consecutive timesteps, we play the same distribution and randomly use one to calculate a loss estimate, and the other to estimate the sampling frequency.
To be precise, let  $\mathcal{T}_e^f$  denote the time-steps selected for estimation the sampling frequency and  $\mathcal{T}_e^\ell$  the time-steps to estimate the losses. Then we have
$$
\widehat {f} _ {e k} = \frac {1}{\left| \mathcal {T} _ {e - 1} ^ {f} \right|} \sum_ {t \in \mathcal {T} _ {e - 1} ^ {f}} \frac {s _ {e c _ {t} k}}{2},
$$
which is an unbiased estimator of  $f_{ek}$ . The loss estimators are
$$
\widehat {\ell} _ {t k} = \frac {2 \ell_ {t k}}{\widehat {f} _ {e k} + \frac {3}{2} \gamma} \mathbb {I} \left(A _ {t} = k \wedge S _ {t} \wedge t \in \mathcal {T} _ {e} ^ {\ell}\right),
$$
where  $\gamma$  is a confidence parameter (which again, we will specify later).