SlowGuess commited on
Commit
3d84746
·
verified ·
1 Parent(s): b1a31cf

Add Batch db07b6ef-c919-40fc-af96-9492bf0f36f3

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. onlinebipartitematchingwithimperfectadvice/b7abe63f-3cc9-4abf-9506-7e9b6f1ccc43_content_list.json +3 -0
  2. onlinebipartitematchingwithimperfectadvice/b7abe63f-3cc9-4abf-9506-7e9b6f1ccc43_model.json +3 -0
  3. onlinebipartitematchingwithimperfectadvice/b7abe63f-3cc9-4abf-9506-7e9b6f1ccc43_origin.pdf +3 -0
  4. onlinebipartitematchingwithimperfectadvice/full.md +716 -0
  5. onlinebipartitematchingwithimperfectadvice/images.zip +3 -0
  6. onlinebipartitematchingwithimperfectadvice/layout.json +3 -0
  7. onlineconformalpredictionwithdecayingstepsizes/0480f286-52a0-42de-acf6-2b1287986b76_content_list.json +3 -0
  8. onlineconformalpredictionwithdecayingstepsizes/0480f286-52a0-42de-acf6-2b1287986b76_model.json +3 -0
  9. onlineconformalpredictionwithdecayingstepsizes/0480f286-52a0-42de-acf6-2b1287986b76_origin.pdf +3 -0
  10. onlineconformalpredictionwithdecayingstepsizes/full.md +727 -0
  11. onlineconformalpredictionwithdecayingstepsizes/images.zip +3 -0
  12. onlineconformalpredictionwithdecayingstepsizes/layout.json +3 -0
  13. onlinelinearregressionindynamicenvironmentsviadiscounting/33cd2428-408d-4fda-9a01-ec7534d5ee56_content_list.json +3 -0
  14. onlinelinearregressionindynamicenvironmentsviadiscounting/33cd2428-408d-4fda-9a01-ec7534d5ee56_model.json +3 -0
  15. onlinelinearregressionindynamicenvironmentsviadiscounting/33cd2428-408d-4fda-9a01-ec7534d5ee56_origin.pdf +3 -0
  16. onlinelinearregressionindynamicenvironmentsviadiscounting/full.md +0 -0
  17. onlinelinearregressionindynamicenvironmentsviadiscounting/images.zip +3 -0
  18. onlinelinearregressionindynamicenvironmentsviadiscounting/layout.json +3 -0
  19. onlinematchingwithstochasticrewardsprovablebetterboundviaadversarialreinforcementlearning/d68942a3-988d-4b42-88e4-6de96a201749_content_list.json +3 -0
  20. onlinematchingwithstochasticrewardsprovablebetterboundviaadversarialreinforcementlearning/d68942a3-988d-4b42-88e4-6de96a201749_model.json +3 -0
  21. onlinematchingwithstochasticrewardsprovablebetterboundviaadversarialreinforcementlearning/d68942a3-988d-4b42-88e4-6de96a201749_origin.pdf +3 -0
  22. onlinematchingwithstochasticrewardsprovablebetterboundviaadversarialreinforcementlearning/full.md +550 -0
  23. onlinematchingwithstochasticrewardsprovablebetterboundviaadversarialreinforcementlearning/images.zip +3 -0
  24. onlinematchingwithstochasticrewardsprovablebetterboundviaadversarialreinforcementlearning/layout.json +3 -0
  25. onlinematrixcompletionacollaborativeapproachwithhottitems/0a50e4a0-0797-44d0-9e0c-d98a7b5bb11c_content_list.json +3 -0
  26. onlinematrixcompletionacollaborativeapproachwithhottitems/0a50e4a0-0797-44d0-9e0c-d98a7b5bb11c_model.json +3 -0
  27. onlinematrixcompletionacollaborativeapproachwithhottitems/0a50e4a0-0797-44d0-9e0c-d98a7b5bb11c_origin.pdf +3 -0
  28. onlinematrixcompletionacollaborativeapproachwithhottitems/full.md +0 -0
  29. onlinematrixcompletionacollaborativeapproachwithhottitems/images.zip +3 -0
  30. onlinematrixcompletionacollaborativeapproachwithhottitems/layout.json +3 -0
  31. onlineresourceallocationwithnonstationarycustomers/1475aa41-d2b5-4316-9a16-58f2b5f808e1_content_list.json +3 -0
  32. onlineresourceallocationwithnonstationarycustomers/1475aa41-d2b5-4316-9a16-58f2b5f808e1_model.json +3 -0
  33. onlineresourceallocationwithnonstationarycustomers/1475aa41-d2b5-4316-9a16-58f2b5f808e1_origin.pdf +3 -0
  34. onlineresourceallocationwithnonstationarycustomers/full.md +0 -0
  35. onlineresourceallocationwithnonstationarycustomers/images.zip +3 -0
  36. onlineresourceallocationwithnonstationarycustomers/layout.json +3 -0
  37. onlinespeculativedecoding/d57a4a03-7165-4267-883a-fb27ae603b12_content_list.json +3 -0
  38. onlinespeculativedecoding/d57a4a03-7165-4267-883a-fb27ae603b12_model.json +3 -0
  39. onlinespeculativedecoding/d57a4a03-7165-4267-883a-fb27ae603b12_origin.pdf +3 -0
  40. onlinespeculativedecoding/full.md +462 -0
  41. onlinespeculativedecoding/images.zip +3 -0
  42. onlinespeculativedecoding/layout.json +3 -0
  43. onlinevariationalsequentialmontecarlo/be0a007f-a784-40d2-81e2-222d2d20bc76_content_list.json +3 -0
  44. onlinevariationalsequentialmontecarlo/be0a007f-a784-40d2-81e2-222d2d20bc76_model.json +3 -0
  45. onlinevariationalsequentialmontecarlo/be0a007f-a784-40d2-81e2-222d2d20bc76_origin.pdf +3 -0
  46. onlinevariationalsequentialmontecarlo/full.md +0 -0
  47. onlinevariationalsequentialmontecarlo/images.zip +3 -0
  48. onlinevariationalsequentialmontecarlo/layout.json +3 -0
  49. openadhocteamworkwithcooperativegametheory/e57b0fbd-0a7c-426d-8b15-78c5ef14ac69_content_list.json +3 -0
  50. openadhocteamworkwithcooperativegametheory/e57b0fbd-0a7c-426d-8b15-78c5ef14ac69_model.json +3 -0
onlinebipartitematchingwithimperfectadvice/b7abe63f-3cc9-4abf-9506-7e9b6f1ccc43_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:781f487de09f65175c742e80ad0c79ae392beab5188505e5a2ff37143c92b3db
3
+ size 158812
onlinebipartitematchingwithimperfectadvice/b7abe63f-3cc9-4abf-9506-7e9b6f1ccc43_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a51211b9656f013756c0a6514c8582df35e50a8b41541b632c4c56810ae21ccf
3
+ size 198987
onlinebipartitematchingwithimperfectadvice/b7abe63f-3cc9-4abf-9506-7e9b6f1ccc43_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c8c1c0f06dc7c7a7404c0397e1e716f3f49fca09404a827c64abbc4259db8438
3
+ size 577897
onlinebipartitematchingwithimperfectadvice/full.md ADDED
@@ -0,0 +1,716 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Online bipartite matching with imperfect advice
2
+
3
+ Davin Choo $^{1}$ Themis Gouleakis $^{1}$ Chun Kai Ling $^{2}$ Arnab Bhattacharyya $^{1}$
4
+
5
+ # Abstract
6
+
7
+ We study the problem of online unweighted bipartite matching with $n$ offline vertices and $n$ online vertices where one wishes to be competitive against the optimal offline algorithm. While the classic RANKING algorithm of (Karp et al., 1990) provably attains competitive ratio of $1 - 1 / e > 1 / 2$ , we show that no learning-augmented method can be both 1-consistent and strictly better than 1/2-robust under the adversarial arrival model. Meanwhile, under the random arrival model, we show how one can utilize methods from distribution testing to design an algorithm that takes in external advice about the online vertices and provably achieves competitive ratio interpolating between any ratio attainable by advice-free methods and the optimal ratio of 1, depending on the advice quality.
8
+
9
+ # 1. Introduction
10
+
11
+ Finding matchings in bipartite graphs is a mainstay of algorithms research. The area's mathematical richness is complemented by a vast array of applications — any two-sided market (e.g., kidney exchange, ridesharing) yields a matching problem. In particular, the online variant enjoys much attention due to its application in internet advertising. Consider a website with a number of pages and ad slots (videos, images, etc.). Advertisers specify ahead of time the pages and slots they like their ads to appear in, as well as the target user. The website is paid based on the number of ads appropriately fulfilled. Crucially, ads slots are available only when traffic occurs on the website and are not known in advance. Thus, the website is faced with the online decision problem of matching advertisements to open ad slots.
12
+
13
+ The classic online unweighted bipartite matching problem
14
+
15
+ *Equal contribution $^{1}$ School of Computing, National University of Singapore $^{2}$ Industrial Engineering and Operations Research, Columbia University. Correspondence to: Davin Choo <davin@u.nus.edu>.
16
+
17
+ Proceedings of the $41^{st}$ International Conference on Machine Learning, Vienna, Austria. PMLR 235, 2024. Copyright 2024 by the author(s).
18
+
19
+ by Karp et al. (1990) features $n$ offline vertices $U$ and $n$ online vertices $V$ . Each $v \in V$ reveals its incident edges sequentially upon arrival. With each arrival, one makes an irreversible decision whether (and how) to match $v$ with a neighboring vertex in $U$ . The final offline graph $\mathcal{G} = (U \cup V, E)$ is assumed to have a largest possible matching of size $n^* \leq n$ , and we seek online algorithms producing matchings of size as close to $n^*$ as possible. The performance of a (randomized) algorithm $\mathcal{A}$ is measured by its competitive ratio:
20
+
21
+ $$
22
+ \min _ {\mathcal {G} = (U \cup V, E)} \min _ {V ^ {\prime} s \text {a r r i v a l s e q .}} \frac {\mathbb {E} [ \# \text {m a t c h e s b y} \mathcal {A} ]}{n ^ {*}}, \tag {1}
23
+ $$
24
+
25
+ where the randomness is over any random decisions made by $\mathcal{A}$ . Traditionally, one assumes the adversarial arrival model, i.e., an adversary controls both the final graph $\mathcal{G}$ and the arrival sequence of online vertices.
26
+
27
+ Since any maximal matching has size at least $n^* / 2$ , a greedy algorithm trivially attains a competitive ratio of $1/2$ . Indeed, Karp et al. (1990) show that no deterministic algorithm can guarantee better than $1/2 - o(1)$ . Meanwhile, the randomized RANKING algorithm of Karp et al. (1990) attains an asymptotic competitive ratio of $1 - 1/e$ which is also known to be optimal (Karp et al., 1990; Goel & Mehta, 2008; Birnbaum & Mathieu, 2008; Vazirani, 2022).
28
+
29
+ In practice, advice (also called predictions or side information) is often available for these online instances. For example, online advertisers often aggregate past traffic data to estimate the future traffic and corresponding user demographic. While such advice may be imperfect, it may nonetheless be useful in increasing revenue and improving upon aforementioned worst-case guarantees. Designing algorithms that utilize such advice in a principled manner falls under the research paradigm of learning-augmented algorithms. A learning-augmented algorithm is said to be (i) $a$ -consistent if it is $a$ -competitive with perfect advice and (ii) $b$ -robust if it is $b$ -competitive with arbitrary advice quality.
30
+
31
+ Goal 1.1. Let $\beta$ be the best-known competitive ratio attainable by any classical advice-free online algorithm. Can we design a learning-augmented algorithm for the online bipartite matching problem that is 1-consistent and $\beta$ -robust?
32
+
33
+ Clearly, Goal 1.1 depends on the form of advice as well as a suitable measure of its quality. Setting these technicalities aside for now, we remark that Goal 1.1 strikes the best of
34
+
35
+ all worlds: it requires that a perfect matching be obtained when the advice is perfect, while not sacrificing performance with respect to advice-free algorithms when faced with low-quality advice. In other words, there is potential to benefit, but no possible harm when employing such an algorithm. We make the following contributions in pursuit of Goal 1.1.
36
+
37
+ # 1. Impossibility under adversarial arrivals
38
+
39
+ We show that under adversarial arrivals, learning augmented algorithms, no matter what form the advice takes, cannot be both 1-consistent and strictly more than $1/2$ -robust. The latter is worse than the competitive ratio of $1 - 1/e$ guaranteed by known advice-free algorithms (Karp et al., 1990).
40
+
41
+ # 2. Achieving Goal 1.1 under the random arrival model
42
+
43
+ We propose an algorithm TESTANDMATCH achieving Goal 1.1 under the weaker random arrival model, in which an adversary controls the online vertices $V$ but its arrival order is randomized. Our advice is a histogram over types of online vertices; in the context of online advertising this corresponds to a forecast of the user demographic and which ads they can be matched to. TESTANDMATCH assumes perfect advice while simultaneously testing for its accuracy via the initial arrivals. If the advice is deemed useful, we mimic the matching suggested by it; else, we revert to an advice-free method. The testing phase is kept short (sublinear in $n$ ) by utilizing state-of-the-art $L_{1}$ estimators from distribution testing. We analyze our algorithm's performance as a function of the quality of advice, showing that its competitive ratio gracefully degrades to $\beta$ as quality of advice decays. To the best of our knowledge, our work is the first that shows how one can leverage techniques from the property testing literature to designing learning-augmented algorithms.
44
+
45
+ While our contributions are mostly theoretical, we give and discuss various practical extensions of TESTANDMATCH, and also show preliminary experiments in Appendix F.
46
+
47
+ # 2. Preliminaries and related work
48
+
49
+ An online bipartite instance is defined by a bipartite graph $\mathcal{G} = (U\cup V,E)$ where $U$ and $V$ are the set of $n$ offline and $n$ online vertices respectively. A type of an online vertex $v\in V$ refers to the subset of offline vertices $\{u\in U\mid \{u,v\} \in E\}$ that it is neighbors with; there are $2^{n}$ possible types and at most $n$ of them are realized through $V$ . The types of vertices $v_{i}\in V$ are revealed one at a time in an online fashion, when the corresponding vertex arrives and one has to decide whether (and how) to match the newly arrived vertex irrevocably. A matching in the graph $\mathcal{G}$ is a set of edges $M\subseteq E$ such that for every vertex $w\in U\cup V$ , there is at most one edge in $M$ incident to $w$ . Given two vectors of length $k$ , we denote the $L_{1}$ -distance between them as $L_{1}(x,y) = ||x - y||_{1} = \sum_{i = 1}^{k}|x_{i} - y_{i}|$ . For any set $S$ , $2^{S}$ denotes its power set (set of all subsets of $S$ ).
50
+
51
+ In this work, we focus on the classic unweighted online bipartite matching (see Mehta (2013) for other variants) where the final offline graph has a matching of size $n^* \leq n$ .
52
+
53
+ Arrival models. The degree of control an adversary has over $V$ affects analysis and algorithms. The adversarial arrival model is the most challenging, with both the final graph $\mathcal{G}$ and the order in which online vertices arrive chosen by the adversary. Here, an algorithm's competitive ratio is given by (1). In random arrival models, $\mathcal{G}$ remains adversarial but the arrival order is random. For this paper, we assume the Random Order setting, where an adversary chooses a $\mathcal{G}$ , but the arrival order of $V$ is a uniformly random permutation. In this setting, the competitive ratio is defined as
54
+
55
+ $$
56
+ \min _ {\mathcal {G} = (U \cup V, E)} \mathbb {E} _ {V ^ {\prime} \text {s a r r i v a l s e q .}} \frac {\mathbb {E} [ \# \text {m a t c h e s b y} \mathcal {A} ]}{n ^ {*}}. \tag {2}
57
+ $$
58
+
59
+ Two even easier random arrival models exist: (i) known-IID model (Feldman et al., 2009), where the adversary chooses a distribution over types (which is known to us), and the arrivals of $V$ are chosen by sampling i.i.d. from this distribution, and (ii) unknown-IID model, which is the same as known-IID but with the distributions are not revealed to us. The competitive ratios between these arrival models are known to exhibit a hierarchy of difficulty (Mehta, 2013):
60
+
61
+ Adversarial $\leq$ Rand. Order $\leq$ Unknown-IID $\leq$ Known-IID
62
+
63
+ As our Random Order setting is the most challenging amongst these random arrival models, our methods also apply to the unknown-IID and known-IID settings.
64
+
65
+ # 2.1. Advice-free online bipartite matching
66
+
67
+ The following example highlights the key difficulty faced by online algorithms. Consider the gadget for $n = 2$ in Figure 1, where the first online vertex $v_{1}$ neighbors with both $u_{1}$ and $u_{2}$ and the second online vertex $v_{2}$ neighbors with only one of $u_{1}$ or $u_{2}$ . Even when promised that the true graph is either $\mathcal{G}_1$ or $\mathcal{G}_2$ , any online algorithm needs to correctly guess whether to match $v_{1}$ with $u_{1}$ or $u_{2}$ to achieve perfect matching when $v_{2}$ arrives.
68
+
69
+ ![](images/7f01bcf981961401303c132ef3fcb1905d28dbbdb6141cc8a5e8b7af322aacd1.jpg)
70
+ Figure 1. Gadget for $n = 2$ . Red edges observed when $v_{2}$ arrives.
71
+
72
+ Table 1 summarizes known results about attainable competitive ratios and impossibility results in the adversarial and Random Order arrival models; see Appendix A.1 for more details. In particular, observe that there is a gap between the upper and lower bounds in the Random Order arrival model which remains unresolved.
73
+
74
+ Table 1. Known competitive ratios for the classic unweighted online bipartite matching problem for deterministic (det.) and randomized (rand.) algorithms under the adversarial and Random Order arrival models. Note that $1 - 1 / e \approx 0.63$ .
75
+
76
+ <table><tr><td></td><td>Adversarial</td><td>Random Order</td></tr><tr><td>det. algo.</td><td>1/2</td><td>1 - 1/e</td></tr><tr><td>det. hardness</td><td>1/2</td><td>3/4</td></tr><tr><td>rand. algo.</td><td>1 - 1/e</td><td>0.696</td></tr><tr><td>rand. hardness</td><td>1 - 1/e + o(1)</td><td>0.823</td></tr></table>
77
+
78
+ The deterministic GreEDy algorithm which matches a newly arrived vertex with any unmatched offline neighbor attains a competitive ratio of at least $1/2$ in the adversarial arrival model and at least $1 - 1/e$ in the random arrival model (Goel & Mehta, 2008). Meanwhile, the randomized RANKING algorithm of Karp et al. (1990) achieves a competitive ratio of $1 - 1/e$ in the adversarial arrival model. In the Random Order arrival model, RANKING achieves a strictly larger competitive ratio, shown to be at least 0.653 in Karande et al. (2011) and 0.696 in Mahdian & Yan (2011). However, Karande et al. (2011) showed that RANKING cannot beat 0.727 in general; so, new ideas will be required if one believes that the tight competitive ratio bound is 0.823 (Manshadi et al., 2012).
79
+
80
+ # 2.2. Learning-augmented algorithms for matching
81
+
82
+ Appendix A.2 broadly reviews learning-augmented algorithms and we focus on matching algorithms here.
83
+
84
+ Aamand et al. (2022) studied the adversarial arrival models with offline vertex degrees as advice. While their algorithm is optimal under the Chung-Lu-Vu random graph model (Chung et al., 2003), the class of offline degree advice is unable to attain 1-consistency. Feng et al. (2021) propose a two-stage vertex-weighted variant, where advice is a proposed matching for the online vertices arriving in the first stage. Jin & Ma (2022) showed in this setting a tight robustness-consistency tradeoff and derive a continuum of algorithms tracking this Pareto frontier. Antoniadis et al. (2020b) studied settings with random vertex arrival and weighted edges. Their advice is a prediction on edge weights adjacent to $V$ under an optimal offline matching. Furthermore, their algorithm and analysis uses a hyper-pameter quantifying confidence in the advice, leading to different consistency and robustness tradeoffs. Another relevant work is the LOMAR method proposed by Li et al. (2023). Using a pre-trained reinforcement learning (RL) model along with a switching mechanism based on regret to guarantee robustness with respect to any provided expert algorithm, they claim "for some tuning parameter $\rho \in [0,1]$ , LOMAR is $\rho$ -competitive against our choice of expert online algorithm". We differ from LOMAR in two key ways.
85
+
86
+ 1. Our method does not require any pre-training phase and directly operate on the sequence of online vertices themselves. This means that whatever mistakes made during our "testing" phase contributes to our competitive ratio; a key technical contribution is the use of distribution testing to ensure that the number of such mistakes incurred is sublinear. 2. The robustness guarantee of Li et al. (2023) is substantially weaker than what we provide. Suppose the expert used by LOMAR is $\beta$ -competitive, just like how we use the state-of-the-art algorithm as the baseline. Although Li et al. (2023) does not analyze the consistency guarantee of their method, one can see that LOMAR is $(1 - \rho)$ -consistent and $\rho \cdot \beta$ -robust (ignoring the $B \geq 0$ hyperparameter). LOMAR can only be 1-consistent when $\rho = 0$ , i.e. it blindly follows the RL-based method; but then it will have no robustness guarantees. In other words, LOMAR cannot simultaneously achieve 1-consistency and $\rho \cdot \beta$ -robustness without knowing the RL quality. In contrast, our method is simultaneously 1-consistent and $\approx \beta$ -robust without knowing the quality of our given advice; we evaluate its quality as vertices arrive. Table 2 compares the consistency-robustness tradeoffs.
87
+
88
+ Table 2. Consistency-robustness guarantees of methods that can achieve 1-consistency. Here, $R \in [0,3/4]$ and $\rho \in [0,1]$ . Note that Jin & Ma (2022) is for the 2-staged setting.
89
+
90
+ <table><tr><td></td><td>Jin &amp; Ma (2022)</td><td>LOMAR</td><td>Ours</td></tr><tr><td>Robustness</td><td>R</td><td>ρ·β</td><td>≈β</td></tr><tr><td>Consistency</td><td>1 - (1 - √1-R)2</td><td>1 - ρ</td><td>1</td></tr></table>
91
+
92
+ More broadly, Lavastida et al. (2020; 2021) learn and exploit parameters of the online matching problem and provide PAC-style guarantees. Dinitz et al. (2022) studied the use of multiple advice and seek to compete with the best on a per-instance basis. Finally, others suggest using advice to speedup offline matching via "warm-start" heuristics (Dinitz et al., 2021; Chen et al., 2022; Sakaue & Oki, 2022).
93
+
94
+ # 2.3. Distribution testing and distance estimation
95
+
96
+ In this work, we will use results from (Jiao et al., 2018) for the problem of $L_{1}$ distance estimation. This is closely related to tolerant identity testing, where the tester's task is to distinguish whether a distribution $p$ is $\varepsilon_{1}$ -close to some known distribution $q$ from the case where $p$ is $\varepsilon_{2}$ -far from $q$ , according to some natural distance measure.
97
+
98
+ The following theorem states the number of samples from an unknown distribution $p$ that needed by the algorithm in (Jiao et al., 2018) to get an estimate of $L_{1}(p, q)$ for some reference distribution $q$ with additive error $\varepsilon$ and error probability $\delta$ .<sup>1</sup>
99
+
100
+ Theorem 2.1 (adapted from (Jiao et al., 2018)). Fix a reference distribution $q$ over a domain $T$ of size $|T| = r$ and let $s \in \mathcal{O}\left(\frac{r \cdot \log(1 / \delta)}{\varepsilon^2 \cdot \log r}\right)$ be an even integer. There exists an algorithm that draws $s_1 + s_2$ IID samples from an unknown distribution $p$ over $T$ , where $s_1, s_2 \sim \mathrm{Poisson}(s/2)$ , and outputs an estimate $\hat{L}_1$ such that $|\hat{L}_1 - L_1(p, q)| \leq \varepsilon$ with success probability at least $1 - \delta$ .
101
+
102
+ The algorithm of Theorem 2.1 uses a standard technique in distribution testing known as Poissonization which aims to eliminate correlations between samples at the expense of not having a fixed sample size. Instead, the number of samples follows a Poisson distribution and we treat its mean as the sample complexity. As a consequence, the known result regarding the concentration of the Poisson distribution would be helpful in bounding the overall algorithmic success probability, e.g. see (Canonne, 2019).
103
+
104
+ Lemma 2.2. For any $m > 0$ and any $x > 0$ , we have $\operatorname*{Pr}[|X - m|\geq x]\leq 2e^{-\frac{x^2}{2(m + x)}}$ , where $X\sim \mathrm{Poisson}(m)$ .
105
+
106
+ # 3. Impossibility for adversarial arrival model
107
+
108
+ Unfortunately, Goal 1.1 is unattainable under the adversarial arrival model. Our construction is based on generalizing the gadget in Figure 1 to state Theorem 3.1.
109
+
110
+ Theorem 3.1. For even $n$ , there exists input graphs $\mathcal{G}_1$ and $\mathcal{G}_2$ such that no advice can distinguish between the two within $n/2$ online arrivals. Consequently, an algorithm cannot be both 1-consistent and strictly more than 1/2-robust.
111
+
112
+ Proof. Consider the restricted case where there are only two possible final offline graphs $\mathcal{G}^{(1)} = (U\cup V^{(1)},E^{(1)})$ and $\mathcal{G}^{(2)} = (U\cup V^{(2)},E^{(2)})$ where
113
+
114
+ $$
115
+ \begin{array}{l} E ^ {(1)} = \left\{\left\{u _ {j} ^ {(1)}, v _ {j} ^ {(1)} \right\}, \left\{u _ {j + n / 2} ^ {(1)}, v _ {j} ^ {(1)} \right\}: 1 \leq j \leq n / 2 \right\} \\ \cup \left\{\left\{u _ {j - n / 2} ^ {(1)}, v _ {j} ^ {(1)} \right\}: n / 2 + 1 \leq j \leq n \right\} \\ \end{array}
116
+ $$
117
+
118
+ $$
119
+ \begin{array}{l} E ^ {(2)} = \left\{\left\{u _ {j} ^ {(2)}, v _ {j} ^ {(2)} \right\}, \left\{u _ {j + n / 2} ^ {(2)}, v _ {j} ^ {(2)} \right\}: 1 \leq j \leq n / 2 \right\} \\ \cup \left\{\left\{u _ {j} ^ {(2)}, v _ {j} ^ {(2)} \right\}: n / 2 + 1 \leq j \leq n \right\} \\ \end{array}
120
+ $$
121
+
122
+ We will even restrict the first $n/2$ to be exactly $v_{1}^{(i)}, \ldots, v_{n/2}^{(i)}$ , where $i \in \{1, 2\}$ is the chosen input graph by the adversary. See Figure 2 for an illustration.
123
+
124
+ Suppose $\mathcal{G}_i$ was the chosen graph, for $i\in \{1,2\}$ . In this restricted problem input setting, the strongest possible advice is knowing the bit $i$ since all other viable advice can be derived from this bit. Thus, for the sake of a hardness result, it suffices to only consider the advice of $\hat{i}\in \{1,2\}$ .
125
+
126
+ Within the first $n / 2$ arrivals, any algorithm cannot distinguish and will behave in the same manner. Suppose there is
127
+
128
+ ![](images/40839b99353fd1a90a6ab5c60c2187fe9d14bf2f0684a2a4b0a441eff355141a.jpg)
129
+ Figure 2. Illustration of $\mathcal{G}_1$ and $\mathcal{G}_2$ for Theorem 3.1
130
+
131
+ a 1-consistent algorithm $A$ given bit $\hat{i}$ . In the first $n/2$ steps, $A$ needs to match $v_j$ to $u_{j+n/2}$ if $\hat{i} = 1$ and $v_j$ to $u_j$ for $\hat{i} = 2$ . However, if $i \neq \hat{i}$ , then $A$ will not be able to match any remaining arrivals and hence be at most $1/2$ -robust.
132
+
133
+ In fact, Theorem 3.1 can be strengthened: for any $\alpha \in [0,1/2]$ , no algorithm can be simultaneously $(1 - \alpha)$ -consistent and strictly more than $(1/2 + \alpha)$ -robust. The proof is essentially identical and deferred to Appendix B.
134
+
135
+ While Theorem 3.1 appears simple, we stress that hardness results for learning-augmented algorithms are rare, since the form of advice and its utilization is arbitrary. For instance, Aamand et al. (2022) only showed that when advice is the true degrees of the offline vertices, there exist inputs such that any learning-augmented algorithm can only achieve a competitive ratio of at most $1 - 1 / e + o(1)$ .
136
+
137
+ # 4. Imperfect advice for random arrival model
138
+
139
+ In this section, we present our learning-augmented algorithm TESTANDMATCH which is 1-consistent, $(\beta - o(1))$ -robust, and achieves a smooth interpolation on an appropriate notion of advice quality, where $\beta$ is any achievable competitive ratio by some advice-free baseline algorithm. As discussed in Section 2, the best known competitive ratio of $\beta = 0.696$ is achievable using RANKING (Karp et al., 1990) but it is unknown if it can be improved. In fact, TESTANDMATCH is a meta-algorithm that uses any advice-free baseline algorithm as a blackbox and so our robustness guarantee improves as $\beta$ improves.
140
+
141
+ Using realized type counts as advice. Given the final offline graph $\mathcal{G}^* = (U \cup V, E)$ with maximum matching size $n^* \leq n$ , we can classify each online vertex based on their types, i.e., the set of offline vertices they are adjacent to (Borodin et al., 2020). Define the vector $c^* \in \mathbb{Z}^{2^n}$ indexed by the possible types $2^U$ , such that $c^*(t)$ is the number of times type $t \in 2^U$ occurs in $\mathcal{G}^*$ . Even though there are $2^n$ possible types, the number of realized types is at most
142
+
143
+ # Algorithm 1 TESTANDMATCH
144
+
145
+ input Advice $\hat{c}$ with $\hat{r} = |\hat{T}|$ , BASELINE advice-free algorithm with competitive ratio $\beta < 1$ , error threshold $\varepsilon > 0$ , failure rate $\delta = \delta' + \delta_{poi}$ for $\delta_{poi} = O\left(\frac{1}{poly(\hat{r})}\right)$
146
+
147
+ 1: Compute advice matching $\hat{M}$ from $\hat{c}$
148
+ 2: if $\frac{\hat{n}}{n} \leq \beta$ then
149
+ 3: Run BASELINE on all arrivals
150
+ 4: end if
151
+ 5: Define $s_{\hat{r},\varepsilon,\delta} = \mathcal{O}\left(\frac{(\hat{r} + 1)\cdot\log(1 / \delta')}{\varepsilon^2\cdot\log(\hat{r} + 1)}\right)$
152
+ 6: Define testing threshold $\tau = 2\left(\frac{\hat{n}}{n} -\beta\right) - \varepsilon$
153
+ 7: Run MIMIC on $s_{\hat{r},\varepsilon,\delta} \cdot \sqrt{\log(\hat{r} + 1)}$ arrivals while keeping track of the online arrivals in a set $A$
154
+ 8: if MINIMAXTEST $(s_{\hat{r},\varepsilon ,\delta},\frac{\hat{c}}{n},A,\tau ,\delta^{\prime}) =$ "Pass" then
155
+ 9: Run MIMIC on the remaining arrivals
156
+ 10: else
157
+ 11: Run BASELINE on the remaining arrivals
158
+ 12: end if
159
+
160
+ $n$ . Let $T^{*} \subseteq 2^{U}$ be the set of types with non-zero counts in $c^{*}$ . Since $|U| = |V| = n$ , $c^{*}$ is sparse and contains $r^{*} = |T^{*}| \leq n \ll 2^{n}$ non-zero elements; see Figure 3. Note that $c^{*}$ fully determines $\mathcal{G}^{*}$ for our purposes, as vertices may be permuted but $n^{*}$ remains identical.
161
+
162
+ ![](images/9585182d11528ed325f418460de95b877cc38e35a7fd622e158cb78b17700e40.jpg)
163
+ Figure 3. For $n = 4$ , there may be $2^4 = 16$ possible types but at most $n = 4$ of them can ever be non-zero. Here, $c^* (\{u_1, u_3\}) = 1$ , $c^* (\{u_2, u_3\}) = 1$ and $c^* (\{u_1, u_2, u_4\}) = 2$ . We see that type $\{u_1, u_2, u_4\}$ appears twice in $c^*$ and $|T^*| = 3$ .
164
+
165
+ <table><tr><td colspan="3">Type counts c* in G*</td></tr><tr><td></td><td>Type</td><td>Count</td></tr><tr><td rowspan="3">T*</td><td>{u1, u3}</td><td>1</td></tr><tr><td>{u2, u3}</td><td>1</td></tr><tr><td>{u1, u2, u4}</td><td>2</td></tr><tr><td>2U\T*</td><td>...</td><td>0</td></tr></table>
166
+
167
+ In this work, we consider advice to be an estimate of the realized type counts $\hat{c} \in \mathbb{Z}^{2^n}$ with non-zero entries in $\hat{T} \subseteq 2^U$ . As before, we assume that $\hat{c}$ sums to $n$ and contains $\hat{r} = |\hat{T}| \leq n \ll 2^n$ non-zero entries. Just like $c^*$ , $\hat{c}$ fully defines some "advice graph" $\hat{\mathcal{G}} = (U \cup V, \hat{E})$ that we can find a maximum matching for in polynomial time. We discuss the practicality of obtaining such advice in Appendix C.
168
+
169
+ Throughout this section, we will use star $(\cdot)^{*}$ and hat $(\hat{\cdot})$ to denote ground truth and advice quantities respectively. In particular, we use $n^{*} \leq n$ and $\hat{n} \leq n$ to denote the maximum matching size in the final offline graph $\mathcal{G}^{*}$ and advice graph $\hat{\mathcal{G}}$ respectively. Note that star $(\cdot)^{*}$ quantities are not known and exist purely for the purpose of analysis.
170
+
171
+ Intuition behind TESTANDMATCH. If $\hat{c} = c^{*}$ , one triv-
172
+
173
+ ially obtains a 1-consistency by solving for a maximum matching $\hat{M}$ on the advice graph $\hat{\mathcal{G}}$ and then mimicking matches based on $\hat{M}$ as vertices arrive. While $\hat{c} \neq c^*$ in general, we may consider distributions $p^* = c^* / n$ and $q = \hat{c} / n$ and test if $p^*$ is close to $q$ in $L_1$ distance via Theorem 2.1; this is done sample efficiently using just the first $o(n)$ online vertices (Section 4.2). If $L_1(p^*, q)$ is less than some threshold $\tau$ , we conclude $\hat{c} \approx c^*$ and continue mimicking $\hat{M}$ , enjoying a competitive ratio close to 1. If not, we revert to BASELINE. Crucially, each wrong match made during the testing phase hurts our final matching size by at most a constant, yielding a competitive ratio of $\beta - o(1)$ .
174
+
175
+ TESTANDMATCH is described in Algorithm 1, which takes as input a number of additional parameters $(\delta, \epsilon, \text{etc})$ and subroutines that we will explain in a bit. For now, we state our main result describing the performance of TESTAND-MATCH in terms of the competitive ratio.
176
+
177
+ Theorem 4.1. For any advice $\hat{c}$ with $|\hat{T}| = \hat{r}$ , $\varepsilon > 0$ and $\delta > \frac{1}{poly(\hat{r})}$ , let $\hat{L}_1$ be the estimate of $L_1(p^*, q)$ obtained from $k = s_{\hat{r}, \varepsilon, \delta} \cdot \sqrt{\log(\hat{r} + 1)}$ IID samples of $p^*$ . TESTAND-MATCH produces a matching of size $m$ with competitive ratio of at least $\frac{\hat{n}}{n} - \frac{L_1(p,q)}{2} \geq \beta$ when $\hat{L}_1 \leq 2\left(\frac{\hat{n}}{n} - \beta\right) - \varepsilon$ , and at least $\beta \cdot (1 - \frac{k}{n})$ otherwise, with success prob. $1 - \delta$ .
178
+
179
+ For sufficiently large $n$ and constants $\varepsilon, \delta$ , we have $s_{\hat{r},\varepsilon,\delta} \cdot \sqrt{\log(\hat{r} + 1)} \in o(1)$ , so Theorem 4.1 implies a lower bound on the achieved competitive ratio of $\frac{m}{n^*}$ (see Figure 4) where
180
+
181
+ $$
182
+ \frac {m}{n ^ {*}} \geq \frac {m}{n} \geq \left\{ \begin{array}{l l} \frac {\hat {n}}{n} - \frac {L _ {1} (p ^ {*} , q)}{2} & \text {w h e n} \hat {L} _ {1} \leq 2 \left(\frac {\hat {n}}{n} - \beta\right) - \varepsilon \\ \beta \cdot (1 - o (1)) & \text {o t h e r w i s e} \end{array} \right.
183
+ $$
184
+
185
+ ![](images/5efc28c714e16bc6c839c254a468ab52beece1ab6ded8dc8f828f2eb0d643c5a.jpg)
186
+ Figure 4. A (conservative) competitive ratio plot for $\frac{\hat{n}}{n} > \beta$ . If MINIMAXTEST (Algorithm 3) succeeds, we have $L_{1}(p^{*}, q) < 2\left(\frac{\hat{n}}{n} - \beta\right) - 2\varepsilon$ whenever $\hat{L}_{1} < 2\left(\frac{\hat{n}}{n} - \beta\right) - \varepsilon$ . Observe that there is a smooth interpolation between the achievable competitive ratio as $L_{1}(p^{*}, q)$ degrades whilst paying only $o(1)$ for robustness.
187
+
188
+ Under random order arrivals, the competitive ratio is measured in expectation over all possible arrival sequences. One can easily convert the guarantees of Theorem 4.1 to one in expectation by assuming the extreme worst case scenario
189
+
190
+ # Algorithm 2 MIMIC
191
+
192
+ input Matching $\hat{M}$ , advice counts $\hat{c}$ , arrival type label $t$
193
+
194
+ 1: if $c(t) > 0$ then
195
+ 2: Mimic an arbitrary unused type $t$ match in $\hat{M}$
196
+ 3: Decrement $c(t)$ by 1
197
+ 4: end if
198
+ 5: return $c$
199
+
200
+ of obtaining 0 matches whenever the tester fails. So, the expected competitive ratio is simply $(1 - \delta)$ factor of the bounds given in Theorem 4.1. Setting $\delta = 0.001$ , we get a robustness guarantee of $\beta \cdot (1 - o(1)) \cdot 0.999$ in expectation. Note that our guarantees hold regardless of what value of $\varepsilon$ is used. In the event that a very small $\varepsilon$ is chosen and the test always fails, we are still guaranteed the robustness guarantees of $\approx \beta$ . One possible default for $\varepsilon$ could be to assume that the optimal offline matching has size $n$ and just set it to half the threshold value, i.e. set $\varepsilon = \hat{n} / n - \beta$ .
201
+
202
+ Remark about lines 4 and 6 in TESTANDMATCH. As we subsequently require Poisson $(s_{\hat{r},\varepsilon,\delta})$ IID samples from $p^*$ for testing, we collect $s_{\hat{r},\varepsilon,\delta} \cdot \sqrt{\log(\hat{r} + 1)}$ online arrivals into the set $A$ . Note that $\mathbb{E}[\mathrm{Poisson}(s_{\hat{r},\varepsilon,\delta})] = s_{\hat{r},\varepsilon,\delta}$ and $\mathrm{Poisson}(s_{\hat{r},\varepsilon,\delta}) \leq s_{\hat{r},\varepsilon,\delta} \cdot \sqrt{\log(\hat{r} + 1)}$ with high probability. This additional slack of $\sqrt{\log(\hat{r} + 1)}$ allows for Theorem 4.1 to hold with high probability (as opposed to constant) while ensuring that the competitive ratio remains in the $\beta \cdot (1 - o(1))$ regime. Finally, when $r \in \Omega(n)$ , we remark that $s_{\hat{r},\varepsilon,\delta}$ is sublinear in $n$ only for sufficiently large $n$ ; see Section 5 for some practical modifications.
203
+
204
+ The rest of this section is devoted to describing Algorithm 1 and proving Theorem 4.1. We study in Section 4.1 how mimicking poor advice quality impacts matching sizes, yielding conditions where mimicking is desirable, which we test for via Theorem 2.1. Section 4.2 describes transformations to massage our problem into the form required by Theorem 2.1. Lastly, we tie up our analysis of Theorem 4.1 in Section 4.3.
205
+
206
+ # 4.1. Effect of advice quality on matching sizes
207
+
208
+ Given an advice $\hat{c}$ of type counts, we first solve optimally for a maximum matching $\hat{M}$ on the advice graph $\hat{\mathcal{G}}$ and then mimic the matches for online arrivals whenever possible; see Algorithm 2. That is, whenever new vertices arrive, we match according to some unused vertex of the same type if possible and leave it unmatched otherwise.
209
+
210
+ It is useful to normalize counts as $p^* = c^* / n$ and $q = \hat{c} / n$ . These are distributions on the realized and predicted (by advice) counts, and have sparse support $T^*$ and $\hat{T}$ .
211
+
212
+ Now, suppose $\hat{M}$ has matching size $\hat{n} \leq n$ . By definition of $L_{1}(c^{*}, \hat{c})$ and MIMIC, one would obtain a matching of size at least $\hat{n} - L_{1}(c^{*}, \hat{c}) / 2$ by blindly following advice. This
213
+
214
+ yields a competitive ratio of $\frac{\hat{n} - L_1(c^*,\hat{c}) / 2}{n^*}$ . Rearranging, we see that MIMIC outperforms the advice-free baseline (in terms of worst case guarantees) if and only if
215
+
216
+ $$
217
+ \frac {\hat {n} - L _ {1} \left(c ^ {*} , \hat {c}\right) / 2}{n ^ {*}} > \beta \Longleftrightarrow L _ {1} \left(p ^ {*}, q\right) < \frac {2}{n} (\hat {n} - \beta n ^ {*})
218
+ $$
219
+
220
+ The above analysis suggests a natural way to use advice type counts: use MIMIC if $L_{1}(p^{*},q) \leq \frac{2}{n} (\hat{n} -\beta n^{*})$ , and BASELINE otherwise. Note that one should always just use BASELINE whenever $\frac{\hat{n}}{n^*} < \beta$ , matching the natural intuition of ignoring advice of poor quality.
221
+
222
+ Unfortunately, as we only know $n$ but not $n^*$ , our algorithm conservatively checks whether $L_1(p^*, q) < 2(\hat{n} / n - \beta)$ and so the resulting guarantee is conservative since $n^* \leq n$ .
223
+
224
+ # 4.2. Estimating advice quality via property testing
225
+
226
+ As $c^*$ is unknown, we cannot obtain $L_{1}(p^{*},q)$ . However, $p^*$ and $q$ are distributions and we can apply the property testing method of Theorem 2.1 to estimate $L_{1}(p^{*},q)$ to some $\varepsilon >0$ accuracy. Applying Theorem 2.1 raises two difficulties.
227
+
228
+ Simulating IID arrivals. Under the Random Order arrival model (Section 2), online vertices arrive "without replacement", which is incompatible with Theorem 2.1. Thankfully, we can apply a standard trick to simulate IID "sampling with replacement" from $p^*$ by "re-observing arrivals". See SIMULATEP (Algorithm 4) in the appendix for details.
229
+
230
+ Operating in reduced domains. Strictly speaking, the domain of $p^*$ and $q$ could be as large as $2^n$ , since any one of these types may occur. If all of these types occur with non-zero probability, then applying Theorem 2.1 for testing could take a near-exponential (in $n$ ) number of online vertex arrivals, which is clearly impossible. However, as established earlier, $p^*$ and $q$ enjoy sparsity; in particular, $\hat{c}$ and thus $q$ contain 0 in all but at most $\hat{r} = |\hat{T}| \leq n \ll 2^n$ entries. The key insight is to express $L_1$ distances by operating on $\hat{T}$ , plus an additional dummy type $t_0$ which has 0 counts in $\hat{c}$ . Whenever we observe an online vertex with type $t \in T^* \backslash \hat{T}$ , we classify it as $t_0$ . Specifically,
231
+
232
+ $$
233
+ \begin{array}{l} L _ {1} \left(p ^ {*}, q\right) = \sum_ {t \in 2 ^ {U}} \left| p ^ {*} (t) - q (t) \right| = \sum_ {t \in \hat {T} \cup T ^ {*}} \left| p ^ {*} (t) - q (t) \right| \\ = \sum_ {t \in \hat {T}} | p ^ {*} (t) - q (t) | + \sum_ {t \in T ^ {*} \backslash \hat {T}} p ^ {*} (t), \\ \end{array}
234
+ $$
235
+
236
+ which we can view as an $L_{1}$ distance on distributions with support $\hat{T} \cup \{t_0\}$ . Thus, the domain size when applying Theorem 2.1 is $\hat{r} + 1 \leq n + 1$ . For any constant $\epsilon, \delta > 0$ , the required samples is $s_{\hat{r},\varepsilon,\delta} \cdot \sqrt{\log(\hat{r} + 1)} \in o(n)$ .
237
+
238
+ Now that these difficulties are overcome, the estimation of $L_{1}(p^{*},q) = L_{1}\left(\frac{c^{*}}{n},\frac{\hat{c}}{n}\right)$ is done via MINIMAXTEST (Algorithm 3), whose correctness follows from Theorem 2.1.
239
+
240
+ Algorithm 3 MINIMAXTEST $(s, \frac{\hat{c}}{n}, A, \tau, \delta')$
241
+
242
+ input Sample size $s$ , distribution $q = \hat{c} / n$ , $s \sqrt{\log(\hat{r} + 1)}$ online arrivals $A$ , testing threshold $\tau$ , failure rate $\delta'$
243
+
244
+ 1: Compute $s_1, s_2 \sim \text{Poisson}(s/2)$
245
+ 2: if $s_1 + s_2 > s\sqrt{\log(\hat{r} + 1)}$ then
246
+ 3: return "Fail" $\triangleright$ occurs w.p. $\delta_{poi} \leq 1/poly(\hat{r})$
247
+ 4: end if
248
+ 5: Collect $s_1 + s_2$ IID samples from $p^* = \frac{c^*}{n}$ by running SIMULATEP with $A$ .
249
+ 6: Run algorithm of Theorem 2.1 to obtain estimate $\hat{L}_1$ such that $|\hat{L}_1 - L_1(p,q)|\leq \varepsilon$ with probability $1 - \delta^{\prime}$
250
+ 7: return $\tilde{L}_1 < \tau$
251
+
252
+ Lemma 4.2. Suppose MINIMAXTEST uses the estimator of Theorem 2.1 and passes if and only if $\hat{L}_1 < \tau$ . Given $s_{\hat{r},\varepsilon,\delta} \cdot \sqrt{\log(\hat{r} + 1)}$ online arrivals in a set $A$ , we have $L_1(p^*,q) < 2(\hat{n}/n - \beta)$ whenever MINIMAXTEST passes. The success probability of MINIMAXTEST is at least $1 - \delta$ .
253
+
254
+ Proof. The algorithm of Theorem 2.1 guarantees tells us that $|\hat{L}_1 - L_1(p^*, q)| \leq \varepsilon$ with probability at least $1 - \delta'$ . Therefore, when MINIMAXTEST passes, we are guaranteed that $L_1(p^*, q) \leq \hat{L}_1 + \varepsilon < \tau + \varepsilon = 2(\hat{n} / n - \beta)$ .
255
+
256
+ Meanwhile, in the analysis of Theorem 2.1, one actually needs to use $s_1 + s_2$ IID samples from $p^*$ , where $s_1, s_2 \sim \mathrm{Poisson}(s_{\hat{r},\varepsilon,\delta'})$ , which can be simulated from the arrival set $A$ ; see SIMULATEP (Algorithm 4) in the appendix. By Lemma 2.2, we may assume that $s_1 + s_2 \leq s$ with probability at least $1 - \delta_{poi}(s)$ . Taking a union bound over the failure probability of the "Poissonization" event and the estimator, we see that the overall success probability is at least $1 - (\delta' + \delta_{poi}) = 1 - \delta$ .
257
+
258
+ # 4.3. Tying up our analysis of TESTANDMATCH
259
+
260
+ If we run BASELINE from the beginning due to $\frac{\hat{n}}{n} \leq \beta$ , then we trivially recover a $\beta$ -competitive ratio. The following lemma gives a lower bound on the obtained matching size if we performed MINIMAXTEST but decided switch to BASELINE due to the estimated $\hat{L}_1$ being too large.
261
+
262
+ Lemma 4.3. Suppose we run an arbitrary algorithm for the first $k \in [n]$ online arrivals and then switch to BASELINE for the remaining $n - k$ online arrivals. If $j$ matches made in the first $k$ arrivals, where $0 \leq j \leq k$ , then the overall produced matching size is at least $\beta \cdot (n - k - j) + j$ .
263
+
264
+ Proof. Any match made in the first $k$ arrivals decreases the maximum attainable matching size by at most two, excluding the match made. As the maximum attainable matching size was originally $n$ , the maximum attainable matching size on the postfix sequence after the $k$ is at least $n - k - j$ . Since BASELINE has competitive ratio $\beta$ , running BASELINE on
265
+
266
+ the remaining $n - k$ steps will produce a matching of size at least $\beta \cdot (n - k - j)$ . Thus, the overall produced matching size is at least $\beta \cdot (n - k - j) + j$ .
267
+
268
+ The proof of Theorem 4.1 requires the following lemma.
269
+
270
+ Lemma 4.4. For any advice $\hat{c}$ with $|\hat{T}| = \hat{r}$ , $\varepsilon > 0$ and $\delta > \frac{1}{poly(\hat{r})}$ , let $\hat{L}_1$ be the estimate of $L_1(p^*, q)$ in MINIMAXTEST. If MINIMAXTEST succeeds, then TESTAND-MATCH produces a matching of size $m$ with competitive ratio $\frac{m}{n^*}$ at least $\frac{\hat{n}}{n} - \frac{L_1(p,q)}{2} \geq \beta$ when $\hat{L}_1 \leq 2\left(\frac{\hat{n}}{n} - \beta\right) - \varepsilon$ , and at least $\beta \cdot (1 - \frac{s_{\hat{r},\varepsilon,\delta} \cdot \sqrt{\log(\hat{r} + 1)}}{n})$ otherwise.
271
+
272
+ Proof. We consider each case separately.
273
+
274
+ Case 1: $\hat{L}_1\leq 2\left(\frac{\hat{n}}{n} -\beta\right) - \varepsilon$
275
+
276
+ TESTANDMATCH executed MIMIC for all online arrivals, yielding a matching of size $m \geq \hat{n} - \frac{L_1(c^*, \hat{c})}{2}$ . Since MINMAXTEST succeeds, $|\hat{L}_1 - L_1(p, q)| \leq \varepsilon$ , so $L_1(p, q) \leq \hat{L}_1 + \varepsilon \leq 2\left(\frac{\hat{n}}{n} - \beta\right) - \varepsilon + \varepsilon = 2\left(\frac{\hat{n}}{n} - \beta\right)$ . Therefore,
277
+
278
+ $$
279
+ \frac {m}{n ^ {*}} \geq \frac {m}{n} \geq \frac {\hat {n}}{n} - \frac {L _ {1} (c ^ {*} , \hat {c})}{2 n} = \frac {\hat {n}}{n} - \frac {L _ {1} (p ^ {*} , q)}{2} \geq \beta
280
+ $$
281
+
282
+ Case 2: $\hat{L}_1 > 2\left(\frac{\hat{n}}{n} -\beta\right) - \varepsilon$
283
+
284
+ TESTANDMATCH executes BASELINE after an initial batch of $k = s_{\hat{r},\varepsilon,\delta} \cdot \sqrt{\log(\hat{r} + 1)}$ arrivals that follow MIMIC. Suppose we made $j$ matches via MIMIC before MINIMAXTEST. Then, Lemma 4.3 tells us that the overall produced matching size is at least $m \geq \beta \cdot (n - k - j) + j$ . Since $\beta < 1$ , we have $\beta \cdot (n - k - j) + j \geq \beta \cdot (n - k)$ . Therefore,
285
+
286
+ $$
287
+ \frac {m}{n ^ {*}} \geq \frac {m}{n} \geq \beta \cdot \left(1 - \frac {s _ {\hat {r} , \varepsilon , \delta} \cdot \sqrt {\log (\hat {r} + 1)}}{n}\right) \quad \square
288
+ $$
289
+
290
+ Theorem 4.1 follows from bounding the failure probability.
291
+
292
+ Proof of Theorem 4.1. The competitive ratio guarantees follow directly from Lemma 4.4, given that MINIMAXTEST succeeds. Therefore, it only remains to bound the failure probability, which equals that probability that MINIMAXTEST fails. This can happen if either line 3 is executed (event $E_{1}$ ) or the algorithm in line 5 fails (event $E_{2}$ ).
293
+
294
+ The event $E_{1}$ occurs when the one of the Poisson random variables in line 1 of Algorithm 3 exceeds the expectation by a $\sqrt{\log\hat{r}}$ factor. Since $s_1, s_2 \sim \mathrm{Poisson}(s/2)$ , we have that $(s_1 + s_2) \sim \mathrm{Poisson}(s)$ . Thus, by Lemma 2.2 we have that:
295
+
296
+ $$
297
+ \begin{array}{l} \delta_ {p o i} = \Pr \left[ \left| \left(s _ {1} + s _ {2}\right) - s \right| > s \sqrt {\log \hat {r}} \right] \\ \leq 2 e ^ {- \frac {s ^ {2} \log \hat {r}}{2 (s + s \sqrt {\log \hat {r}})}} = O \left(\hat {r} ^ {- \frac {s}{2 (1 + \sqrt {\log \hat {r}})}}\right) = O \left(\frac {1}{p o l y (\hat {r})}\right) \\ \end{array}
298
+ $$
299
+
300
+ for the value of $s = \mathcal{O}\left(\frac{(\hat{r} + 1)\cdot\log(1 / \delta')}{\varepsilon^2\cdot\log(\hat{r} + 1)}\right)$ chosen.
301
+
302
+ Combining the above with Lemma 4.2 via union bound yields $\operatorname{Pr}(\text{failure}) \leq \operatorname{Pr}(E_1) + \operatorname{Pr}(E_2) \leq \delta_{\text{poi}} + \delta' = \delta$ .
303
+
304
+ # 5. Practical considerations
305
+
306
+ While our contributions are mostly theoretical, we discuss some practical considerations here. In particular, we would like to highlight that there is no existing practical implementation of the algorithm of Theorem 2.1 by Jiao et al. (2018). As is the case for most state-of-the-art distribution testing algorithms, this implementation is highly non-trivial and requires the use of optimal polynomial approximations over functions, amongst other complicated constructions. For completeness, we implemented a proof-of-concept based on the empirical $L_{1}$ estimation; see Appendix F. While it is known that the estimation error scales with the sample size in the form $\Omega(r / \varepsilon^{2})$ , we observe good empirical performance when $r$ is sublinear in $n$ or when combined with some of the practical extensions that we discussed below.
307
+
308
+ Section 5.1 and Section 5.2 can be viewed as ways to extend the usefulness of a given advice. Section 5.3 provides a way to "patch" an advice with $\hat{n} < n$ to one with perfect matching, without hurting the provable guarantees. Section 5.4 gives a pre-processing step that can be prepended to any procedure: by losing $o(1)$ , one can test whether $|T^{*}|$ is small and if so learn $p^{*}$ up to $\varepsilon$ error to fully exploit it.
309
+
310
+ # 5.1. Remapping online arrival types
311
+
312
+ Consider the graph example in Figure 3 with type counts $c^*$ and we are given some advice count $\hat{c}$ as follows:
313
+
314
+ <table><tr><td>Types T*</td><td>c* count</td><td>Types T&#x27;</td><td>ˆc count</td></tr><tr><td>{u1, u3}</td><td>1</td><td>{u1}</td><td>1</td></tr><tr><td>{u2, u3}</td><td>1</td><td>{u3}</td><td>1</td></tr><tr><td>{u1, u2, u4}</td><td>2</td><td>{u4}</td><td>1</td></tr><tr><td></td><td></td><td>{u2, u4}</td><td>1</td></tr></table>
315
+
316
+ While one can verify that both the true graph $\mathcal{G}^*$ and the advice graph $\hat{\mathcal{G}}$ have perfect matching, $L_{1}(c^{*},\hat{c}) = 4$ since as $T^{*}$ and $\hat{T}$ have disjoint types. From the perspective of our earlier analysis, $\hat{c}$ would be deemed as a poor quality advice and one should default to BASELINE.
317
+
318
+ However, a closer look reveals there exists a mapping $\sigma$ from $T^{*}$ to $\hat{T}$ such that one can credibly "mimic" the proposed matching of $\hat{\mathcal{G}}$ as online vertices arrive. For example, when an online vertex $v$ with neighborhood type $\{u_1,u_3\}$ arrive, one can "ignore" the edge $u_{3}\sim v$ and treat it as if $v$ had the type $\{u_1\}$ . Similarly, $\{u_{2},u_{3}\}$ could be treated as $\{u_3\}$ , the first instance of $\{u_{1},u_{2},u_{4}\}$ could be treated as $\{u_{2},u_{4}\}$ ,
319
+
320
+ and the second instance of $\{u_1, u_2, u_4\}$ could be treated as $\{u_4\}$ . Running MIMIC under such a remapping of online types would then produce a perfect matching! We discuss how to perform such remappings in Appendix D.2.
321
+
322
+ # 5.2. Coarsening of advice
323
+
324
+ While Theorem 4.1 has good asymptotic guarantees as $n \to \infty$ , the actual number of vertices $n$ is finite in practice. In particular, when $n$ is "not large enough", TESTANDMATCH will never utilize the advice and always default to BASELINE for all problem instances where $n \ll s_{\hat{r},\varepsilon,\delta}$ .
325
+
326
+ In practice, while the given advice types may be diverse, there could be many "overlapping subtypes" and a natural idea is to "coarsen" the advice by grouping similar types together in an effort to reduce the resultant support size of the advice (and hence $s_{\hat{r},\varepsilon,\delta}$ ). Figure 5 illustrates an extreme example where we could decrease the support size from $n$ to 2 while still maintaining a perfect matching. In Appendix D.1, we explain two possible ways to coarsen $\hat{c}$ .
327
+
328
+ ![](images/c36566607b72d5dca95ff580f6f4367e969db3bfc674c791eddacfa9b19bfad2.jpg)
329
+ Figure 5. Consider $\hat{\mathcal{G}}$ made by taking the union of two complete bipartite graphs $(\hat{\mathcal{G}}^{\prime})$ and adding the red dashed edges. By connecting $v_{i}$ to $u_{(i + n / 2)\mathrm{mod}n}$ , $|\hat{T}| = r = n$ . Meanwhile, if we coarsen $\hat{c}$ into $\hat{c}^{\prime}$ by ignoring the red dashed edges, $\hat{\mathcal{G}}^{\prime}$ still has a maximum matching of size $\hat{n}^{\prime} = n$ while $|\hat{T}^{\prime}| = r^{\prime} = 2$ , thus requiring significantly less samples to test since $s_{\hat{r}^{\prime},\varepsilon ,\delta}\ll s_{\hat{r},\varepsilon ,\delta}$ . Furthermore, if $\mathcal{G}^{*} = \hat{G}^{\prime}$ , then $L_{1}(c^{*},\hat{c}) = 2n$ and we will reject the advice $\hat{c}$ if we do not coarsen it first.
330
+
331
+ ![](images/12e114c9ec27815f6f6ecda8ea1c475071bfabb8587ccd9462cd409fd758aa84.jpg)
332
+
333
+ # 5.3. Advice does not have perfect matching
334
+
335
+ As the given advice $\hat{c}$ is arbitrary, it could be the case that any maximum matching of size $\hat{n}$ in the graph $\hat{\mathcal{G}}$ implied by $\hat{c}$ is not perfect, i.e. $\hat{n} < n$ . A natural idea would be to "patch" $\hat{c}$ into some other type count $\hat{c}'$ which has a maximum matching size of $\hat{n}' = n$ in the tweaked graph $\hat{\mathcal{G}}'$ . This can be done by augmenting $\hat{c}$ with additional edges between the unmatched vertices in the advice graph to obtain $\hat{c}'$ . In Appendix D.3, we show how to do this in a way that running TESTANDMATCH on $\hat{c}'$ does not worsen the provable guarantees as compared to directly using $\hat{c}$ .
336
+
337
+ # 5.4. True distribution has small support size
338
+
339
+ If the support size of the true types is $o(n)$ , a natural thing to do is to learn $c^*$ up to some $\varepsilon$ accuracy while forgoing some $o(n)$ initial matches, and then obtain $\approx 1 - \varepsilon$ competitive ratio on the remaining arrivals. Though this is wholly possible in the random arrival model, it crucially depends on $c^*$ having at most $o(n)$ types. Although we do not know the support size of $c^*$ a priori, we can again employ techniques from property testing. For any desired support size $k$ and constant $\varepsilon$ , Valiant & Valiant (2017); Wu & Yang (2019) tell us that $O\left(\frac{k}{\log k}\right)$ samples are sufficient for us to estimate the support size of a discrete distribution up to additive error of $\varepsilon k$ . Therefore, for any $k \in o(n)$ and constant $\varepsilon$ , given any algorithm ALG under the random arrival model achieving competitive ratio $\alpha$ , we can first spend $o(1)$ arrivals to test whether $c^*$ is supported on $(1 + \varepsilon) \cdot k$ types:
340
+
341
+ - If "Yes", then we can spend another $O(k / \varepsilon^2) \subseteq o(1)$ arrivals to estimate $c^*$ up to $\varepsilon$ accuracy, i.e. we can form $\hat{c}$ with $L_1(c^*, \hat{c}) \leq \varepsilon$ , then exploit $\hat{c}$ via MIMIC.
342
+ - If "No", use ALG and achieve a comp. ratio of $\alpha - o(1)$ .
343
+
344
+ The choice of $k$ is flexible in practice, depending on how much one is willing to lose in the $o(1)$ in the "No" case.
345
+
346
+ # 6. Discussion and future directions
347
+
348
+ We studied the online bipartite matching problem with respect to Goal 1.1. We showed that it is impossible under the adversarial arrival model and designed a meta algorithm TESTANDMATCH for the random arrival model that is 1-consistent and $\beta \cdot (1 - o(1))$ -robust while using histograms over arrival types as advice. The guarantees TESTANDMATCH degrades gracefully as the quality of the advice worsens, and improves whenever the state-of-the-art $\beta$ improves. There are several interesting follow-up questions:
349
+
350
+ 1. Other versions of online bipartite matching. Whether the ideas presented in this work can be generalized to other versions of the online bipartite matching problem is indeed an interesting question. The hardness results of Theorem 3.1 directly translate as the unit weight version is a special case of the general case with vertex or edge weights, implying impossibility more general settings. Algorithmically, we believe that the TESTANDMATCH framework should generalize. However, it would require a different advice quality metric in the space of edge weights (e.g., something like earthmover distance), along with a corresponding sample efficient way to test this quality with sublinear samples so that one can still achieve a competitive ratio of $\beta \cdot (1 - o(1))$ when the test detects that the advice quality is bad.
351
+ 2. Consistency and robustness tradeoff. Our algorithm is a meta-algorithm that is both 1-consistent and $\beta \cdot (1 - o(1))$ -robust, where the robustness guarantee improves with the
352
+
353
+ state-of-the-art (with respect to $\beta$ ). As, it is impossible for any algorithm to be strictly better than 1-consistent (by definition of competitive ratio) or strictly better than $\beta$ -robust (by definition of $\beta$ ), our algorithm (weakly-)paretodominates all other possible algorithms for this problem up to an $1 - o(1)$ multiplicative factor in the robustness guarantee. Can this $1 - o(1)$ multiplicative factor be removed?
354
+
355
+ 3. Beyond consistency and robustness. TESTAND-MATCH's performance guarantee is based on the $L_{1}$ distance over type histograms. This is very sensitive to certain types of noise, e.g., adding or removing edges at random (Erdos-Renyi). However, Section 5 suggests there are practical extensions that hold even when $L_{1}$ is large, implying it is a non-ideal metric despite satisfying consistency and robustness. Is there another criterion that could fill this gap?
356
+ 4. Going beyond MIMIC.Our current approach exploits advice solely through MIMIC, which arbitrarily chooses one matching $\hat{M}$ to follow. Is there a more intelligent way of doing so? For example, Feldman et al. (2009) constructed two matchings to "load balance" in the known IID setting.
357
+ 5. Is there a graph where advice coarsening recovers perfect matching while RANKING does not have a competitive ratio close to 1? RANKING is known to have a competitive ratio of $1 - 1 / \sqrt{k}$ if there exist $k$ disjoint perfect matchings in the graph (Karande et al., 2011). Beyond trivial settings where there are no perfect matchings or having a pattern connecting to just 1 offline vertex (so that there is at most 1 disjoint perfect matching), we do not have an example with a formal proof that advice coarsening recovers a perfect matching while RANKING does not have a competitive ratio close to 1. We suspect that one may not be able to construct a graph with few disjoint matchings and few patterns. To see why, fix some graph with a perfect matching and suppose there are $q$ types $t_1, t_2, \ldots, t_q$ of sizes $s_1, \ldots, s_q$ . By "circularly permuting the matches", we see that there will be $k = \min(s_1, \ldots, s_q)$ disjoint perfect matchings. However, this does not totally invalidate TESTANDMATCH in general. For example, consider the following augmentation to our approach: if $\hat{c}$ has $k$ disjoint perfect matchings after coarsening, one can run RANKING instead of MIMIC and switch to BASELINE if the test fails later. By doing so, one pays only an additive $1 / \sqrt{k}$ in consistency by running RANKING instead of MIMIC in the event that the advice was perfect. Note that BASELINE may be different from RANKING as it is still unknown what is the true $\beta \in [0.696, 0.823]$ . In particular, if $\beta > 0.727$ , then BASELINE cannot be RANKING (Karande et al., 2011).
358
+ 6. Other online problems with random arrivals. TESTANDMATCH did not exploit any specific properties of bipartite matching, and we suspect it may be generalized to a certain class of online problems.
359
+
360
+ # Acknowledgements
361
+
362
+ This research/project is supported by the National Research Foundation, Singapore under its AI Singapore Programme (AISG Award No: AISG-PhD/2021-08-013). AB and TG were supported by National Research Foundation Singapore under its NRF Fellowship Programme (NRF-NRFFAI1-2019-0002). We would like to thank the reviewers for valuable feedback and discussions. DC and CKL thank Anupam Gupta for discussions about learning-augmented algorithms. DC would also like to thank Clement Canonne and Yanjun Han for discussions about distribution testing, and Yongho Shin about discussions about learning-augmented algorithms.
363
+
364
+ # Impact Statement
365
+
366
+ While the contributions of this paper is mostly theoretical, one should be wary of possible societal impacts if online matching algorithms are implemented in practice. For instance, our proposed methods did not explicitly account for possible fairness issues and such concerns warrant further investigation before being operationalized in real-world settings.
367
+
368
+ # References
369
+
370
+ Aamand, A., Chen, J., and Indyk, P. (Optimal) Online Bipartite Matching with Degree Information. Advances in Neural Information Processing Systems, 35:5724-5737, 2022.
371
+ Alomrani, M. A., Moravej, R., and Khalil, E. B. Deep policies for online bipartite matching: A reinforcement learning approach. arXiv preprint arXiv:2109.10380, 2021.
372
+ Angelopoulos, S., Durr, C., Jin, S., Kamali, S., and Renault, M. Online Computation with Untrusted Advice. In 11th Innovations in Theoretical Computer Science Conference (ITCS 2020). Schloss Dagstuhl-Leibniz-Zentrum für Informatik, 2020.
373
+ Antoniadis, A., Coester, C., Elias, M., Polak, A., and Simon, B. Online Metric Algorithms with Untrusted Predictions. In International Conference on Machine Learning, pp. 345-355. PMLR, 2020a.
374
+ Antoniadis, A., Gouleakis, T., Kleer, P., and Kolev, P. Secretary and online matching problems with machine learned advice. Advances in Neural Information Processing Systems, 33:7933-7944, 2020b.
375
+ Antoniadis, A., Jabbarzade, P., and Shahkarami, G. A Novel Prediction Setup for Online Speed-Scaling. In 18th Scandinavian Symposium and Workshops on Algorithm The
376
+
377
+ ory (SWAT 2022). Schloss Dagstuhl-Leibniz-Zentrum für Informatik, 2022.
378
+ Bamas, É., Maggiori, A., Rohwedder, L., and Svensson, O. Learning Augmented Energy Minimization via Speed Scaling. Advances in Neural Information Processing Systems, 33:15350-15359, 2020a.
379
+ Bamas, E., Maggiori, A., and Svensson, O. The Primal-Dual method for Learning Augmented Algorithms. Advances in Neural Information Processing Systems, 33:20083-20094, 2020b.
380
+ Bernardini, G., Lindermayr, A., Marchetti-Spaccamela, A., Megow, N., Stougie, L., and Sweering, M. A Universal Error Measure for Input Predictions Applied to Online Graph Problems. In Advances in Neural Information Processing Systems, 2022.
381
+ Birnbaum, B. and Mathieu, C. On-line bipartite matching made simple. *Acm Sigact News*, 39(1):80-87, 2008.
382
+ Borodin, A., Karavasilis, C., and Pankratov, D. An experimental study of algorithms for online bipartite matching. Journal of Experimental Algorithmics (JEA), 25:1-37, 2020.
383
+ Brubach, B., Sankararaman, K. A., Srinivasan, A., and Xu, P. New algorithms, better bounds, and a novel model for online stochastic matching. In 24th Annual European Symposium on Algorithms (ESA 2016). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik, 2016.
384
+ Brubach, B., Sankararaman, K. A., Srinivasan, A., and Xu, P. Online stochastic matching: New algorithms and bounds. Algorithmica, 82(10):2737-2783, 2020.
385
+ Canonne, C. L. A short note on poisson tail bounds. Available at http://www.cs.columbia.edu/ ccanonne/files/misc/2017-poissonconcentration.pdf, 2019.
386
+ Chen, J., Silwal, S., Vakilian, A., and Zhang, F. Faster fundamental graph algorithms via learned predictions. In International Conference on Machine Learning, pp. 3583-3602. PMLR, 2022.
387
+ Choo, D., Gouleakis, T., and Bhattacharyya, A. Active causal structure learning with advice. In International Conference on Machine Learning, pp. 5838-5867. PMLR, 2023.
388
+ Chung, F., Lu, L., and Vu, V. Spectra of random graphs with given expected degrees. Proceedings of the National Academy of Sciences, 100(11):6313-6318, 2003.
389
+ Dinitz, M., Im, S., Lavastida, T., Moseley, B., and Vassilitskii, S. Faster matchings via learned duals. Advances in
390
+
391
+ neural information processing systems, 34:10393-10406, 2021.
392
+ Dinitz, M., Im, S., Lavastida, T., Moseley, B., and Vassilvitskii, S. Algorithms with prediction portfolios. Advances in neural information processing systems, 35: 20273-20286, 2022.
393
+ Dütting, P., Lattanzi, S., Paes Leme, R., and Vassilvitskii, S. Secretaries with Advice. In Proceedings of the 22nd ACM Conference on Economics and Computation, pp. 409-429, 2021.
394
+ Feldman, J., Mehta, A., Mirrokni, V., and Muthukrishnan, S. Online stochastic matching: Beating 1-1/e. In 2009 50th Annual IEEE Symposium on Foundations of Computer Science, pp. 117-126. IEEE, 2009.
395
+ Feng, Y., Niazadeh, R., and Saberi, A. Two-stage stochastic matching with application to ride hailing. In Proceedings of the 2021 ACM-SIAM Symposium on Discrete Algorithms (SODA), pp. 2862-2877. SIAM, 2021.
396
+ Goel, G. and Mehta, A. Online budgeted matching in random input models with applications to Adwords. In SODA, volume 8, pp. 982-991, 2008.
397
+ Gollapudi, S. and Panigrahi, D. Online Algorithms for Rentor-Buy with Expert Advice. In International Conference on Machine Learning, pp. 2319-2327. PMLR, 2019.
398
+ Gouleakis, T., Lakis, K., and Shahkarami, G. Learning-Augmented Algorithms for Online TSP on the Line. In 37th AAAI Conference on Artificial Intelligence. AAAI, 2023.
399
+ Han, Y. Personal communication (20 Jan 2024), 2024.
400
+ Jaillet, P. and Lu, X. Online stochastic matching: New algorithms with better bounds. Mathematics of Operations Research, 39(3):624-646, 2014.
401
+ Jiao, J., Han, Y., and Weissman, T. Minimax estimation of the $l_{-}\{1\}$ distance. IEEE Transactions on Information Theory, 64(10):6672-6706, 2018.
402
+ Jin, B. and Ma, W. Online bipartite matching with advice: Tight robustness-consistency tradeoffs for the two-stage model. Advances in Neural Information Processing Systems, 35:14555-14567, 2022.
403
+ Karande, C., Mehta, A., and Tripathi, P. Online bipartite matching with unknown distributions. In Proceedings of the forty-third annual ACM symposium on Theory of computing, pp. 587-596, 2011.
404
+ Karp, R. M., Vazirani, U. V., and Vazirani, V. V. An optimal algorithm for on-line bipartite matching. In Proceedings of the twenty-second annual ACM symposium on Theory of computing, pp. 352-358, 1990.
405
+
406
+ Kraska, T., Beutel, A., Chi, E. H., Dean, J., and Polyzotis, N. The Case for Learned Index Structures. In Proceedings of the 2018 international conference on management of data, pp. 489-504, 2018.
407
+ Lattanzi, S., Lavastida, T., Moseley, B., and Vassilvitskii, S. Online Scheduling via Learned Weights. In Proceedings of the Fourteenth Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 1859-1877. SIAM, 2020.
408
+ Lavastida, T., Moseley, B., Ravi, R., and Xu, C. Learnable and instance-robust predictions for online matching, flows and load balancing. arXiv preprint arXiv:2011.11743, 2020.
409
+ Lavastida, T., Moseley, B., Ravi, R., and Xu, C. Using predicted weights for ad delivery. In SIAM Conference on Applied and Computational Discrete Algorithms (ACDA21), pp. 21-31. SIAM, 2021.
410
+ Li, P., Yang, J., and Ren, S. Learning for edge-weighted online bipartite matching with robustness guarantees. In International Conference on Machine Learning, pp. 20276-20295. PMLR, 2023.
411
+ Lykouris, T. and Vassilvitskii, S. Competitive Caching with Machine Learned Advice. Journal of the ACM (JACM), 68(4):1-25, 2021.
412
+ Mahdian, M. and Yan, Q. Online Bipartite Matching with Random Arrivals: An Approach Based on Strongly Factor-Revealing LPs. In Proceedings of the forty-third annual ACM symposium on Theory of computing, pp. 597-606, 2011.
413
+ Manshadi, V. H., Gharan, S. O., and Saberi, A. Online stochastic matching: Online actions based on offline statistics. Mathematics of Operations Research, 37(4): 559-573, 2012.
414
+ Mehta, A. Online matching and ad allocation. Foundations and Trends® in Theoretical Computer Science, 8(4):265-368, 2013.
415
+ Mitzenmacher, M. A Model for Learned Bloom Filters, and Optimizing by Sandwiching. Advances in Neural Information Processing Systems, 31, 2018.
416
+ Purohit, M., Svitkina, Z., and Kumar, R. Improving Online Algorithms via ML Predictions. Advances in Neural Information Processing Systems, 31, 2018.
417
+ Rohatgi, D. Near-Optimal Bounds for Online Caching with Machine Learned Advice. In Proceedings of the Fourteenth Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 1834-1845. SIAM, 2020.
418
+
419
+ Sakaue, S. and Oki, T. Discrete-convex-analysis-based framework for warm-starting algorithms with predictions. Advances in Neural Information Processing Systems, 35: 20988-21000, 2022.
420
+ Valiant, G. and Valiant, P. The power of linear estimators. In 2011 IEEE 52nd Annual Symposium on Foundations of Computer Science, pp. 403-412. IEEE, 2011.
421
+ Valiant, G. and Valiant, P. Estimating the unseen: improved estimators for entropy and other properties. Journal of the ACM (JACM), 64(6):1-41, 2017.
422
+ Vazirani, V. V. Online Bipartite Matching and Adwords (Invited Talk). In 47th International Symposium on Mathematical Foundations of Computer Science (MFCS 2022). Schloss Dagstuhl-Leibniz-Zentrum für Informatik, 2022.
423
+ Wang, S., Li, J., and Wang, S. Online Algorithms for Multi-shop Ski Rental with Machine Learned Advice. Advances in Neural Information Processing Systems, 33: 8150-8160, 2020.
424
+ Wei, A. Better and Simpler Learning-Augmented Online Caching. In Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques (APPROX/RANDOM 2020). Schloss Dagstuhl-Leibniz-Zentrum für Informatik, 2020.
425
+ Wu, Y. and Yang, P. Chebyshev polynomials, moment matching, and optimal estimation of the unseen. The Annals of Statistics, 47(2):857-883, 2019.
426
+
427
+ # A. Additional related work
428
+
429
+ # A.1. A more detailed discussion of advice-free online bipartite matching results
430
+
431
+ As mentioned in Section 2, Table 1 (replicated below for convenience as Table 3) summarizes known results about attainable competitive ratios and impossibility results in the adversarial and Random Order arrival models. Observe that there is a gap between the upper and lower bounds in the Random Order arrival model which remains unresolved.
432
+
433
+ Table 3. (Restated) Known competitive ratios for the classic unweighted online bipartite matching problem for deterministic and randomized algorithms under the adversarial and Random Order arrival models. Note that $1 - 1 / e \approx 0.63$ .
434
+
435
+ <table><tr><td></td><td>Adversarial arrival model</td><td>Random Order arrival model</td></tr><tr><td>deterministic algorithms</td><td>1/2</td><td>1 - 1/e</td></tr><tr><td>deterministic hardness</td><td>1/2</td><td>3/4</td></tr><tr><td>randomized algorithms</td><td>1 - 1/e</td><td>0.696</td></tr><tr><td>randomized hardness</td><td>1 - 1/e + o(1)</td><td>0.823</td></tr></table>
436
+
437
+ On the positive side of things, the deterministic GreEDy algorithm which matches newly arrived vertex with any unmatched offline neighbor attains a competitive ratio of at least $1/2$ in the adversarial arrival model and at least $1 - 1/e$ in the random arrival model (Goel & Mehta, 2008). Meanwhile, the randomized RANKING algorithm of Karp et al. (1990) achieves a competitive ratio of $1 - 1/e$ in the adversarial arrival model. In the Random Order arrival model, RANKING achieves a strictly larger competitive ratio, shown to be at least 0.653 in Karande et al. (2011) and 0.696 in Mahdian & Yan (2011). However, Karande et al. (2011) showed that RANKING cannot beat 0.727 in general; so, new ideas will be required if one believes that the tight competitive ratio bound is 0.823.
438
+
439
+ On the negative side, the following example highlights the key difficulty faced by online algorithms. Consider the gadget for $n = 2$ in Figure 1 (replicated below for convenience as Figure 6), where the first online vertex $v_{1}$ neighbors with both $u_{1}$ and $u_{2}$ and the second online vertex $v_{2}$ neighbors with only one of $u_{1}$ or $u_{2}$ . Even when promised that the true graph is either $\mathcal{G}_1$ or $\mathcal{G}_2$ , any online algorithm needs to correctly guess whether to match $v_{1}$ with $u_{1}$ or $u_{2}$ to achieve perfect matching when $v_{2}$ arrives.
440
+
441
+ ![](images/c7bcc2cb991af4a07cd387c2eef81d4d20e280c65c0d74a6d253f4435fef9cff.jpg)
442
+ Figure 6. (Restated) Gadget for $n = 2$ . Red edges observed when $v_{2}$ arrives.
443
+
444
+ By repeating the gadget multiple times sequentially, any deterministic algorithm can only hope to attain competitive ratios of $1/2$ and $3/4$ in the adversarial and random arrival models respectively. For randomized algorithms, (Karp et al., 1990) showed that RANKING is essentially optimal for the adversarial arrival model since no algorithm can achieve a competitive ratio better than $1 - 1/e + o(1)$ . In the Random Order arrival model, Goel & Mehta (2008) showed (in their Appendix E) that a ratio better than $5/6 \approx 0.83$ cannot be attained by brute force analysis of a $3 \times 3$ gadget bipartite graph. Subsequently, Manshadi et al. (2012) showed that no algorithm (deterministic or randomized) can achieve a competitive ratio better than 0.823.
445
+
446
+ Technically speaking, the hardness result of Manshadi et al. (2012) is for the known IID model introduced by Feldman et al. (2009), but this extends to the Random Order arrival model since the former is an easier setting; e.g. see Theorem 2.1 in (Mehta, 2013) for an explanation. Under the easier known IID model, the current state of the art algorithms achieve a competitive ratio of 0.7299 using linear programming (Jaillet & Lu, 2014; Brubach et al., 2016; 2020).
447
+
448
+ # A.2. Broad overview of learning-augmented algorithms
449
+
450
+ Learning-augmented algorithms as a whole have received significant attention since the seminal work of Lykouris & Vassilvitskii (2021), where they investigated the online caching problem with predictions; their result was further improved by Rohatgi (2020); Antoniadis et al. (2020a); Wei (2020). Algorithms with advice was also studied for the ski- rental problem
451
+
452
+ Gollapudi & Panigrahi (2019); Wang et al. (2020); Angelopoulos et al. (2020), non-clairvoyant scheduling Purohit et al. (2018), scheduling (Lattanzi et al., 2020; Bamas et al., 2020a; Antoniadis et al., 2022), augmenting classical data structures with predictions (e.g. indexing (Kraska et al., 2018) and Bloom filters (Mitzenmacher, 2018)), online selection and matching problems (Antoniadis et al., 2020b; Dütting et al., 2021), online TSP (Bernardini et al., 2022; Gouleakis et al., 2023), a more general framework of online primal-dual algorithms (Bamas et al., 2020b), and causal graph learning (Choo et al., 2023).
453
+
454
+ # B. Extended variant of Theorem 3.1
455
+
456
+ Let us first prove the case when the algorithm $\mathcal{A}$ is deterministic, but $\alpha \in [0,1/2]$ . We will again use $\mathcal{G}_1$ and $\mathcal{G}_2$ of Figure 2 (replicated below for convenience as Figure 7) as a counterexample. Our argument follows that of the case where $\alpha = 0$ .
457
+
458
+ ![](images/1c2cf458c057a00b288a7c499916feaf9e4c66d3e3476b941e409b90305a0cfa.jpg)
459
+ Figure 7. (Restated) Illustration of $\mathcal{G}_1$ and $\mathcal{G}_2$ for Theorem 3.1
460
+
461
+ Special case: $\mathcal{A}$ is deterministic. As before, we observe that any algorithm cannot distinguish between the $\mathcal{G}_1$ and $\mathcal{G}_2$ after the first $n / 2$ arrivals. Suppose $\mathcal{A}$ is $(1 - \alpha)$ -consistent. Without loss of generality, by symmetry of the argument, suppose $\mathcal{G}^* = \mathcal{G}^2$ and $\mathcal{A}$ is given advice bit $\hat{i} = 2$ .
462
+
463
+ Since $\mathcal{A}$ is $(1 - \alpha)$ -consistent, it has to make at least $\frac{n}{2} - (1 - \alpha) \cdot n$ matches in the first $\frac{n}{2}$ arrivals $^3$ , leaving at most $\alpha \cdot n$ unmatched offline vertices amongst $\{u_1, \ldots, u_{\frac{n}{2}}\}$ . Meanwhile, if $\mathcal{G}^* = \mathcal{G}^1$ instead, there can only be at most $\alpha \cdot n$ matches amongst the remaining $\frac{n}{2}$ arrivals $\{v_{\frac{n}{2} + 1}, \ldots, v_n\}$ , resulting in a total matching size of at most $\frac{n}{2} + \alpha \cdot n = \left(\frac{1}{2} + \alpha\right) \cdot n$ . That is, any deterministic $\mathcal{A}$ that is $(1 - \alpha)$ -consistent cannot be strictly more than $\left(\frac{1}{2} + \alpha\right)$ -robust.
464
+
465
+ General case where $\mathcal{A}$ could be randomized. Unfortunately, randomization does not appear to help much, as we can repeat all of the above arguments in expectation. That is, if $\hat{i} = 2$ , it follows from consistency that in expectation, at least $(1 - \alpha)\cdot n$ of all vertices must be eventually matched, meaning that in expectation there must be $\frac{n}{2} -\alpha \cdot n$ matches in the first half. Now, if $\mathcal{G}_1$ was the true graph, then in expectation we only have $\alpha \cdot n$ possible matches to make in the second half, thus we have a maximum of $\left(\frac{1}{2} +\alpha\right)\cdot n$ matches in expectation when $\hat{i}$ is wrong.
466
+
467
+ # C. Examples of realized type counts as advice
468
+
469
+ Example 1: Online Ads. The canonical example of online bipartite matching is that of online ads (Mehta, 2013). Recall that the online vertices are advertisement slots (also called impressions) and the offline vertices are advertisers. We can see that the distribution over types can be possibly forecasted by machine learning models (and in fact, indirectly used (Alomrani et al., 2021) for bipartite matching) and used as advice. This directly gives us $q$ , possibly bypassing $\hat{c}$ . Regardless, the more accurate the forecasting, the lower $L_{1}(p^{*},q)$ will be.
470
+
471
+ Example 2: Food allocation. Consider a conference organizer catering lunch. As a cost-cutting measure, they cater exactly one food item per attendee, based on their self-reported initial dietary preferences reported during registration (each attendee may report more than one item). During the conference, attendees will queue up in random order, sequentially reporting
472
+
473
+ their preferences once again and being assigned their food. Organizers have the flexibility to assign food items based on this new reporting of preferences (or, in a somewhat morally questionable fashion refuse to serve the attendee—though in the unweighted setting, reasonable algorithms should not have to do this!). Alas, a fraction of attendees claim a different preference from their initial preference, e.g., because they were fickle, or did not take initial dietary preference questionnaire seriously. Given that food is already catered, how should the conference organizers sequentially distribute meals to minimize hungry attendees?
474
+
475
+ The attendees are represented by $n$ online vertices, while each of the $n$ offline vertices represent one of $k$ types of food item<sup>4</sup>. The attendees' initial preference gives our advice $q$ (the distribution over types of food preferences), which also describes a perfect matching. This preference may differ from the distribution over true preferences reported on the day of the conference $p$ . However, one can reasonable assume that only a small fraction of attendees exhibit such a mismatch, meaning that the $L_{1}(p^{*},q)$ is fairly small and advice should be accepted most of the time.
476
+
477
+ Example 3: Centralized labor Allocation. Suppose there are $n$ employees and $m$ jobs. There are $\eta$ different qualifications. This is represented by a binary matrix $\{0,1\}^{n,\eta}$ , where $X_{i,k} = 1$ , if employee $i$ possesses qualification $k$ . Therefore, the $i$ -th row of $X$ , $X_{i}$ is a length $\eta$ boolean string containing all of $i$ 's skills.
478
+
479
+ For employee $i$ to perform a job, $X_{i}$ needs to satisfy a boolean formula (say, given in conjunctive form). This is quite reasonable, e.g., to be an AI researcher, it needs to have knowledge of some programming language (Python, Matlab, etc.), some statistics (classical or modern), and some optimization (whether discrete or continuous). In the bipartite graph, employee $i$ has an edge to job $j$ if and only if $X_{i}$ satisfies this formula.
480
+
481
+ In this case, the qualifications of each employee are known by the company, who has access to their employees. Given the qualifications, the set of jobs that may be performed can be computed offline and used as advice. This advice may not be entirely correct: for example, employees may have picked up new skills (hence there may be more edges than we thought, but no less). Of course, there could also be some employees with phoney qualifications; this fraction is not too high.
482
+
483
+ One interesting property about this application is that advice may only be imperfect in the sense that edges could be added. This means that if we just mimicked, we are guaranteed to get at least $\hat{n}$ . Also, the coarsening method is more easily applied.
484
+
485
+ # D. Practical considerations and extensions to our learning-augmented algorithm
486
+
487
+ # D.1. Advice coarsening
488
+
489
+ While Theorem 4.1 has good asymptotic guarantees as $n \to \infty$ , the actual number of vertices $n$ is finite in practice. In particular, when $n$ is "not large enough", TESTANDMATCH will never utilize the advice and always default to BASELINE for all problem instances where $n \ll s_{\hat{r},\varepsilon,\delta}$ .
490
+
491
+ In practice, while the given advice types may be diverse, there could be many "overlapping subtypes" and a natural idea is to "coarsen" the advice by grouping similar types together in an effort to reduce the resultant support size of the advice (and hence $s_{\hat{r},\varepsilon,\delta}$ ). Figure 5 illustrates an extreme example where we could decrease the support size from $n$ to 2 while still maintaining a perfect matching.
492
+
493
+ While one could treat this coarsening subproblem as an optimization pre-processing task. For completeness, we show later how one may potentially model the coarsening optimization as an integer linear program (ILP) but remark that it does not scale well in practice. That said, there are many natural scenarios where a coarsening is readily available to us. For instance, in the online advertising, market studies typically classify users into "types" (with the number of types significantly less than $n$ ) where each type of user typically have a "core set" of suitable ads though the actual realized type of each arrival may be perturbed due to individual differences.
494
+
495
+ Another way to reduce the required samples for testing is to "bucket" the counts which are below a certain threshold to reduce the number of distinct types within the advice. The newly created bucket type will then be a union of the types that are being grouped together.
496
+
497
+ # D.1.1. ILP FOR ADVICE COARSENING
498
+
499
+ Here, we give an integer linear program (ILP) that takes in any number $|\hat{T}| = \hat{r}$ of desired groupings as input and produces a grouping proposed advice count $\hat{c}_{\hat{r}}$ on $\hat{r}$ labels that implies the maximum possible matching. Recall that the smaller number of resulting groups $\hat{r}$ directly translates to fewer samples $s_{\hat{r},\varepsilon,\delta}$ required in TESTANDMATCH. So, to utilize this ILP, one can solve for decreasing values of $r = |\hat{L}|, |\hat{L}| - 1, \ldots, 1$ and evaluate the resulting maximum matching size $\hat{n}_r$ for each proposed advice count $\hat{c}_r$ . Then, one can either use the smallest possible $r$ which still preserves the size of maximum matching or even combine this with the idea from Section 5.3 if one needs to further decrease $r$ .
500
+
501
+ We propose to update the labels by taking intersections of the patterns, i.e. for any resulting group $g_i$ , we define its label pattern as $\cap_{v \in g_i} N(v)$ . Since taking intersections only restricts the edges which can be used in forming a maximum matching, this ensures that MIMIC will always be able to mimic any proposed matching implied by the grouped patterns.
502
+
503
+ # Explanation of constants and variables
504
+
505
+ - Given the $n$ online input patterns, $b_{i,j}$ is a Boolean constant indicating whether online vertex $i \in [n]$ does not have $j \in [n]$ as a neighbor in its pattern.
506
+ - Main decision variable: $x_{i,j}$ whether edge from online vertex $i$ to offline vertex $j$ is part of the matching.
507
+ - Auxiliary variable: $z_{i,\ell}$ is an indicator whether online vertex $i \in [n]$ is assigned to group $\ell \in [k]$ .
508
+ - Product variable: $w_{i,j,\ell} = z_{i,\ell} \cdot z_{j,\ell}$ is an indicator whether both online vertices $i$ and $j$ are in group $\ell$ .
509
+
510
+ # The ILP
511
+
512
+ $$
513
+ \max \qquad \sum_ {(i, j) \in E} x _ {i, j}
514
+ $$
515
+
516
+ $$
517
+ s. t. \quad \sum_ {\substack {j \in [ n ] \\ (i, j) \in E}} x _ {i, j} \leq 1 \quad \forall i \in [ n ] \tag{C1}
518
+ $$
519
+
520
+ $$
521
+ \sum_ {\substack {i \in [ n ] \\ (i, j) \in E}} x _ {i, j} \leq 1 \quad \forall j \in [ n ] \tag{C2}
522
+ $$
523
+
524
+ $$
525
+ x _ {i, j} \leq 1 - w _ {i, q, \ell} \cdot b _ {q, j} \quad \forall (i, j) \in E, q \in [ n ], \ell \in [ k ] \tag {C3}
526
+ $$
527
+
528
+ $$
529
+ w _ {i, j, \ell} \leq z _ {i, \ell} \quad \forall i \in [ n ], \ell \in [ k ] \tag {C4}
530
+ $$
531
+
532
+ $$
533
+ w _ {i, j, \ell} \leq z _ {j, \ell} \quad \forall j \in [ n ], \ell \in [ k ] \tag {C5}
534
+ $$
535
+
536
+ $$
537
+ w _ {i, j, \ell} \geq z _ {i, \ell} + z _ {j, \ell} - 1 \quad \forall i, j \in [ n ], \ell \in [ k ] \tag {C6}
538
+ $$
539
+
540
+ $$
541
+ \sum_ {\ell = 1} ^ {k} z _ {i, \ell} = 1 \quad \forall i \in [ n ] \tag {C7}
542
+ $$
543
+
544
+ $$
545
+ x _ {i, j} \in \{0, 1 \} \quad \forall (i, j) \in E
546
+ $$
547
+
548
+ $$
549
+ z _ {i, \ell} \in \{0, 1 \} \quad \forall i \in [ n ], \ell \in [ k ]
550
+ $$
551
+
552
+ $$
553
+ w _ {i, j, \ell} \in \{0, 1 \} \quad \forall i, j \in [ n ], \ell \in [ k ]
554
+ $$
555
+
556
+ # Explanation of constraints
557
+
558
+ (C1, C2) Standard matching constraints.
559
+ - (C3) Can only use edge $(i,j)$ if it is not "disabled" due to intersections. As long as some other vertex in the same group as $i$ does not have $j$ , the edge $(i,j)$ will be disabled.
560
+ (C4, C5, C6) Encoding $w_{i,j,\ell} = z_{i,\ell} \cdot z_{j,\ell}$ .
561
+ (C7) Every vertex assigned exactly one group.
562
+
563
+ # D.2. Remapping online arrival types
564
+
565
+ Recall the example described in Section 5.1 and how remapping helps obtain a perfect matching. In fact, remappings can only increase the number of matches as these vertices would have been left unmatched otherwise under MIMIC. Note that the proposed remappings always maps an online type to a subset so that any subsequent proposed matching can be credibly performed.
566
+
567
+ In an offline setting, given $c^*$ and $\hat{c}$ , one can efficiently compute a mapping $\sigma$ that maximizes overlap using a max-flow formulation (see Appendix D.2.1) and then redefine the quality of $\hat{c}$ in terms of $L_1(\sigma(c^*), \hat{c})$ . As this is impossible in an online setting, we propose a following simple mapping heuristic: when type $L$ arrives, map it to the largest subset of $A \subseteq L$ with the highest remaining possible match count. Note that it may be the case that all subset types of $L$ no longer have a matching available to mimic from $\hat{M}$ . In the example above, we first mapped $\{u_1, u_2, u_4\}$ to $\{u_2, u_4\}$ and then to $\{u_4\}$ as $\hat{c}$ only had one count for $\{u_2, u_4\}$ .
568
+
569
+ # D.2.1. COMPUTING THE OPTIMAL REMAPPING $\sigma$ VIA A MAXIMUM FLOW FORMULATION
570
+
571
+ Consider the offline setting where we are given the true counts $c^*$ and the advice counts $\hat{c}$ .
572
+
573
+ Suppose $c^*$ has $r$ non-zero counts, represented by: $\langle L_1^*, c_1^* \rangle, \langle L_2^*, c_2^* \rangle, \dots, \langle L_r^*, c_r^* \rangle$ , where $\sum_{i=1}^{r} c_i^* = n$ .
574
+
575
+ Suppose $\hat{c}$ has $s$ non-zero counts, represented by: $\langle \hat{L}_1,\hat{c}_1\rangle ,\langle \hat{L}_2,\hat{c}_2\rangle ,\ldots \langle \hat{L}_s,\hat{c}_s\rangle$ , where $\sum_{i = 1}^{s}\hat{c}_i = n$ .
576
+
577
+ To compute a remapping from $c^*$ to $\hat{c}$ to maximize the number of resulting overlaps, consider the following max flow formulation on a directed graph $G = (V, E)$ with $|V| = r + s + 2$ nodes:
578
+
579
+ - Create a node for each of $L_1^*, \dots, L_r^*, \hat{L}_1, \dots, \hat{L}_s$ .
580
+ - Create a "source" and a "destination" node.
581
+ - Add an edge with a capacity $c_{i}^{*}$ from the "source" node to each of the $L_{i}^{*}$ nodes, for $i \in \{1, \dots, r\}$
582
+ $\cdot (*)$ Add an edge from $L_{i}^{*}$ to $\hat{L}_j$ with capacity $c_{i}^{*}$ if $\hat{L}_j\subseteq L_i^*$ , for $i\in \{1,\ldots ,r\}$ and $j\in \{1,\dots ,s\}$ .
583
+ - Add an edge with a capacity $\hat{c}_j$ from each of the $\hat{L}_j$ nodes to the "destination" node, for $j \in \{1, \dots, s\}$ .
584
+ - Compute the maximum flow from "source" to "destination".
585
+
586
+ Since the graph has integral edge weights, the maximum flow is integral and the flow across each edge is integral. The resultant maximum flow is the maximum attainable overlap between a remapped $c^*$ and $\hat{c}$ , and we can obtain the remapping $\sigma$ by reading off the flows between on the edges from $(*)$ .
587
+
588
+ # D.3. Augmenting advice to perfect matching
589
+
590
+ The following lemma tells us that there is an explicit way of augmenting $\hat{c}$ to form a new advice $\hat{c}^{\prime}$ such that using $\hat{c}^{\prime}$ in TESTANDMATCH does not hurt the provable theoretical guarantees as compared to directly using $\hat{c}$ .
591
+
592
+ Lemma D.1. Let $\hat{c}$ be an arbitrary type count with labels $\hat{T}$ implying a graph $\hat{\mathcal{G}}$ with maximum matching size $\hat{n}$ . There is an explicit way to augment $\hat{c}$ to obtain $\hat{c}'$ with labels $\hat{T}'$ such that the implied graph $\hat{\mathcal{G}}'$ has maximum matching size $\hat{n}' = n$ . Furthermore, running TESTANDMATCH with a slight modification of MIMIC on $(\hat{c}',\hat{T}')$ produces a matching of size $m$ where
593
+
594
+ $$
595
+ \frac {m}{n ^ {*}} \geq \frac {m}{n} \geq \left\{ \begin{array}{l l} \frac {\hat {n}}{n} - \frac {L _ {1} (p ^ {*} , q)}{2} & \text {w h e n} \hat {L} _ {1} \leq 2 (1 - \beta) - \varepsilon \\ \beta - o (1) & \text {o t h e r w i s e} \end{array} \right.
596
+ $$
597
+
598
+ Proof. Suppose we are given an arbitrary pattern count $\hat{c}$ and corresponding labels $\hat{L}$ such that the corresponding graph $\hat{\mathcal{G}}$ has maximum matching $\hat{M}$ of size $\hat{n} < n$ . Let us fix any arbitrary maximum matching $\hat{M}$ . Denote $A_U \subseteq U$ as the set of $k = n - \hat{n}$ offline vertices and $A_V \subseteq V$ as the set of $k$ online vertices that are unmatched in $\hat{M}$ . We construct a new graph $\hat{\mathcal{G}}'$ by adding a complete bipartite graph of size $k$ on $A_U \cup A_V$ to $\hat{\mathcal{G}}$ . By construction, the resulting graph $\hat{\mathcal{G}}'$ has a maximum matching of size $\hat{n}' = n$ due to the modified adjacency patterns of the online vertices $A_V$ .
599
+
600
+ We now explain how to modify the pattern counts and labels accordingly. Define the new set of labels $\hat{L}'$ as $\hat{L}$ with a new pattern called "New". Then, we subtract away the counts of $A_V$ from $\hat{c}$ and add a count of $k$ to the label "New" to obtain a new pattern count $\hat{c}'$ . By construction, we see that $|\hat{L}'| = |\hat{L}| + 1$ and
601
+
602
+ $$
603
+ L _ {1} (\hat {c}, \hat {c} ^ {\prime}) = | \hat {c} (“ \mathrm {N e w} ”) - \hat {c} ^ {\prime} (“ \mathrm {N e w} ”) | + \sum_ {\ell \in \hat {L}} | \hat {c} (\ell) - \hat {c} ^ {\prime} (\ell) | = k + k = 2 k
604
+ $$
605
+
606
+ Note that $c^* (\text{New}) = 0$ . By triangle inequality, we also see that
607
+
608
+ $$
609
+ L _ {1} \left(c ^ {*}, \hat {c} ^ {\prime}\right) \leq L _ {1} \left(c ^ {*}, \hat {c}\right) + L _ {1} \left(\hat {c}, \hat {c} ^ {\prime}\right) \leq L _ {1} \left(c ^ {*}, \hat {c}\right) + 2 k
610
+ $$
611
+
612
+ Slight modification of MIMIC. MIMIC will now be informed of the sets $A_U$ and $A_V$ along with the proposed matching $\hat{M}$ for the online vertices $V \setminus A_V$ . Then, whenever an online vertex $v$ arrives whose pattern does not match any in $\hat{L}$ , we first try to match $v$ to an unmatched neighbor in $A_U$ if possible before leaving it unmatched. Observe that this modified procedure can only increase the number of resultant matches since we do not disrupt any possible matchings under $(\hat{c}, \hat{L})$ while only possibly increasing the matching size via the complete bipartite graph between $A_U$ and $A_V$ .
613
+
614
+ To complete the analysis, we again consider whether MIMIC was executed throughout the online arrivals or we switched to BASELINE, as in the analysis of Theorem 4.1. Note that now $\hat{L}_1$ is an estimate of $L_{1}(c^{*},\hat{c}^{\prime})$ instead of $L_{1}(c^{*},\hat{c})$ and the threshold is $2\left(\frac{\hat{n}'}{n} -\beta\right) - \varepsilon = 2(1 - \beta) - \varepsilon$ instead of $2\left(\frac{\hat{n}}{n} -\beta\right) - \varepsilon$ since $\hat{n}^{\prime} = n$ . Also, recall that $k = n - \hat{n}$ .
615
+
616
+ Case 1: $\hat{L}_1 < 2(1 - \beta) - \varepsilon$
617
+
618
+ Then, TESTANDMATCH executed MIMIC throughout for all online arrivals, yielding a matching of size $m \geq n - \frac{L_1(c^*, \hat{c}')}{2}$ . Therefore,
619
+
620
+ $$
621
+ \frac {m}{n ^ {*}} \geq \frac {m}{n} \geq 1 - \frac {L _ {1} (c ^ {*} , \hat {c} ^ {\prime})}{2 n} \geq 1 - \frac {L _ {1} (c ^ {*} , \hat {c}) + 2 k}{2 n} = 1 - \frac {L _ {1} (p , q)}{2} - \frac {n - \hat {n}}{n} = \frac {\hat {n}}{n} - \frac {L _ {1} (p , q)}{2}
622
+ $$
623
+
624
+ Case 2: $\hat{L}_1 \geq 2(1 - \beta) - \varepsilon$
625
+
626
+ Repeat the exact same analysis as in Theorem 4.1 but with $\hat{r}$ replaced by $\hat{r}' = |\hat{T}'| = |\hat{T}| + 1 = \hat{r} + 1$ yields a matching size of at least $\beta \cdot n - s_{\hat{r} + 1, \varepsilon, \delta} \cdot \sqrt{\log(\hat{r} + 1)}$ , where
627
+
628
+ $$
629
+ s _ {\hat {r}, \varepsilon , \delta} = O \left(\frac {(\hat {r} + 1) \cdot \log 1 / \delta}{\varepsilon^ {2} \cdot \log (\hat {r} + 1)}\right)
630
+ $$
631
+
632
+ and $s_{\hat{r} +1,\varepsilon ,\delta}\cdot \sqrt{\log(\hat{r} + 1)}\in o(1)$
633
+
634
+ # E. Deferred proofs
635
+
636
+ Lemma E.1. In the output of SIMULATEP (Algorithm 4), $T_{p^*}^s$ contains $s$ i.i.d. samples from the realized type count distribution $p^* = c^* / n$ while using at most $s$ fresh online arrivals.
637
+
638
+ Proof. With probability $i / n$ , we choose a uniform at random item from $\{A[0],\dots ,A[i - 1]\}$ . With probability $1 - i / n$ , we pick the next item $A[i]$ from the existing arrivals which was uniform at random under the random arrival model assumption. Since we could possibly reuse arrivals, $T_{p^*}^s$ is formed by using at most $s$ fresh arrivals.
639
+
640
+ # E.1. Proof of Theorem 2.1
641
+
642
+ Theorem 2.1 (adapted from (Jiao et al., 2018)). Fix a reference distribution $q$ over a domain $T$ of size $|T| = r$ and let $s \in \mathcal{O}\left(\frac{r\cdot\log(1 / \delta)}{\varepsilon^2\cdot\log r}\right)$ be an even integer. There exists an algorithm that draws $s_1 + s_2$ IID samples from an unknown distribution $p$ over $T$ , where $s_1, s_2 \sim \mathrm{Poisson}(s / 2)$ , and outputs an estimate $\hat{L}_1$ such that $|\hat{L}_1 - L_1(p,q)| \leq \varepsilon$ with success probability at least $1 - \delta$ .
643
+
644
+ Proof. Using Theorem 2 in (Jiao et al., 2018), we get that using $s = \Theta\left(\frac{r}{\varepsilon^2 \log r}\right)$ , their estimator has $\varepsilon$ additive error in expectation. Therefore, by using $100 \cdot s$ samples, we can achieve $\varepsilon / 10$ additive error in expectation, i.e. $\mathbb{E}[|\hat{L}_1 - L_1(p,q)|] =$
645
+
646
+ Algorithm 4 SIMULATEp
647
+ input Array A of online arrivals so far and number of desired i.i.d. samples s, where s ≤ |A| output $T_{p^*}^{s}$ ▷s i.i.d. samples from p\* 1: $T_{p^*}^{s}\gets \emptyset$ ▷ Collect simulated i.i.d. arrivals from p\* 2: i←0 3: while $|T_{p^*}^s | < s$ do 4: if Bernoulli(i/n) == 1 then 5: x← Pick uniformly at random from the set $\{A[0],\dots ,A[i - 1]\}$ 6: else 7: x← A[i] ▷ Uniform at random from $c^*$ under the random arrival model 8: i← i + 1 9: end if 10: Add x to $T_{p^*}^s$ 11: end while 12: return $T_{p^*}^{s}$
648
+
649
+ $\varepsilon /10$ .ByMarkov'sinequality,we get:
650
+
651
+ $$
652
+ \Pr \left[ | \hat {L} _ {1} - L _ {1} (p, q) | > \varepsilon \right] \leq 1 / 1 0
653
+ $$
654
+
655
+ Thus, by repeating the entire algorithm $O(\log(1/\delta))$ times and choosing the median $\tilde{L}_1$ of the resulting estimates, we get:
656
+
657
+ $$
658
+ \Pr [ | \tilde {L} _ {1} - L _ {1} (p, q) | > \varepsilon ] \leq \delta
659
+ $$
660
+
661
+ # F. Proof of concept
662
+
663
+ It is our understanding that the tester proposed by Jiao et al. (2018) requires a significant amount of hyperparameter tuning and no off-the-shelf implementation is available (Han, 2024). One may consider using an older method by Valiant & Valiant (2011) which is also sublinear in the number of samples but their proposed algorithm is for non-tolerant testing and requires a non-trivial code adaptation before it is applicable to $L_{1}$ estimation.
664
+
665
+ As a proof-of-concept, we implemented TESTANDMATCH with the empirical $L_{1}$ estimator and study the resultant competitive ratio under degrading advice quality. The source code is available at https://github.com/cxjdavin/online-bipartite-matching-with-imperfect-advice.
666
+
667
+ # F.1. Implementation details
668
+
669
+ From Section 2, we know that the state-of-the-art advice-less algorithm for random order arrival is the RANKING algorithm of (Karp et al., 1990) which achieve a competitive ratio of $\beta = 0.696$ (Mahdian & Yan, 2011).
670
+
671
+ For our testing threshold, we set $\varepsilon = \hat{n} / n - \beta$ so that $\tau = 2(\hat{n} / n - \beta) - \varepsilon = \hat{n} / n - \beta$ . We also implemented the following practical extensions to TESTANDMATCH which we discussed in Section 5:
672
+
673
+ 1. Sigma remapping (Section 5.1)
674
+ 2. Bucketing so that $\hat{r} / \varepsilon^2 < n$ (Section 5.2)
675
+ 3. Patching so that $\hat{n}^{\prime} = n$ (Section 5.3)
676
+
677
+ We tested 4 variants of TESTANDMATCH, one with all extensions enabled and three others that disable one extension at a time (for ablation testing).
678
+
679
+ # F.2. Instances
680
+
681
+ Our problem instances are generated from the synthetic hard known IID instance of (Manshadi et al., 2012) where any online algorithm achieves a competitive ratio of at most 0.823 in expectation:
682
+
683
+ - Let $Y_{k}$ denote the set of online vertices with $k$ random offline neighbors (out of $\binom{n}{k}$ )
684
+ - Let $m = \frac{c_{2.5}^{*}}{2} \cdot n$ , where $c_{2.5}^{*} = 0.81034$ is some constant defined in (Manshadi et al., 2012) (not to be confused with our type counts $c^{*}$ )
685
+ - Sample $m$ random online vertices from $Y_{2}$ , i.e. each online vertex is adjacent to a random subset of 2 offline vertices.
686
+ - Sample $m$ random online vertices from $Y_{3}$ , i.e. each online vertex is adjacent to a random subset of 3 offline vertices.
687
+ - Sample $n - 2m$ random online vertices from $Y_{n}$ , i.e. each online vertex is adjacent to every offline vertex.
688
+ - Permute the online vertices for a random order arrival
689
+
690
+ Here, the support size of any generated type count $c^*$ is roughly $0.8n$ due to the samples from $Y_{2}$ and $Y_{3}$ .
691
+
692
+ # F.3. Corrupting advice
693
+
694
+ Starting with perfect advice $\hat{c} = c^{*}$ , we corrupt the advice by an $\alpha$ parameter using two types of corruption.
695
+
696
+ 1. Pick a random $\alpha \in [0,1]$ fraction of online vertices
697
+ 2. Generate a random type for each of them by independently connecting to each offline vertex with probability $\frac{\ln n}{10n}$ .
698
+ 3. Type 1 corruption (add extra connections): Define the new type as the union of the old vertex type and the new random type.
699
+ 4. Type 2 corruption (replace connections): Define the new type as the new random type.
700
+
701
+ As a remark, our random type generation biases towards a relatively sparse corrupted graph.
702
+
703
+ # F.4. Preliminary results
704
+
705
+ We generated 10 random graph instances with $n = 2000$ offline and $n$ online vertices. Figure 8 illustrates the resulting plots with error bars.
706
+
707
+ ![](images/4924d80d8d6c0671b43c4479b2a4d262712ae638872b0282a13208a590be33b2.jpg)
708
+ Figure 8. $n = 2000$ , averaged over 10 runs. TaM refers to our implementation of TESTANDMATCH.
709
+
710
+ ![](images/653a23e840be9c461fbc1654db0c73d5596b40f7bff9136dfd902d249a46fcba.jpg)
711
+
712
+ In all cases, we see that the attained competitive ratio is highest when all extensions are enabled. We also see that the degradation below the baseline is not very severe ( $< 0.1$ for all cases, even when not all extensions are enabled).
713
+
714
+ Unsurprisingly, the competitive ratios of Ranking and "TaM without bucket" coincide because because $r / \varepsilon^2 > n$ and we always default to baseline without performing any tests (to maintain robustness).
715
+
716
+ For corruption type 1, the "sigma remapping" extension makes our algorithm robust against additive edge corruption, and so the "patching" extension has no further impact.
onlinebipartitematchingwithimperfectadvice/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:83c0ec5803939b10cb487665aff0b749d7609703cbf16264b8c8e16d8c568205
3
+ size 430009
onlinebipartitematchingwithimperfectadvice/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:97d686c5aafe60f067cca5b4ce259114c668a02cd36b370c2006a21f05f46287
3
+ size 1382991
onlineconformalpredictionwithdecayingstepsizes/0480f286-52a0-42de-acf6-2b1287986b76_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7dea052f867f8dd3cecea5b49cc00fc364837d7778806e781b3b9216068387b6
3
+ size 130360
onlineconformalpredictionwithdecayingstepsizes/0480f286-52a0-42de-acf6-2b1287986b76_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:71cc7736aa7194f31707d92b69e733f0e97746f92e6ebf54c9b3963d02960144
3
+ size 153314
onlineconformalpredictionwithdecayingstepsizes/0480f286-52a0-42de-acf6-2b1287986b76_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:146d5108a5b66ba7786668cda67389b31855853886b2c7d588f9867f43b3c488
3
+ size 800253
onlineconformalpredictionwithdecayingstepsizes/full.md ADDED
@@ -0,0 +1,727 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Online conformal prediction with decaying step sizes
2
+
3
+ Anastasios N. Angelopoulos*1 Rina Foygel Barber*2 Stephen Bates*3
4
+
5
+ # Abstract
6
+
7
+ We introduce a method for online conformal prediction with decaying step sizes. Like previous methods, ours possesses a retrospective guarantee of coverage for arbitrary sequences. However, unlike previous methods, we can simultaneously estimate a population quantile when it exists. Our theory and experiments indicate substantially improved practical properties: in particular, when the distribution is stable, the coverage is close to the desired level for every time point, not just on average over the observed sequence.
8
+
9
+ # 1. Introduction
10
+
11
+ We study the problem of online uncertainty quantification, such as that encountered in time-series forecasting. Our goal is to produce a prediction set at each time, based on all previous information, that contain the true label with a specified coverage probability. Such prediction sets are useful to the point of being requirements in many sequential problems, including medicine (Robinson, 1978), robotics (Lindemann et al., 2023), finance (Mykland, 2003), and epidemiology (Cramer et al., 2022). Given this broad utility, it comes as no surprise that prediction sets have been studied for approximately one hundred years (and possibly more; see Section 1.1 of Tian et al. (2022)).
12
+
13
+ Formally, consider a sequence of data points $(X_{t},Y_{t})\in$ $\mathcal{X}\times \mathcal{Y}$ , for $t = 1,2,\ldots$ . At each time $t$ , we observe $X_{t}$ and seek to cover $Y_{t}$ with a set $\mathcal{C}_t(X_t)$ , which depends on a base model trained on all past data (as well as the current feature
14
+
15
+ *Equal contribution $^{1}$ Department of Electrical Engineering and Computer Science, University of California at Berkeley, Berkeley CA USA $^{2}$ Department of Statistics, University of Chicago, Chicago IL USA $^{3}$ Department of Electrical Engineering and Computer Science, Massachusetts Institute of Technology, Cambridge MA USA. Correspondence to: Anastasios N. Angelopoulos <angelopoulos@berkeley.edu>, Rina Foygel Barber <rina@uchicago.edu>, Stephen Bates <stephenbates@mit.edu>.
16
+
17
+ Proceedings of the $41^{st}$ International Conference on Machine Learning, Vienna, Austria. PMLR 235, 2024. Copyright 2024 by the author(s).
18
+
19
+ $X_{t})$ . After predicting, we observe $Y_{t}$ , and the next timestep ensues. Note that we have not made any assumptions yet about the data points and their dependencies.
20
+
21
+ This paper introduces a method for constructing the prediction sets $\mathcal{C}_t$ that has simultaneous best-case and worst-case guarantees—that is, a "best of both worlds" property. We will describe the method shortly in Section 1.1. Broadly speaking, the method can gracefully handle both arbitrary adversarial sequences data points and also independent and identically distributed (I.I.D.) sequences. In the former case, our method will remain robust, ensuring that the historical fraction of miscovered labels converges to the desired error rate, $\alpha \in (0,1)$ . In the latter case, our method will converge, eventually producing the optimal prediction sets. We summarize our results below:
22
+
23
+ 1. Worst-case guarantee (Theorem 1): When the data points are arbitrary, our algorithm achieves
24
+
25
+ $$
26
+ \frac {1}{T} \sum_ {t = 1} ^ {T} \mathbb {1} _ {Y _ {t} \in \mathcal {C} _ {t} \left(X _ {t}\right)} \in \left(1 - \alpha \pm \frac {C}{T ^ {1 / 2 - \epsilon}}\right), \tag {1}
27
+ $$
28
+
29
+ for a constant $C$ and any fixed $\epsilon > 0$ . We call this a long-run coverage guarantee.
30
+
31
+ 2. Best-case guarantee (Theorem 3): When the data points are I.I.D., our algorithm achieves
32
+
33
+ $$
34
+ \lim _ {T \rightarrow \infty} \mathbb {P} \left(Y _ {T} \in \mathcal {C} _ {T} \left(X _ {T}\right)\right)\rightarrow 1 - \alpha . \tag {2}
35
+ $$
36
+
37
+ We call this a convergence guarantee.
38
+
39
+ Our algorithm is the first to satisfy both guarantees simultaneously. Moreover, the decaying step size yields more stable behavior than prior methods, as we will see in experiments. See Section 1.2 for a discussion of the relationship with other methods, such as those of Gibbs & Candes (2021), Angelopoulos et al. (2023), and Xu & Xie (2021).
40
+
41
+ # 1.1. Method and Setup
42
+
43
+ We now describe our prediction set construction. Borrowing from conformal prediction, consider a bounded conformal score function $s_t: \mathcal{X} \times \mathcal{Y} \to [0, B]$ , at each time $t$ . This score $s_t = s_t(X_t, Y_t)$ is large when the predictions of the
44
+
45
+ base model disagree greatly with the observed label; an example would be the residual score, $s_t(x,y) = |y - \hat{f}_t(x)|$ , for a model $\hat{f}_t: \mathcal{X} \to \mathbb{R}$ trained online. This concept is standard in conformal prediction (Vovk et al., 2005), and we refer the reader to Angelopoulos & Bates (2023) for a recent overview. Given this score function, define
46
+
47
+ $$
48
+ \mathcal {C} _ {t} (x) = \{y \in \mathcal {Y}: s _ {t} (x, y) \leq q _ {t} \}, \tag {3}
49
+ $$
50
+
51
+ where the threshold $q_{t}$ is updated with the rule
52
+
53
+ $$
54
+ q _ {t + 1} = q _ {t} + \eta_ {t} \left(\mathbb {1} _ {Y _ {t} \notin \mathcal {C} _ {t} \left(X _ {t}\right)} - \alpha\right). \tag {4}
55
+ $$
56
+
57
+ In particular, if we fail to cover $Y_{t}$ at time $t$ , then the threshold increases to make the procedure slightly more conservative at the next time step (and vice versa).
58
+
59
+ Familiar readers will notice the similarity of the update step (4) to that of Gibbs & Candes (2021); Bhatnagar et al. (2023); Feldman et al. (2023); Angelopoulos et al. (2023), the main difference being that here, $\eta_t$ can change over time—later on we will see that $\eta_t \propto t^{-1/2 - \epsilon}$ , for some small $\epsilon \in (0, 1/2)$ , leads to guarantees (1) and (2) as described above. We remark also that the update step for $q_t$ can be interpreted as an online (sub)gradient descent algorithm on the quantile loss $\rho_{1 - \alpha}(t) = (1 - \alpha)\max\{t, 0\} + \alpha\max\{-t, 0\}$ (Koenker & Bassett Jr, 1978), i.e., we can equivalently write the update step (4) as
60
+
61
+ $$
62
+ q _ {t + 1} = q _ {t} - \eta_ {t} \nabla \rho_ {1 - \alpha} (s _ {t} - q _ {t}).
63
+ $$
64
+
65
+ In this work, we will consider two different settings:
66
+
67
+ Setting 1 (Adversarial setting). We say that we are in the adversarial setting if we allow $(X_{1},Y_{1}),(X_{2},Y_{2}),\ldots$ to be an arbitrary sequence of elements in $\mathcal{X}\times \mathcal{V}$ , and $s_1,s_2,\ldots$ to be an arbitrary sequence of functions from $\mathcal{X}\times \mathcal{V}$ to $[0,B]$ .
68
+
69
+ Setting 2 (I.I.D. setting). We say that we are in the I.I.D. setting if we require that $(X_{t},Y_{t})\stackrel {\mathrm{iid}}{\sim}P$ for some distribution $P$ , and require that the choice of the function $s_t:\mathcal{X}\times \mathcal{Y}\to [0,B]$ depends only on $\{(X_r,Y_r)\}_{r < t}$ , for each $t$ (i.e., the model is trained online).
70
+
71
+ Of course, any result proved for Setting 1 will hold for Setting 2 as well. We remark that Setting 2 can be relaxed to allow for randomness in the choice of the score functions $s_t$ — our results for the I.I.D. setting will hold as long as the function $s_t$ is chosen independently of $\{(X_r, Y_r)\}_{r \geq t}$ .
72
+
73
+ Our method, like all conformal methods, has coverage guarantees that hold for any underlying model and data stream. Still, the quality of the output (e.g., the size of the prediction sets) does critically depend on the quality of the underlying model. This general interplay between conformal methods and models is discussed throughout the conformal literature (e.g., Vovk et al., 2005; Angelopoulos & Bates, 2023).
74
+
75
+ # 1.2. Related work
76
+
77
+ We begin by reviewing the most closely related literature. Set constructions of the form in (3), which "invert" the score function, are commonplace in conformal prediction (Vovk et al., 2005), with $q_{t}$ chosen as a sample quantile of the previous conformal scores. However, the exchangeability-based arguments of the standard conformal framework cannot give any guarantees in Setting 1. The idea to set $q_{t}$ via online gradient descent with a fixed step size appears first in Gibbs & Candes (2021), which introduced online conformal prediction in the adversarial setting. The version we present here builds also on the work of Bhatnagar et al. (2023), Feldman et al. (2023), and Angelopoulos et al. (2023); in particular, Angelopoulos et al. (2023) call the update in (4) the "quantile tracker". These papers all have long-run coverage guarantees in Setting 1, but do not have convergence guarantees in Setting 2.
78
+
79
+ Subsequent work to these has explored time-varying step sizes that respond to distribution shifts, primarily for the purpose of giving other notions of validity, such as regret analyses (Gibbs & Candès, 2022; Zaffran et al., 2022; Bastani et al., 2022; Noarov et al., 2023; Bhatnagar et al., 2023). From an algorithmic perspective, these methods depart significantly from the update in (4), generally by incorporating techniques from online learning—such as strongly adaptive online learning (Daniely et al., 2015), adaptive regret (Gradu et al., 2023), and adaptive aggregation of experts (Cesa-Bianchi & Lugosi, 2006). To summarize, the long-run coverage and regret bounds in these papers apply to substantially different, usually more complicated algorithms than the simple expression we have in (4). We remark that "best of both worlds" guarantees appear in the online learning literature (e.g., Bubeck & Slivkins, 2012; Koolen et al., 2016; Zimmert & Seldin, 2021; Jin et al., 2021; Chen et al., 2023; Dann et al., 2023), where the aim is to find a single algorithm whose regret is optimal both in a stochastic setting (i.e., data sampled from a distribution) and in an adversarial setting. A crucial difference, however, is that our paper's guarantees are concerned with inference and predictive coverage, rather than with estimation or regret.
80
+
81
+ Further afield from our work, there have been several other explorations of conformal prediction in time-series, but these are quite different. For example, the works of Barber et al. (2022) and Chernozhukov et al. (2018) provide conformal-type procedures with coverage guarantees under certain relaxations of exchangeability; both can provide marginal coverage in Setting 2, but cannot give any guarantees in Setting 1. Xu & Xie (2021; 2023) study the behavior of conformal methods under classical nonparametric assumptions such as model consistency and distributional smoothness for its validity, and thus cannot give
82
+
83
+ distribution-free guarantees in Settings 1 or 2. Lin et al. (2022) studies the problem of cross-sectional coverage for multiple exchangeable time-series. The online conformal prediction setup was also considered early on by Vovk (2002) for exchangeable sequences. These works are not directly comparable to ours, the primary point of difference being the adversarial guarantee we can provide in Setting 1.
84
+
85
+ Finally, traditional solutions to the prediction set problem have historically relied on Bayesian modeling (e.g., Foreman-Mackey et al., 2017) or distributional assumptions such as autoregression, smoothness, or ergodicity (e.g., Biau & Patra, 2011). A parallel literature on calibration exists in the adversarial sequence model (e.g., Foster & Vohra, 1998). Our work, like that of Gibbs & Candes (2021), is clearly related to the literatures on both calibration and online convex optimization (Zinkevich, 2003), and we hope these connections will continue to reveal themselves; our work takes online conformal prediction one step closer to online learning by allowing the use of decaying step sizes, which is typical for online gradient descent.
86
+
87
+ # 1.3. Our contribution
88
+
89
+ We provide the first analysis of the online conformal prediction update in (4) with an arbitrary step size. Our analysis gives strong long-run coverage bounds for appropriately decaying step sizes, even in the adversarial setting (Setting 1). We also give a simultaneous convergence guarantee in the I.I.D. setting (Setting 2), showing that the parameter $q_{t}$ converges to the optimal value $q^{*}$ . Importantly, this type of convergence does not hold with a fixed step size (the case previously analyzed in the online conformal prediction literature). In fact, we show that with a fixed step size, online conformal prediction returns meaningless prediction sets (i.e., either $\emptyset$ or $\mathcal{V}$ ) infinitely often. From the theoretical point of view, therefore, our method is the first to provide this type of "best-of-both-worlds" guarantee.
90
+
91
+ While these theoretical results show an improvement (relative to the fixed-step-size method) in an I.I.D. setting, from the practical perspective we will see that a decaying step size also enables substantially better results and more stable behavior on real time series data, which lies somewhere between the I.I.D. and the adversarial regime.
92
+
93
+ # 2. Main results in the adversarial setting
94
+
95
+ We now present our main results for the adversarial setting, Setting 1, which establish long-run coverage guarantees with no assumptions on the data or the score functions.
96
+
97
+ # 2.1. Decreasing step sizes
98
+
99
+ Our first main result shows that, for a nonincreasing step size sequence, the long-run coverage rate
100
+
101
+ $$
102
+ \frac {1}{T} \sum_ {t = 1} ^ {T} \mathbb {1} _ {Y _ {t} \in \mathcal {C} _ {t} \left(X _ {t}\right)} \tag {5}
103
+ $$
104
+
105
+ will converge to the nominal level $1 - \alpha$
106
+
107
+ Theorem 1. Let $(X_{1},Y_{1}),(X_{2},Y_{2}),\ldots$ be an arbitrary sequence of data points, and let $s_t:\mathcal{X}\times \mathcal{Y}\to [0,B]$ be arbitrary functions. Let $\eta_t$ be a positive and nonincreasing sequence of step sizes, and fix an initial threshold $q_{1}\in [0,B]$ .
108
+
109
+ Then online conformal prediction satisfies
110
+
111
+ $$
112
+ \left| \frac {1}{T} \sum_ {t = 1} ^ {T} \mathbb {1} _ {Y _ {t} \in \mathcal {C} _ {t} (X _ {t})} - (1 - \alpha) \right| \leq \frac {B + \eta_ {1}}{\eta_ {T} T}
113
+ $$
114
+
115
+ for all $T\geq 1$
116
+
117
+ As a special case, if we choose a constant step size $\eta_t \equiv \eta$ then this result is analogous to Gibbs & Candes (2021, Proposition 4.1). On the other hand, if we choose $\eta_t \propto t^{-a}$ for some $a \in (0,1)$ , then the long-run coverage at time $T$ has error bounded as $\mathcal{O}\left(\frac{1}{T^{1 - a}}\right)$ .
118
+
119
+ # 2.2. Arbitrary step sizes
120
+
121
+ As discussed above, if the data appears to be coming from the same distribution then a decaying step size can be advantageous, to stabilize the behavior of the prediction sets over time. However, if we detect a sudden distribution shift and start to lose coverage, we might want to increase the step size $\eta_t$ to recover coverage more quickly. To accommodate this, the above theorem can be generalized to an arbitrary step size sequence, as follows.
122
+
123
+ Theorem 2. Let $(X_{1},Y_{1}),(X_{2},Y_{2}),\ldots$ be an arbitrary sequence of data points, and let $s_t:\mathcal{X}\times \mathcal{Y}\to [0,B]$ be arbitrary functions. Let $\eta_t$ be an arbitrary positive sequence, and fix an initial threshold $q_{1}\in [0,B]$ .
124
+
125
+ Then online conformal prediction satisfies
126
+
127
+ $$
128
+ \begin{array}{l} \left| \frac {1}{T} \sum_ {t = 1} ^ {T} \mathbb {1} _ {Y _ {t} \in \mathcal {C} _ {t} (X _ {t})} - (1 - \alpha) \right| \\ \leq \frac {B + \max _ {1 \leq t \leq T} \eta_ {t}}{T} \cdot \| \Delta_ {1: T} \| _ {1} \\ \end{array}
129
+ $$
130
+
131
+ for all $T \geq 1$ , where the sequence $\Delta$ is defined with values
132
+
133
+ $$
134
+ \Delta_ {1} = \eta_ {1} ^ {- 1}, \text {a n d} \Delta_ {t} = \eta_ {t} ^ {- 1} - \eta_ {t - 1} ^ {- 1} \text {f o r a l l} t \geq 2.
135
+ $$
136
+
137
+ We can see that Theorem 1 is indeed a special case of this more general result, because in the case of a nonincreasing sequence $\eta_t$ , we have $\max_{1 \leq t \leq T} \eta_t = \eta_1$ , and
138
+
139
+ $$
140
+ \begin{array}{l} \| \Delta_ {1: T} \| _ {1} = | \eta_ {1} ^ {- 1} | + \sum_ {t = 2} ^ {T} | \eta_ {t} ^ {- 1} - \eta_ {t - 1} ^ {- 1} | \\ = \eta_ {1} ^ {- 1} + \sum_ {t = 2} ^ {T} (\eta_ {t} ^ {- 1} - \eta_ {t - 1} ^ {- 1}) = \eta_ {T} ^ {- 1}. \\ \end{array}
141
+ $$
142
+
143
+ But Theorem 2 can be applied much more broadly. For example, we might allow the step size to decay during long stretches of time when the distribution seems stationary, but then reset to a larger step size whenever we believe the distribution may have shifted. In this case, we can obtain an interpretable error bound from the result of Theorem 2 by observing that $\| \Delta_{1:T}\| _1\leq \frac{2N_T}{\min_{1\leq t\leq T}\eta_t}$ , where $N_{T} = \sum_{t = 2}^{T}\mathbb{1}_{\eta_{t} > \eta_{t - 1}}$ is the number of times we increase the step size. Thus, as long as the step size does not decay too quickly, and the number of "resets" $N_{T}$ is o(T), the upper bound of Theorem 2 will still be vanishing.
144
+
145
+ # 3. Results for I.I.D. data
146
+
147
+ We now turn to studying the setting of I.I.D. data, Setting 2, where $(X_{1},Y_{1}),(X_{2},Y_{2}),\ldots$ are sampled I.I.D. from some distribution $P$ on $\mathcal{X}\times \mathcal{Y}$ . While Theorems 1 and 2 show that the coverage of the procedure converges in a weak sense, as in (5), for any realization of the data (or even with a nonrandom sequence of data points), we would also like to understand whether the procedure might satisfy stronger notions of convergence with "nice" data. Will the sequence of prediction intervals converge in a suitable sense? We will see that decaying step size does indeed lead to convergence, whereas a constant step size leads to oscillating behavior.
148
+
149
+ In order to make our questions precise, we need to introduce one more piece of notation to capture the notion of coverage at a particular time $t$ — the "instantaneous" coverage. Let
150
+
151
+ $$
152
+ \operatorname {C o v e r a g e} _ {t} (q) = \mathbb {P} _ {P} \left(s _ {t} (X, Y) \leq q \mid s _ {t}\right),
153
+ $$
154
+
155
+ where the probability is calculated with respect to a data point $(X,Y) \sim P$ drawn independently of $s_t$ . Then, at time $t$ , the prediction set $\mathcal{C}_t(X_t)$ has coverage level $\mathrm{Coverage}_t(q_t)$ , by construction. We will see in our results below that for an appropriately chosen decaying step size, $\mathrm{Coverage}_t(q_t)$ will concentrate around $1 - \alpha$ over time, while if we choose a constant step size, then $\mathrm{Coverage}_t(q_t)$ will be highly variable.
156
+
157
+ # 3.1. Results with a pretrained score function
158
+
159
+ To begin, we assume that the score function is pretrained, i.e., that $s_1 = s_2 = \ldots$ are all equal to some fixed function $s: \mathcal{X} \times \mathcal{Y} \to [0, B]$ . The reader should interpret this as the case where the underlying model is not updated online
160
+
161
+ (e.g., $s(x, y) = |y - \hat{f}(x)|$ for a pretrained model $\hat{f}$ that is no longer being updated). This simple case is intended only as an illustration of the trends we might see more generally; in Section 3.2 below we will study a more realistic setting, where model training is carried out online as the data is collected.
162
+
163
+ In this setting, since the score function does not vary with $t$ , we have $\mathsf{Coverage}_t(\cdot) \equiv \mathsf{Coverage}(\cdot)$ where
164
+
165
+ $$
166
+ \operatorname {C o v e r a g e} (q) = \mathbb {P} _ {P} (s (X, Y) \leq q),
167
+ $$
168
+
169
+ i.e., instantaneous coverage at time $t$ is $\mathrm{Coverage}(q_t)$ .
170
+
171
+ First, we will see that choosing a constant step size leads to undesirable behavior: while coverage will hold on average over time (as recorded in Theorem 1 and in the earlier work of Gibbs & Candes (2021)), there will be high variability in Coverage $(q_{t})$ over time—for instance, we may have $\mathcal{C}_t(X_t) = \emptyset$ infinitely often.
172
+
173
+ Proposition 1. Let $(X_{t},Y_{t})\stackrel {\mathrm{iid}}{\sim}P$ for some distribution $P$ . Suppose also that $s_t\equiv s$ for some fixed function $s:\mathcal{X}\times$ $\mathcal{V}\to [0,B]$ , and that $\eta_t\equiv \eta$ for a positive constant step size $\eta >0$ . Assume also that $\alpha$ is a rational number.
174
+
175
+ Then online conformal prediction satisfies
176
+
177
+ $$
178
+ \operatorname {C o v e r a g e} \left(q _ {t}\right) = 0 \text {f o r i n f i n i t e l y m a n y} t,
179
+ $$
180
+
181
+ and
182
+
183
+ $$
184
+ \operatorname {C o v e r a g e} \left(q _ {t}\right) = 1 \text {f o r i n f i n i t e l y m a n y} t,
185
+ $$
186
+
187
+ almost surely.
188
+
189
+ In other words, even in the simplest possible setting of I.I.D. data and a fixed model, we cannot expect convergence of the method if we use a constant step size.
190
+
191
+ On the other hand, if we choose a sequence of step sizes $\eta_t$ that decays at an appropriate rate (such as $\eta_t \propto t^{-1/2 - \epsilon}$ , for some $\epsilon \in (0, 1/2)$ , as mentioned earlier) then over time, this highly variable behavior can be avoided. Instead, we will typically see coverage converging to $1 - \alpha$ for each constructed prediction set $\mathcal{C}_t(X_t)$ , i.e., $\mathrm{Coverage}(q_t) \to 1 - \alpha$ . We will need one more assumption: defining $q^*$ as the $(1 - \alpha)$ -quantile of $s(X,Y)$ , we assume that $q^*$ is unique:
192
+
193
+ $$
194
+ \operatorname {C o v e r a g e} (q) < 1 - \alpha \text {f o r a l l} q < q ^ {*}, \tag {6}
195
+ $$
196
+
197
+ $$
198
+ \operatorname {C o v e r a g e} (q) > 1 - \alpha \text {f o r a l l} q > q ^ {*}.
199
+ $$
200
+
201
+ Theorem 3. Let $(X_{t},Y_{t})\stackrel {\mathrm{iid}}{\sim}P$ for some distribution $P$ . Suppose also that $s_t\equiv s$ for some fixed function $s:\mathcal{X}\times$ $\mathcal{V}\to [0,B]$ . Assume that $\eta_t$ is a fixed nonnegative step size sequence satisfying
202
+
203
+ $$
204
+ \sum_ {t = 1} ^ {\infty} \eta_ {t} = \infty , \quad \sum_ {t = 1} ^ {\infty} \eta_ {t} ^ {2} < \infty . \tag {7}
205
+ $$
206
+
207
+ Assume also that $q^{*}$ is unique as in (6).
208
+
209
+ Then online conformal prediction satisfies
210
+
211
+ $$
212
+ q _ {t} \rightarrow q ^ {*} \text {a l m o s t s u r e l y}.
213
+ $$
214
+
215
+ With an additional assumption, this immediately implies convergence of the coverage, $\mathrm{Coverage}(q_t)$ :
216
+
217
+ Corollary 1. Under the setting and assumptions of Theorem 3, assume also that $s(X,Y)$ has a continuous distribution (under $(X,Y) \sim P$ ). Then
218
+
219
+ $\operatorname{Coverage}(q_t) \to 1 - \alpha$ almost surely.
220
+
221
+ That is, instead of the high variance in coverage incurred by a constant step size (as in Proposition 1), here the coverage converges to the nominal level $1 - \alpha$ . Finally, with additional assumptions, we can also characterize the rate at which the threshold $q_{t}$ converges to $q^{*}$ :
222
+
223
+ Proposition 2. Under the setting and assumptions of Corollary 1, assume also that the distribution of $s(X,Y)$ (under $(X,Y)\sim P$ ) has density lower-bounded by $\gamma$ in the range $[q^{*} - \delta ,q^{*} + \delta ]$ , for some $\gamma ,\delta >0$ . Take the step size sequence $\eta_t = ct^{-1 / 2 - \epsilon}$ , for some $c > 0$ and $\epsilon \in (0,1 / 2)$ . Then it holds for all $t\geq 1$ that
224
+
225
+ $$
226
+ \mathbb {E} \left[ \left(q _ {t} - q ^ {*}\right) ^ {2} \right] \leq b t ^ {- 1 / 2 - \epsilon},
227
+ $$
228
+
229
+ where $b$ is a constant that depends only on $B, \gamma, \delta, c, \epsilon$ .
230
+
231
+ # 3.2. Results with online training of the score function
232
+
233
+ The result of Theorem 3 above is restricted to a very simple setting, where the score functions are given by $s_t \equiv s$ for some fixed $s$ , i.e., we are using a pretrained model. We now consider the more interesting setting where the model is trained online. Formally, we consider Setting 2 where we allow the score function $s_t$ to depend arbitrarily on the data observed before time $t$ , i.e., on $\{(X_r, Y_r)\}_{r < t}$ .
234
+
235
+ First, we will consider a constant step size $\eta_t \equiv \eta$ .
236
+
237
+ Proposition 3. Let $(X_{t},Y_{t})\stackrel {\mathrm{iid}}{\sim}P$ for some distribution $P$ , and assume the score functions $s_t:\mathcal{X}\times \mathcal{Y}\to [0,B]$ are trained online. Let $\eta_t\equiv \eta$ for a positive constant step size $\eta >0$ .
238
+
239
+ Then online conformal prediction satisfies
240
+
241
+ $$
242
+ \liminf_{t\to \infty}\mathsf{Coverage}_{t}(q_{t}) = 0,\quad \limsup_{t\to \infty}\mathsf{Coverage}_{t}(q_{t}) = 1
243
+ $$
244
+
245
+ almost surely.
246
+
247
+ This result is analogous to Proposition 1 for the case of a pretrained score function (but with a slightly weaker conclusion due to the more general setting). As before, the
248
+
249
+ conclusion we draw is that a constant step size inevitably leads to high variability in $\text{Coverage}_t(q_t)$ .
250
+
251
+ On the other hand, if we take a decaying step size, Theorem 3 established a convergence result given a pretrained score function. We will now see that similar results hold in for the online setting as long as the model converges in some sense. In many settings, we might expect $s_t$ to converge to some score function $s$ — for example, if our fitted regression functions, $\hat{f}_t$ , converge to some "true" model $f^*$ , then $s_t(x,y) = |y - \hat{f}_t(x)|$ converges to $s(x,y) = |y - f^*(x)|$ . As before, we let $\text{Coverage}(q) = \mathbb{P}_P(s(X,Y) \leq q)$ , and write $q^*$ to denote the $(1 - \alpha)$ -quantile of this distribution. We now extend the convergence results of Theorem 3 to this setting.
252
+
253
+ Theorem 4. Let $(X_{t},Y_{t})\stackrel {\mathrm{iid}}{\sim}P$ for some distribution $P$ , and assume the score functions $s_t$ are trained online. Assume that $\eta_t$ is a fixed nonnegative step size sequence satisfying (7). Let $s:\mathcal{X}\times \mathcal{V}\to [0,B]$ be a fixed score function, and assume that $q^{*}$ is unique as in (6).
254
+
255
+ Then online conformal prediction satisfies the following statement almost surely:
256
+
257
+ $$
258
+ \text {I f} s _ {t} \xrightarrow {\mathrm {d}} s, \text {t h e n} q _ {t} \rightarrow q ^ {*}.
259
+ $$
260
+
261
+ As in the previous section, an additional assumption implies convergence of the coverage, $\text{Coverage}_t(q_t)$ :
262
+
263
+ Corollary 2. Under the setting and assumptions of Theorem 4, assume also that $s(X,Y)$ has a continuous distribution (under $(X,Y) \sim P$ ). Then online conformal prediction satisfies the following statement almost surely:
264
+
265
+ $$
266
+ \text {I f} s _ {t} \xrightarrow {\mathrm {d}} s, \text {t h e n} \operatorname {C o v e r a g e} _ {t} (q _ {t}) \rightarrow 1 - \alpha .
267
+ $$
268
+
269
+ To summarize, the results of this section show that the coverage of each prediction set $\mathcal{C}_t(X_t)$ , given by $\mathrm{Coverage}_t(q_t)$ , will converge even in a setting where the model is being updated in a streaming fashion, as long as the fitted model itself converges over time.
270
+
271
+ In particular, if we choose $\eta_t \propto t^{-1/2 - \epsilon}$ for some $\epsilon \in (0, 1/2)$ , then in the adversarial setting the long-run coverage error is bounded as $\mathcal{O}\left(\frac{1}{T^{1/2 - \epsilon}}\right)$ by Theorem 1, while in the I.I.D. setting, Theorem 4 guarantees convergence. In other words, this choice of $\eta_t$ simultaneously achieves both types of guarantees.
272
+
273
+ While the results of this section have assumed I.I.D. data, the proof techniques used here can be extended to handle broader settings—for example, a stationary time series,
274
+
275
+ where despite dependence we may still expect to see convergence over time. We leave these extensions to future work.
276
+
277
+ # 4. Experiments
278
+
279
+ We include two experiments: an experiment on the Elec2 dataset (Harries et al., 1999) where the data shows significant distribution shift over time, and an experiment on ImageNet (Deng et al., 2009) where the data points are exchangeable.
280
+
281
+ The experiments are run with two different choices of step size for online conformal: first, a fixed step size $(\eta_t \equiv 0.05)$ ; and second, a decaying step size $(\eta_t = t^{-1/2 - \epsilon}$ with $\epsilon = 0.1$ ). We also compare to an oracle method, where online conformal is run with $q^*$ in place of $q_t$ at each time $t$ , and $q^*$ is chosen to be the value that gives $1 - \alpha$ average coverage over the entire sequence $t = 1, \ldots, T$ . All methods are run with $\alpha = 0.1$ .
282
+
283
+ # 4.1. Results
284
+
285
+ Figures 1 and 2 display the results of the experiment for the Elec2 data and the Imagenet data, respectively. We now discuss our findings.
286
+
287
+ The thresholds $q_{t}$ . The first panel of each figure plots the value of the threshold $q_{t}$ over time $t$ . We can see that the procedure with a fixed step size has significantly larger fluctuations in the quantile value as compared to the decaying step size procedure.
288
+
289
+ The instantaneous coverage $\mathrm{Coverage}_t(q_t)$ . The second panel of each figure plots the value of the instantaneous coverage $\mathrm{Coverage}_t(q_t)$ over time $t$ . For each dataset, since the true data distribution is unknown, we estimate $\mathrm{Coverage}_t(q_t)$ using a holdout set. We observe that $\mathrm{Coverage}_t(q_t)$ is substantially more stable for the decaying step size as compared to fixed step size in both experiments. While $\mathrm{Coverage}_t(q_t)$ concentrates closely around the nominal level $1 - \alpha$ for decaying $\eta_t$ , for fixed $\eta_t$ the coverage level oscillates and does not converge.
290
+
291
+ Long-run coverage and rolling coverage. The third panel of each figure plots the value of the long-run coverage, $\frac{1}{r}\sum_{r = 1}^{t}\mathbb{1}_{Y_r\in \mathcal{C}_r(X_r)}$ , over time $t$ . We see that the long-run coverage converges quickly to $1 - \alpha$ for all methods, and we cannot differentiate between them in this plot.
292
+
293
+ Consequently, in the fourth panel of each figure, we also plot the "rolling" coverage, which computes coverage rate
294
+
295
+ averaged over a rolling window of 1000 time points. We can see that this measure is tighter around $1 - \alpha$ for the fixed step size procedure; for the decaying step size procedure, rolling coverage fluctuates more, but is not larger than the fluctuations for the oracle method. At first glance, it might appear that having lower variance in the rolling coverage indicates that the fixed step size procedure is actually performing better than decaying step size—but this is not the case. The low variance with fixed $\eta_t \equiv \eta$ is due to overcorrecting. For example, if we have several miscoverage events in a row (which can happen by random chance, even with the oracle intervals), then the fixed-step-size method will necessarily return an overly wide interval (e.g., $\mathcal{C}_t(X_t) = \mathbb{R}$ ) to give certain coverage at the next time step. Thus, the fixed-step-size method ensures low variance in rolling coverage at the cost of extremely high variance in the width and instantaneous coverage of the interval $\mathcal{C}_t(X_t)$ at each time $t$ . This type of overcorrection is undesirable.
296
+
297
+ # 4.2. Implementation details for Elec2 Time Series
298
+
299
+ The Elec2 (Harries et al., 1999) dataset is a time-series of 45312 hourly measurements of electricity demand in New South Wales, Australia. We use even-numbered time points as the time series, and odd-numbered time points as a holdout set for estimating $\text{Coverage}_t(q_t)$ . The demand measurements are normalized to lie in the interval $Y_t \in [0,1]$ . The covariate vector $X_t = (Y_1, \ldots, Y_{t-1})$ is the sequence of all previous demand values. The forecast $\hat{Y}_t$ is one-day-delayed moving average of $Y_t$ (i.e., at time $t$ , our predicted value $\hat{Y}_t$ is given by the average of observations taken between 24 and 48 hours earlier), and the score is $s_t(X_t, Y_t) = |Y_t - \hat{Y}_t|$ .
300
+
301
+ # 4.3. Implementation details for Imagenet
302
+
303
+ The Imagenet (Deng et al., 2009) is a standard computer vision dataset of natural images. We take the 50000 validation images of Imagenet 2012 and treat them as a time series for the purpose of evaluating our methods. Because the validation split of Imagenet is shuffled, this comprises an exchangeable time series. We use 45000 points for the time series, and the remaining 5000 points as a holdout set for estimating Coverage $_t(q_t)$ . As the score function, we use $s_t(X_t,Y_t) = 1 - \max_{y\in \mathcal{Y}}\hat{f} (X_t)_y$ (here $\max_{y\in \mathcal{Y}}\hat{f} (X_t)_y$ is the softmax score of the pretrained ResNet-152 model).
304
+
305
+ # 4.4. Additional experiments
306
+
307
+ As discussed in Section 2.2, in applications where the distribution of the data may drift or may have changepoints, it might be beneficial to allow $\eta_t$ to increase at times to allow for updates in the learning process. To study this empirically, in the Appendix, we include additional experiments in a broader range of settings—we test over 3000
308
+
309
+ ![](images/78c3d511231f1bcb2d8a58646f4ad283d27f6973da83cd885e5d0439b891ad6a.jpg)
310
+ Figure 1. Elec2 results. From left to right, the panels display the following (over all times $t$ ): first, the value of the threshold $q_{t}$ ; second, the instantaneous coverage $Coverage_{t}(q_{t})$ ; third, the long-run coverage $\frac{1}{t}\sum_{r = 1}^{t}\mathbb{1}_{Y_{r}\in \mathcal{C}_{r}(X_{r})}$ ; and fourth, the rolling coverage, averaged over a rolling window of 1000 time points.
311
+
312
+ ![](images/e6de3bf6e56cffa56ab1e35c310b2586471003c547aa45e6554f24d9ceab0ae3.jpg)
313
+
314
+ ![](images/f202e32c0f2cd2f91073152643ca47c4d210c1f0b55b6fe1c046175dfd2aff8b.jpg)
315
+
316
+ ![](images/42fcec2583c1c175fc574f9d06d2ac047a210391e90cd97918a1aa21c4b4ad51.jpg)
317
+
318
+ ![](images/fc772143d5a6ec3c2a8eb9cf82f7bfe41a75af64e643074ff87e8431106e9ef0.jpg)
319
+ Figure 2. Imagenet results. Same details as for Figure 1.
320
+
321
+ ![](images/3557cba545b214c83bbeaf4b8e99570a119d5135c9aa53aa60abaa57c794ec94.jpg)
322
+
323
+ ![](images/154563987fa7c3a7884bee741c15fdc94a92d1d0e51107df9b15002e0c1b53e3.jpg)
324
+
325
+ ![](images/273528da68be13406f870594d19f9cf7f3bf478191ac4a5eb1b1fac0b4a4d2b3.jpg)
326
+
327
+ real datasets, and compare the fixed step size method, the decaying step size method, and a "decay+adapt" version of our method where the sequence $\eta_t$ adapts to trends in the data (decaying if the distribution of the data appears stationary, but increasing if distribution shift is detected).
328
+
329
+ # 5. Proofs
330
+
331
+ In this section, we prove Theorems 1, 2, 3, and 4, and Propositions 1 and 3. All other results are proved in the Appendix.
332
+
333
+ # 5.1. Proof of Theorems 1 and 2
334
+
335
+ First, we need a lemma to verify that the values $q_{t}$ are uniformly bounded over all $t$ . This result is essentially the same as that in Lemma 4.1 of Gibbs & Candes (2021), except extended to the setting of decaying, rather than constant, step size. The proof is given in the Appendix.
336
+
337
+ Lemma 1. Let $(X_{1},Y_{1}),(X_{2},Y_{2}),\ldots$ be an arbitrary sequence of data points, and let $s_t:\mathcal{X}\times \mathcal{Y}\to [0,B]$ be arbitrary functions. Let $\eta_t$ be an arbitrary nonnegative sequence, and fix an initial threshold $q_{1}\in [0,B]$ .
338
+
339
+ Then online conformal prediction satisfies
340
+
341
+ $$
342
+ - \alpha M _ {t - 1} \leq q _ {t} \leq B + (1 - \alpha) M _ {t - 1} \text {f o r a l l} t \geq 1, \tag {8}
343
+ $$
344
+
345
+ where $M_0 = 0$ , and $M_t = \max_{1 \leq r \leq t} \eta_r$ for each $t \geq 1$ .
346
+
347
+ We are now ready to prove the theorems. As discussed ear
348
+
349
+ lier, Theorem 1 is simply a special case, so we only prove the more general result Theorem 2.
350
+
351
+ By definition of $\Delta$ , we have $\eta_t^{-1} = \sum_{r=1}^t \Delta_r$ for all $t \geq 1$ . We then calculate
352
+
353
+ $$
354
+ \begin{array}{l} \left| \frac {1}{T} \sum_ {t = 1} ^ {T} \mathbb {1} _ {Y _ {t} \in \mathcal {C} _ {t} (X _ {t})} - (1 - \alpha) \right| = \left| \frac {1}{T} \sum_ {t = 1} ^ {T} \mathbb {1} _ {Y _ {t} \notin \mathcal {C} _ {t} (X _ {t})} - \alpha \right| \\ = \left| \frac {1}{T} \sum_ {t = 1} ^ {T} \left(\sum_ {r = 1} ^ {t} \Delta_ {r}\right) \cdot \eta_ {t} \left(\mathbb {1} _ {Y _ {t} \notin \mathcal {C} _ {t} \left(X _ {t}\right)} - \alpha\right) \right| \\ = \left| \frac {1}{T} \sum_ {r = 1} ^ {T} \Delta_ {r} \left(\sum_ {t = r} ^ {T} \eta_ {t} \left(\mathbb {1} _ {Y _ {t} \not \in \mathcal {C} _ {t} \left(X _ {t}\right)} - \alpha\right)\right) \right| \\ = \left| \frac {1}{T} \sum_ {r = 1} ^ {T} \Delta_ {r} \left(q _ {T + 1} - q _ {r}\right) \right| \text {b y} (4) \\ \leq \frac {1}{T} \sum_ {r = 1} ^ {T} \left| \Delta_ {r} \right| \cdot \max _ {1 \leq r \leq T} \left| q _ {T + 1} - q _ {r} \right| \\ \leq \frac {1}{T} \cdot \| \Delta_ {1: T} \| _ {1} \cdot \left(B + \max _ {1 \leq t \leq T} \eta_ {t}\right), \\ \end{array}
355
+ $$
356
+
357
+ where the last step holds since $q_{r}, q_{T + 1}$ are bounded by Lemma 1.
358
+
359
+ # 5.2. Proof of Proposition 3
360
+
361
+ First we prove that $\lim \sup_{t\to \infty}\mathsf{Coverage}_t(q_t) = 1$ almost surely. Equivalently, for any fixed $\epsilon >0$ , we need to prove
362
+
363
+ that $\mathbb{P}\left(\lim \sup_{t\to \infty}\mathsf{Coverage}_t(q_t) < 1 - \epsilon\right) = 0$
364
+
365
+ We begin by constructing a useful coupling between the online conformal process, and a sequence of I.I.D. uniform random variables. For each $t \geq 1$ , define
366
+
367
+ $$
368
+ U _ {t} \sim \left\{ \begin{array}{l l} \text {U n i f o r m [ 0 , C o v e r a g e} _ {t} (q _ {t}) ], & \text {i f Y _ {t} \in \mathcal {C} _ {t} (X _ {t})}, \\ \text {U n i f o r m [ C o v e r a g e} _ {t} (q _ {t}), 1 ], & \text {i f Y _ {t} \notin \mathcal {C} _ {t} (X _ {t})}, \end{array} \right.
369
+ $$
370
+
371
+ drawn independently for each $t$ after conditioning on all the data, $\{(X_{t},Y_{t})\}_{t\geq 1}$ . Since $\mathbb{P}(Y_t\in \mathcal{C}_t(X_t)\mid \{(X_r,Y_r)\}_{r < t}) = \mathsf{Coverage}_t(q_t)$ by construction, we can verify that $U_{t}\stackrel {\mathrm{iid}}{\sim}\mathsf{Uniform}[0,1]$ .
372
+
373
+ Next fix any integer $N \geq \frac{B + \eta\alpha}{\eta(1 - \alpha)}$ . Let $A_{i}$ be the event that
374
+
375
+ $$
376
+ U _ {t} > 1 - \epsilon \text {f o r a l l} (i - 1) N < t \leq i N.
377
+ $$
378
+
379
+ Since the $U_{t}$ 's are I.I.D. uniform random variables, we have $\mathbb{P}(A_i) = \epsilon^N$ for each $i$ , and the events $A_{i}$ are mutually independent. Therefore, by the second Borel-Cantelli lemma, $\mathbb{P}\left(\sum_{i\geq 1}\mathbb{1}_{A_i} = \infty\right) = 1$ . Now we claim that
380
+
381
+ If $A_{i}$ occurs then $\max_{(i - 1)N < t\leq iN + 1}\mathsf{Coverage}_t(q_t) > 1 - \epsilon .$ (9)
382
+
383
+ Suppose that $A_{i}$ holds and that $\mathsf{Coverage}_t(q_t)\leq 1 - \epsilon$ for all $t$ in the range $(i - 1)N < t\leq iN$ . Then by construction of the $U_{t}$ 's, we have $Y_{t}\notin \mathcal{C}_{t}(X_{t})$ for all $(i - 1)N < t\leq iN$ . Therefore by (4),
384
+
385
+ $$
386
+ \begin{array}{l} q _ {i N + 1} = q _ {(i - 1) N + 1} + \sum_ {t = (i - 1) N + 1} ^ {i N} \eta \left(\mathbb {1} _ {Y _ {t} \not \in \mathcal {C} _ {t} \left(X _ {t}\right)} - \alpha\right) \\ = q _ {(i - 1) N + 1} + N \cdot \eta (1 - \alpha) \geq B, \\ \end{array}
387
+ $$
388
+
389
+ where the last step holds by our choice of $N$ , together with the fact that $q_{(i - 1)N + 1} \geq -\alpha \eta$ by Lemma 1. But since the score function $s_{iN + 1}$ takes values in $[0, B]$ by assumption, we therefore have $\mathsf{Coverage}_{iN + 1}(q_{iN + 1}) \geq \mathsf{Coverage}_{iN + 1}(B) = 1$ . Therefore, we have verified the claim (9).
390
+
391
+ Since $A_{i}$ occurs for infinitely many $i$ , almost surely, by (9) we therefore have $\lim \sup_{t\to \infty}\mathsf{Coverage}_t(q_t)\geq 1 - \epsilon$ , almost surely, as desired. Since $\epsilon >0$ is arbitrary, this completes the proof that $\lim \sup_{t\to \infty}\mathsf{Coverage}_t(q_t) = 1$ almost surely.
392
+
393
+ Finally, a similar argument verifies $\lim \inf_{t\to \infty}\mathrm{Coverage}(q_t) = 0$ almost surely.
394
+
395
+ # 5.3. Proof of Proposition 1
396
+
397
+ Since $s_t \equiv s$ , we have $\text{Coverage}_t(q_t) = \text{Coverage}(q_t)$ , for each $t$ . By Proposition 3, $\lim \inf_{t \to \infty} \text{Coverage}(q_t) = 0$ and $\lim \sup_{t \to \infty} \text{Coverage}(q_t) = 1$ , almost surely. Since
398
+
399
+ we have assumed that $\alpha$ is a rational number, by the definition of the procedure (4), all values $q_{t}$ must lie on a discrete grid (i.e., if $\alpha = k / K$ for some integers $k, K$ then, for all $t$ , $q_{t} - q_{1}$ must be an integer multiple of $\eta / K$ ). Moreover, by Lemma 1, $q_{t}$ is uniformly bounded above and below for all $t$ , so $q_{t}$ can only take finitely many values. This implies $\operatorname{Coverage}(q_t)$ also can take only finitely many values, and in particular, this means that if $\lim \inf_{t\to \infty}\operatorname{Coverage}(q_t) = 0$ (respectively, if $\lim \sup_{t\to \infty}\operatorname{Coverage}(q_t) = 1$ ) then $\operatorname{Coverage}(q_t) = 0$ (respectively, $\operatorname{Coverage}(q_t) = 1$ ) for infinitely many $t$ .
400
+
401
+ # 5.4. Proofs of Theorems 3 and 4
402
+
403
+ We observe that Theorem 3 is simply a special case of Theorem 4 (obtained by taking $s_t \equiv s$ for all $t$ ), so we only need to prove Theorem 4.
404
+
405
+ First, consider the sequence
406
+
407
+ $$
408
+ Z _ {t} = \sum_ {r = 1} ^ {t} \eta_ {r} \left(\mathbb {1} _ {Y _ {r} \in \mathcal {C} _ {r} \left(X _ {r}\right)} - \operatorname {C o v e r a g e} _ {r} \left(q _ {r}\right)\right).
409
+ $$
410
+
411
+ Define events $\mathcal{E}_Z$ , the event that $\lim_{t\to \infty}Z_t$ exists, and $\mathcal{E}_s$ , the event that $s_t\stackrel {\mathrm{d}}{\to}s$ . In the Appendix, we will verify that
412
+
413
+ $$
414
+ \lim _ {t \rightarrow \infty} Z _ {t} \text {e x i s t s , a l m o s t s u r e l y ,} \tag {10}
415
+ $$
416
+
417
+ i.e., $\mathbb{P}(\mathcal{E}_Z) = 1$ , using martingale theory.
418
+
419
+ To establish the theorem, then, it suffices for us to verify that on the event $\mathcal{E}_Z\cap \mathcal{E}_s$ , it holds that $q_{t}\to q^{*}$ . From this point on, we assume that $\mathcal{E}_Z$ and $\mathcal{E}_s$ both hold.
420
+
421
+ Fix any $\epsilon > 0$ . Since $q \mapsto \operatorname{Coverage}(q)$ is monotone, it can have at most countably infinitely many discontinuities. Without loss of generality, then, we can assume that this map is continuous at $q = q^{*} - \epsilon / 3$ and at $q = q^{*} + \epsilon / 3$ (by taking a smaller value of $\epsilon$ if needed).
422
+
423
+ First, since $Z_{t}$ converges, we can find some finite time $T_{1}$ such that
424
+
425
+ $$
426
+ \begin{array}{l} \sup _ {t ^ {\prime} \geq t \geq T _ {1}} \left| \sum_ {r = t} ^ {t ^ {\prime}} \eta_ {r} \left(\mathbb {1} _ {Y _ {r} \in \mathcal {C} _ {r} \left(X _ {r}\right)} - \text {C o v e r a g e} _ {r} \left(q _ {r}\right)\right) \right| \\ = \sup _ {t ^ {\prime} \geq t \geq T _ {1}} \left| Z _ {t ^ {\prime}} - Z _ {t - 1} \right| \leq \frac {\epsilon}{3}. \tag {11} \\ \end{array}
427
+ $$
428
+
429
+ Moreover, since $\sum_{t}\eta_{t}^{2} < \infty$ , we have $\eta_t\to 0$ and so we can find some finite time $T_{2}$ such that $\eta_t\leq \frac{\epsilon}{3}$ for all $t\geq T_2$ . Furthermore, on $\mathcal{E}_s$ , we have $\mathrm{Coverage}_t(q)\to$ Coverage(q), at each $q = q^{*}\pm \epsilon /3$ . Thus we can find some finite time $T_{3}$ and some $\delta >0$ such that
430
+
431
+ $$
432
+ \text {C o v e r a g e} _ {t} \left(q ^ {*} - \epsilon / 3\right) \leq 1 - \alpha - \delta \tag {12}
433
+ $$
434
+
435
+ for all $t \geq T_3$ (we are using the fact that $\mathrm{Coverage}(q^* - \epsilon / 3) < 1 - \alpha$ by (6)). Similarly we can find a finite $T_4$ and some $\delta' > 0$ such that $\mathrm{Coverage}_t(q^* + \epsilon / 3) \geq 1 - \alpha + \delta'$ for all $t \geq T_4$ . Let $T = \max \{T_1, T_2, T_3, T_4\}$ .
436
+
437
+ We will now split into cases. If it does not hold that $q_{t} \in q^{*} \pm \epsilon$ for all sufficiently large $t$ , then one of the following cases must hold:
438
+
439
+ - Case 1a: $q_{t} < q^{*} - \epsilon /3$ for all $t\geq T$ .
440
+ - Case 1b: $q_{t} > q^{*} + \epsilon /3$ for all $t\geq T$ .
441
+ - Case 2a: for some $t' \geq t \geq T$ , it holds that $q_t \geq q^* - \epsilon/3$ and $q_{t'} < q^* - \epsilon$ .
442
+ - Case 2b: for some $t' \geq t \geq T$ , it holds that $q_t \leq q^* + \epsilon/3$ and $q_{t'} > q^* + \epsilon$ .
443
+
444
+ We now verify that each case is impossible.
445
+
446
+ Case 1a is impossible. We have
447
+
448
+ $$
449
+ \begin{array}{l} q ^ {*} - \frac {\epsilon}{3} - q _ {T} \geq \sup _ {t > T} q _ {t} - q _ {T} \\ = \sup _ {t > T} \sum_ {r = T} ^ {t - 1} \eta_ {r} \left(\mathbb {1} _ {Y _ {r} \notin \mathcal {C} _ {r} \left(X _ {r}\right)} - \alpha\right) \text {b y} (4) \\ \geq \sup _ {t > T} \sum_ {r = T} ^ {t - 1} \eta_ {r} ((1 - \alpha) - \operatorname {C o v e r a g e} _ {r} (q _ {r})) - \frac {\epsilon}{3} \text {b y} (1 1) \\ \geq \sup _ {t > T} \left\{\left[ \sum_ {r = T} ^ {t - 1} \eta_ {r} \cdot \delta \right] - \frac {\epsilon}{3} \right\}, \\ \end{array}
450
+ $$
451
+
452
+ where the last step holds since $q_r < q^* - \epsilon / 3$ for $r \geq T$ , and $q \mapsto \mathsf{Coverage}_r(q)$ is nondecreasing, and so we have
453
+
454
+ $$
455
+ \operatorname {C o v e r a g e} _ {r} \left(q _ {r}\right) \leq \operatorname {C o v e r a g e} _ {r} \left(q ^ {*} - \epsilon / 3\right) \leq 1 - \alpha - \delta , \tag {13}
456
+ $$
457
+
458
+ by (12). Since $\sum_{r}\eta_{r} = \infty$ , we therefore have that $q^{*} - \frac{\epsilon}{3} - q_{T} \geq \infty$ , which is a contradiction.
459
+
460
+ Case 1b is impossible. This proof is analogous to the proof for Case 1a.
461
+
462
+ Case 2a is impossible. First, by assumption for this case, we can find a unique time $t'' \geq T$ such that
463
+
464
+ $$
465
+ \left\{ \begin{array}{l} q _ {t ^ {\prime \prime}} \geq q ^ {*} - \epsilon / 3, \\ q _ {r} < q ^ {*} - \epsilon / 3 \text {f o r a l l} t ^ {\prime \prime} < r < t ^ {\prime}, \\ q _ {t ^ {\prime}} < q ^ {*} - \epsilon . \end{array} \right.
466
+ $$
467
+
468
+ In other words, $t''$ is the last time before time $t'$ when the threshold is $\geq q^* - \epsilon / 3$ . Then we have
469
+
470
+ $$
471
+ - \frac {2 \epsilon}{3} > q _ {t ^ {\prime}} - q _ {t ^ {\prime \prime}} = \sum_ {r = t ^ {\prime \prime}} ^ {t ^ {\prime} - 1} \eta_ {r} \left(\mathbb {1} _ {Y _ {r} \notin \mathcal {C} _ {r} \left(X _ {r}\right)} - \alpha\right) \text {b y (4)}
472
+ $$
473
+
474
+ $$
475
+ \begin{array}{l} \geq \left[ \sum_ {r = t ^ {\prime \prime}} ^ {t ^ {\prime} - 1} \eta_ {r} \left((1 - \alpha) - \operatorname {C o v e r a g e} _ {r} \left(q _ {r}\right)\right) \right] - \frac {\epsilon}{3} \text {b y (1 1)} \\ \geq - \eta_ {t ^ {\prime \prime}} + \left[ \sum_ {r = t ^ {\prime \prime} + 1} ^ {t ^ {\prime} - 1} \eta_ {r} \left((1 - \alpha) - \operatorname {C o v e r a g e} _ {r} (q _ {r})\right) \right] - \frac {\epsilon}{3} \\ \geq - \eta_ {t ^ {\prime \prime}} - \frac {\epsilon}{3} \text {b y (1 3)}. \\ \end{array}
476
+ $$
477
+
478
+ But since $\eta_{t^{\prime \prime}}\leq \epsilon /3$ (because $t''\geq T$ ), we have therefore reached a contradiction.
479
+
480
+ Case 2b is impossible. This proof is analogous to the proof for Case 2a.
481
+
482
+ We have verified that all four cases are impossible. Therefore, $q_{t} \in q^{*} \pm \epsilon$ for all sufficiently large $t$ . Since $\epsilon > 0$ is arbitrarily small, this completes the proof.
483
+
484
+ # 6. Discussion
485
+
486
+ Our paper analyzes online conformal prediction that with a decaying step size, enabling simultaneous guarantees of convergence for I.I.D. sequences and long-run coverage for adversarial ones. Moreover, it helps further unify online conformal prediction with online learning and online convex optimization, since decaying step sizes are known to have desirable properties and hence standard for the latter. Of course, the usefulness of the method will rely on choosing score functions that are well suited to the (possibly time-varying) data distribution, and choosing step sizes that decay at an appropriate rate and perhaps adapt to the level of distribution shift—building a better understanding of how to make these choices in practice is crucial for achieving informative and stable prediction intervals. Many additional open questions about extending the methodology to broader settings and understanding connections to other tools remain. In particular, we expect fruitful avenues of future inquiry would be: (1) to extend this analysis to online risk control, as in Feldman et al. (2021); (2) to adapt our analysis of Theorem 3 to deal with stationary or slowly moving time-series which may not be I.I.D. but are slowly varying enough to permit estimation; and (3) to further understand the connection between this family of techniques and the theory of online learning.
487
+
488
+ # Acknowledgements
489
+
490
+ The authors thank Isaac Gibbs, Ryan Tibshirani, and Margaux Zaffran for helpful feedback on this work. R.F.B. was partially supported by the National Science Foundation via grant DMS-2023109, and by the Office of Naval Research via grant N00014-20-1-2337.
491
+
492
+ # Impact Statement
493
+
494
+ This paper presents work whose goal is to advance the field of conformal prediction and, more broadly, reliable machine learning. These tools may be used for machine learning methods across a broad range of domains (including applications with societal consequences), but do not relate directly to any specific issues of impact and ethics, and therefore we do not highlight any particular examples here.
495
+
496
+ # References
497
+
498
+ Angelopoulos, A. N. and Bates, S. Conformal prediction: A gentle introduction. Foundations and Trends® in Machine Learning, 16(4):494-591, 2023.
499
+ Angelopoulos, A. N., Candes, E., and Tibshirani, R. Conformal PID control for time series prediction. In Neural Information Processing Systems, 2023.
500
+ Barber, R. F., Candes, E. J., Ramdas, A., and Tibshirani, R. J. Conformal prediction beyond exchangeability. arXiv:2202.13415, 2022.
501
+ Bastani, O., Gupta, V., Jung, C., Noarov, G., Ramalingam, R., and Roth, A. Practical adversarial multivalid conformal prediction. Advances in Neural Information Processing Systems, 35:29362-29373, 2022.
502
+ Bhatnagar, A., Wang, H., Xiong, C., and Bai, Y. Improved online conformal prediction via strongly adaptive online learning. arXiv preprint arXiv:2302.07869, 2023.
503
+ Biau, G. and Patra, B. Sequential quantile prediction of time series. IEEE Transactions on Information Theory, 57(3):1664-1674, 2011.
504
+ Bubeck, S. and Slivkins, A. The best of both worlds: Stochastic and adversarial bandits. In Conference on Learning Theory, pp. 42-1. JMLR Workshop and Conference Proceedings, 2012.
505
+ Cesa-Bianchi, N. and Lugosi, G. Prediction, learning, and games. Cambridge university press, 2006.
506
+ Chen, S., Tu, W.-W., Zhao, P., and Zhang, L. Optimistic online mirror descent for bridging stochastic and adversarial online convex optimization. In International Conference on Machine Learning, pp. 5002-5035. PMLR, 2023.
507
+ Chernozhukov, V., Wüthrich, K., and Yinchu, Z. Exact and robust conformal inference methods for predictive machine learning with dependent data. In Conference On Learning Theory, pp. 732-749. PMLR, 2018.
508
+ Cramer, E. Y., Ray, E. L., Lopez, V. K., Bracher, J., Brennen, A., Castro Rivadeneira, A. J., Gerding, A., Gneiting, T., House, K. H., Huang, Y., et al. Evaluation of
509
+
510
+ individual and ensemble probabilistic forecasts of COVID-19 mortality in the united states. Proceedings of the National Academy of Sciences, 119(15):e2113561119, 2022.
511
+ Daniely, A., Gonen, A., and Shalev-Shwartz, S. Strongly adaptive online learning. In International Conference on Machine Learning, pp. 1405-1411. PMLR, 2015.
512
+ Dann, C., Wei, C.-Y., and Zimmert, J. Best of both world's policy optimization. In International Conference on Machine Learning, pp. 6968-7008. PMLR, 2023.
513
+ Deng, J., Dong, W., Socher, R., Li, L.-J., Li, K., and Fei-Fei, L. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248-255, 2009.
514
+ Feldman, S., Bates, S., and Romano, Y. Improving conditional coverage via orthogonal quantile regression. In Advances in Neural Information Processing Systems, 2021.
515
+ Feldman, S., Ringel, L., Bates, S., and Romano, Y. Achieving risk control in online learning settings. Transactions on Machine Learning Research, 2023.
516
+ Foreman-Mackey, D., Agol, E., Ambikasaran, S., and Angus, R. Fast and scalable Gaussian process modeling with applications to astronomical time series. The Astronomical Journal, 154(6):220, 2017.
517
+ Foster, D. P. and Vohra, R. V. Asymptotic calibration. Biometrika, 85(2):379-390, 1998.
518
+ Gibbs, I. and Candes, E. Adaptive conformal inference under distribution shift. In Ranzato, M., Beygelzimer, A., Dauphin, Y., Liang, P., and Vaughan, J. W. (eds.), Advances in Neural Information Processing Systems, volume 34, pp. 1660-1672. Curran Associates, Inc., 2021.
519
+ Gibbs, I. and Candès, E. Conformal inference for online prediction with arbitrary distribution shifts. arXiv preprint arXiv:2208.08401, 2022.
520
+ Gradu, P., Hazan, E., and Minasyan, E. Adaptive regret for control of time-varying dynamics. In Learning for Dynamics and Control Conference, pp. 560-572. PMLR, 2023.
521
+ Harries, M., Wales, N. S., et al. Splice-2 comparative evaluation: Electricity pricing. 1999.
522
+ Jin, T., Huang, L., and Luo, H. The best of both worlds: stochastic and adversarial episodic MDPs with unknown transition. Advances in Neural Information Processing Systems, 34:20491-20502, 2021.
523
+
524
+ Koenker, R. and Bassett Jr, G. Regression quantiles. Econometrica: Journal of the Econometric Society, 46 (1):33-50, 1978.
525
+ Koolen, W. M., Grünwald, P., and Van Erven, T. Combining adversarial guarantees and stochastic fast rates in online learning. Advances in Neural Information Processing Systems, 29, 2016.
526
+ Lin, Z., Trivedi, S., and Sun, J. Conformal prediction with temporal quantile adjustments. Advances in Neural Information Processing Systems, 35:31017-31030, 2022.
527
+ Lindemann, L., Cleaveland, M., Shim, G., and Pappas, G. J. Safe planning in dynamic environments using conformal prediction. IEEE Robotics and Automation Letters, 2023.
528
+ Mykland, P. A. Financial options and statistical prediction intervals. The Annals of Statistics, 31(5):1413-1438, 2003.
529
+ Noarov, G., Ramalingam, R., Roth, A., and Xie, S. High-dimensional unbiased prediction for sequential decision making. In OPT 2023: Optimization for Machine Learning, 2023.
530
+ Robinson, J. Sequential choice of an optimal dose: A prediction intervals approach. Biometrika, 65(1):75-78, 1978.
531
+ Tian, Q., Nordman, D. J., and Meeker, W. Q. Methods to compute prediction intervals: A review and new results. Statistical Science, 37(4):580-597, 2022.
532
+ Vovk, V. On-line confidence machines are well-calibrated. In The 43rd Annual IEEE Symposium on Foundations of Computer Science, pp. 187-196. IEEE, 2002.
533
+ Vovk, V., Gammerman, A., and Shafer, G. Algorithmic Learning in a Random World. Springer, 2005. doi: 10. 1007/b106715.
534
+ Xu, C. and Xie, Y. Conformal prediction interval for dynamic time-series. In International Conference on Machine Learning, pp. 11559-11569. PMLR, 2021.
535
+ Xu, C. and Xie, Y. Sequential predictive conformal inference for time series. In International Conference on Machine Learning, pp. 38707-38727. PMLR, 2023.
536
+ Zaffran, M., Feron, O., Goude, Y., Josse, J., and Dieuleveut, A. Adaptive conformal predictions for time series. In International Conference on Machine Learning, pp. 25834-25866. PMLR, 2022.
537
+ Zimmert, J. and Seldin, Y. Tsallis-inf: An optimal algorithm for stochastic and adversarial bandits. Journal of Machine Learning Research, 22(28):1-49, 2021.
538
+
539
+ Zinkevich, M. Online convex programming and generalized infinitesimal gradient ascent. In Proceedings of the 20th international conference on machine learning (icml-03), pp. 928-936, 2003.
540
+
541
+ # A. Additional proofs
542
+
543
+ # A.1. Proof of Lemma 1
544
+
545
+ The proof of this result is similar to the proof of Lemma 4.1 of Gibbs & Candes (2021). We prove this by induction. First, $q_{1} \in [0, B]$ by assumption, so (8) is satisfied at time $t = 1$ . Next fix any $t \geq 1$ and assume $q_{t}$ lies in the range specified in (8), and consider $q_{t+1}$ . We now split into cases:
546
+
547
+ - If $q_{t} \in [0, B]$ , then we have
548
+
549
+ $$
550
+ q _ {t + 1} = q _ {t} + \eta_ {t} \left(\mathbb {1} _ {Y _ {t} \not \in \mathcal {C} _ {t} (X _ {t})} - \alpha\right) \in [ q _ {t} - \eta_ {t} \alpha , q _ {t} + \eta_ {t} (1 - \alpha) ] \subseteq [ - \alpha M _ {t}, B + (1 - \alpha) M _ {t} ].
551
+ $$
552
+
553
+ - If $q_{t} \in (B, B + (1 - \alpha)M_{t - 1}]$ , then we must have $\mathcal{C}_t(X_t) = \mathcal{V}$ . Then $\mathbb{1}_{Y_t \notin \mathcal{C}_t(X_t)} = 0$ , and so
554
+
555
+ $$
556
+ q _ {t + 1} = q _ {t} - \eta_ {t} \alpha \in [ B - \eta_ {t} \alpha , B + (1 - \alpha) M _ {t - 1} ] \subseteq [ - \alpha M _ {t}, B + (1 - \alpha) M _ {t} ].
557
+ $$
558
+
559
+ - If $q_{t} \in [-\alpha M_{t - 1}, 0)$ , then we must have $\mathcal{C}_t(X_t) = \emptyset$ . Then $\mathbb{1}_{Y_t \notin \mathcal{C}_t(X_t)} = 1$ , and so
560
+
561
+ $$
562
+ q _ {t + 1} = q _ {t} + \eta_ {t} (1 - \alpha) \in [ - \alpha M _ {t - 1}, \eta_ {t} (1 - \alpha) ] \subseteq [ - \alpha M _ {t}, B + (1 - \alpha) M _ {t} ].
563
+ $$
564
+
565
+ In all cases, then, (8) holds for $t + 1$ in place of $t$ , which completes the proof.
566
+
567
+ # A.2. Proof of 10
568
+
569
+ We need to prove that $Z_{t}$ converges almost surely (note that the limit of $Z_{t}$ may be a random variable). For each $t \geq 1$ , we have
570
+
571
+ $$
572
+ \mathbb {P} \left(Y _ {t} \in \mathcal {C} _ {t} \left(X _ {t}\right) \mid \left\{\left(X _ {r}, Y _ {r}\right) \right\} _ {r < t}\right) = \mathbb {P} \left(s _ {t} \left(X _ {t}, Y _ {t}\right) \leq q _ {t} \mid \left\{\left(X _ {r}, Y _ {r}\right) \right\} _ {r < t}\right) = \text {C o v e r a g e} _ {t} (q _ {t}),
573
+ $$
574
+
575
+ since $q_{t}$ and $s_{t}$ are functions of $\{(X_{r},Y_{r})\}_{r < t}$ and are therefore independent of $(X_{t},Y_{t}) \sim P$ . This proves that $Z_{t}$ is a martingale with respect to the filtration generated by the sequence of data points. We also have $\sup_{t \geq 1} \mathrm{Var}(Z_{t}) < \infty$ , since we have assumed $\sum_{t=1}^{\infty} \eta_{t}^{2} < \infty$ . This means that $Z_{t}$ is a uniformly integrable martingale, and therefore, $Z_{t}$ converges almost surely (to some random variable), by Doob's second martingale convergence theorem.
576
+
577
+ # A.3. Proofs of Corollaries 1 and 2
578
+
579
+ As for the theorems, it suffices to prove Corollary 2, since Corollary 1 is simply a special case.
580
+
581
+ Using the notation defined in the proof of Theorem 4, suppose that events $\mathcal{E}_Z$ and $\mathcal{E}_s$ both hold. Now we need to show that $\mathrm{Coverage}_t(q_t) \to 1 - \alpha$ holds as well. Fix any $\epsilon > 0$ . Since $s(X,Y)$ has a continuous distribution, the map $q \mapsto \mathrm{Coverage}(q)$ is continuous, and so we can find some $\delta > 0$ such that
582
+
583
+ $$
584
+ \left| \operatorname {C o v e r a g e} (q) - \operatorname {C o v e r a g e} \left(q ^ {*}\right) \right| \leq \epsilon / 2 \text {f o r a l l} q \in q ^ {*} \pm \delta .
585
+ $$
586
+
587
+ Moreover, $\text{Coverage}(q^{*}) = 1 - \alpha$ , since the distribution of $s(X,Y)$ is continuous and $q^{*}$ is its $(1 - \alpha)$ -quantile, so we have
588
+
589
+ $$
590
+ \left| \operatorname {C o v e r a g e} (q) - (1 - \alpha) \right| \leq \epsilon / 2 \text {f o r a l l} q \in q ^ {*} \pm \delta .
591
+ $$
592
+
593
+ Next, by Theorem 4, for all sufficiently large $t$ , we have
594
+
595
+ $$
596
+ \left| q _ {t} - q ^ {*} \right| \leq \delta .
597
+ $$
598
+
599
+ By definition of the event $\mathcal{E}_s$ , for all sufficiently large $t$ we have
600
+
601
+ $$
602
+ \left| \operatorname {C o v e r a g e} _ {t} \left(q ^ {*} - \delta\right) - \operatorname {C o v e r a g e} \left(q ^ {*} - \delta\right) \right| \leq \epsilon / 2
603
+ $$
604
+
605
+ and
606
+
607
+ $$
608
+ \left| \operatorname {C o v e r a g e} _ {t} \left(q ^ {*} + \delta\right) - \operatorname {C o v e r a g e} \left(q ^ {*} + \delta\right) \right| \leq \epsilon / 2.
609
+ $$
610
+
611
+ Then, combining all of these calculations, for all sufficiently large $t$ we have
612
+
613
+ $$
614
+ \operatorname {C o v e r a g e} _ {t} \left(q _ {t}\right) \geq \operatorname {C o v e r a g e} _ {t} \left(q ^ {*} - \delta\right) \geq \operatorname {C o v e r a g e} \left(q ^ {*} - \delta\right) - \epsilon / 2 \geq \left(1 - \alpha - \epsilon / 2\right) - \epsilon / 2 = 1 - \alpha - \epsilon ,
615
+ $$
616
+
617
+ where the first step holds since $q_{t} \geq q^{*} - \delta$ , and $q \mapsto \mathrm{Coverage}_t(q)$ is nondecreasing. Similarly, for all sufficiently large $t$ it holds that
618
+
619
+ $$
620
+ \operatorname {C o v e r a g e} _ {t} \left(q _ {t}\right) \leq 1 - \alpha + \epsilon .
621
+ $$
622
+
623
+ Since $\epsilon > 0$ is arbitrary, this completes the proof.
624
+
625
+ # A.4. Proof of Proposition 2
626
+
627
+ By Lemma 1, $q_{t} \in [-\alpha c, B + (1 - \alpha)c]$ for all $t$ (since $\eta_t \leq c$ for all $t$ ). Since $q^{*} \in [0, B]$ , we therefore have $|q_{t} - q^{*}| \leq B + c$ almost surely for all $t$ . We also have $2\gamma \delta \leq 1$ and $\delta \leq B \leq B + c$ , since the density of $s(X, Y)$ is supported on $[0, B]$ and must integrate to 1.
628
+
629
+ Next, by the assumptions of the proposition, for any $q_{t} \geq q^{*}$ , if $q_{t} \leq q^{*} + \delta$ then
630
+
631
+ $$
632
+ \operatorname {C o v e r a g e} \left(q _ {t}\right) \geq 1 - \alpha + \gamma \left(q _ {t} - q ^ {*}\right)
633
+ $$
634
+
635
+ while if $q_{t} > q^{*} + \delta$ then
636
+
637
+ $$
638
+ \operatorname {C o v e r a g e} \left(q _ {t}\right) \geq \operatorname {C o v e r a g e} \left(q ^ {*} + \delta\right) \geq 1 - \alpha + \gamma \delta .
639
+ $$
640
+
641
+ Either way, then, if $q_{t} \geq q^{*}$ then
642
+
643
+ $$
644
+ \mathsf {C o v e r a g e} (q _ {t}) \geq (1 - \alpha) + (q _ {t} - q ^ {*}) \cdot \frac {\gamma \delta}{B + c}.
645
+ $$
646
+
647
+ A similar calculations show that if $q_{t} \leq q^{*}$ , then
648
+
649
+ $$
650
+ \operatorname {C o v e r a g e} \left(q _ {t}\right) \leq (1 - \alpha) - \left(q ^ {*} - q _ {t}\right) \cdot \frac {\gamma \delta}{B + c}.
651
+ $$
652
+
653
+ Defining $a = \frac{\gamma\delta}{B + c} >0$ , we therefore have
654
+
655
+ $$
656
+ \frac {\operatorname {C o v e r a g e} \left(q _ {t}\right) - (1 - \alpha)}{q _ {t} - q ^ {*}} \geq a \tag {14}
657
+ $$
658
+
659
+ whenever $q_{t} \neq q^{*}$ . Note that we must have $a \leq 1 / c$ , by construction.
660
+
661
+ Next, from the update step (4), we have
662
+
663
+ $$
664
+ q _ {t + 1} - q ^ {*} = \left(q _ {t} - q ^ {*}\right) + \eta_ {t} \left(\left(1 - \alpha\right) - \mathbb {1} _ {Y _ {t} \in \mathcal {C} _ {t} \left(X _ {t}\right)}\right).
665
+ $$
666
+
667
+ Since $\mathbb{P}(Y_t\in \mathcal{C}_t(X_t)\mid \{(X_r,Y_r)\}_{r < t}) = \mathrm{Coverage}(q_t)$ , we then calculate
668
+
669
+ $$
670
+ \mathbb {E} \left[ q _ {t + 1} - q ^ {*} \mid \left\{\left(X _ {r}, Y _ {r}\right) \right\} _ {r < t} \right] = \left(q _ {t} - q ^ {*}\right) + \eta_ {t} \left(\left(1 - \alpha\right) - \operatorname {C o v e r a g e} \left(q _ {t}\right)\right),
671
+ $$
672
+
673
+ and
674
+
675
+ $$
676
+ \operatorname {V a r} \left(q _ {t + 1} - q ^ {*} \mid \left\{\left(X _ {r}, Y _ {r}\right) \right\} _ {r < t}\right) = \eta_ {t} ^ {2} \cdot \text {C o v e r a g e} (q _ {t}) \cdot \left(1 - \text {C o v e r a g e} (q _ {t})\right) \leq \eta_ {t} ^ {2} / 4.
677
+ $$
678
+
679
+ Therefore,
680
+
681
+ $$
682
+ \begin{array}{l} \mathbb {E} \left[ (q _ {t + 1} - q ^ {*}) ^ {2} \mid \{(X _ {r}, Y _ {r}) \} _ {r < t} \right] \leq \left((q _ {t} - q ^ {*}) + \eta_ {t} ((1 - \alpha) - \text {C o v e r a g e} (q _ {t}))\right) ^ {2} + \eta_ {t} ^ {2} / 4 \\ \leq \left(q _ {t} - q ^ {*}\right) ^ {2} \cdot \left(1 - a \eta_ {t}\right) ^ {2} + \eta_ {t} ^ {2} / 4, \\ \end{array}
683
+ $$
684
+
685
+ where the last step holds by (14) above. After marginalizing, then,
686
+
687
+ $$
688
+ \mathbb {E} \left[ (q _ {t + 1} - q ^ {*}) ^ {2} \right] \leq \mathbb {E} \left[ (q _ {t} - q ^ {*}) ^ {2} \right] \cdot (1 - a \eta_ {t}) ^ {2} + \eta_ {t} ^ {2} / 4.
689
+ $$
690
+
691
+ Next recall $\eta_t = ct^{-1/2 - \epsilon}$ for each $t$ . Fix some $T \geq 1$ that satisfies $T^{1/2 - \epsilon} \geq \frac{1/2 + \epsilon}{ac}$ . First, since $|q_t - q^*| \leq B + c$ for all $t$ as above, by choosing $b \geq (B + c)^2 T^{1/2 + \epsilon}$ we must have $(q_t - q^*)^2 \leq bt^{-1/2 - \epsilon}$ for all $t \leq T$ , almost surely. Next, for each $t \geq T$ , we proceed by induction. Assume $\mathbb{E}\left[(q_t - q^*)^2\right] \leq bt^{-1/2 - \epsilon}$ . Then
692
+
693
+ $$
694
+ \begin{array}{l} \mathbb {E} \left[ (q _ {t + 1} - q ^ {*}) ^ {2} \right] \leq \mathbb {E} \left[ (q _ {t} - q ^ {*}) ^ {2} \right] \cdot (1 - a \eta_ {t}) ^ {2} + \eta_ {t} ^ {2} / 4 \\ = \mathbb {E} \left[ (q _ {t} - q ^ {*}) ^ {2} \right] (1 - 2 a \eta_ {t}) + \left(\mathbb {E} \left[ (q _ {t} - q ^ {*}) ^ {2} \right] \cdot a ^ {2} + 1 / 4\right) \eta_ {t} ^ {2} \\ \leq b t ^ {- 1 / 2 - \epsilon} \left(1 - 2 a c t ^ {- 1 / 2 - \epsilon}\right) + ((B + c) ^ {2} a ^ {2} + 1 / 4) c ^ {2} t ^ {- 1 - 2 \epsilon} \\ = b t ^ {- 1 / 2 - \epsilon} - 2 a b c t ^ {- 1 - 2 \epsilon} + ((B + c) ^ {2} a ^ {2} + 1 / 4) c ^ {2} t ^ {- 1 - 2 \epsilon} \\ \leq b \left(t ^ {- 1 / 2 - \epsilon} - a c t ^ {- 1 - 2 \epsilon}\right), \\ \end{array}
695
+ $$
696
+
697
+ ![](images/773b68c374b4de9ce08a2de60a6da1b93c742f0f162f0a83d66f207550b6d8b1.jpg)
698
+ Figure 3. Density plots of results on M4 datasets. These plots show the same quantities as in Table 1, but now as histograms over the time-series in M4.
699
+
700
+ ![](images/af3672cef5d9d8968fed76aacad3701b9a80e5e1c51685de0c9378883a69ea2a.jpg)
701
+
702
+ ![](images/20c598174efd505604d113d8b99eb9a24c4a21208c727005016b5a8bf99955dc.jpg)
703
+
704
+ <table><tr><td>method</td><td>coverage</td><td>variance</td><td>MSE</td><td>infinite sets</td></tr><tr><td>DTACI</td><td>0.895491</td><td>4.107740</td><td>5.439935</td><td>0.036584</td></tr><tr><td>decay+adapt</td><td>0.885174</td><td>1.144337</td><td>1.967552</td><td>0.005011</td></tr><tr><td>decaying</td><td>0.900495</td><td>1.320579</td><td>2.366297</td><td>0.006883</td></tr><tr><td>fixed</td><td>0.901636</td><td>1.580243</td><td>2.922989</td><td>0.011179</td></tr></table>
705
+
706
+ Table 1. Table of results on M4 datasets. The table shows average results over all time series in the dataset—thus, all columns should be interpreted on average over time-series in M4. The coverage column displays the long-run coverage. The variance column shows the variance of the quantile normalized by the variance of the score sequence. The MSE column shows the squared error of the quantile normalized by the variance of the score sequence. Finally, the infinite sets column shows the fraction of time steps in the sequence for which the output is an infinite-width prediction set.
707
+
708
+ where the last step holds as long as we choose $b \geq \frac{((B + c)^2a^2 + 1/4)c}{a}$ . And, since $t \geq T$ , we have
709
+
710
+ $$
711
+ a c t ^ {- 1 - 2 \epsilon} = a c t ^ {1 / 2 - \epsilon} \cdot t ^ {- 3 / 2 - \epsilon} \geq a c T ^ {1 / 2 - \epsilon} \cdot t ^ {- 3 / 2 - \epsilon} \geq (1 / 2 + \epsilon) t ^ {- 3 / 2 - \epsilon} \geq t ^ {- 1 / 2 - \epsilon} - (t + 1) ^ {- 1 / 2 - \epsilon},
712
+ $$
713
+
714
+ where the last step holds since $t \mapsto t^{-1/2 - \epsilon}$ is convex, with derivative $-(1/2 + \epsilon)t^{-3/2 - \epsilon}$ . Therefore, we have verified that $\mathbb{E}\left[(q_{t+1} - q^*)^2\right] \leq b(t + 1)^{-1/2 - \epsilon}$ , as desired.
715
+
716
+ # B. Additional experiments
717
+
718
+ We compare against two additional methods: first, "decay+adapt", a variant of our procedure that decays until it detects a change point, then resets the learning rate. Change points are identified when at least $N_{\mathrm{miscoverage}}$ consecutive miscoverage events or $N_{\mathrm{coverage}}$ events are observed in a row (we set these constants to 10 and 30 by default, respectively). When a change point is identified, the learning rate is reset to $\frac{\hat{B}}{(t - T_{\mathrm{changepoint}})^{1/2 + \epsilon}}$ , where $T_{\mathrm{changepoint}}$ is the time at which the changepoint is detected and $\epsilon \in (0,1/2)$ . In these experiments, like in the main text, we set $\epsilon = 0.1$ .
719
+
720
+ We additionally compare against DTACI (Gibbs & Candès, 2022), an adaptive-learning-rate variant of ACI that uses multiplicative weights to perform the updates (see (Gibbs & Candès, 2022) for further details.)
721
+
722
+ We compare these methods on a dataset of over 3000 time series subsampled from the M4 time series dataset. This dataset is a diverse array of time series with varying numbers of samples and distribution shifts. Code is available in our GitHub repository to run on all 100,000 time series in M4; here, we show results on the first 3000.
723
+
724
+ Finally, to showcase the conceptual differences between the standard decaying learning rate sequence and the 'decay+adapt' method, we display a simulated score sequence in Figure 4. Here, the scores are simulated from $\mathcal{N}(\mu_t,1)$ where $\mu_t = 0$ for the first thousand time steps, $\mu_t = 2$ for the second thousand, $\mu_t = 4$ for the third thousand, and $\mu_t = 6$ for the final thousand. Especially towards the end of the time series, 'decay+adapt' can more quickly adjust to the change points.
725
+
726
+ ![](images/6bccd03a3f8535fc81ffddd2c7b67efb24ce9f89ca0e2f9e6f03a33f1edd051a.jpg)
727
+ Figure 4. Simulation comparison of decaying step size and 'decay+adapt'. The raw score sequence is shown in blue, the decaying step size sequence is in orange, and 'decay+adapt' is in green.
onlineconformalpredictionwithdecayingstepsizes/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:663cd2ebc6c8291d0c0f887e48b8e9a1ecb7dfd89dcfc4f03af63c0dc1a7086c
3
+ size 582390
onlineconformalpredictionwithdecayingstepsizes/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:799ec0ce8644c9a48ee9f2fdcf98d5e7d58677dcc162ff9273a7c5f2ecf49d92
3
+ size 897812
onlinelinearregressionindynamicenvironmentsviadiscounting/33cd2428-408d-4fda-9a01-ec7534d5ee56_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0248feb89d9853844d458719b7382eeed51a3099bc3d4cca717a6dae8ca0bcde
3
+ size 283860
onlinelinearregressionindynamicenvironmentsviadiscounting/33cd2428-408d-4fda-9a01-ec7534d5ee56_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d52b1a3195df3484affce1ba3a9044f0890c53d72ae4ec508979d1e78ddb963d
3
+ size 318976
onlinelinearregressionindynamicenvironmentsviadiscounting/33cd2428-408d-4fda-9a01-ec7534d5ee56_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7890162c1d3809306492cadd2eb1b5b82a05ffac164151e6c9b31f716155c962
3
+ size 637758
onlinelinearregressionindynamicenvironmentsviadiscounting/full.md ADDED
The diff for this file is too large to render. See raw diff
 
onlinelinearregressionindynamicenvironmentsviadiscounting/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:154c9d3b42701be2e73c0165af2a57e866e82e175e945db4debb32e48081b841
3
+ size 2310948
onlinelinearregressionindynamicenvironmentsviadiscounting/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d1b9cc5eaa714370834f379da3b85f67b8423662414681552f7ccc334be290f3
3
+ size 1716913
onlinematchingwithstochasticrewardsprovablebetterboundviaadversarialreinforcementlearning/d68942a3-988d-4b42-88e4-6de96a201749_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d362f67c22d8a91addce087a7c5d9968b6dca979fcef86beafcdc01fbac16831
3
+ size 135422
onlinematchingwithstochasticrewardsprovablebetterboundviaadversarialreinforcementlearning/d68942a3-988d-4b42-88e4-6de96a201749_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:547a93d916a721a1d06318f9f36552fa8589659c57cd640e9dd0752193ef7e4d
3
+ size 164503
onlinematchingwithstochasticrewardsprovablebetterboundviaadversarialreinforcementlearning/d68942a3-988d-4b42-88e4-6de96a201749_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9edfb78dc9c30affdb235bc28de438e2de065ef6261afeac500cd3030c29c31b
3
+ size 784256
onlinematchingwithstochasticrewardsprovablebetterboundviaadversarialreinforcementlearning/full.md ADDED
@@ -0,0 +1,550 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Online Matching with Stochastic Rewards: Provable Better Bound via Adversarial Reinforcement Learning
2
+
3
+ Qiankun Zhang*1 Aocheng Shen*1 Boyu Zhang<sup>1</sup> Hanrui Jiang<sup>1</sup> Bingqian Du<sup>2</sup>
4
+
5
+ # Abstract
6
+
7
+ For a specific online optimization problem, for example, online bipartite matching (OBM), research efforts could be made in two directions before it is finally closed, i.e., the optimal competitive online algorithm is found. One is to continuously design algorithms with better performance. To this end, reinforcement learning (RL) has demonstrated great success in literature. However, little is known on the other direction: whether RL helps explore how hard an online problem is. In this paper, we study a generalized model of OBM, named online matching with stochastic rewards (OMSR, FOCS 2012), for which the optimal competitive ratio is still unknown. We adopt an adversarial RL approach that trains two RL agents adversarially and iteratively: the algorithm agent learns for algorithms with larger competitive ratios, while the adversarial agent learns to produce a family of hard instances. Through such a framework, agents converge at the end with a robust algorithm, which empirically outperforms the state of the art (STOC 2020). Much more significantly, it allows to track how the hard instances are generated. We succeed in distilling two structural properties from the learned graph patterns, which remarkably reduce the action space, and further enable theoretical improvement on the best-known hardness result of OMSR, from 0.621 (FOCS 2012) to 0.597. To the best of our knowledge, this gives the first evidence that RL can help enhance the theoretical understanding of an online problem.
8
+
9
+ *Equal contribution ${}^{1}$ School of Cyber Science and Engineering, Huazhong University of Science and Technology, Wuhan, China ${}^{2}$ School of Computer Science and Technology, Huazhong University of Science and Technology, Wuhan, China. Correspondence to: Qiankun Zhang <qiankun@hust.edu.cn>.
10
+
11
+ Proceedings of the $41^{st}$ International Conference on Machine Learning, Vienna, Austria. PMLR 235, 2024. Copyright 2024 by the author(s).
12
+
13
+ # 1. Introduction
14
+
15
+ Optimization in an online setting is one of the most significant research branches in combinatorial optimization, because it captures more practical real-world applications by considering sequential variables or constraints arriving over time. For example, in online advertising, a search engine like Google must select an advertiser to show for a search request, without any knowledge of the future requests that may follow. This scenario is intrinsically modeled by the online bipartite matching (OBM) problem proposed by Karp et al. (1990). To deal with the challenge of the uncertainty of inputs, theoretical studies (See Mehta (2013) for a survey) constantly improve the ratio between the (expected) solution given by an algorithm and the optimal solution to a corresponding offline benchmark, which is called competitive ratio. Recently, there has been a line of research using machine learning (ML) techniques to solve online optimization problems, among which, reinforcement learning (RL) achieves remarkable success in finding high-performance algorithms (Du et al., 2022a; Kong et al., 2019; Wang et al., 2019; Alomrani et al., 2021). These successes essentially stem from the similarities in sight between RL and online algorithms. Both of them deal with sequences of inputs, and target on finding strategies that optimize (maximize or minimize) their objectives (or cumulative rewards).
16
+
17
+ However, almost all existing works target training algorithms for online optimization problems, for which the optimal competitive ratios have been known. In other words, their results indicate that the RL agents can eventually converge to perform the best on the worst-case inputs, and the learned policies are broadly consistent with the best-known theoretical algorithms (e.g., the online primal-dual algorithms). These attempts are significant but preliminary. There is a large class of open-ended online optimization problems, which may face critical challenges from two directions: one is to find robust algorithms as previous works, corresponding to improve the lower bound of competitive ratio; another one is to construct hard instances, corresponding to an upper bound, such that no algorithm can achieve a competitive ratio better than that. Applying RL approaches to such problems raises the following interesting questions:
18
+
19
+ # Our Research Questions
20
+
21
+ - Can RL help enhance our (theoretical) understanding in the hardness of an online problem?
22
+ - Can and how can RL be applied to an unclosed online problem?
23
+
24
+ This paper gives an attempt to address these issues. We focus on a concrete problem, named Online Matching with Stochastic Rewards (OMSR) proposed by Mehta & Panigrahi (2012), which generalizes the classic OBM model. This model is more practical to the online advertising platform, where payments are given by advertisers only when their ads are clicked by a user. The click-through-rate can be used as an estimation of the probability of those clicks. Only when the user actually clicks the ad, which is dominated by a stochastic process, the advertiser should pay for it. The randomness coming from the problem itself brings remarkable difficulties in theoretical analysis. While an optimal $1 - 1 / e \approx 0.632$ -competitive algorithm is known to OBM, OMSR remains open: an upper bound of $0.621^1$ (Mehta & Panigrahi, 2012) and a lower bound of $0.572^2$ (Huang & Zhang, 2020) are known the best.
25
+
26
+ Our paper studies OMSR and considers both directions in learning robust algorithms and hard instances. We set up an adversarial reinforcement learning (Pinto et al., 2017) framework for OMSR. The framework consists of an iterative process between an adversary agent (adv) and an algorithm agent (alg): adv learns the hardest instances which make the current alg perform the worst; alg then learns for a better performance over these hard instances $^{3}$ . Besides obtaining a robust algorithm for OMSR as what previous works have done, much more significantly and interestingly, we observe two structural properties from graph patterns of hard instances learned by adv, named a consistency property and an exclusivity property. These properties not only help reduce the action space in training adv, but further serve as ingredients for theoretically proving an improved upper bound for OMSR. Precisely, our main results are concluded as follows:
27
+
28
+ - We prove that there is no algorithm for OMSR with a competitive ratio of more than 0.597, beating the best known upper bound of 0.621 (Mehta & Panigrahi, 2012).
29
+ - We empirically show that our algorithms learned by
30
+
31
+ alg performs better than the state-of-the-art (SOTA).
32
+
33
+ Extensive experiments are conducted to evaluate both hard instances and algorithms learned through our framework.
34
+
35
+ # 1.1. Related Works
36
+
37
+ Theoretical results for OMSR. Like the well-known online optimization problem, AdWords (Mehta et al., 2005; Huang et al., 2020), OMSR is also a variant of the online bipartite matching problem, which is first proposed by Mehta & Panigrahi (2012). They give an upper bound of 0.621 for OMSR as a hardness result. Also, they propose two algorithms, named Balance and Ranking, for a special case when success probabilities are all equal, and prove that they are 0.567 and 0.534-competitive respectively. For the unequal probability case, Mehta et al. (2014) prove that Balance can achieve 0.534-competitive. Later, these bounds are improved by Huang & Zhang (2020). They prove that the competitive ratios of the Balance algorithm are 0.576 for equal success probabilities and 0.572 for unequal case. Their results are restricted to small success probabilities (e.g., smaller than 0.01), which is close to the real click-through rate in an internet advertising platform. Meanwhile, another series of work (Goyal & Udwani, 2019; Huang et al., 2023) also analyzes Balance and Ranking but against a weaker benchmark. In this paper, we evaluate our algorithms in both equal and unequal success probability settings, varying from 0 to 1, by viewing Balance as a baseline.
38
+
39
+ Reinforcement learning for online optimization. These series of work are the most relevant to ours, and can be roughly divided into two main categories. One is about designing high-performance algorithms towards real-world datasets. Wang et al. (2019) propose a Q-learning for node batches, for a dynamic generalization of OBM; Alomrani et al. (2021) train an algorithm agent based on historical data, and evaluate it on two generalizations of OBM: edge-weighted OBM and online submodular maximization. The other line is about designing robust algorithms using RL towards worst-case inputs. Kong et al. (2019) find optimal algorithms for three well-studied online problems, relying on prior knowledge of hard instances. They claim that the RL agent can learn the behavior as theoretically optimal algorithms, i.e., the primal-dual algorithms. Zuzic et al. (2020) propose a GAN-like framework based on Yao's Lemma. They work on AdWords problem but whether their framework can be used for those unclosed problems is not yet clear. Compared to these works, our paper is new in: (1) studying an open-ended online problem; (2) utilizing an adversarial RL approach to model online optimizations as a game; (3) obtaining theoretical bounds with an assistance of learned patterns; (4) generalization ability to other online problems. Besides, using RL to solve (offline) combinato
40
+
41
+ rial optimization problems is not young (Bello et al., 2016; Zhang et al., 2020a; Nazari et al., 2018; Kool et al., 2018; Khalil et al., 2017; Du et al., 2022b; Boutilier & Lu, 2016; Shao et al., 2022). We refer to surveys (Mazyavkina et al., 2020; Bengio et al., 2018; Yang & Whinston, 2020) for readers interested in this area.
42
+
43
+ Adversarial reinforcement learning. Our idea of adversarial RL is similar to Pinto et al. (2017), who train an agent to operate in the presence of a destabilizing adversary. They jointly train the adversary to learn an optimal destabilization policy. Subsequently, follow-up work targets on finding its applications, for example, in video captioning (Hua et al., 2022), grasping moving objects (Wu et al., 2022), robotics (Jiang et al., 2021), and so forth (Ma et al., 2018; Zhang et al., 2020b; Spooner & Savani, 2020; Gisslen et al., 2021). The idea behind online algorithm design is exactly adversarially constructing hard instances while improving algorithms. That is why our methods are intuitively effective. Moreover, for robustness, Vinitsky et al. (2020); Dong et al. (2023) train agents against multiple adversaries instead of a single one. We utilize a similar but slightly different approach that trains the algorithm agent against a mixture of hard instances and some randomly generated instances. See Appendix D for details.
44
+
45
+ Other related work. Recently, there is another line of work designing online algorithms with predictions given by machine learning (Antoniadis et al., 2020; Wang et al., 2020; Diakonikolas et al., 2021; Purohit et al., 2018; Wei & Zhang, 2020; Li et al., 2023a,b; Yang et al., 2023), with an objective to see how much improvements can be made on competitive ratios with such predictions. Although they also concern about theoretical guarantees, their bounds depend on how precise these predictions are. Our work focuses on a better understanding of challenges from the online optimization problem itself.
46
+
47
+ # 1.2. Roadmap
48
+
49
+ In Section 2, we present the formal definition of the OMSR problem, along with a benchmark problem we evaluate algorithms against, and provide an overview of existing algorithms and (upper and lower) bounds. We omit details that are not so necessary to grasp our main ideas and contributions for readers who are new to OMSR, or even online algorithms. Our framework, as illustrated in Figure 1, is described in detail in Section 3 and Section 4. Specifically, our framework is made up of two RL agents: an adv to generate hard (or worst-case) instances, and an alg to learn robust algorithms. Each agent views the other as its environment, and rewards are opposite to each other. We train the agents iteratively and from scratch: at first, adv is trained against an arbitrary or a simple known algorithm,
50
+
51
+ for example, a greedy policy; alg is next learned against those hard instances; followed by repeating until a convergence. In our task on OMSR, we start from our baseline algorithm, Balance. After the iterative training, the hard instances learned by adv help give a provable upper bound for OMSR, beating the best-known upper bound in previous literature, as presented in Section 3. Section 4 will then present what alg learns against those hard instances, beating our baseline empirically.
52
+
53
+ ![](images/df824491bdabab8129e1b6b2c3dc123583a85d142825a5916f3f216cb0d357a1.jpg)
54
+ Figure 1. Our adversarial reinforcement learning framework.
55
+
56
+ # 2. Preliminaries
57
+
58
+ Formal definition of OMSR. Consider a bipartite graph $G = (U \cup V, E)$ . There are $n$ advertisers in $U = \{u_1, u_2, \dots, u_n\}$ known in advance, and $m$ search requests in $V = (v_1, v_2, \dots, v_m)$ arriving one by one. Upon the arrival of each search request $v_j, j \in [m]$ , its adjacent edges are revealed associated with a vector $p_j = (p_{1j}, p_{2j}, \dots, p_{nj})$ to represent the success probabilities (click-through-rates) on every edge<sup>4</sup>. The algorithm then has to choose an available $u_i$ and assign $v_j$ to it immediately and irreversibly. If $v_j$ is assigned to $u_i$ , a coin is tossed to determine whether or not this assignment is successful with probability $p_{ij}$ , independent of previous outcomes. If so, $u_i$ becomes unavailable for future online vertices.<sup>5</sup> Conversely, if the assignment is unsuccessful, $u_i$ remains available for another attempt of assignment. The objective of OMSR is to maximize the expected number of successful matchings. Existing studies vary on: (1) assuming success probabilities are sufficiently small<sup>6</sup> (e.g. $p_{ij} < 0.01, \forall (i,j) \in E$ ) or not; (2) assuming success probabilities are identical (i.e., $\forall (i,j) \in E, p_{ij} = p$ ) or not. For a clear presentation for
59
+
60
+ readers not familiar with OMSR, we focus on the restricted case of identical and infinitesimal success probabilities in our paper, but our experiments are not restricted to this assumption in Section 4. Under this assumption, the input instance is simplified as a matrix $\mathcal{P}_{n\times m}$ where for each $(i,j)\in E$ , $p_{ij} = p$ , and otherwise $p_{ij} = 0$ .
61
+
62
+ Benchmark and evaluation. To evaluate the performance of an algorithm, denoted as ALG, we compare it to an offline and non-stochastic version of OMSR, named budgeted allocation (BA) problem (Mehta & Panigrahi, 2012; Huang & Zhang, 2020) (See Appendix A for details). For a given instance (input graph) $G$ , we define the optimal solution, denoted as $\mathsf{OPT}(G)$ , as the maximum objective value can be found over the same $G$ of BA. Further, we define the competitive ratio (CR) of an algorithm as the infimum of ratio between $\mathsf{ALG}(G)$ and $\mathsf{OPT}(G)$ over all possible input graphs in an input space $\mathcal{G}$ , that is, $\mathsf{CR} = \inf_{G \in \mathcal{G}} \frac{\mathsf{ALG}(G)}{\mathsf{OPT}(G)}$ . Note that $\mathsf{CR} \in [0,1)$ , and the closer to 1 the better. We make an early clarification on our abuse of CR in our experiments: CR is defined as the competitive ratio of an algorithm on a specific input graph $G$ , i.e., $\mathsf{CR} = \frac{\mathsf{ALG}(G)}{\mathsf{OPT}(G)}$ .
63
+
64
+ Existing algorithms and bounds. For hardness result (upper bound), Mehta & Panigrahi (2012) prove that no algorithm for OMSR has a competitive ratio of more than $0.621 < 1 - 1/e \approx 0.632$ , indicating that OMSR is strictly harder than OBM, for which the optimal CR is 0.632. As one of our main results, we improve this bound to 0.597. For algorithm design (lower bound), the current SOTA is achieved by an algorithm named Balance (Huang & Zhang, 2020), which is also our baseline for evaluating learned algorithms. Balance<sup>7</sup> is a deterministic greedy strategy presented as follows and it is our starting point for training adv as the environment at the first iteration. CR of Balance varies on whether probabilities on all edges are equal. Table 1 concludes the above results related to our work.
65
+
66
+ # Balance Algorithm:
67
+
68
+ Upon the arrival of each online vertex, match it to a neighbor with the fewest failure attempts.
69
+
70
+ # 3. Learning Worst Cases: a Provable Better Bound
71
+
72
+ Recall that our adversarial RL framework trains adv and alg iteratively. This section first presents how to set up the adv agent to learn hard instances against the current alg in every single iteration. At the very beginning, we could initialize alg as any random policy. In our experiments,
73
+
74
+ to compare with the baseline, we train adv to generate worst-case instances against Balance in the first iteration. After several iterations such that the agents converge to a Nash equilibrium, graph instances can be sampled from the learning outcomes of adv in each iteration. We distill two properties related to learned patterns, which are what we call a consistency property and an exclusivity property, from statistical observations. Combining them up proves an improved upper bound for OMSR as stated in Table 1.
75
+
76
+ # 3.1. MDP Formulation
77
+
78
+ We formulate the adv as a Markov Decision Process (MDP) model. Recall that in OMSR, the input instance is a matrix $\mathcal{P}_{n\times m}$ for $n$ offline vertices and $m$ online vertices. $p_{ij} = p$ or 0 for $\forall i\in n.j\in m$ according to whether there exists an edge $(i,j)$ . Columns are revealed online one by one. In a nutshell, adv is trained to construct $\mathcal{P}$ gradually, generating the $j$ -th column $\mathcal{P}_{[i,j]}$ of $\mathcal{P}$ at the state $s_j$ . alg serves as the environment, which runs the current algorithm on $\mathcal{P}$ and produces a reward equal to $1 - \mathrm{CR}$ . Details are presented as follows.
79
+
80
+ Environment. The current matching policy is defined by alg, and a calculator on CR.
81
+
82
+ State Space. A state $s_j$ at a timestep $j$ is the current (partial) matrix of $\mathcal{P}$ , i.e. $\mathcal{P}_{[:1:j-1]}$ . A terminal state $\hat{S}$ is reached when a complete $\mathcal{P}$ is generated. The length of an episode is $T = m$ .
83
+
84
+ Action space. At state $s_j$ , an action $a_j \in A_j$ taken by adv is to select a subset $U' \subseteq U$ , and set $p_{ij} = p$ for $i \in U'$ in other words, determine the neighbor of $v_j$ . The size of action space $|A_j|$ is $2^n$ .
85
+
86
+ Transition. The transition from state $s_j$ to the next state $s_{j+1}$ is deterministic. If action $a_j$ is taken, the $j$ -th column in matrix $\mathcal{P}$ is updated and moves on to the next episode step, $j + 1$ .
87
+
88
+ Reward. If an episode ends, all taken actions will receive a reward of $1 - \mathrm{CR}$ , where CR is the competitive ratio of the current algorithm environment running on the generated instance.
89
+
90
+ Policy. At state $s_j$ , a stochastic policy $\pi(a_j | s_j)$ outputs a distribution, the support of which is $2^U$ .
91
+
92
+ # 3.2. Training Algorithm
93
+
94
+ We use the Cross-Entropy method for reinforcement learning. The steps are as follows with hyperparameters $N_{\mathrm{batch}} = 1024$ and $\alpha = 30\%$ :
95
+
96
+ 1. Initialize the policy distribution $\pi^{(0)}$ as random.
97
+ 2. Generate $N_{\mathrm{batch}}$ matrices of $\mathcal{P}$ from $\pi^{(k)}$ .
98
+ 3. For each episode, compute the total reward by summing up all the rewards at each step.
99
+
100
+ Table 1. Existing bounds of OMSR
101
+
102
+ <table><tr><td></td><td>Lower Bound (Algorithms)</td><td>Upper Bound (Hardness)</td></tr><tr><td>Equal Prob.</td><td>0.576 (Balance) (Huang &amp; Zhang, 2020)</td><td rowspan="2">0.621 (Mehta &amp; Panigrahi, 2012) → 0.597 (This paper)</td></tr><tr><td>Unequal Prob.</td><td>0.572 (Huang &amp; Zhang, 2020)</td></tr></table>
103
+
104
+ 4. Select the top $\alpha$ elite episodes with the highest total rewards.
105
+ 5. Update the policy to $\pi^{(k + 1)}$ for the set $S$ of steps $(s,a,r)$ in elite episodes by:
106
+
107
+ $$
108
+ \pi^ {(k + 1)} = \arg \max _ {\pi} \sum_ {(s, a, r) \in S} \log \pi (a | s). \tag {1}
109
+ $$
110
+
111
+ 6. Repeat steps 2-5 until convergence.
112
+
113
+ We use a feed-forward neural network with a single hidden layer with $2^{n + 2}$ neurons and ReLU for non-linearity. A fixed learning rate for the Adam optimizer is set as $10^{-3}$ . We also take an $\epsilon$ -greedy strategy, where the agent takes the action given by $\pi$ with probability $\epsilon$ , and takes a random action with probability $(1 - \epsilon)$ . We set $\epsilon = 0.5$ .
114
+
115
+ # 3.3. Bridging Statistics and Theory
116
+
117
+ To understand in depth what adv learns and how it behaves in generating worst cases, we conduct experiments towards the output of adv's networks in every iteration. Our empirical observations indicate two immediate properties on the learned graph patterns, which contribute to a formal proof of the upper bound as claimed. Recall that the size of graph instances is $n \times m$ , where $n$ and $m$ denote the number of offline and online vertices, respectively. We experiment on different choices of $n$ and $m$ . Besides, we also consider the success probability $p$ varying from 0 to 1.
118
+
119
+ Expected number of offline neighbors. For each online vertex, adv outputs a distribution on its offline neighbor subset. Figure 2 plots the expected number of neighbors for online vertices from 1 to $m$ in their arriving order. The larger numbered vertices come later. We experiment on $m = 240$ (Figure 2(a)) and $m = 200$ (Figure 2(b)). We observe a clear trend that vertices arrive later may have fewer neighbors. Such observations are in fact consistent with our intuition in constructing hard instances in OBM and its related problems: Early matching mistakes will lead to few choices for later arriving vertices, which are constructed with fewer neighbors.
120
+
121
+ Online vertices with identical neighbors. Another key observation is the adjacent arriving online vertices tend to share identical neighbors. To see this, we experiment on graph instances with only two offline vertices, that is, $n = 2$ .
122
+
123
+ ![](images/8b839965d35e6355c2a6625a2b5be26e988c3091fc619715bd729e8a0b684d4e.jpg)
124
+ Figure 2. The expected number of each online vertex neighbors. The curve plots the expectation as a function of the index of online vertex.
125
+
126
+ ![](images/ea2d26f1b88235556092e3364872e31bbe52dc5d3a66b4fadbc760687a814ddc.jpg)
127
+
128
+ Figure 3(a) shows instances sampled from adv's output. In this case, the first $x$ vertices have edges with both offline vertices, while the remaining ones has only one neighbor. To further validate such finding, we restrict adv generates instances as Figure 3(a) and train it to find an optimal number of $x$ . Figure 3(b) shows the probability distribution of $x$ and the competitive ratios on the corresponding graph instances. The competitive ratio is minimized when $x = 40$ , meaning that the worst instance is conducted when the first half online vertices has two neighbors, while the other half has only one.
129
+
130
+ To summarize the above empirical findings, we define a consistency property as follows, which restricts the graph patterns that adv generates, and thus reduces the size of the action space.
131
+
132
+ Definition 3.1 (Consistency Property). A bipartite graph $G$ satisfies a consistency property if the online vertices $V$ of $G$ can be partitioned into $k$ disjoint subsets $V_{1}, V_{2}, \ldots, V_{k}$ , such that $V = V_{1} \cup V_{2} \cup \dots \cup V_{n}$ , and for each $i \in [k]$ , all vertices in $V_{i}$ have the same neighbors.
133
+
134
+ Correlations between online vertices groups. Consistency property allows us to partition the online vertices into groups such that vertices in the same group can be viewed identically. So in the following discussion, we use a single online vertex to represent a group of online vertices. We further investigate correlations on how these groups are connected to offline neighbors. Take $n = 4$ as an example. Figure 4 presents hard instances sampled from adv's output with the smallest four competition ratios during all training iterations until the convergence. We define an exclusivity property as follows to capture the learned patterns. Intu
135
+
136
+ ![](images/21f2fe4a8705544c10a28d48ebc117b24731d672eef0da2d923d92dfaa1dac0f.jpg)
137
+ (a)
138
+
139
+ ![](images/a181a52eca4cd96b2845749b5c49bdd393798cf4a103c3936615d5a6c24bf3e2.jpg)
140
+ (b)
141
+ Figure 3. Figure (a) presents the worst-case instances learned under $n = 2$ , where the first $x$ (green) vertices have both neighbors, and the remaining $m - x$ (blue) vertices have only one neighbor. The curves in Figure (b) plot both the CR as a function of the value $x$ , and the probability distribution $p$ of $x$ .
142
+
143
+ itively, the exclusivity property ensures the later coming online vertex can only have edges to offline vertices, which have identical earlier coming online neighbors. For example, in the last graph of Figure 4, vertex green connects to all four offline vertices. Vertex blue connects to the first three, and vertex orange connects to a subset of blue's neighbors (also a subset of green's neighbors). Definition 3.2 gives a formal definition.
144
+
145
+ Definition 3.2 (Exclusivity Property). Given a bipartite graph $G$ with online vertices $V$ . Let $N_{j}$ denote the neighbor set of a vertex $v_{j} \in V$ . $G$ is said to satisfy an exclusivity property if for each $j \in [m]$ and any $j' < j$ , $N_{j} \subseteq N_{j'}$ or $N_{j} \cap N_{j'} = \emptyset$ .
146
+
147
+ ![](images/eb6a4904f994f574f13f920dbd652f521dfaff4dc8b28e96f84a0d77925ee22f.jpg)
148
+ Figure 4. Worst-case instances learned under $n = 4$ . Each instance has four offline vertices drawn on the left-hand-side, and four groups of online vertices drawn on the right-hand-side. Each online vertex group is drawn in a different color, and its neighbors are circled in the same color.
149
+
150
+ ![](images/12d85ca95ca41a621cbbc628a06af06e98b4f5397c5bf5e2d0740e70bc5d65cc.jpg)
151
+
152
+ ![](images/f05c452a5f7e2647147c6bf825c1d64262e514a0d15d8601eee2a886d713a858.jpg)
153
+
154
+ ![](images/feb8c1460a2270372e1843f17845179f09139762d03000a6d1b685fcc3c34e82.jpg)
155
+
156
+ # 3.4. A Provable Upper Bound for OMSR
157
+
158
+ The properties introduced above not only effectively reduce the action spaces for training adv, but also contribute to a useful lemma that suffices to prove our main theoretical results as stated in Theorem 3.3.
159
+
160
+ Theorem 3.3. No algorithm for the OMSR problem can achieve a competitive ratio of more than 0.597.
161
+
162
+ Proof sketch. We provide a proof sketch of Theorem 3.3 in the rest of this section, and leave a formal proof in Appendix C. The proof consists of two ingredients: we first show that the Balance algorithm is optimal on a family of instances that satisfies both consistency and exclusivity properties as defined in Definition 3.1 and Definition 3.2. By such optimality, to prove an upper bound $\gamma$ of OMSR, it then suffices to find instances where Balance is $\gamma$ -competitive.
163
+
164
+ Consider the graph instances learned by adv as introduced in earlier sections. For a ease of notation, let $\mathcal{G}_n$ denote graph instances with $n$ offline vertices and satisfies both consistency and exclusivity properties as defined in Definition 3.1 and Definition 3.2. Further, or easy calculation on $\mathrm{OPT}(\mathcal{G}_n)^8$ , we restrict all vertices groups in $\mathcal{G}_n$ contains $1/p$ identical online vertices. $\mathcal{G}_n$ is formally defined as:
165
+
166
+ Definition 3.4. $\mathcal{G}_n$ is a family of bipartite graphs, which satisfy the consistency and exclusivity properties, with offline vertices $U = \{u_1, u_2, \dots, u_n\}$ and online vertices $V = V_1 \cup V_2 \cup \dots \cup V_n$ . For each $i \in n$ , $V_i$ contains $1/p$ identical vertices that have the same probabilities vector towards $U$ . Besides, probabilities on edges between $u_i$ and all vertices in $V_i$ can not be 0, i.e., $\forall v_j \in V_i, p_{ij} = p$ .
167
+
168
+ Remarks on $\mathcal{G}_n$ . By definition, $\mathcal{G}_n$ has $n$ offline vertices and $n/p$ online vertices divided into $n$ groups. Further, for $\forall n \in Z_+$ , $\mathrm{OPT}(\mathcal{G}_n) = n$ . Much more importantly, $\mathcal{G}_n$ brings great convenience for a theoretical proof on upper bound through the following lemma.
169
+
170
+ Lemma 3.5. Balance is optimal on $\mathcal{G}_n$ .
171
+
172
+ Lemma 3.5 indicates the optimality of Balance on $\mathcal{G}_n$ . To show an upper bound of 0.597 of OMSR, it then suffices to construct instances from $\mathcal{G}_n$ where Balance is 0.597-competitive. For a consideration of the page limit and a clear presentation, we provide proof of a weaker bound of 0.61 on $\mathcal{G}_3$ , which is slightly larger than 0.597 as claimed in Theorem 3.3, but yet beats the previous best-known 0.621 as stated by Mehta & Panigrahi (2012).
173
+
174
+ Lemma 3.6. There exists a subset of instances in $\mathcal{G}_3$ , such that no algorithm on them can achieve a competitive ratio of more than 0.61.
175
+
176
+ Let's see how Balance runs on one of these instances $G_3^\star \in \mathcal{G}_3$ as presented in Figure 5 and compute the expected number of successful offline vertices. Briefly speaking, we need to compute the probabilities of whether $u_1, u_2,$ and $u_3$ are successful, together with $2^3$ cases, and take an expectation. The expected number of successful vertices in $u_1, u_2, u_3$ is $3(1 - 11/(18e) - 11/(9e^2))$ , deriving a competitive ratio of $(1 - 11/(18e) - 11/(9e^2)) < 0.61$ . The complete proof is shown in Appendix C.
177
+
178
+ ![](images/2da8b243b23fa8f851d4ffd10447d3716191fcbcfbfa9fbe8270291c7eab602e.jpg)
179
+ Figure 5. $G_3^\star$ with $|U| = 3$ and $|V| = 3k$ , where $k = 1/p$ and $p \to 0$ . Online vertices are listed at the top and arrive from left to right. Offline vertices are at the bottom.
180
+
181
+ Combining with Lemma 3.5 completes the proof of Lemma 3.6.
182
+
183
+ Finally, to obtain our final result as stated in Theorem 3.3, the adv finds $\mathcal{G}_n$ 's as $n$ grows up. The smallest competitive ratio, 0.597, is achieved when $n = 7$ . Table 2 records these results as $n$ grows from 1 to 10.
184
+
185
+ # 3.5. Evaluations on Hard Instances
186
+
187
+ We set up experiments to further validate the hardness of graph instances we construct.
188
+
189
+ The performance of algorithms on the learned worst-case distributions. To validate that adv can efficiently find hard instances in iterative training, we evaluate the performance of the algorithm learned by alg and Balance on the worst-case distributions in each iteration. We take experiments with different success probabilities $(p = 1/40, 1/10, 1/5$ and $1/2)$ , and plot the results in Figure 6. The results show that, in general, the performance of algorithms gets worse on the hard instances generated by the learned distributions in iterative training. In addition, we find that when the success probabilities are small enough (e.g. $p = 1/40$ ), the learned algorithm and Balance perform almost identically in the experiments. This may imply that Balance is optimal when $p$ is vanishing.
190
+
191
+ $\mathcal{G}_n$ v.s. baselines. We compare the hardness of $\mathcal{G}_n$ to some other instances that are well known to be hard for OBM and its related problem, for example, the Thick-z and Triangular graphs (formally defined in Appendix B.1). Besides, we also compare with the worst-case instance constructed in Mehta & Panigrahi (2012). We experiment on the performances of algorithms learned by alg in each iteration from 0 to 10 running on these instances. Figure 7 shows that the learned algorithm gets better performance after iterative training, and converges to the corresponding CRs of these instances. The algorithm performs worst on the hard instances in our paper, and this experimentally indicates the generated
192
+
193
+ ![](images/cb2aa6341359db54af646aa80e17ecb520840be47856842571bf787a83f4ed83.jpg)
194
+
195
+ ![](images/d9b4c10330a3a30116f2dc88cca3184e887c239bd96d71cc0b671be9b6915116.jpg)
196
+ Figure 6. The average CRs of learned algorithm and Balance running on the learned worst-case distributions in each iteration $T$ from 1 to 10. There are 4 experiments on different $p = 1/40, 1/10, 1/5$ and $1/2$ . The solid and dashed curves plot the CR as a function of the iteration $T$ for learned algorithm and Balance, respectively. In the figure with $p = 1/40$ , the solid and dashed curves are nearly coincident.
197
+
198
+ ![](images/9edd3a467e3ff14aa7b2445744337f9f82379352e4d92f8fd43ff6c766b65b28.jpg)
199
+
200
+ ![](images/d69418a7242f0343aa6496f6cb0652f267af70f530ec7fb7310fa474067f4289.jpg)
201
+
202
+ instances are harder than other known worst-case instances.
203
+
204
+ ![](images/b2b0a94f76ad8e1fae58d17209727cf24a8749b158b99e619bdcee130e0cf9b0.jpg)
205
+ Figure 7. The average CRs of learned algorithms from iteration 0 to 10 running on some specific worst-case instances. The curve plots the CR as a function of the iteration $T$ .
206
+
207
+ # 4. Learning Robust Algorithms: Experimental Evaluations
208
+
209
+ This section introduces the other component of our framework, the algorithm agent alg. We utilize a similar design for the agent as previous literature (Alomrani et al., 2021; Kong et al., 2019). The algorithm agent takes the input instances generated from adv in Section 3 as the environment, and learns robust algorithms under the given input instances.
210
+
211
+ Table 2. The competitive ratio on $\mathcal{G}_n$ rounded to three decimal places.
212
+
213
+ <table><tr><td>Gn</td><td>n = 1</td><td>n = 2</td><td>n = 3</td><td>n = 4</td><td>n = 5</td><td>n = 6</td><td>n = 7</td><td>n = 8</td><td>n = 9</td><td>n = 10</td></tr><tr><td>CR</td><td>0.632</td><td>0.623</td><td>0.610</td><td>0.605</td><td>0.604</td><td>0.599</td><td>0.597</td><td>0.597</td><td>0.598</td><td>0.599</td></tr></table>
214
+
215
+ We defer the MDP formulation and training details in Appendix D.
216
+
217
+ # 4.1. Evaluations
218
+
219
+ We evaluate the performances of algorithms learned by alg in both equal and unequal probabilities cases $^9$ by the following experiments. For an easy calculation on OPT, we restrict input instances to $\mathcal{G}_n$ as defined in Definition 3.4.
220
+
221
+ The average CRs of algorithms under worst-case distributions in different iterations. Let $T$ denote the number of iterations. (An iteration consists of one training for adv and alg) We fix the number of offline vertices as $n = 6$ , and the number of online vertices in one group is $1/p$ , where $p$ is the probability on the edges. For equal probability case, the probability on each edge is identical and sampled randomly. For unequal probability case, the probability on each edge is sampled independently. Figure 8 plots the average CR under worst-case distributions in iterations from 0 to 10. At the beginning ( $T = 0$ ) when it is initialized as random, alg performs poorly against the trained adversary inputs, with around 0.307 (equal) and 0.225 (unequal). Average CRs converge to 0.635 (equal) and 0.614 (unequal), better than that of Balance.
222
+
223
+ ![](images/8b2cb5840af89eda000fc866269d9c2afb9b54595e06550fdf1671d075f64256.jpg)
224
+ Figure 8. The average CRs of algorithms under worst-case distributions in iteration 0 to 10. The curve plots the CR as a function of the iteration $T$ . As a comparison, the dashed line represents the CR of Balance under worst-case distributions in the last iteration (0.615 for equal and 0.594 for unequal).
225
+
226
+ The average CRs of algorithms with different sizes of offline vertices. Table 3 lists the average CRs of algorithms under different numbers of offline vertices $n$ . The CRs of the learned algorithm and Balance are equal when $n = 1$ .
227
+
228
+ As $n$ grows up, CRs of both algorithms decrease. Moreover, it can be observed that the learned algorithm consistently outperforms Balance on average.
229
+
230
+ Table 3. The average CRs of algorithms under worst-case distributions with different numbers of offline vertices.
231
+
232
+ <table><tr><td>Case</td><td>Algotrithm</td><td>n=1</td><td>n=2</td><td>n=3</td><td>n=4</td><td>n=5</td><td>n=6</td></tr><tr><td rowspan="2">Equal</td><td>Learned alg</td><td>0.716</td><td>0.655</td><td>0.649</td><td>0.639</td><td>0.637</td><td>0.635</td></tr><tr><td>Balance</td><td>0.716</td><td>0.654</td><td>0.649</td><td>0.635</td><td>0.621</td><td>0.615</td></tr><tr><td rowspan="2">Unequal</td><td>Learned alg</td><td>0.678</td><td>0.658</td><td>0.648</td><td>0.639</td><td>0.632</td><td>0.614</td></tr><tr><td>Balance</td><td>0.678</td><td>0.622</td><td>0.617</td><td>0.610</td><td>0.600</td><td>0.594</td></tr></table>
233
+
234
+ The average CRs of algorithms under worst-case distributions with different success probabilities. For equal probability $p$ , we train adv and alg with $m = n / p, n = 6$ . Success probabilities $p$ vary from 0 to 1. We observe in Figure 9 a tiny gap of CR when $p < 0.5$ . When $p > 0.5$ , our learned algorithms significantly outperform Balance.
235
+
236
+ ![](images/212df0c0a04f0f43b37be6b9afafa164b44f13218682f8288c48c5b61951a463.jpg)
237
+ Figure 9. The average CRs of algorithms under worst-case distributions with $n = 6$ varying on $p$ . As a comparison, the dashed line represents the CR of Balance.
238
+
239
+ # 5. Conclusions and Limitations
240
+
241
+ There has been extensive literature research on using ML methods to solve classic combinatorial optimization problems or apply techniques in combinatorial algorithms to enhance the ability of ML. However, research that uses ML to illuminate the understanding of online optimization problems is rare. To the best of our knowledge, this paper gives the first successful attempt by improving the best-known upper bound with insights from RL for a specific online
242
+
243
+ matching problem. Besides, our framework can also learn robust (optimal) algorithms as done in previous literature. We point out a major limitation but also an interesting future research direction: while we get insights from what adv learns, it is pretty hard to summarize what alg learns although it performs better than the SOTA algorithm and its competitive ratio. If we could achieve it, the lower bound for OMSR would also be improved. Nevertheless, we believe that our framework gives a representative example and could be generalized to other online optimization problems.
244
+
245
+ # Impact Statement
246
+
247
+ This paper advances the field of ML by enhancing the theoretical understanding of an online combinatorial problem via RL. To the best of our knowledge, this gives the first successful attempt in such a field. We believe in the great potential of ML to assist in theory studies in the future. In ethical aspects, we are not aware of related issues in this paper.
248
+
249
+ # Acknowledgements
250
+
251
+ Qiankun Zhang is supported by National Natural Science Foundation of China (Grant No. 62302183) and CCF-Huawei Huyanglin Fund - Theoretical Computer Science Special Project (No. CCF-HuaweiLK2023004). Bingqian Du is supported by National Natural Science Foundation of China (Grant No. 62302187).
252
+
253
+ # References
254
+
255
+ Alomrani, M. A., Moravej, R., and Khalil, E. B. Deep policies for online bipartite matching: a reinforcement learning approach. arXiv preprint arXiv:2109.10380, 2021.
256
+ Antoniadis, A. F., Gouleakis, T., Kleer, P., and Kolev, P. Secretary and online matching problems with machine learned advice. ArXiv, abs/2006.01026, 2020.
257
+ Bello, I., Pham, H., Le, Q. V., Norouzi, M., and Bengio, S. Neural combinatorial optimization with reinforcement learning. arXiv preprint arXiv:1611.09940, 2016.
258
+ Bengio, Y., Lodi, A., and Prouvost, A. Machine learning for combinatorial optimization: a methodological tour d'horizon. Eur. J. Oper. Res., 290:405-421, 2018.
259
+ Boutilier, C. and Lu, T. Budget allocation using weakly coupled, constrained markov decision processes. In Ihler, A. and Janzing, D. (eds.), Proceedings of the Thirty-Second Conference on Uncertainty in Artificial Intelligence, UAI 2016, June 25-29, 2016, New York City, NY, USA. AUAI Press, 2016.
260
+
261
+ Diakonikolas, I., Kontonis, V., Tzamos, C., Vakilian, A., and Zarifis, N. Learning online algorithms with distributional advice. In International Conference on Machine Learning, 2021.
262
+ Dong, J., Hsu, H.-L., Gao, Q., Tarokh, V., and Pajic, M. Robust reinforcement learning through efficient adversarial herding. arXiv preprint arXiv:2306.07408, 2023.
263
+ Du, B., Huang, Z., and Wu, C. Adversarial deep learning for online resource allocation. ACM Transactions on Modeling and Performance Evaluation of Computing Systems, 6(4):1-25, 2022a.
264
+ Du, Y., Li, J., Li, C., and Duan, P. A reinforcement learning approach for flexible job shop scheduling problem with crane transportation and setup times. IEEE Transactions on Neural Networks and Learning Systems, 2022b.
265
+ Gisslen, L., Eakins, A., Gordillo, C., Bergdahl, J., and Tollmar, K. Adversarial reinforcement learning for procedural content generation. In 2021 IEEE Conference on Games (CoG), pp. 1-8. IEEE, 2021.
266
+ Goyal, V. and Udwani, R. Online matching with stochastic rewards: Optimal competitive ratio via path based formulation. Proceedings of the 21st ACM Conference on Economics and Computation, 2019.
267
+ Hua, X., Wang, X., Rui, T., Shao, F., and Wang, D. Adversarial reinforcement learning with object-scene relational graph for video captioning. IEEE Transactions on Image Processing, 31:2004-2016, 2022.
268
+ Huang, Z. and Zhang, Q. Online primal dual meets online matching with stochastic rewards: configuration lp to the rescue. In Proceedings of the 52nd Annual ACM SIGACT Symposium on Theory of Computing, pp. 1153-1164, 2020.
269
+ Huang, Z., Zhang, Q., and Zhang, Y. Adwords in a panorama. In 2020 IEEE 61st Annual Symposium on Foundations of Computer Science (FOCS), pp. 1416-1426. IEEE, 2020.
270
+ Huang, Z., Jiang, H., Shen, A., Song, J., Wu, Z., and Zhang, Q. Online matching with stochastic rewards: Advanced analyses using configuration linear programs. In International Conference on Web and Internet Economics, pp. 384-401. Springer, 2023.
271
+ Jiang, Y., Zhang, T., Ho, D., Bai, Y., Liu, C. K., Levine, S., and Tan, J. Simgan: Hybrid simulator identification for domain adaptation via adversarial reinforcement learning. 2021 IEEE International Conference on Robotics and Automation (ICRA), pp. 2884-2890, 2021.
272
+
273
+ Karp, R. M., Vazirani, U. V., and Vazirani, V. V. An optimal algorithm for on-line bipartite matching. In Proceedings of the twenty-second annual ACM symposium on Theory of computing, pp. 352-358. ACM, 1990.
274
+ Khalil, E., Dai, H., Zhang, Y., Dilkina, B., and Song, L. Learning combinatorial optimization algorithms over graphs. Advances in neural information processing systems, 30, 2017.
275
+ Kong, W., Liaw, C., Mehta, A., and Sivakumar, D. A new dog learns old tricks: RL finds classic optimization algorithms. In International conference on learning representations, 2019.
276
+ Kool, W., Van Hoof, H., and Welling, M. Attention, learn to solve routing problems! arXiv preprint arXiv:1803.08475, 2018.
277
+ Li, P., Yang, J., and Ren, S. Learning for edge-weighted online bipartite matching with robustness guarantees. arXiv preprint arXiv:2306.00172, 2023a.
278
+ Li, P., Yang, J., Wierman, A., and Ren, S. Robust learning for smoothed online convex optimization with feedback delay. In Thirty-seventh Conference on Neural Information Processing Systems, 2023b.
279
+ Ma, X., Driggs-Campbell, K., and Kochenderfer, M. J. Improved robustness and safety for autonomous vehicle control with adversarial reinforcement learning. In 2018 IEEE Intelligent Vehicles Symposium (IV), pp. 1665-1671. IEEE, 2018.
280
+ Mazyavkina, N., Sviridov, S. V., Ivanov, S., and Burnaev, E. Reinforcement learning for combinatorial optimization: A survey. Comput. Oper. Res., 134:105400, 2020.
281
+ Mehta, A. Online matching and ad allocation. Foundations and Trends in Theoretical Computer Science, 8(4):265-368, 2013.
282
+ Mehta, A. and Panigrahi, D. Online matching with stochastic rewards. In 2012 IEEE 53rd Annual Symposium on Foundations of Computer Science, pp. 728-737. IEEE, 2012.
283
+ Mehta, A., Saberi, A., Vazirani, U. V., and Vazirani, V. V. Adwords and generalized on-line matching. 46th Annual IEEE Symposium on Foundations of Computer Science (FOCS'05), pp. 264-273, 2005.
284
+ Mehta, A., Waggoner, B., and Zadimoghaddam, M. Online stochastic matching with unequal probabilities. In Proceedings of the twenty-sixth annual ACM-SIAM symposium on Discrete algorithms, pp. 1388-1404. SIAM, 2014.
285
+
286
+ Nazari, M., Oroojlooy, A., Snyder, L., and Takác, M. Reinforcement learning for solving the vehicle routing problem. Advances in neural information processing systems, 31, 2018.
287
+ Pinto, L., Davidson, J., Sukthankar, R., and Gupta, A. K. Robust adversarial reinforcement learning. In International Conference on Machine Learning, 2017.
288
+ Purohit, M., Svitkina, Z., and Kumar, R. Improving online algorithms via ml predictions. In Neural Information Processing Systems, 2018.
289
+ Shao, Z., Yang, J., Shen, C., and Ren, S. Learning for robust combinatorial optimization: Algorithm and application. In IEEE INFOCOM 2022-IEEE Conference on Computer Communications, pp. 930-939. IEEE, 2022.
290
+ Spooner, T. and Savani, R. Robust market making via adversarial reinforcement learning. arXiv preprint arXiv:2003.01820, 2020.
291
+ Vinitsky, E., Du, Y., Parvate, K., Jang, K., Abbeel, P., and Bayen, A. Robust reinforcement learning using adversarial populations. arXiv preprint arXiv:2008.01825, 2020.
292
+ Wang, S.-F., Li, J., and Wang, S. Online algorithms for multi-shop ski rental with machine learned advice. arXiv: Data Structures and Algorithms, 2020.
293
+ Wang, Y., Tong, Y., Long, C., Xu, P., Xu, K., and Lv, W. Adaptive dynamic bipartite graph matching: A reinforcement learning approach. In 2019 IEEE 35th international conference on data engineering (ICDE), pp. 1478-1489. IEEE, 2019.
294
+ Wei, A. and Zhang, F. Optimal robustness-consistency trade-offs for learning-augmented online algorithms. Advances in Neural Information Processing Systems, 33: 8042-8053, 2020.
295
+ Wu, T., Zhong, F., Geng, Y., Wang, H., Zhu, Y., Wang, Y., and Dong, H. Grasparl: Dynamic grasping via adversarial reinforcement learning. *ArXiv*, abs/2203.02119, 2022.
296
+ Yang, J., Li, P., Li, T., Wierman, A., and Ren, S. Anytime-competitive reinforcement learning with policy prior. In Thirty-seventh Conference on Neural Information Processing Systems, 2023.
297
+ Yang, Y. and Whinston, A. A survey on reinforcement learning for combinatorial optimization. ArXiv, abs/2008.12248, 2020.
298
+ Zhang, C., Song, W., Cao, Z., Zhang, J., Tan, P. S., and Chi, X. Learning to dispatch for job shop scheduling via deep reinforcement learning. Advances in Neural Information Processing Systems, 33:1621-1632, 2020a.
299
+
300
+ Zhang, K., Hu, B., and Basar, T. On the stability and convergence of robust adversarial reinforcement learning: A case study on linear quadratic systems. Advances in Neural Information Processing Systems, 33:22056-22068, 2020b.
301
+ Zuzic, G., Wang, D., Mehta, A., and Sivakumar, D. Learning robust algorithms for online allocation problems using adversarial training. arXiv preprint arXiv:2010.08418, 2020.
302
+
303
+ # A. Benchmark: Budgeted Allocation (BA) Problem
304
+
305
+ Formal definition of BA. Consider a bipartite graph $G(U \cup V, E)$ with $n$ vertices in $U$ and $m$ vertices in $v$ all known at the very beginning. For each $i \in [n]$ and each $j \in [m]$ , edge $(u_i, v_j)$ is associated with $p_{ij}$ . Compared to OMSR, $p_{ij}$ represents a weight instead of a probability over an edge. For each vertex $v_j$ , the algorithm has to assign it to one of its neighbors $u_i$ , and after that, $u_i$ gains a deterministic weight of $p_{ij}$ . The total weights gained by each $u_i$ are constrained to be no greater than 1. The objective of this problem is to maximize the total weights among all vertices in $U$ .
306
+
307
+ We address that BA is a proper benchmark for OMSR, basically because for any given instances, the expected solution of OMSR can be upper bounded by the optimal solution of BA. Readers may refer to Lemma 1 in Mehta & Panigrahi (2012) for details.
308
+
309
+ # B. Baselines
310
+
311
+ # B.1. Baselines for Hard Instances
312
+
313
+ Triangular graphs. If an instance $G = (U \cup V, E)$ is a triangular graph, it satisfies that $U = \{u_1, u_2, \dots, u_n\}$ , $V = V_1 \cup V_2 \cup \dots \cup V_n$ , and the neighbors of each online vertex in set $V_i$ is $\{u_i, u_{i+1}, \dots, u_n\}$ . The size of $V_i$ is randomly chosen from the set $\{k_1, k_1 + 1, \dots, k_2\}$ , where $k_1$ and $k_2$ are hyperparameters. The probabilities on edges associated with vertex in $V_i$ are $1 / |V_i|$ .
314
+
315
+ Thick-z graphs. If an instance $G = (U \cup V, E)$ is a thick-z graph, it satisfies that $U = \{u_1, u_2, \dots, u_{2n}\}$ , $V = V_1 \cup V_2 \cup \dots \cup V_{2n}$ , the neighbors of each online vertex in the first $n$ set $V_i, i \in [n]$ is $\{u_i\} \cup \{u_{n+1}, u_{n+2}, \dots, u_{2n}\}$ , and the vertex in the last $n$ set $V_i, i \in (n, 2n]$ has only one neighbor $u_i$ . The size of $V_i$ is randomly chosen from the set $\{k_1, k_1 + 1, \dots, k_2\}$ , where $k_1$ and $k_2$ are hyperparameters. The probabilities on edges associated with vertices in $V_i$ are $1 / |V_i|$ .
316
+
317
+ Random graphs. We used a random graph generator to generate some random graphs. For a graph $G = (U \cup V, E)$ with $U = \{u_1, u_2, \dots, u_{2n}\}$ and $V = V_1 \cup V_2 \cup \dots \cup V_{2n}$ , the generator first determines the edge set $E$ . For each pair $(u, V)$ , the generator determines whether all edges $(u, v)$ , $v \in V$ , should be included in $E$ , with a probability of 0.5. The size of $V_i$ is randomly chosen from the set $\{k_1, k_1 + 1, \dots, k_2\}$ , where $k_1$ and $k_2$ are hyperparameters. The probabilities on edges associated with vertices in $V_i$ are $1 / |V_i|$ .
318
+
319
+ Hard-instances in MP12 (Mehta & Panigrahi, 2012). The hard-instances $G = (U \cup V, E)$ in MP12 satisfies that $U = \{u_1, u_2, \dots, u_n\}$ , $V = V_1 \cup V_2 \cup \dots \cup V_n$ , and the neighbors of each online vertex in set $V_i$ is $\{u_i, u_{i+1}, \dots, u_n\}$ . Choose value $k$ from the set $\{k_1, k_1 + 1, \dots, k_2\}$ , where $k_1$ and $k_2$ are hyperparameters, and set sizes of $V_i, i \in [n]$ as $k$ . The probabilities on all edges are $1 / k$ .
320
+
321
+ # B.2. Baselines for Robust Algorithms: Balance
322
+
323
+ Balance (Equal Probability). On the arrival of each online vertex $v_{j} \in V$ , Balance matches it to the available neighbor with the least failure attempts, breaking ties arbitrarily. Huang & Zhang (2020) prove Balance achieves 0.576-competitive under the small-probability assumption.
324
+
325
+ Generalized-Balance (Unequal Probability). In this case, success probabilities vary on edges, meaning that each edge contributes differently to the marginal gains of the offline vertex. Instead of the number of failure attempts, Generalized-Balance uses a similar indicator, total success probabilities on edges matched to an offline vertex, named as load $L_{i}$ of an offline vertex $u_{i}$ . On the arrival of each online vertex $v_{j} \in V$ , match it to the available neighbor $u_{i^{\star}}$ with $i^{\star} = \arg \max_{1 \leq i \leq |U|} p_{ij}(1 - g(L_{i}))$ , where $g:[0,1] \to [0,1]$ is a monotonic non-decreasing function, and break ties arbitrarily. Readers may easily verify when all $p_{ij} = p$ , it reduces to the algorithm in equal probabilities case. Generalized-Balance can achieve 0.572-competitive under the small-probability assumption.
326
+
327
+ # C. Omitted proofs
328
+
329
+ # C.1. Proof of Lemma 3.5
330
+
331
+ For each offline vertex $u \in U$ , let the load $L_{u}$ denote the total success probabilities on edges matched to $u$ . The insight and details on the load definition are in Appendix B.2. $L_{u}$ is capped by 1. To better capture the stochastic rewards in our analysis, we change the objective of this problem from maximizing the expected number of successful offline vertices to maximizing the total loads by Lemma C.1.
332
+
333
+ Lemma C.1. For any algorithm running on $\mathcal{G}_n$ , the expected load on a vertex $u$ is equal to its probability of success.
334
+
335
+ Proof. Let $x_{uv}$ be the random variables that if the algorithm matches $u$ to $v$ , set $x_{uv} = 1$ ; and otherwise, set $x_{uv} = 0$ . Recall all probabilities on the edges are equal to $p$ and $p \to 0$ . The expected load on $u$ by definition is $\mathbb{E}[L_u] = \sum_{v \in V} p \cdot \mathbb{E}[x_{uv}]$ . For a specific matching assignments $x_u = (x_{u1}, \dots, x_{um})$ , the probability that $u$ succeeds is $1 - \prod_{v \in V} (1 - p \cdot x_{uv}) = 1 - \exp(\sum_{v \in V} (-p \cdot x_{uv}) = 1 - (-p \cdot \sum_{v \in V} x_{uv} + 1) = p \cdot \sum_{v \in V} x_{uv} (p \to 0)$ . Therefore, the probability that $u$ succeeds under the matching assignments produced by algorithm is that $\mathbb{E}[p \cdot \sum_{v \in V} x_{uv}] = \sum_{v \in V} p \cdot \mathbb{E}[x_{uv}] = \mathbb{E}[L_u]$ .
336
+
337
+ The next two lemmas show the key property to prove the optimality and how Balance performs with this property on $\mathcal{G}_n$ .
338
+
339
+ Let $N_{i}$ denote the shared neighbors of vertices in $V_{i}$ .
340
+
341
+ Lemma C.2. There exists an optimal algorithm on $\mathcal{G}_n$ that equally distributes the load of each group $V_{i}$ among all $V_{i}$ 's neighbors.
342
+
343
+ Proof. Configure a set partition process. During the execution of the algorithm, it partitions the offline vertex set into a family of subsets $\mathbb{S}$ . Initially, set $\mathbb{S} = \{U\}$ . When the first group of online vertices $V_{1}$ arrives, $N_{1} \subseteq U$ . At this time, partition $U$ to $N_{1}$ and $U \setminus N_{1}$ , and replace $U$ with non-empty set $N_{1}$ and $U \setminus N_{1}$ in $\mathbb{S}$ . For the algorithm, since $L_{u}$ for all $u$ are equal to zero, these offline vertices are identical to the algorithm.
344
+
345
+ Suppose that algorithm (unequally) distributes the load increment $\ell_1, \dots, \ell_{|N_1|}$ for each offline vertices, and $\ell_{\pi(1)} \leq \dots \leq \ell_{\pi(|N_1|)}, \ell_{\pi(1)} < \ell_{\pi(|N_1|)}$ , where $\pi$ is a permutation of $|N_1|$ . If this assignment is better than equal distribution, this means there exists at least one offline vertex that accommodates more load. W.l.o.g., assume that this vertex is $\pi(1)$ . Let $\bar{\ell}$ denote the load increment when equally distributing the load, and inequality $\ell_{\pi(1)} < \bar{\ell} < \ell_{\pi(|N_1|)}$ holds. Thus, if $\pi(1)$ can accommodate more load, the load increment of $L_{\pi(1)}$ by the unrevealed arrivals is greater than $1 - \bar{\ell}$ , since $L_{\pi(1)}$ is capped by 1. But the input is adversarial, imagine there is an adversary who reveals the online vertices according to the previous assignments made by the algorithm. Thus, the adversary can rearrange the order of offline vertices in $N_1$ for the unrevealed vertices, because these vertices in $N_1$ are identical. So, the input can be modified as swapping vertices $\pi(1)$ and $\pi(|V_1|)$ . At this time, future increment of the load has to be $1 - \ell_{\pi(|N_1|)} < 1 - \bar{\ell}$ . The result is worse than equally distributing the load. By contradiction, we show that equally distributing the load of $V_i$ is optimal. Further, after the assignment of $V_i$ , the vertices in $N_1$ have the same load $\bar{\ell}$ .
346
+
347
+ When the $i$ -th group of online vertices $V_{i}$ arrives, by Definition 3.2, there exists $S \in \mathbb{S}$ , such that $N_{i} \subseteq S$ . It also partitions $N_{i}$ to $N_{i}$ and $S \setminus N_{i}$ , and replace $S$ with non-empty set $N_{i}$ and $S \setminus N_{i}$ in $\mathbb{S}$ . For the algorithm, the vertices in $N_{i}$ all have the same load. Therefore, it is optimal for the algorithm to distribute the load equally based on the previous analysis. This completes the proof by induction on $i$ .
348
+
349
+ Lemma C.3. When Balance runs on $\mathcal{G}_n$ , it equally distributes the load of each group $V_{i}$ among all $V_{i}$ 's neighbors.
350
+
351
+ Proof. Configure the same set partition process in the proof of Lemma C.2. When the first group of online vertices $V_{i}$ arrives, the loads of all the vertices are equal to 0. Since Balance matches each online vertices to the neighbor with the lowest load, and $|V_{i}| = 1 / p, p \to 0$ , it distributes the load from $V_{1}$ to all its neighbors equally. When the $i$ -th group of online vertices $V_{i}$ arrives, the set $S \in \mathbb{S}$ , such that $N_{i} \subseteq S$ , the vertices in $N_{i}$ also has the same load, so Balance equally distributes the load of $V_{i}$ . This completes the proof by induction on $i$ .
352
+
353
+ Lemma C.2 and Lemma C.3 complete the proof of Lemma 3.5.
354
+
355
+ # C.2. Proof of Lemma 3.6
356
+
357
+ Recall $G_3^\star$ in Figure 5, and $G_3^\star$ satisfies the symmetry property.
358
+
359
+ We first calculate the expected number of successful matchings of the Balance algorithm on $G_3^\star$ , i.e. $\mathsf{ALG}(G_3^\star)$ . Consider the instance $G_1^\star \in \mathcal{G}_1$ where there is only one offline vertex $u_1$ and one set of online vertices $V_1$ in which vertices are connected to $u_1$ , with equal probability $p \to 0$ . Let $k = 1 / p$ . In this case, each vertex in $V_1$ tries to get matched with $u_1$ , so $u_1$ success with probability $1 - (1 - p)^k = 1 - (1 - 1 / k)^k = 1 - 1 / e$ ( $k \to \infty$ ). Thus, the expected number of successes for $G_1^\star$ is $1 - 1 / e$ .
360
+
361
+ For $G_3^*$ , we calculate the expected number of successes in 8 cases corresponding to the outcomes of vertices in $V_1$ . Let $U^{\star}$ be a subset of $\{u_1, u_2, u_3\}$ , and denote the set of offline vertices that get matched to a vertex in $V_1$ successfully.
362
+
363
+ These 8 cases are listed below according to the vertices in set $U^{\star}$
364
+
365
+ 1. $|U^{\star}| = 0$ . There is one subcase with no success in $\{u_1, u_2, u_3\}$ , i.e. $U^{\star} = \varnothing$ , and this happens with probability $(1 - p)^k = 1 / e$ ; in this case, the expected number of successes overall is the same as double that for $G_1^{\star}$ , i.e. $2(1 - 1 / e)$ .
366
+ 2. $|U^{\star}| = 1$ . This case happens with probability $\binom{k}{1} \cdot p(1-p)^{k-1} = 1/e$ . There are three subcases with equal probability:
367
+
368
+ (a) $U^{\star} = \{u_{1}\}$ . This happens with probability $1 / (3e)$ ; in this case, the expected number of successes for $V_{2}$ and $V_{3}$ is the same as that for $G_{1}^{\star}$ , i.e. $2(1 - 1/e)$ ; Therefore, the expected number of successes overall is $3 - 2/e$ .
369
+ (b) $U^{\star} = \{u_{2}\}$ . This happens with probability $1 / (3e)$ ; in this case, the expected number of successes for $V_{2}$ and $V_{3}$ is $1 - 1/e$ , since no vertex in $V_{2}$ can be matched. Therefore, the expected number of successes overall is $2 - 1/e$ .
370
+ (c) $U^{\star} = \{u_{3}\}$ . This case is similar to last subcase, so the expected number of successes overall is $2 - 1 / e$ .
371
+
372
+ 3. $|U^{\star}| = 2$ . This case happens with probability $\binom{k}{2} \cdot p^{2}(1 - p)^{k-2} = 1/(2e)$ . There are three subcases with equal probability:
373
+
374
+ (a) $U^{\star} = \{u_{1}, u_{2}\}$ . This happens with probability $1 / (6e)$ ; in this case, the expected number of successes for $V_{2}$ and $V_{3}$ is $1 - 1 / e$ ; Therefore, the expected number of successes overall is $3 - 1 / e$ .
375
+ (b) $U^{\star} = \{u_{1},u_{3}\}$ . This case is the same as last subcase, so the expected number of successes overall is $3 - 1 / e$ .
376
+ (c) $U^{\star} = \{u_{2}, u_{3}\}$ . This happens with probability $1 / (6e)$ ; in this case, the number of successes overall is 2.
377
+
378
+ 4. $|U^{\star}| = 3$ . In this case, $U^{\star} = \{u_{1}, u_{2}, u_{3}\}$ happens with probability $1 - 5 / (2e)1 - 5 / (2e)$ ; in this case, the number of successes overall is 3.
379
+
380
+ Combining the above, the expected number of successes overall is $3(1 - 11 / (18e) - 11 / (9e^2))$ . Therefore, the competitive ratio of $G_3^\star$ is $1 - 11 / (18e) - 11 / (9e^2) < 0.61$ . That is, Balance achieves 0.61-competitive on $G_3^\star$ .
381
+
382
+ Finally, together with Lemma 3.5 where Balance is optimal on $G_3^\star$ , the proof is completed.
383
+
384
+ # C.3. Proof of Theorem 3.3
385
+
386
+ We illustrate the worst-case instances $G_{n}^{\star}, n \in \{4, 5, 6, 7\}$ corresponding to the values in Table 2 in Figure 10. By Lemma 3.5, it is sufficient to compute the competitive ratio of the Balance algorithm on graph $G_{7}^{\star}$ , which is 0.597.
387
+
388
+ Because $\mathsf{OPT}(G_7^*) = 7$ , the ratio of $G_7^*$ is $\frac{1}{7}\mathsf{ALG}(G_7^*)$ . We calculate the expected number of success matches on $G_7^*$ (i.e. $\mathsf{ALG}(G_7^*)$ ) in the rest of this section. We use a dynamic programming approach for the calculation, rather than what we do in the proof of Lemma 3.6.
389
+
390
+ Let $H_{i}, i \in [7]$ denote the set of offline vertices, which successfully match the online vertices in $V_{i}$ .
391
+
392
+ Thus,
393
+
394
+ $$
395
+ \mathbf {A L G} \left(G _ {7} ^ {\star}\right) = \sum_ {i = 1} ^ {7} \mathbb {E} \left[ | H _ {i} | \right] = \mathbb {E} \left[ \sum_ {i = 1} ^ {7} | H _ {i} | \right]. \tag {2}
396
+ $$
397
+
398
+ ![](images/f780e58a1998e2235801a8eb76a6a65387269ecbe07defddb417a8dfe75c4b56.jpg)
399
+
400
+ ![](images/21b3dc7d9b9e39b2e6ca750d653773aff7b9abba6e6e17ae5f1c7d57b09aa792.jpg)
401
+
402
+ ![](images/33552bb29999aed742448d2a2ea570ab84f37e58812de9d7921bbf0d0b2ddd6c.jpg)
403
+
404
+ ![](images/21ab0b64da11bb77951d5ca7f8ea64bc79199ef539eb11f11ca39d70ac946399.jpg)
405
+ Figure 10. $G_{n}^{\star}, n = 4,5,6,7$ from left to right with $|U| = n$ and $|V| = kn$ , where $k = 1 / p$ and $p \to 0$ . To simplify the illustration, we use a single node to represent the online vertex set $V_{i}, i \in [n]$ , with the edges representing the edges between all vertices in the online vertex sets and the offline vertices, since online vertices have the same neighbors.
406
+
407
+ As $H_{i}, i > 1$ depends on $H_{1}$ , rephrase the expectation expression as a conditional expectation with respect to $H_{1}$ :
408
+
409
+ $$
410
+ \begin{array}{l} \mathbb {E} \left[ \sum_ {i = 1} ^ {7} \left| H _ {i} \right| \right] = \sum_ {h _ {1}} \Pr \left[ h _ {1} \right] \mathbb {E} \left[ \sum_ {i = 1} ^ {7} \left| H _ {i} \right| \mid H _ {1} = h _ {1} \right] (3) \\ = \sum_ {h _ {1}} \Pr [ h _ {1} ] \left(| h _ {1} | + \mathbb {E} \left[ \sum_ {i = 2} ^ {7} | H _ {i} | \mid H _ {1} = h _ {1} \right]\right). (4) \\ \end{array}
411
+ $$
412
+
413
+ $H_{i}, i > 2$ also depends on $H_{2}$ , so rephrase the factor of $\mathbb{E}\left[\sum_{i=2}^{7}|H_{i}|\Big|H_{1}=h_{1}\right]$ in Eqn.(4):
414
+
415
+ $$
416
+ \begin{array}{l} \mathbb {E} \left[ \sum_ {i = 2} ^ {7} | H _ {i} | \Bigg | H _ {1} = h _ {1} \right] = \sum_ {h _ {2}} \Pr [ h _ {2} | H _ {1} = h _ {1} ] \mathbb {E} \left[ \sum_ {i = 2} ^ {7} | H _ {i} | \Bigg | H _ {1} = h _ {1}, H _ {2} = h _ {2} \right] (5) \\ = \sum_ {h _ {2}} \Pr \left[ h _ {2} \mid H _ {1} = h _ {1} \right] \left(\left| h _ {2} \right| + \mathbb {E} \left[ \sum_ {i = 3} ^ {7} \left| H _ {i} \right| \Bigg | H _ {1} = h _ {1}, H _ {2} = h _ {2} \right]\right). (6) \\ \end{array}
417
+ $$
418
+
419
+ For Eqn.(6), the value of conditional expectation $\mathbb{E}\left[\sum_{i=3}^{7}|H_i|\Big|H_1 = h_1, H_2 = h_2\right]$ only depends on the number of remaining vertices in the set $\{u_3, u_4, \dots, v_7\}$ after the occurrence of $H_1$ and $H_2$ .
420
+
421
+ Thus, let $f_{1}(k)$ represent conditional expected value when there has $k$ vertices remaining in the set $\{u_{3}, u_{4}, \dots, v_{7}\}$ (after $h_{1}$ and $h_{2}$ ). Then we have
422
+
423
+ $$
424
+ f _ {1} (k) = k \cdot \operatorname {A L G} \left(G _ {1} ^ {\star}\right) = k \left(1 - \frac {1}{e}\right). \tag {7}
425
+ $$
426
+
427
+ To calculate Eqn.(6), it needs to compute the value of $\operatorname*{Pr}[h_2|H_1 = h_1]$ . We define $p_i^{(n)}$ as follows, and recall that $k\to \infty$ is the size of $V_{i}$
428
+
429
+ $$
430
+ p _ {i} ^ {(n)} = \left\{ \begin{array}{l l} {\binom {k} {i}} p ^ {i} (1 - p) ^ {k - i} = \frac {1}{i ! \cdot e} & i < n, \\ 1 - \sum_ {i = 0} ^ {n - 1} p _ {i} & i = n. \end{array} \right. \tag {8}
431
+ $$
432
+
433
+ Therefore,
434
+
435
+ $$
436
+ \Pr \left[ h _ {2} \mid H _ {1} = h _ {1} \right] = \frac {p _ {\left| h _ {2} \right|} ^ {(7 - \left| h _ {1} \right|)}}{\binom {7 - \left| h _ {1} \right|} {h _ {2}}}. \tag {9}
437
+ $$
438
+
439
+ Let $f_{2}(j,k)$ represent the conditional expected value when $u_{2}$ is matched $(j = 0)$ or unmatched $(j = 1)$ and the set $\{u_{3},u_{4},\dots ,v_{7}\}$ has $k$ vertices remaining after $h_1$ . From Eqn.(7), (8) and (9), we rephrase Eqn.(6) using $f_{2}$
440
+
441
+ $$
442
+ f _ {2} (J, K) = \sum_ {j = 0} ^ {J} \sum_ {k = 0} ^ {K} \frac {p _ {j + k} ^ {(J + K)}}{\binom {J + K} {j + k}} \cdot \binom {K} {k} \cdot (j + k + f _ {1} (K - k)). \tag {10}
443
+ $$
444
+
445
+ We calculate the values of $f_{2}(j,k)$ and present them in Table 4.
446
+
447
+ Table 4. The values of function ${f}_{2}\left( {j,k}\right)$ when $j = 0,1$ and $k = 0,1,\cdots ,5$ .
448
+
449
+ <table><tr><td>f2(j,k)</td><td>k=0</td><td>k=1</td><td>k=2</td><td>k=3</td><td>k=4</td><td>k=5</td></tr><tr><td>j=0</td><td>0</td><td>1-e-2</td><td>2-3e-2</td><td>3-11/2e2</td><td>4-49/6e2</td><td>5-87/8e2</td></tr><tr><td>j=1</td><td>1-1/e</td><td>2-3/2e-3/2e2</td><td>3-11/6e-11/3e2</td><td>4-49/24e-49/8e2</td><td>5-87/40e-87/10e2</td><td>6-1631/720e-1631/144e2</td></tr></table>
450
+
451
+ Remarks. $\mathsf{ALG}(G_3^\star) = f_2(1,2) = 3 - \frac{11}{6e} -\frac{11}{3e^2}$ , and $\mathsf{ALG}(G_4^\star) = f_2(1,3) = 4 - \frac{49}{24e} -\frac{49}{8e^2}$ . Thus, the competitive ratio of Balance on $G_{4}^{\star}$ is $\frac{\mathsf{ALG}(G_4^{\star})}{\mathsf{OPT}(G_4^{\star})} = \frac{1}{4} (4 - \frac{49}{24e} -\frac{49}{8e^2})\approx 0.605$ .
452
+
453
+ Let $f_{3}(i,j,k)$ represent the conditional expected value when $u_{1}$ is matched $(i = 0)$ or unmatched $(i = 1)$ and $u_{2}$ is matched $(j = 0)$ or unmatched $(j = 1)$ and the set $\{u_3,u_4,\dots ,v_7\}$ has $k$ vertices remaining. From Eqn.(4), we have
454
+
455
+ $$
456
+ f _ {3} (I, J, K) = \sum_ {i = 0} ^ {I} \sum_ {j = 0} ^ {J} \sum_ {k = 0} ^ {K} \frac {p _ {i + j + k} ^ {(I + J + K)}}{\binom {I + J + K} {i + j + k}} \cdot \binom {K} {k} \cdot (i + j + k + f _ {2} (J - j, K - k)). \tag {11}
457
+ $$
458
+
459
+ We calculate the values of $f_{3}(i,j,k)$ and present part of them in Table 5.
460
+
461
+ Table 5. The values of function ${f}_{3}\left( {i,j,k}\right)$ when $i = j = 1$ and $k = 0,1,\cdots ,5$ .
462
+
463
+ <table><tr><td>k</td><td>f3(1,1,k)</td></tr><tr><td>0</td><td>2 - 3/2e - 3/2e2</td></tr><tr><td>1</td><td>1/6e3(-15 - 15e - 11e2 + 18e3)</td></tr><tr><td>2</td><td>1/24e3(-164 - 82e - 49e2 + 96e3)</td></tr><tr><td>3</td><td>1/40e3(-498 - 166e - 87e2 + 200e3)</td></tr><tr><td>4</td><td>1/720e3(-13536 - 3384e - 1631e2 + 4320e3)</td></tr><tr><td>5</td><td>1/5040e3(-128680 - 25736e - 11743e2 + 35280e3)</td></tr></table>
464
+
465
+ The expected number of successes of $G_7^\star$ is $f_3(1, 1, 5)$ . Therefore, Balance achieves competitive ratio of $\frac{1}{7} f_3(1, 1, 5) \approx 0.597$ on $G_7^\star$ .
466
+
467
+ Remarks. Using the values of function $f_{3}$ , we can obtain the competitive ratio of Balance on $G_{5}^{\star}$ and $G_{6}^{\star}$ , which are $\frac{1}{5} f_{3}(1,1,3) \approx 0.604$ and $\frac{1}{6} f_{3}(1,1,4) \approx 0.599$ , respectively. In addition, we can also obtain the competitive ratio of Balance on $G_{3}$ in (Mehta & Panigrahi, 2012), which is $\frac{1}{3} f_{3}(1,1,1) \approx 0.621$ .
468
+
469
+ # D. Agent alg Setup
470
+
471
+ # D.1. MDP Formulation
472
+
473
+ Recall that the input instance is a probability matrix $\mathcal{P}$ sampled from $\pi$ . In general, alg reads $\mathcal{P}$ column-by-column, and takes an action at state $s_j$ to match $v_j$ to which neighbor. We first highlight the main differences in OMSR to the RL agents for other OBM problems:
474
+
475
+ 1. To achieve robustness, in the environment, all distributions learned by adv from previous iterations will be taken into consideration with a discounted factor, as well as a mixture of a random distribution.
476
+ 2. In the construction of state space, besides the current graph patterns, i.e., the partial $\mathcal{P}$ , we involve another observation: the number of failure attempts for each offline vertex, denoted by a vector $L$ of size $n$ . The main reason comes from the idea behind Balance: fewer failure attempts bring a larger marginal gain in success probability.
477
+ 3. Because of the endogenous randomness from OMSR, i.e., a matching is successful with a certain probability $p$ , special treatments are necessary: (1) an indicator on whether each offline vertex is successful must be observed in state space; (2) the transition is random. Different states will be observed according to whether the matching taken by an action is successful; (3) positive rewards are only given to successful matchings.
478
+
479
+ Environment. Suppose this is $(T + 1)$ -th iteration of training. Environment samples instances over a distribution $\pi$ given by: with probability $\frac{\beta\gamma^{k - i}}{\sum_{j = 0}^{k - 1}\gamma^j}$ sampled from $\pi_k$ ; with probability $1 - \beta$ sampled from a random distribution $\pi_{\mathrm{rand}}$ , where $\pi_k, k \in [T]$ represents the policy distribution learned by adv in $k$ -th iteration, and $\beta, \gamma$ are hyperparameters.
480
+
481
+ State Space. At timestep $j$ , online vertex $v_{j}$ arrives with the $j$ -th column $\mathcal{P}_{[:,j]}$ of $\mathcal{P}$ . A state $s_{j}$ consists of $\mathcal{P}_{[:,j]}$ and two vectors of size $n$ towards $n$ offline vertices: $L$ for the number of previous failure attempts and $w$ for whether each offline vertex is successful or not. A terminal state $\hat{S}$ is reached when the complete $\mathcal{P}$ is revealed. The length of an episode is $T = m$ .
482
+
483
+ Action space. An action $a_{j} \in A_{j}$ is a vector of size $n + 1$ , with only one component set as 1 and $n$ components set 0, indicating that which neighbor is matched to $v_{j}$ or leaving $v_{j}$ unmatched.
484
+
485
+ Transition. $s_j$ is transited to $s_{j+1}$ with probability $p$ if $a_j$ produces a successful matching, and to $s_{j+1}'$ with probability $1 - p$ otherwise. $s_{j+1}$ and $s_{j+1}'$ differ in vectors $L$ and $w$ .
486
+
487
+ Reward. Reward $r_{a_j}$ is set as 1 if $a_j$ produces a successful matching, and 0 otherwise.
488
+
489
+ Policy. A stochastic policy $\pi(a_j|s_j)$ outputs a distribution over the actions in $A_j$ , yielding an expected return $Q_{\pi}(s_j, a_j)$ which represents the expected future return obtained by taking action $a_j$ in state $s_j$ .
490
+
491
+ # D.2. Training Algorithm
492
+
493
+ We use a simple DQN algorithm. Our model is a feed-forward neural network with two hidden layers and ReLU for non-linearity. The first layer contains $3n + 2$ neurons and the second contains $2^{n + 3}$ neurons. We set a fixed learning rate of $10^{-3}$ for the Adam optimizer and a batch size of $N_{\mathrm{batch}} = 16$ . For $\epsilon$ -greedy, we set $\epsilon = 0.2$ .
494
+
495
+ # D.3. Training for Unequal Probability Case
496
+
497
+ The training details for the algorithm agent in this case are consistent with the MDP formulation in Section 4. So we only discuss the differences in the adversary agent. Note that the equal probability case is a special case of the unequal probability case.
498
+
499
+ Recall that in OMSR, the input instance is a matrix $\mathcal{P}_{n\times m}$ for $n$ offline vertices and $m$ online vertices. The difference between the MDP in Section 3 and that in this case is that the values in the matrix $\mathcal{P}$ are not only $p$ or 0, but are randomly selected. We typically randomly select a value $k$ from the set $\{k_1,k_1 + 1,\dots ,k_2\}$ , and set the probability of the edge to be $1 / k$ or set the probability to be 0. $k_{1}$ and $k_{2}$ are hyperparameters. When $k_{1} = k_{2}$ , this special case corresponds to the equal probability case. The details of MDP formulation are presented as follows.
500
+
501
+ Environment. The current matching policy defined by a1g, and a calculator on CR.
502
+
503
+ State Space. A state $s_j$ at a timestep $j$ is the current (partial) matrix of $\mathcal{P}$ , i.e. $\mathcal{P}_{[;1:j-1]}$ . A terminal state $\hat{S}$ is reached when a complete $\mathcal{P}$ is generated. The length of an episode is $T = m$ .
504
+
505
+ Action space. At state $s_j$ , an action $a_j \in A_j$ taken by adv is to determine the probabilities in the $j$ -th row. It selects a value in $\{0, 1/k_1, 1/(k_1 + 1), \dots, 1/k_2\}$ , and sets it as $p_{ij}$ . The size of action space $|A_j|$ is $(k_2 - k_1 + 2)^n$ .
506
+
507
+ Transition. The transition from state $s_j$ to the next state $s_{j+1}$ is deterministic. If action $a_j$ is taken, the $j$ -th column in matrix $\mathcal{P}$ is updated and moves on to the next episode step, $j + 1$ .
508
+
509
+ Reward. If an episode ends, all taken actions will receive a reward of $1 - \mathrm{CR}$ , where CR is the competitive ratio of the current algorithm environment running on the generated instance.
510
+
511
+ Policy. At state $s_j$ , a stochastic policy $\pi(a_j | s_j)$ outputs a distribution on $(k_2 - k_1 + 2)^n$ cases.
512
+
513
+ # E. Supplementary Experiments
514
+
515
+ We present more empirical evaluations of the trained hard instances and robust algorithms to demonstrate the effectiveness of our framework. Our codes are given in the supplementary material.
516
+
517
+ # E.1. Experiments for Hard Instances Validation
518
+
519
+ The performance of algorithms on the worst-case instances in different iterations. In the equal probability case, we evaluate the performance of the learned algorithms in each iteration, against the corresponding outputs of the adversary agent. We compare these results to our baseline: Balance to show how Balance performs on these hard instances. In Figure 11, we plot the average competitive ratios as a function of the (equal) probability $p$ on edges in each iteration. In general, the learned algorithms perform similarly to the Balance algorithm when $p < 0.5$ . However, when $p > 0.5$ , the learned algorithms significantly outperform Balance. As the number of iterations increases, the curves become smoother, and if fix $p$ , the performance of algorithms get worse. This indicates that adv can generate hard instances in iterative training. Note that, as $p$ tends to 1, Balance performs poorly under the outputs of adv with only 0.5-competitive. This also indicates that adv can learn worst-case instances for alg, since if $p = 1$ , OBSR reduces to OBM, Balance is known to perform bad.
520
+
521
+ ![](images/009c5b27cbf7a81c4a268a84207be20ec8aac99a27effc6ce5eaef585585a1b5.jpg)
522
+ Figure 11. The average CRs of learned algorithms and Balance under the worst-case distributions in each iteration, with $m = n / p$ varying on $p$ .
523
+
524
+ The performance of algorithms on known worst cases. To see the performances of Balance and our algorithms (from training iterations 1 to 10) on the worst instances given in both MP12 (Mehta & Panigrahi, 2012) (their $G_{3}$ and $G_{4}$ ) and this paper ( $G_{6}^{*}$ and $G_{7}^{*}$ in Figure 10). Figure 12 plots the results. The algorithm learned by alg can converge to optimal CRs on these instances. It shows that the worst-case instances generated by adv make the algorithm perform worse than other known hard instances.
525
+
526
+ ![](images/b99a128f7b1e8ada1721411357d3b298d9f7c480134cb577725dbca6f96a62d7.jpg)
527
+ Figure 12. The CRs of learned algorithms from iteration 0 to 10 running on some specific worst-case instances. As a comparison, the dashed line represents the CR of Balance.
528
+
529
+ # E.2. Experiments for Robust Algorithms Evaluation
530
+
531
+ The performance of algorithms on baselines. We take experiments and evaluations on some instances which are well known to be hard for OBM and related problems, including triangular graphs and thick-z graphs. We also test the average performance on some randomly generated instances. These instances are formally defined in Appendix B.1.
532
+
533
+ We test the learned algorithm in each iteration $T$ on the triangular graphs. Figure 13 plots the average CRs as a function of iteration $T$ , in both equal and unequal cases.
534
+
535
+ ![](images/4eac3070b813ee3a832d4d6815f1ee150f1c52a169b9173655d63ab61698a3a1.jpg)
536
+ Figure 13. The average CRs of algorithms on triangular graphs in iteration 0 to 10. The curve plots the CR as a function of the iteration $T$ . As a comparison, the dashed line represents the CR of Balance (0.623 for equal and 0.615 for unequal).
537
+
538
+ We test the learned algorithm in each iteration $T$ on the thick-z graphs. Figure 14 plots the average CRs as a function of iteration $T$ , in both equal and unequal cases.
539
+
540
+ We test the learned algorithm in each iteration $T$ on the random graphs. Figure 15 plots the average CRs as a function of iteration $T$ , in both equal and unequal cases.
541
+
542
+ ![](images/348a682bec205b754d35280066642442ca4c69d026b3b0222b4517493d5e6949.jpg)
543
+ Figure 14. The average CRs of algorithms on thick-z graphs in iteration 0 to 10. The curve plots the CR as a function of the iteration $T$ . As a comparison, the dashed line represents the CR of Balance (0.619 for equal and 0.605 for unequal).
544
+
545
+ ![](images/5f32638cc2535685cdc463e1cac62700f5f7b9c1eb0a6e765da95a5ba28a1a77.jpg)
546
+
547
+ ![](images/b8bbf6b2ca56a2646fad3d68e266c394f81fce28925fe510b841a5d935f9f572.jpg)
548
+ Figure 15. The average CRs of algorithms on random graphs in iteration 0 to 10. The curve plots the CR as a function of the iteration $T$ . As a comparison, the dashed line represents the CR of Balance (0.857 for equal and 0.803 for unequal).
549
+
550
+ ![](images/059bb6cfdadf187615f51c2ab0dde44787f6526e979c955ab2b14f0f28f7247d.jpg)
onlinematchingwithstochasticrewardsprovablebetterboundviaadversarialreinforcementlearning/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bcb163784aa9b8e3f437dbe63996cc0f2658c98b92a43e5d6a81dc481642d3e7
3
+ size 744526
onlinematchingwithstochasticrewardsprovablebetterboundviaadversarialreinforcementlearning/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:129a16b51540eba8c16a495e0d2e24cecb54097d8b5ab758e516f091061b9bcd
3
+ size 1093761
onlinematrixcompletionacollaborativeapproachwithhottitems/0a50e4a0-0797-44d0-9e0c-d98a7b5bb11c_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c250bdc2813dc8871f39d6136a2da6a12e607026531e88ce3350b97ce51cabb8
3
+ size 237682
onlinematrixcompletionacollaborativeapproachwithhottitems/0a50e4a0-0797-44d0-9e0c-d98a7b5bb11c_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9dab950708254538fdb10cfbc66288f8e6c844961db1e3852fea339508662155
3
+ size 276946
onlinematrixcompletionacollaborativeapproachwithhottitems/0a50e4a0-0797-44d0-9e0c-d98a7b5bb11c_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:73ec2202404dfef3189e32de6da6dcd983a2987d512b36733feee9b893d828b4
3
+ size 747956
onlinematrixcompletionacollaborativeapproachwithhottitems/full.md ADDED
The diff for this file is too large to render. See raw diff
 
onlinematrixcompletionacollaborativeapproachwithhottitems/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5834392b07dd7a3c27f4f8d211da425ffd700e208b318edc8d822aaaac57abb4
3
+ size 711089
onlinematrixcompletionacollaborativeapproachwithhottitems/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee5936c80021b946707b688f30266c2f531011c5e65ed6bf60c34956191c5ae2
3
+ size 1947290
onlineresourceallocationwithnonstationarycustomers/1475aa41-d2b5-4316-9a16-58f2b5f808e1_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a2e9ed47033be708b718eda1b5a4b1a0fb5f0112b9110ebb6fc891b37f73164a
3
+ size 220444
onlineresourceallocationwithnonstationarycustomers/1475aa41-d2b5-4316-9a16-58f2b5f808e1_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ca66809939c7e249a7423662c53db4145ef961fe3259eb24f1b72856acd5b7f
3
+ size 248087
onlineresourceallocationwithnonstationarycustomers/1475aa41-d2b5-4316-9a16-58f2b5f808e1_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e9522bd3b65417bb36661dcf92e759d472dd1579a76145f67a14d873b2b422e9
3
+ size 693171
onlineresourceallocationwithnonstationarycustomers/full.md ADDED
The diff for this file is too large to render. See raw diff
 
onlineresourceallocationwithnonstationarycustomers/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:54a8011fb5e1f5b39feadc9a5238227c29533eec4f55d495a93b82aff6301104
3
+ size 1819798
onlineresourceallocationwithnonstationarycustomers/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f4ebc0b4655884f59f10c8cf9e18ca221866c90fc5958bf84c5b7e1cb94d3b35
3
+ size 1199464
onlinespeculativedecoding/d57a4a03-7165-4267-883a-fb27ae603b12_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:50b5b063d896119358b0e712976ee754569c546a9a49f7cfc3e106dba7935266
3
+ size 117378
onlinespeculativedecoding/d57a4a03-7165-4267-883a-fb27ae603b12_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:daba6603fff6639bb9c472a789044f953869c2b500b560ebc70e10abd4787d67
3
+ size 140705
onlinespeculativedecoding/d57a4a03-7165-4267-883a-fb27ae603b12_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:793073b8121366e68468ca08a5946855a971b504d1a9ec916c702ad0eaebc052
3
+ size 2323975
onlinespeculativedecoding/full.md ADDED
@@ -0,0 +1,462 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Xiaoxuan Liu 1 Lanxiang Hu 2 Peter Bailis 3 Alvin Cheung 1 Zhijie Deng 4 Ion Stoica 1 Hao Zhang 2
2
+
3
+ # Abstract
4
+
5
+ Speculative decoding is a pivotal technique to accelerate the inference of large language models (LLMs) by employing a smaller draft model to predict the target model's outputs. However, its efficacy can be limited due to the low predictive accuracy of the draft model, particularly when faced with diverse text inputs and a significant capability gap between the draft and target models. We introduce online speculative decoding to address this challenge. The main idea is to continuously update the (multiple) draft model(s) on observed user query data. Adapting to query distribution mitigates the shifts between the training distribution of the draft model and the query distribution, enabling the draft model to more accurately predict the target model's outputs. We develop a prototype of online speculative decoding based on knowledge distillation and evaluate it using both synthetic and real query data. The results show a substantial increase in the token acceptance rate by 0.1 to 0.65, bringing $1.42 \times$ to $2.17 \times$ latency reduction. Our code is available at https://github.com/LiuXiaoxuanPKU/OSD.
6
+
7
+ # 1. Introduction
8
+
9
+ Large language models (LLMs) such as GPT-4 (OpenAI, 2023) and LLaMA (Touvron et al., 2023a;b) are rapidly reinventing today's applications. Many companies are racing to deploy LLMs in online services, such as search, chatbots, and virtual assistants. Since most of these services demand low latency, optimizing LLM serving latency directly translates into better quality of service and cost reduction.
10
+
11
+ The latency of today's LLM service is unfortunately very high, primarily because serving a user query requires multiple serial evaluations of the LLM, each generating only one
12
+
13
+ <sup>1</sup>UC Berkeley <sup>2</sup>UCSD <sup>3</sup>Google Inc. <sup>4</sup>SJTU. Correspondence to: Hao, Zhang <haozhang@ucsd.edu>, Zhijie, Deng <zhijied@sjtu.edu.cn>.
14
+
15
+ Proceedings of the $41^{st}$ International Conference on Machine Learning, Vienna, Austria. PMLR 235, 2024. Copyright 2024 by the author(s).
16
+
17
+ ![](images/c08c98fed5000404171f76d2e26448335f4f5bd71e0f52d86fab1906852da676.jpg)
18
+ Figure 1. Overview of online speculative decoding (OSD) framework: For each prompt, the draft model suggests multiple tokens and the target model performs the verification. If the student proposes incorrect tokens, both the draft and target distributions are stored in a buffer. Once the buffer exceeds a size limit or is too old, the draft model is updated by calculating the loss between the draft and target distributions using various distance metrics.
19
+
20
+ token of the response. An emerging solution to reduce the latency is speculative decoding (Leviathan et al., 2023)—it employs a small draft model to speculate multiple output tokens of the target (large) model, and then lets the target LLM verify these speculations in parallel. If the verification of a token fails, the large model must recompute from that point. Therefore, the performance of speculative decoding largely depends on the speculation accuracy of the draft model (also known as the token acceptance rate). In the presence of diverse text inputs, the accuracy of the speculations is often not very high, due to the capability gap between the draft and target models. Employing a larger, more accurate draft model, however, defeats the purpose of speculative decoding as it will increase latency.
21
+
22
+ To address this challenge, we introduce a novel method, online speculative decoding (OSD), to periodically finetune the draft model based on the corrections of the target model. OSD aims to reduce query latency while preserving the compact size of the draft model.
23
+
24
+ First, OSD employs knowledge distillation within speculative decoding to enhance the alignment between the draft and target models. Speculative decoding involves the draft model proposing potential tokens with their respective probability distributions. The target model then assesses these suggestions, correcting discrepancies to ensure that the outputs remain consistent with those produced without the draft model. This correction mechanism serves as an effective way for the draft model to assimilate and learn from this enriched information. Compared to conventional label finetuning, knowledge distillation offers a significant advantage
25
+
26
+ by providing a probability distribution for each token. By leveraging the insights from the teacher model (Gu et al., 2023), this method effectively aligns the draft and the target models.
27
+
28
+ Furthermore, instead of relying on a static draft model, we periodically update the draft model. This is because user queries to a specific LLM service often exhibit domain-specific distributions (Zheng et al., 2023a), reflecting shared usage patterns. While accurately speculating the larger model's outputs on any diverse input is challenging, it is feasible to enhance the draft model's prediction accuracy, only for similar inputs posted to the service, characterized by the query distribution. Updates can be implemented through several methods. One approach is to fine-tune the draft model in the background and then apply these updates in real-time after a predetermined period. Alternatively, one can leverage the excess computational capacity of the serving system while it is running, as detailed in § 4.2.2. Importantly, the real-time tuning of the draft models enables them to continuously adapt based on incoming query data. This dynamic approach is essential for preserving a high token acceptance rate, ensuring the model remains efficient and current with evolving data and trends.
29
+
30
+ Lastly, to further improve the token acceptance rate, OSD not only narrows the query distribution but also routes each query to the draft model best suited for that specific distribution. This is accomplished by developing draft models that are finely tuned to cater to distinct domains. Concentrating on a narrower query distribution has proven more effective for learning. Consequently, OSD efficiently directs queries to the corresponding draft model that specializes in their domain. As evidenced in § 5.2 of our evaluation, we have adeptly trained multiple draft models, each uniquely tailored to distinct languages or topics. This method highlights the significant potential for improved efficiency and accuracy when dealing with a diverse range of queries.
31
+
32
+ In summary, this paper makes the following contributions:
33
+
34
+ - We explore various generalized knowledge distillation (GKD) methods for constructing draft models and identify the most effective variants (Section 4.1).
35
+ - We introduce online speculative decoding to reduce LLM serving latency by adapting draft models on the fly (§ 4.2).
36
+ - We investigate draft model customization for speculative decoding, wherein each query is directed to the draft model that corresponds with the query's domain (§ 4.3).
37
+ - OSD demonstrates a significant improvement in token acceptance rate, by up to $10 - 65\%$ on diverse datasets, which translates into a $1.4 - 2.1 \times$ reduction in latency. OSD can be combined with existing methods that construct static draft models and match the accuracy achieved if all query data were available beforehand (§ 5).
38
+
39
+ # 2. Related Work
40
+
41
+ Speculative decoding. Speculative decoding (Leviathan et al., 2023; Chen et al., 2023a) accelerates LLM decoding by employing a (small) draft model to predict the outputs of the larger target model, which the target model then verifies. Suppose the draft model can correctly predict more than one token per verification step, the memory I/O for accessing the weights and KV cache of the (large) target model at inference is amortized across multiple output tokens, thereby reducing latency, especially since LLM inference is often constrained by GPU HBM bandwidth. The efficacy of speculative decoding hinges on the draft model's ability to accurately predict the target model's outputs. Existing work improves the speculation accuracy by using staged (Spector & Re, 2023), RAG-style (He et al., 2023), multiple (Miao et al., 2023; Chen et al., 2023b) draft models and sampling multiple candidates from the draft model (Yang et al., 2024; Cai et al., 2024). Additionally, there exists a line of research that eliminates the need for a separate draft model by leveraging auxiliary modules within the target model itself (Cai et al., 2023; Stern et al., 2018; Cai et al., 2024; Lin et al., 2024; Zhang et al., 2023). These methods predominantly assume a static draft model post-deployment. In contrast, our work introduces a framework that actively adapts the draft model to the evolving user query distribution on the fly, irrespective of the draft model's construction. OSD is orthogonal to the aforementioned methods, enabling its integration with them to improve overall efficacy in online deployment scenarios.
42
+
43
+ Distillation for auto-regressive models. Knowledge distillation (KD) is a framework to generate smaller models that emulate the performance of larger models. However, KD in its conventional form has been observed to be less effective for LLMs. Gu et al. (2023) extends KD to autoregressive LLMs by decoding from the student model and optimizing the reserve KL divergence between students and teachers. Agarwal et al. (2023) introduce generalized knowledge distillation (GKD) to optimize a linear combination of the forward KL and reverse KL between teacher and student, using a blend of teacher- and student-sampled data. Drawing inspiration from both works, OSD applies KD to speculative decoding for LLMs and extends it to dynamically adjust draft models (Section 4.1). We acknowledge the simultaneous emergence of a related work, DistillSpec (Zhou et al., 2023), which also employs KD for speculative decoding. However, our work and DistillSpec were developed concurrently. Moreover, DistillSpec represents a specific aspect of our broader framework OSD. OSD not only explores KD for speculative decoding but also addresses challenges in the online setting and routes queries across various distributions.
44
+
45
+ # 3. Background
46
+
47
+ We first briefly review speculative decoding (Leviathan et al., 2023), a critical technique that accelerates inference of a large target LLM $p(\cdot | \boldsymbol{x})$ with token proposals from a small draft model $q_{\theta}(\cdot | \boldsymbol{x})$ . $\boldsymbol{x}$ denotes the concatenation of the input prompts and already generated tokens. The two distributions are both learned in an auto-regressive way. We emphasize the parameters $\theta$ of the draft model because we usually need to tailor them according to the target LLM for more substantial acceleration.
48
+
49
+ Speculative decoding uses a (small) draft model to propose $k$ tokens $\pmb{y} \triangleq \{y_i\}_{i=1}^k \sim q_\theta(\cdot|\pmb{x})$ , and lets the target LLM estimate the $k+1$ token probabilities $\{p(y|\pmb{x},\pmb{y}_{<i})\}_{i=1}^{k+1}$ in parallel. We detailed the sampling process in Appendix A.1. Prior work has shown that the resulting samples $\tilde{\pmb{y}} \triangleq \{y_1,\dots,y_{a+1}\}$ strictly follow the distribution of the target LLM $p(\cdot|\pmb{x})$ (Leviathan et al., 2023). It concatenates $\tilde{\pmb{y}}$ to $\pmb{x}$ and repeats the above process until meeting $\langle \mathrm{EOS} \rangle$ .
50
+
51
+ Expected acceptance rate & speedups. The acceptance rate, denoted as $\alpha$ , serves as a measure of how closely the draft model approximates the target model. It is defined as the expected probability that speculative decoding will accept a proposal token given the prompt $y_{i} \sim q_{\theta}(y_{i} | \boldsymbol{x}, \boldsymbol{y}_{< i})$ . This rate directly influences the expected length $(\mathbb{E}(|\tilde{\boldsymbol{y}}|))$ of $\tilde{\boldsymbol{y}}$ for each target LLM run and the speedup of speculative decoding as detailed in Figure 8.
52
+
53
+ Assuming that the $k + 1$ simultaneous evaluation of the target LLM $p$ takes roughly the same amount of time as generating a single token in parallel, let $c$ be the time ratio for a single run between $q_{\theta}$ and $p$ . The expected generation length of a single target LLM run and the speedup in the total wall time due to speculative decoding is represented as (Leviathan et al., 2023):
54
+
55
+ $$
56
+ \mathbb {E} (| \tilde {\boldsymbol {y}} |) = \frac {1 - \alpha^ {k + 1}}{1 - \alpha}, \quad \mathbb {E} (s p e e d u p) = \frac {1 - \alpha^ {k + 1}}{(1 - \alpha) (k c + 1)}. \tag {1}
57
+ $$
58
+
59
+ Observation. The speculative decoding process inherently identifies the inaccuracies of the draft LLM and offers correct solutions for these inaccuracies. Hence, we receive valuable insights on the areas and strategies to refine the draft model at no additional cost. Furthermore, given the reduced size of the draft model (e.g., over $20 \times$ smaller than the target model), its tuning is not only efficient but also viable for real-time online adjustments. Prior work (Leviathan et al., 2023; Miao et al., 2023) has primarily approached speculative decoding in an offline manner, meaning the draft model remains static during online deployment. We next develop online speculative decoding to bridge this gap.
60
+
61
+ $$
62
+ { } ^ { 1 } \mathbf { y } _ { < i } \text { ~ r e f e r s t s ~ } \left\{ \mathcal { Y } _ { j } \right\} _ { j = 1 } ^ { i - 1 } .
63
+ $$
64
+
65
+ # 4. Online Speculative Decoding
66
+
67
+ We propose the online speculative decoding approach to update the draft model dynamically. We frame the learning problem based on the aforementioned auxiliary information as online knowledge distillation, where the teacher and student models correspond to the target and draft LLMs in speculative decoding, respectively.
68
+
69
+ # 4.1. Knowledge Distillation for Speculative Decoding
70
+
71
+ Knowledge distillation is a general framework to align the predictive distribution of a small model (i.e., student model) with that of a larger one (i.e., teacher model). Prior research has utilized knowledge distillation to compress neural networks, resulting in decreased inference costs and memory requirements. We posit that knowledge distillation is highly effective for speculative decoding. In this approach, the draft model acts as the student and the target model serves as the teacher. During speculative decoding, we possess complete information on both the proposed and verified probabilities of each token. This information helps to construct objectives for distilling the draft model, aligning its output distributions with those of the target model and thereby improving the token acceptance rate of the draft model.
72
+
73
+ The distillation loss generally takes the form of:
74
+
75
+ $$
76
+ \ell (\boldsymbol {\theta}) = \frac {1}{n _ {B}} \sum_ {\boldsymbol {x} ^ {(i)} \in \mathcal {B}} \ell \left(\boldsymbol {x} ^ {(i)}, \boldsymbol {\theta}\right), \quad \ell (\boldsymbol {x}, \boldsymbol {\theta}) = D (p (\cdot | \boldsymbol {x}) \| q _ {\boldsymbol {\theta}} (\cdot | \boldsymbol {x})), \tag {2}
77
+ $$
78
+
79
+ where $\mathcal{B} = \{\pmb{x}^{(i)}\}_{i=1}^{n_B}$ denotes a batch of inputs and $D$ denotes some distance measure.
80
+
81
+ Distance measure. In the case of auto-regressive models, the prediction distribution is categorical at each token. Often, we can augment the predicted logits with a tunable temperature $\tau$ for softmax transformation. We then use the popular forward KL and reverse KL (RKL), as well as their mixture (i.e., the JSD divergence) to instantiate $D$ (Agarwal et al., 2023; Gu et al., 2023):
82
+
83
+ $$
84
+ \ell_ {K L} (\boldsymbol {x}, \boldsymbol {\theta}) = D _ {\mathrm {K L}} (p (\cdot | \boldsymbol {x}) \| q _ {\boldsymbol {\theta}} (\cdot | \boldsymbol {x})),
85
+ $$
86
+
87
+ $$
88
+ \ell_ {R K L} (\boldsymbol {x}, \boldsymbol {\theta}) = D _ {\mathrm {K L}} \left(q _ {\boldsymbol {\theta}} (\cdot | \boldsymbol {x}) \| p (\cdot | \boldsymbol {x})\right),
89
+ $$
90
+
91
+ $$
92
+ \begin{array}{l} \ell_ {J S D [ \beta ]} (\boldsymbol {x}, \boldsymbol {\theta}) = \beta D _ {\mathrm {K L}} \left(p (\cdot | \boldsymbol {x}) \| p _ {\boldsymbol {\theta}} ^ {\beta} (\cdot | \boldsymbol {x})\right) \tag {3} \\ + (1 - \beta) D _ {\mathrm {K L}} \left(q _ {\boldsymbol {\theta}} (\cdot | \boldsymbol {x}) \| p _ {\boldsymbol {\theta}} ^ {\beta} (\cdot | \boldsymbol {x})\right), \\ \end{array}
93
+ $$
94
+
95
+ where $p_{\pmb{\theta}}^{\beta}(\cdot|\pmb{x}) \triangleq \beta p(\cdot|\pmb{x}) + (1 - \beta) q_{\pmb{\theta}}(\cdot|\pmb{x})$ . These objectives diverge from the conventionally used label-based finetuning objectives in speculative decoding, as highlighted in (Miao et al., 2023; Leviathan et al., 2023). As shown in Section 5.1, objectives based on the KL divergence prove to be more effective. This is because distributions convey richer information than mere labels, thereby enhancing their capability to guide the student model (Hinton et al.,
96
+
97
+ 2015). Additionally, these objectives enhance convergence rates (He et al., 2022) and bolster calibration. In our study, aligning with previous research (Agarwal et al., 2023), we empirically determine that the optimal distance measure can vary depending on the tasks and the relative capacities of the teacher and student models (see §5.1).
98
+
99
+ Sampling and gradient estimation. Estimating the above objectives involves the expectation over $q_{\theta}(\cdot|\boldsymbol{x})$ or $p(\cdot|\boldsymbol{x})$ , which should be expanded recursively. Once the recursion depth exceeds 1, we can not analytically compute $D_{\mathrm{KL}}$ but hinge on Monte Carlo approximation. When sampling from $q_{\theta}(\cdot|\boldsymbol{x})$ , we should differentiate through the sampling process for unbiased gradient estimation. However, this leads to policy gradient-style estimators and should rely on elaborate policies such as reward hacking and single-step regularization to reduce gradient variance and stabilize training (Gu et al., 2023).
100
+
101
+ In comparison, a more straightforward approach is to omit the differentiation through the sampling process (Agarwal et al., 2023), where the sample $\mathbf{y}$ is directly plugged into the objective:
102
+
103
+ $$
104
+ \ell (\boldsymbol {x}, \boldsymbol {\theta}) \approx \sum_ {j = 1} ^ {| \boldsymbol {y} | + 1} D (p (y | \boldsymbol {x}, \boldsymbol {y} _ {< j}) \| q _ {\boldsymbol {\theta}} (y | \boldsymbol {x}, \boldsymbol {y} _ {< j})). \tag {4}
105
+ $$
106
+
107
+ This way, various distance measures can be readily applied. Besides, the sampling becomes disentangled from the distance measure. i.e., we sample $\mathbf{y}$ from an arbitrary mixture of $p(\cdot | \mathbf{x})$ and $q_{\theta}(\cdot | \mathbf{x})$ but use KL, RKL or JSD for estimating the distribution misalignment.
108
+
109
+ Intuitively, the samples from the teacher model are usually coherent, which may raise difficulties in fitting the small student model, while samples from the student model may be less structured or even meaningless. A workaround strategy is to trade off between them via mixed sampling (Gu et al., 2023), i.e., $y_{j} \sim \beta p(\cdot | \boldsymbol{x}, \boldsymbol{y}_{< j}) + (1 - \beta) q_{\boldsymbol{\theta}}(\cdot | \boldsymbol{x}, \boldsymbol{y}_{< j})$ .
110
+
111
+ # 4.2. Online Adaptation
112
+
113
+ This section expands the application of knowledge distillation for speculative decoding in online environments. The approach enables improving the performance of the draft model using results from speculative decoding, thus dynamically adapting to the query distribution and improving the token acceptance rate. We also discuss the trade-off of our approach when integrating LLM serving systems.
114
+
115
+ # 4.2.1. ALGORITHM
116
+
117
+ We depict our online speculative decoding algorithm (OSD) in Algorithm 1. OSD begins by training the draft model using the warmup dataset (Line 2). The serving system then continuously handles incoming requests (as described in Lines 6 to 23). For each request, it uses standard specu
118
+
119
+ # Algorithm 1 Online Speculative Decoding.
120
+
121
+ 1: Input: Target LLM $p(\cdot | \boldsymbol{x})$ , draft LLM $q_{\theta}(\cdot | \boldsymbol{x})$ , warmup dataset $\mathcal{D}$ , online data stream $S$ , guess number $k$ , temporary buffer $\mathcal{R}$ , replay buffer $\mathcal{Q}$ , update interval for the draft model $I$ .
122
+ 2: Pre-train $q_{\theta}$ to approximate $p$ with data from $\mathcal{D}$ by minimizing $\ell (\pmb {x},\pmb {\theta})$ using Equation (4);
123
+ 3: $i\gets 0$
124
+ 4: $\mathcal{Q}\gets \mathbb{I}$
125
+ 5: cur_len = $|\pmb{x}|$ // Total sequence length, including prompt length and tokens generated so far.
126
+ 6: while True do
127
+ 7: $\mathcal{R} \gets [] // \text{List of (error_index, target logits at error_index)}$ pairs for a single request.
128
+ 8: $x\sim S,i\gets i + 1;$
129
+ 9: while $\langle \mathrm{EOS}\rangle$ not in $x$ do
130
+ 10: $\pmb{y} = \{y_{1},\dots,y_{k}\} \sim q_{\pmb{\theta}}(\cdot |\pmb {x})$
131
+ 11: Estimate $\{p(y|\boldsymbol{x},\boldsymbol{y}_{< i})\}_{i = 1}^{k + 1}$ in parallel;
132
+ 12: Determine number of accepted tokens $a$ and sample one more token, yielding $\pmb{y} = \{y_1,\dots ,y_{a + 1}\}$
133
+ 13: cur_len $\leftarrow$ cur_len + a + 1;
134
+ 14: error_index $\leftarrow$ cur_len;
135
+ 15: Append (error_index, $p(y|\mathbf{x},\mathbf{y}_{< a + 1}))$ to $\mathcal{R}$
136
+ 16: $\pmb{x}\gets [\pmb {x},\pmb{y}_{< a + 2}]$
137
+ 17: end while
138
+ 18: Append $(\pmb {x},\mathcal{R})$ to $\mathcal{Q}$
139
+ 19: if $i \bmod I = 0$ then
140
+ 20: Update $q_{\theta}$ on $\mathcal{Q}$ to minimize $\ell (\pmb {x},\pmb {\theta})$ analytically;
141
+ 21: $\mathcal{Q}\gets []$
142
+ 22: end if
143
+ 23: end while
144
+
145
+ lative decoding (Lines 10-11) to generate responses until the $\langle \mathrm{EOS}\rangle$ token. Concurrently, OSD tracks the token index (error_index) and target logits where the draft model proposes the wrong tokens (Line 15). Leveraging tracked information, OSD updates the draft model every $I$ iteration, with $I$ being a dynamically adjustable parameter. OSD updates the draft model with different loss functions (Line 20) as described in Section 4.1. The choice of loss function depends on the specific (draft, target) model pairs and the corresponding input data.
146
+
147
+ Discussion. OSD utilizes a replay buffer, $\mathcal{Q}$ , to capture all pertinent information for updating the draft model. Various eviction policies can be employed to maintain a compact size for $\mathcal{Q}$ . For example, one could opt to retain only the most informative pairs or the most recent entries. Similarly, users have the option to retain data in $\mathcal{Q}$ even after utilizing it to update the model multiple times. Determining the optimal eviction/retention strategy is a subject for future exploration. In the current study, we refrain from evicting any pairs and release $\mathcal{Q}$ after each model update. Furthermore, $I$ is a dynamic parameter. Depending on the system load and the rate at which the query distribution changes, users can adjust $I$ accordingly. For example, we can perform a gradient update opportunistically only when the service traffic is not on spike (i.e., spare flops are available).
148
+
149
+ In the implementation of the system, two distinct pipelines can be established: one for training and another for inference. This approach allows for the utilization of existing infrastructure. Periodic updates of the draft model weights are essential to ensure continuous adaptation. Alternatively, a unified pipeline that accommodates both training and inference can be developed. This integrated system continuously reinforces the draft model, maintaining a consistently high token acceptance rate. Overall, OSD continuously improves the draft model's approximation (indicated by increased token acceptance rate $\alpha$ ) by learning from the target model during the serving phase. We next demonstrate how the enhanced acceptance rate directly contributes to a reduction in request latency.
150
+
151
+ # 4.2.2. LATENCY & FLOPS ANALYSIS
152
+
153
+ Latency. As detailed in Appendix A.3, compared with standard speculative decoding, the expected speedup for online speculative decoding is $\frac{1 + \alpha_2 + \alpha_2^2 + \ldots + \alpha_2^k}{1 + \alpha_1 + \alpha_1^2 + \ldots + \alpha_1^k}$ . Based on the data from our experiment (refer to Table 1), when compared to standard speculative decoding, we expect a speedup improvement for Vicuna-7B (LLaMA-160M as the draft model) by factors of $2.42\times$ , $1.43\times$ , $1.64\times$ , and $1.22\times$ . Similarly, for Flan-T5-XL 3B (T5-small 80M as the draft model), the speedup enhancements are $3.06\times$ , $1.76\times$ , $2.72\times$ , and $1.55\times$ across the four evaluated datasets.
154
+
155
+ FLOPs. (1) The FLOPs required to update the draft model are much fewer than those needed for inference on a large model. As elaborated in Appendix A.4, for the two evaluated pairs, the FLOPs ratio between the target model and the draft model is 18.75 for the pair (LLaMA-160M, Vicuna7B), and 12.6 for the pair (T5-small 80M, Flan-T5-XL 3B). (2) In practical systems, the FLOPs required for inference are significantly below the machine's capacity. Appendix A.4 provides an analysis of Arena chatbot traces where the cluster's computational utilization is under 1 percent. Given the above two observations, it becomes evident that the FLOPs spent on inference and updating the draft model are relatively insignificant compared with the FLOPs consumed for target model inference and the cluster's total FLOPs.
156
+
157
+ Memory Bandwidth. As detailed in Tabel 5 and Appendix A.5, updating the draft model is not memory-intensive because it is small. The majority of memory operations are still dominated by loading the target model. OSD can significantly reduce memory bandwidth through a higher token acceptance rate, which consequently decreases the frequency of calling the larger model for verification.
158
+
159
+ # 4.3. Draft Model Customization and Routing
160
+
161
+ Queries can be categorized according to various characteristics. Figure 2 illustrates two ways to classify queries from
162
+
163
+ ![](images/c0a4215d088d5009eb5af009bd575bbe0ac2f2ac00ed186479157a86b55874d7.jpg)
164
+ Figure 2. The left plot depicts the proportion of queries in languages other than English in the Arena dataset (detailed in Appendix A.7). The right plot illustrates the distribution of queries across various topics within the dataset.
165
+
166
+ ![](images/58bdf636ebbc07eb6105abf4638b0d47f35ff01f4dd6f07f4c90f4a7244dae75.jpg)
167
+
168
+ the Arena dataset (detailed in Appendix A.7). We leverage this observation to further narrow down the query domain to improve the draft model adaptation. As highlighted in Section 5.3, we can improve the accuracy of the draft model if we constrain it to a particular domain. This echoes the observation that using a single draft model for all queries results in a lower token acceptance rate compared to tailoring the draft model to specific query domains. Furthermore, we observe a temporal shift in the distribution, detailed in Appendix A.7, the proportion of various topics and languages also varies across different timestamps.
169
+
170
+ In our study, we implemented two approaches for query classification. The first approach involves sorting queries based on language, utilizing the language tags available in the query metadata. The second strategy clusters queries according to their topics, making use of a small BERT model (67M) (Luqmani, 2023). To minimize routing overhead, we perform routing at the query level rather than at the token level. The routing process is highly efficient as it only relies on either the use of query tags (to access metadata) or the implementation of a simple classification model. This paper highlights the enhancement in token acceptance rate achieved via the customization of draft models. We leave it as feature work to identify the optimal routing queries and number or size of these customized draft models.
171
+
172
+ # 5. Experiments
173
+
174
+ To assess the efficacy of OSD, we evaluate its ability to improve the token acceptance rate $(\alpha)$ within an offline context. Subsequently, we examine the approach's impact in an online environment, discovering that the acceptance rate improves even with a moderate amount of data while maintaining accuracy levels comparable to those in the offline scenario. Lastly, we investigate query latency and perform an in-depth quantitative analysis to gain insights into the tokens learned by the draft model.
175
+
176
+ Throughout our experiments, we employ two target models $(M_p)$ : Vicuna-7B (Chiang et al., 2023) and FLAN-T5-XL (3B) (Chung et al., 2022). Specifically for Vicuna-7B, we utilize LLaMA-160M (Miao et al., 2023) as the draft model $(M_q)$ . For FLAN-T5-XL, we use T5-Small (Raffel et al., 2020) as the draft model. We evaluate performance across
177
+
178
+ Table 1. Token acceptance rates $(\alpha)$ after two epochs. FT: Finetuning on teacher-generated labels. TF, SF, MixF: Teacher, student, and mix token sampling respectively, all with forward KL. For tasks, SP: Spider. GS: Gsm8k. CP: Code-serarch-Python. AL: Alpaca-finance.
179
+
180
+ <table><tr><td>Model</td><td>Task</td><td>Original</td><td>FT</td><td>TF</td><td>SF</td><td>MixF</td></tr><tr><td rowspan="4">Vicuna-7B</td><td>SP</td><td>0.28</td><td>0.74</td><td>0.76</td><td>0.62</td><td>0.70</td></tr><tr><td>GS</td><td>0.58</td><td>0.74</td><td>0.75</td><td>0.67</td><td>0.73</td></tr><tr><td>CP</td><td>0.38</td><td>0.65</td><td>0.65</td><td>0.51</td><td>0.61</td></tr><tr><td>AL</td><td>0.57</td><td>0.68</td><td>0.67</td><td>0.63</td><td>0.65</td></tr><tr><td rowspan="4">FLAN T5-XL</td><td>SP</td><td>0.13</td><td>0.33</td><td>0.78</td><td>0.67</td><td>0.70</td></tr><tr><td>GS</td><td>0.29</td><td>0.50</td><td>0.62</td><td>0.51</td><td>0.55</td></tr><tr><td>CP</td><td>0.28</td><td>0.44</td><td>0.81</td><td>0.67</td><td>0.78</td></tr><tr><td>AL</td><td>0.39</td><td>0.56</td><td>0.63</td><td>0.59</td><td>0.60</td></tr></table>
181
+
182
+ four diverse datasets: Text-to-SQL (Spider) (Yu et al., 2018), graduate school math (Gsm8k) (Cobbe et al., 2021), Python code generation (Code-search-Python) (Husain et al., 2019), and financial question answering (Alpaca-finance) (Bharti, 2023). In all experiments, we set the number of proposed tokens to 5 for speculative decoding. For all online experiments, we fix the update interval $I$ at 8.
183
+
184
+ # 5.1. Offline Evaluation
185
+
186
+ In this section, we assess the efficacy of employing knowledge distillation to train a small model specifically for speculation in an offline environment. In such a setting, the speculative $M_{q}$ model has unrestricted access to the dataset, and the query distribution remains stable. To emulate these offline conditions, we distill the $M_{q}$ using the training dataset for two epochs and subsequently evaluate its performance by measuring the average token acceptance rate $(\alpha)$ on the test set. As detailed in Section 4.1, we evaluated various sampling methods, namely teacher sampling, student sampling, and mix token-level sampling. Table 1 displays the token acceptance rate of the draft model for each method, using forward KL as the distance metric on the test dataset. For comparison, we also provide the acceptance rate for teacher-generated label fine-tuning and the original model.
187
+
188
+ For both the Vicuna-7B and FLAN-T5-XL models, the teacher sampling method outperforms others by achieving the highest acceptance rate. Furthermore, knowledge distillation has proven its efficacy in enhancing the draft model's approximation, resulting in a high token acceptance rate. Lastly, we experimented with different distance measurements like reverse KL and JSD. Nevertheless, these measurements either paralleled or underperformed when compared to forward KL. The optimal distance measurement or sampling method varies depending on the task and model, and we leave it to future work to find the best combination.
189
+
190
+ # 5.2. Online Evaluation
191
+
192
+ Online Learning. First, we evaluate the effectiveness of
193
+
194
+ OSD by addressing two questions: (1) Does the online algorithm increase the token acceptance rate? And is this enhancement comparable to the rates achieved in offline settings, which serve as an upper bound given their full access to data? (2) How quickly does the online algorithm increase the token acceptance rate, thereby indicating that the compact model has grasped the underlying distribution?
195
+
196
+ In our approach, we replicate the online serving process by iterating through the datasets, extracting prompts, and streaming generation requests. The system utilizes speculative decoding for each of these requests. Throughout this serving phase, we continually refine the speculative models, as detailed in Algorithm 1. For our baseline, we envision a scenario where the serving system has the capability to collect data offline in order to distill an initial draft model. This model is subsequently deployed online to cater to future requests. This process is simulated by using $10\%$ of the dataset to distill the draft model, which remains static during online serving. For evaluation metrics, we calculate token acceptance rates averaged over the most recent 50 requests. This demonstrates $M_q$ 's efficacy on the most current data.
197
+
198
+ As depicted in Figure 2, both for Vicuna-7B and FLAN-T5, in the beginning, OSD yields a lower token acceptance rate in comparison to the offline distilled model. Nevertheless, these acceptance rates rise swiftly as the draft model is exposed to more data. We also annotate the token acceptance rate from the offline setting to highlight the potential peak performance that the online serving system could reach. In all instances, the online context can achieve comparable results. In some scenarios, OSD even surpasses the token acceptance rate of the offline test alphas. This discrepancy can be attributed to the fact that offline test alphas are assessed on the entire test dataset, whereas the online alphas represent the moving average of the latest 50 requests. It's plausible that OSD performs optimally on specific data subsets, particularly if those subsets are more narrowly distributed than the complete dataset.
199
+
200
+ Distribution Shifts. We evaluate OSD's ability to adapt to distribution shifts. We employ a single LLaMA-160M as the initial draft model and Vicuna-7B as the target model. To simulate the distribution shift, we integrate data from diverse datasets. Concretely, we select 2k prompts from each dataset. The data from the four datasets are amalgamated by direct concatenation, such that the records from $i \times 2k$ to $(i + 1) \times 2k$ belong solely to dataset $i$ .
201
+
202
+ As illustrated in Figure 4, OSD's alpha value dips notably at distribution boundaries, especially around 2K, 4K, and 6K records. This is anticipated since the draft model initially struggles when faced with a new distribution. However, the alpha value rebounds quickly as OSD processes more data, highlighting its adaptability to shifting query distributions.
203
+
204
+ ![](images/a11e0422b9ca21fa54a5040d61842f19c1c7d6cd9e66d7906da7817fc9ddb08a.jpg)
205
+ Figure 3. Online acceptance rate $(\alpha)$ across different datasets. The x-axis represents the number of records that OSD has processed. $\alpha$ is averaged over the most recent 50 records.
206
+
207
+ ![](images/93e1860e77e84e47fbe05ee43d7c9714cbdd9be8b6621bfee71ad321650a3a3e.jpg)
208
+ Figure 4. Distribution Shift
209
+
210
+ We also compared our results to those from a static setting. To ensure the draft model wasn't just memorizing data, we chose samples distinct from the online evaluation data. These samples correspond to $30\%$ , $50\%$ , $70\%$ , and $100\%$ of each dataset's online evaluation volume, at 0.6K, 1K, 1.4K, and 2K quantities respectively. As depicted in Figure 4, upon an initial shift in query distribution, OSD's performance aligns with or slightly trails the distillation with $30\%$ data. However, it quickly catches up, matching or even surpassing performances seen with $70\%$ to $100\%$ data access. This highlights OSD's ability to rival models fully exposed to the query distribution, even without intimate knowledge of the underlying query dynamics.
211
+
212
+ # 5.3. Real Workloads & Customized Draft Model
213
+
214
+ We evaluate OSD on real LMSYS-chat conversations (Appendix A.7) that span 4 months. We propose that employing distinct draft models for queries on various subcategories can enhance the token acceptance rate. To carry out the experiment, we compare two modes: Single Draft Model and Separate Draft Models. Under the Single Draft Model case, the target model is paired with a singular draft model through which all data is processed uniformly. Conversely, in the Separate Draft Models case, while the target model remains unchanged, it is supported by multiple draft models. Here, each draft model is specialized to handle a specific topic. Upon receiving a new request, the query is first classified using some classification models to determine its relevant topic. Subsequently, the query is directed to the appropriate draft model, tailored for that topic, which then speculates and forwards the requests to the target model.
215
+
216
+ Unlike the approach of utilizing a single draft model for all topics, assigning specific draft models to individual topics narrows the range of query distributions each model must adapt to. This focused approach simplifies the learning process for each draft model, as they deal with a more limited set of queries.
217
+
218
+ First, we categorize conversations based on the language and we focus on conversations among the top five languages, excluding English. For every chosen language, we use an independent LLaMA-160M to serve as our draft model. All draft models share the same Vicuna-7B as the target model. The token acceptance rate, averaged over the latest 100 requests, showed in Figure 5, reveals that OSD's enhances rates by 0.1 to 0.2, even with under 2K data points. Notably, Japanese was the easiest while Portuguese was the toughest.
219
+
220
+ Next, we try another way of clustering conversations by routing conversations to draft models with specified for different topics. We get the queries' topics using the fine-tuned distilled Bert model (Luqmani, 2023), focusing on the top five. For topics with over 5K conversations, we sampled evenly to keep it within 5K. Figure 5 shows acceptance rates above 0.6 across topics, with Social and Computer discussions peaking near 0.9.
221
+
222
+ To further compare the Single Draft Model and Separate Draft Models cases, we analyze the token acceptance rate and memory consumption below.
223
+
224
+ Token acceptance rate: we measured and plotted the token acceptance rates using - a single universal draft model versus multiple topic-specific draft models - in Figure 6, to highlight the idea of customizing draft models for different types of queries. As seen from the graph, across all topics, employing multiple draft models results in an increase in the token acceptance rate by 0.1 to 0.2. This aligns with our expectation that draft models benefit from a narrower query distribution, making it easier to learn and adapt.
225
+
226
+ Memory consumption: In the analysis below, we assume that multiple draft models are preloaded into memory. When
227
+
228
+ Table 2. Measured itemn token latency (ms) and speedup across $\alpha$ s measured on a single A100-80G with batch size 1. Original is inference without speculative decoding.
229
+
230
+ <table><tr><td></td><td>Original</td><td>OSD, α = 0.5</td><td>OSD, α = 0.6</td><td>OSD, α = 0.7</td><td>OSD, α = 0.8</td><td>OSD, α = 0.9</td></tr><tr><td>(1.1B, 33B) Time (speedup)</td><td>51.09</td><td>39.90 (1.28 ×)</td><td>35.48 (1.44 ×)</td><td>30.96 (1.65 ×)</td><td>25.42 (2.01 ×)</td><td>19.43 (2.63 ×)</td></tr><tr><td>(160M, 7B) Time (speedup)</td><td>13.21</td><td>13.85 (0.95 ×)</td><td>11.39 (1.17 ×)</td><td>10.20 (1.3 ×)</td><td>7.84 (1.68 ×)</td><td>5.17 (2.55 ×)</td></tr></table>
231
+
232
+ considering five draft models, the cumulative size reaches 800M, approximately $10\%$ of the target model's size (7B), both in terms of model weights and key-value (kv) cache size. Compared with using a single draft model, routing increases the memory overhead from $2\%$ to $10\%$ . However, relative to the size of the target model, this additional memory requirement should be manageable. We do think there is the trade-off between the number of draft models and the memory consumption and leave it to future research to decide the optimal number of draft models and the best classification strategy.
233
+
234
+ # 5.4. Latency Measurement
235
+
236
+ In this section, we measure the OSD latency at various acceptance rates. Subsequently, we evaluate the performance enhancement offered by distilled models across four evaluated datasets. Throughout these experiments, we investigate two configurations: (LLaMA-160M draft, Vicuna-7B target) and (TinyLLaMA-1.1B draft, Vicuna-33B target). We conduct the experiments with llamacpp (Gerganov, 2023) on a single A100-80G.
237
+
238
+ As illustrated in Table 2, for an identical token acceptance rate, the combination of TinyLLaMA-1.1B and Vicuna-33B outperforms the LLaMA-160M and Vicuna-7B pair in terms of speedup. This enhanced performance is attributable to a greater latency difference between the draft and target models in the first pair (denoted by $c = 0.08$ for TinyLLaMA-1.1B and Vicuna-33B, compared to $c = 0.13$ for LLaMA-160M and Vicuna-7B). In simpler terms, the draft model incurs relatively lower costs, leading to a more pronounced speedup with equivalent speculation accuracy. Overall, OSD can achieve a maximum speedup of $2.63 \times$ when the token acceptance rate exceeds 0.9. Lastly, we evaluate the speedup achieved by OSD's distilled model on four evaluated datasets. For the draft model, as discussed in Section 4.1, we employ teacher sampling with forward KD as the distillation method, as detailed in Table 3. The results indicate that our OSD can yield a speedup ranging from $1.42 \times$ to $2.17 \times$ across the four evaluated datasets.
239
+
240
+ # 5.5. Qualitative Analysis
241
+
242
+ In this section, we analyze how OSD enhances the token acceptance rate, and which tokens the draft model acquires across varying query distributions.
243
+
244
+ Table 3. Measured intern token latency (ms) and speedup on four datasets. 1.1B: TinyLLaMA-1.1B. 33B: Vicuna-33B. 160M: Vicuna-160M. 7B: Vicuna-7B.
245
+
246
+ <table><tr><td>Dataset</td><td>Spider</td><td>Gsm8k</td><td>Alpaca-Finance</td><td>Code-Python</td><td>Chatbot-Arena</td></tr><tr><td>(1.1B, 33B)</td><td>23.53</td><td>27.40</td><td>26.53</td><td>30.12</td><td>33.52</td></tr><tr><td>Time (Speedup)</td><td>(2.17 ×)</td><td>(1.89 ×)</td><td>(1.92 ×)</td><td>(1.69 ×)</td><td>(1.51 ×)</td></tr><tr><td>(160M, 7B)</td><td>8.12</td><td>8.83</td><td>10.41</td><td>11.44</td><td>11.9</td></tr><tr><td>Time (Speedup)</td><td>(1.63 ×)</td><td>(1.60 ×)</td><td>(1.47 ×)</td><td>(1.42 ×)</td><td>(1.36 ×)</td></tr></table>
247
+
248
+ High-frequency tokens precision and recall. In the experiment on the Spider dataset, (LLaMA-160M draft, Vicuna7B target). We identify the top 100 tokens most frequently generated by the target model, which account for $72.2\%$ of all appearances, following a power-law distribution. Figure 7 shows a marked improvement in both accuracy and recall of these tokens after distillation.
249
+
250
+ Tokens learned across different datasets We analyze the top 10 tokens with the most pronounced accuracy and recall improvements across various datasets, focusing on the 100 most frequent tokens to understand the draft model's learning trends. As detailed in Table 6, the improved tokens align with the underlying data distribution. For example, in the Spider SQL dataset, tokens like SELECT and WHERE have notably higher acceptance rates post-distillation. These patterns highlight the draft model's ability to adapt and predict tokens consistent with the data distribution.
251
+
252
+ # 5.6. OSD and Medusa
253
+
254
+ Next, we demonstrate the application of OSD to Medusa. By frequently updating the weights of the linear layer during non-peak hours, OSD can further improve the token acceptance rate on the given dataset and achieve further speedup.
255
+
256
+ Medusa (Cai et al., 2024) differs from standard speculative decoding in two key ways: (1) Standard speculative decoding proposes a single token for each position, whereas Medusa proposes multiple token candidates for each position. (2) Standard speculative decoding uses a small, independent draft model to propose tokens, while Medusa employs additional heads—linear layers that take the last hidden states as input and output the token probability distribution for each position.
257
+
258
+ In Table 4, we compare the performance of Medusa-v1 combined with OSD. By fine-tuning the additional heads in Medusa on the Spider dataset, this combination achieves a $2.01 \times$ speedup, compared to the $1.34 \times$ improvement observed with Medusa alone. Notably, when standard speculative decoding with online updates is applied to the Spider dataset, it delivers even greater performance gains, achieving a $2.17 \times$ speedup compared to the $2.01 \times$ enhancement provided by Medusa with OSD. On the Arena dataset, Medusa-v1 generally performs well on the chat dataset since
259
+
260
+ ![](images/91f0ebdec9cf669e0ec3bace6e7210092514bcd0fa3cc8b212d3a83954fe0633.jpg)
261
+
262
+ ![](images/87436c08a93365e90835ee5864c16bbe3f81e405815af77b8fd3b5bcf755602d.jpg)
263
+
264
+ ![](images/97a8a57a64c3d0c7ebe8b66b6cc0aedb49121f0ec760c551ee98096db31fafd5.jpg)
265
+ Figure 6. For the single draft model, we send all queries to the same draft model and measure the token acceptance rate based on query topics. For multiple draft models, we employ a customized draft model for each query based on the topic.
266
+
267
+ ![](images/c49c30c30acc6a4b5313d388e5e7800803fd083825bbe3493753658644dc0847.jpg)
268
+ Figure 5. Chatbot Arena Conversations clustered by language and topic.
269
+
270
+ ![](images/dc03d598daa6f307958063b837938e5d5e806b846bc30b3b7b3d1a78634ceda9.jpg)
271
+
272
+ ![](images/974c4538dbebcf7a8a53a93381a63b55d1d6827efc55a0d65da8611c17ec1c1b.jpg)
273
+
274
+ ![](images/f545749bdf026f72eead23a0d581320226924405977feed9424091c46036e72d.jpg)
275
+
276
+ ![](images/6e623fe58f18a88135a6bd71abda4254cad7a3faa0337b4a87e239f49480069e.jpg)
277
+ Figure 7. Precision and recall of high-frequency tokens. The x-axis shows token ratings based on occurrence. For instance, token 1 appears most frequently in answers. Precision = # of times token $i$ is accepted / # of times token $i$ is proposed. Recall = # of times token $i$ is accepted / # of times token $i$ appears in the final answer.
278
+
279
+ ![](images/1bc867f0bcbca85309e26623bfdf940e28a8758d2d548af3b78a0051936f19b4.jpg)
280
+
281
+ the extra heads are originally trained on the ShareGPT (sha, 2023) dataset, showcasing a $2.03 \times$ speedup without any updates. In contrast, the combination of standard speculative decoding with OSD yields worse results than vanilla Medusa-v1, with only a $1.51 \times$ speedup. Nevertheless, OSD still manages to enhance the performance of Medusa-v1 by $0.35 \times$ . This underscores OSD's potential in further optimizing the tree-style speculative decoding method.
282
+
283
+ Table 4. OSD and Medusa
284
+
285
+ <table><tr><td>Dataset</td><td>Spider</td><td>Chatbot Arena</td><td>Extra Parameters (B)</td></tr><tr><td>Medusa-7B</td><td>1.34×</td><td>2.03×</td><td>0.44</td></tr><tr><td>Medusa-7B + OSD</td><td>2.01×</td><td>2.38×</td><td>0.44</td></tr><tr><td>Draft model + OSD</td><td>2.17×</td><td>1.51×</td><td>0.16</td></tr></table>
286
+
287
+ # 6. Conclusion
288
+
289
+ Speculative decoding's efficiently hinges on the draft model's approximation to the target model. We introduce an online speculative method that continuously enhances the draft model based on varying data distributions. Experiments on both synthetic and real data demonstrate that online speculative decoding swiftly adapts to new data distributions, significantly enhancing token acceptance rate.
290
+
291
+ # Impact Statement
292
+
293
+ This paper presents work whose goal is to advance the field of Machine Learning. There are many potential societal consequences of our work, none of which we feel must be specifically highlighted here.
294
+
295
+ # Acknowledgments
296
+
297
+ Z.J. Deng was supported by NSF of China (No. 62306176), Natural Science Foundation of Shanghai (No. 23ZR1428700), Key R&D Program of Shandong Province, China (2023CXGC010112), and CCF-Baichuan-Ebtech Foundation Model Fund. This work is supported in part by the National Science Foundation through grants CCF-2238346, IIS-1955488, IIS-2027575, ARO W911NF2110339, ONR N00014-21-1-2724, and DOE award DE-SC0016260, DE-SC0021982.
298
+
299
+ # References
300
+
301
+ Huggingface transformers, 2023. URL https://huggingface.co/docs/transformers/en/index.
302
+ Sharegpt, 2023. URL https://huggingface.co/datasets/Aeala/ShareGPT_Vicuna_unfiltered.
303
+ Agarwal, R., Vieillard, N., Stanczyk, P., Ramos, S., Geist, M., and Bachem, O. Gkd: Generalized knowledge distillation for auto-regressive sequence models. arXiv preprint arXiv:2306.13649, 2023.
304
+ Bharti, G. gbharti/finance-alpaca, 2023. URL https://huggingface.co/datasets/gbharti/finance-alpaca. Accessed: 2023-09-17.
305
+
306
+ Cai, T., Li, Y., Geng, Z., Peng, H., and Dao, T. Medusa: Simple framework for accelerating llm generation with multiple decoding heads. https://github.com/FasterDecoding/Medusa, 2023.
307
+ Cai, T., Li, Y., Geng, Z., Peng, H., Lee, J. D., Chen, D., and Dao, T. Medusa: Simple llm inference acceleration framework with multiple decoding heads. arXiv preprint arXiv:2401.10774, 2024.
308
+ Chen, C., Borgeaud, S., Irving, G., Lespiau, J.-B., Sifre, L., and Jumper, J. Accelerating large language model decoding with speculative sampling. arXiv preprint arXiv:2302.01318, 2023a.
309
+ Chen, Z., Yang, X., Lin, J., Sun, C., Huang, J., and Chang, K. C.-C. Cascade speculative drafting for even faster llm inference. arXiv preprint arXiv:2312.11462, 2023b.
310
+ Chiang, W.-L., Li, Z., Lin, Z., Sheng, Y., Wu, Z., Zhang, H., Zheng, L., Zhuang, S., Zhuang, Y., Gonzalez, J. E., Stoica, I., and Xing, E. P. Vicuna: An open-source chatbot impressing gpt-4 with $90\%$ * chatgpt quality, March 2023. URL https://lmsys.org/blog/2023-03-30-vicuna/.
311
+ Chung, H. W., Hou, L., Longpre, S., Zoph, B., Tay, Y., Fedus, W., Li, E., Wang, X., Dehghani, M., Brahma, S., et al. Scaling instruction-finetuned language models. arXiv preprint arXiv:2210.11416, 2022.
312
+ Cobbe, K., Kosaraju, V., Bavarian, M., Chen, M., Jun, H., Kaiser, L., Plappert, M., Tworek, J., Hilton, J., Nakano, R., Hesse, C., and Schulman, J. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168, 2021.
313
+ Gerganov, G. llama.cpp, 2023. URL https://github.com/ggerganov/llama.cpp. Accessed: 2023-11-22.
314
+ Gu, Y., Dong, L., Wei, F., and Huang, M. Knowledge distillation of large language models. arXiv preprint arXiv:2306.08543, 2023.
315
+ He, R., Sun, S., Yang, J., Bai, S., and Qi, X. Knowledge distillation as efficient pre-training: Faster convergence, higher data-efficiency, and better transferability. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 9161-9171, 2022.
316
+ He, Z., Zhong, Z., Cai, T., Lee, J. D., and He, D. Rest: Retrieval-based speculative decoding. arXiv preprint arXiv:2311.08252, 2023.
317
+ Hinton, G., Vinyals, O., and Dean, J. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2015.
318
+
319
+ Husain, H., Wu, H.-H., Gazit, T., Allamanis, M., and Brockschmidt, M. CodeSearchNet challenge: Evaluating the state of semantic code search. arXiv preprint arXiv:1909.09436, 2019.
320
+ Kaplan, J., McCandlish, S., Henighan, T., Brown, T. B., Chess, B., Child, R., Gray, S., Radford, A., Wu, J., and Amodei, D. Scaling laws for neural language models. arXiv preprint arXiv:2001.08361, 2020.
321
+ Leviathan, Y., Kalman, M., and Matias, Y. Fast inference from transformers via speculative decoding. In International Conference on Machine Learning, pp. 19274-19286. PMLR, 2023.
322
+ Lin, F., Yi, H., Li, H., Yang, Y., Yu, X., Lu, G., and Xiao, R. Bita: Bi-directional tuning for lossless acceleration in large language models. arXiv preprint arXiv:2401.12522, 2024.
323
+ Luqmani, A. M. distilled bert topic, 2023. URL https://huggingface.co/alimazhar-110/ website_classification. Accessed: 2023-10-07.
324
+ Miao, X., Oliaro, G., Zhang, Z., Cheng, X., Wang, Z., Wong, R. Y. Y., Chen, Z., Arfeen, D., Abhyankar, R., and Jia, Z. Specinfer: Accelerating generative llm serving with speculative inference and token tree verification, 2023.
325
+ OpenAI, R. Gpt-4 technical report. arXiv, pp. 2303-08774, 2023.
326
+ Raffel, C., Shazeer, N., Roberts, A., Lee, K., Narang, S., Matena, M., Zhou, Y., Li, W., and Liu, P. J. Exploring the limits of transfer learning with a unified text-to-text transformer, 2020.
327
+ Spector, B. and Re, C. Accelerating llm inference with staged speculative decoding. arXiv preprint arXiv:2308.04623, 2023.
328
+ Stern, M., Shazeer, N., and Uszkoreit, J. Blockwise parallel decoding for deep autoregressive models. Advances in Neural Information Processing Systems, 31, 2018.
329
+ Touvron, H., Lavril, T., Izacard, G., Martinet, X., Lachaux, M.-A., Lacroix, T., Roziere, B., Goyal, N., Hambro, E., Azhar, F., et al. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023a.
330
+ Touvron, H., Martin, L., Stone, K., Albert, P., Almahairi, A., Babaei, Y., Bashlykov, N., Batra, S., Bhargava, P., Bhosale, S., et al. Llama 2: Open foundation and finetuned chat models. arXiv preprint arXiv:2307.09288, 2023b.
331
+
332
+ Yang, S., Huang, S., Dai, X., and Chen, J. Multi-candidate speculative decoding. arXiv preprint arXiv:2401.06706, 2024.
333
+ Yu, T., Zhang, R., Yang, K., Yasunaga, M., Wang, D., Li, Z., Ma, J., Li, I., Yao, Q., Roman, S., et al. Spider: A large-scale human-labeled dataset for complex and cross-domain semantic parsing and text-to-sql task. arXiv preprint arXiv:1809.08887, 2018.
334
+ Zhang, J., Wang, J., Li, H., Shou, L., Chen, K., Chen, G., and Mehrotra, S. Draft & verify: Lossless large language model acceleration via self-speculative decoding. arXiv preprint arXiv:2309.08168, 2023.
335
+ Zheng, L., Chiang, W.-L., Sheng, Y., Li, T., Zhuang, S., Wu, Z., Zhuang, Y., Li, Z., Lin, Z., Xing, E., et al. Lmsys-chat1m: A large-scale real-world llm conversation dataset. arXiv preprint arXiv:2309.11998, 2023a.
336
+ Zheng, L., Chiang, W.-L., Sheng, Y., Li, T., Zhuang, S., Wu, Z., Zhuang, Y., Li, Z., Lin, Z., Xing, E. P., Gonzalez, J. E., Stoica, I., and Zhang, H. Lmsys-chat-1m: A large-scale real-world llm conversation dataset, 2023b.
337
+ Zhou, Y., Lyu, K., Rawat, A. S., Menon, A. K., Rostamizadeh, A., Kumar, S., Kagy, J.-F., and Agarwal, R. Distillspec: Improving speculative decoding via knowledge distillation. arXiv preprint arXiv:2310.08461, 2023.
338
+
339
+ # A. Appendix
340
+
341
+ # A.1. Speculative Decoding Sampling
342
+
343
+ With $i$ rising from 1 to $k$ , speculative decoding accepts the proposal $y_{i}$ if $u \leq p(y_{i}|\boldsymbol{x}, \boldsymbol{y}_{<i}) / q_{\boldsymbol{\theta}}(y_{i}|\boldsymbol{x}, \boldsymbol{y}_{<i})$ where $u \sim U[0,1]$ ; otherwise exits. Let $a$ denote the number of accepted tokens, which takes values in $\{0, \dots, k\}$ . We can sample an additional token $y_{a+1}$ from the following distribution
344
+
345
+ $$
346
+ p ^ {\prime} (y) = \left\{ \begin{array}{l l} p (y | \boldsymbol {x}, \boldsymbol {y} _ {< a + 1}) & \text {i f} a = k \\ \operatorname {n o r m} (\max (0, \\ p (y | \boldsymbol {x}, \boldsymbol {y} _ {< a + 1}) - q _ {\theta} (y | \boldsymbol {x}, \boldsymbol {y} _ {< a + 1}))) & \text {o t h e r w i s e} \end{array} \right. \tag {5}
347
+ $$
348
+
349
+ where $\mathrm{norm}(\cdot)$ makes the probabilities over the vocabulary sum to 1.
350
+
351
+ Prior work has shown that the resulting samples $\tilde{\pmb{y}}\triangleq \{y_1,\dots ,y_{a + 1}\}$ strictly follow the distribution of the target LLM $p(\cdot |\pmb {x})$ (Leviathan et al., 2023). We concatenate $\tilde{\pmb{y}}$ to $\pmb{x}$ and repeat the above process until meeting $\langle \mathrm{EOS}\rangle$ . Each run of the target LLM generates $a + 1$ tokens with $a\geq 0$ . This ensures that at least one new token is generated even in the worst case. The generation process can be significantly accelerated if the draft LLM better approximates the target one, particularly $a$ is larger for each target LLM run.
352
+
353
+ # A.2. Speculative Decoding Speedup
354
+
355
+ ![](images/e2a663e782f5e06dd9eef06d0b8a46b74182ed8488914826819d6df4a070c736.jpg)
356
+ Figure 8. Speculative decoding speedups for different $\alpha$ s. $c$ : time ratio for a single run between the draft and target model. $k$ : propose length. For small $\alpha$ , speculative decoding may slow down inference (speedup $< 1$ ). The connection between speedup and $\alpha$ is superlinear; doubling the acceptance yields over $2\times$ speedup.
357
+
358
+ ![](images/67f456803c3817671e8d4506cbc50b00c117fdbb56a350a04c57e5b88cf5b5cf.jpg)
359
+
360
+ As proved in (Leviathan et al., 2023), compared with standard decoding, the expected improvement factor for offline speculative decoding is $\frac{1 - \alpha^{k + 1}}{(1 - \alpha)(ck + 1)}$ . Let the time taken for a single run of $M_p$ be $T$ . Define $c$ , the cost coefficient, as the ratio of the time taken for a single run of $M_q$ to that of $M_p$ . Each execution of lines 7 to 8 takes $Tck + T$ and, on average, yields $\frac{1 - \alpha^{k + 1}}{1 - \alpha}$ tokens. As a result, the average time to produce one token using speculative decoding is given by $\frac{(ck + 1)(1 - \alpha)}{1 - \alpha^{k + 1}} T$ . In contrast, the time to produce a single token using standard decoding is $T$ . Hence, the wallclock time reduction of offline speculative decoding can be described as $\frac{1 - \alpha^{k + 1}}{(1 - \alpha)(ck + 1)}$ .
361
+
362
+ # A.3. Latency Analysis
363
+
364
+ Suppose OSD can improve the token acceptance rate from $\alpha_{1}$ to $\alpha_{2}$ and $T$ is the generation time for standard decoding. Based on Equation 1, this improvement leads to a decrease in the average generation time for each token, transitioning from $\frac{(ck + 1)(1 - \alpha_1)}{1 - \alpha_1^{k + 1}} T$ to $\frac{(ck + 1)(1 - \alpha_2)}{1 - \alpha_2^{k + 1}} T$ . Consequently, this results in a speedup factor of $\frac{1 - \alpha_2^{k + 1}}{1 - \alpha_1^{k + 1}}\frac{1 - \alpha_1}{1 - \alpha_2} = \frac{1 + \alpha_2 + \alpha_2^2 + \ldots + \alpha_2^k}{1 + \alpha_1 + \alpha_1^2 + \ldots + \alpha_1^k}$ compared to standard speculative decoding.
365
+
366
+ In the aforementioned analysis, we omitted the additional latency due to updating the smaller model for the following reasons: (1) As illustrated subsequently, the additional computational cost (FLOPs) from the update remains marginal when juxtaposed with the computational demands of running the larger model. (2) Updates are periodic, during times of moderate request loads, the latency for serving individual requests remains largely unaffected. Additionally, given that the update operation for the smaller model is considerably less resource-intensive than inference, the associated latency might be seamlessly masked, rendering it virtually imperceptible. Lastly, the processes of updating and inference can even be executed concurrently on separate devices.
367
+
368
+ # A.4. Flops Analysis
369
+
370
+ The FLOPs required to update the draft model are significantly fewer than those needed for inference on a large model. Denote $L$ as the average length of the generated sequence. For each verification, the draft model suggests $k$ tokens. The expected length for a single run of the target LLM, denoted as $a$ , can be calculated using Equation 1. Therefore, OSD undergoes the verification process $\frac{L}{a}$ times, with each time verifying $k + 1$ tokens. We use $F_{qfdw}$ to represent the arithmetic operations required by a singular forward run of the draft model for each token, and $F_{pfwd}$ stands for the FLOPs needed for a single forward run of the target model per token. Therefore, the computational demand (in FLOPs) for the draft and teacher models to handle one request can be expressed as: $\mathrm{FLOPs}(draft) = \frac{L}{a} \times k \times F_{qfdw}$ , $\mathrm{FLOPs(target)} = \frac{L}{a} \times (k + 1) \times F_{pfwd}$ . Let's consider the FLOPs required to update the student model per token as $F_{qbwd}$ . The cumulative FLOPs necessary to process $I$ requests is given by:
371
+
372
+ $$
373
+ \frac {L I}{a} \times [ k \times F _ {q f w d} + (k + 1) \times F _ {p f w d} ] + I \times L \times F _ {q b w d}.
374
+ $$
375
+
376
+ Based on the findings of (Kaplan et al., 2020), training is approximately three times costlier than inference. This translates to roughly 6 FLOPs per parameter for training on a single token and 2 FLOPs per parameter for inferring on one token. Thus, we can simplify the total FLOPs expression to:
377
+
378
+ $$
379
+ \frac {L I}{a} \left[ (k + 3 a) \times F _ {q f w d} + (k + 1) \times F _ {p f w d} \right]. \tag {6}
380
+ $$
381
+
382
+ The proportion of FLOPs needed to run the target model to that of the draft model is given by:
383
+
384
+ $$
385
+ \frac {(k + 1) \times F _ {p f w d}}{(k + 3 a) \times F _ {q f w d}}.
386
+ $$
387
+
388
+ For the two model pairs evaluated, assuming an average of 5 proposed tokens per run: (1) (LLaMA-160M, Vicuna7B) with an average acceptance rate of 0.71, the ratio is approximately $\frac{(5 + 1)\times 7B}{(5 + 3\times 3)\times 160M} = 18.75$ . (2) (T5-small 80M, Flan-T5-XL 3B), with an average acceptance rate of 0.76, the ratio is roughly $\frac{(5 + 1)\times 3B}{(5 + 3\times 4.3)\times 80M} = 12.6$ .
389
+
390
+ In practical systems, the FLOPs required for inference are significantly below the machine's capacity. Consider the LMSYS-Chat-1M (Zheng et al., 2023b). It comprises traces spanning 125 days with 1000,000 requests, averaging less than 2,000 tokens per request (including both prompts and responses). When serving a 30B model with 8 A100 GPUs, the FLOPs consumed per second can be estimated as (Still, we estimate 2 FLOPs per token per parameter):
391
+
392
+ $$
393
+ \frac {2 0 0 0 \times 1 0 0 0 , 0 0 0}{1 2 5 \times 2 4 \times 3 6 0 0} \times 3 0 \times 1 0 ^ {9} \times 2 = 5. 5 \times 1 0 ^ {9} \text {F L O P s} \text {o r} 5. 5 \text {G F L O P s}
394
+ $$
395
+
396
+ On the other hand, 8 A100 GPUs offer a combined capacity of $8 \times 312$ TFLOPs, and the computational utilization is notably low. While Arena (the platform that generates LMSYS-Chat-1M) may not be the most efficient and might lack substantial traffic, it's the only publicly accessible LLM service trace. Even after amplifying the load multiple times, based on the above calculations, the computation efficiency remains limited.
397
+
398
+ # A.5. Bandwidth Analysis
399
+
400
+ LLM inference is memory bandwidth bound. When the input/output length is short, the memory operations are dominated by loading model parameters from GPU HBM to SRAM. We analyze the memory loading requirements of different inference techniques below (batch_size = 1). We first introduce the notations used in the analysis. $M / m$ : The total bytes of the target/draft model. $L$ : inference length. $a_1 / a_2$ : The expected generation length for a single run of the target LLM of Vanilla speculative decoding(VSD)/OSD. $I$ : the interval to update the draft model. On a high level, $\frac{L}{a} * M$ represents the bytes required to load the target model, while $L * m$ indicates the bytes needed for loading the draft model. For OSD, $m * \frac{L}{I}$ denotes the bytes necessary to load the draft model for updates.
401
+
402
+ We applied Formula 1 from our paper to calculate $a_1$ , $a_2$ , using the token acceptance rates for standard vanilla speculative decoding and OSD on the Spider dataset with the LLaMA-160M and Vicuna-7B models as the draft and target models, respectively. This resulted in $a_1 = 1.4$ and $a_2 = 3.4$ . The memory sizes are $M = 14\mathrm{GB}$ for the target model and $m = 0.32\mathrm{GB}$ for the draft model. For OSD, the draft model is updated every 8 iterations ( $I = 8$ ). Using these values, we have estimated the memory loading bytes, presented in the right column.
403
+
404
+ Table 5. Bandwidth analysis. Original means inference without speculative decoding. VSD, vanilla Speculative Decoding. OSD, online speculative decoding.
405
+
406
+ <table><tr><td></td><td>Memory Loading Formula</td><td>Memory Loading in bytes of
407
+ (LLaMA-160M, Vicuna-7B) pair, L=128, a1=1.4, a2=3.4</td></tr><tr><td>Original</td><td>L * M</td><td>1792 GB</td></tr><tr><td>VSD</td><td>L/a1* M + L*m</td><td>1320 GB</td></tr><tr><td>OSD</td><td>L/a2* M + L*m + m*L/T</td><td>573 GB</td></tr></table>
408
+
409
+ ![](images/787221176e1ee9c3f56a7c824e1ba2623281e14a86c9dfe4d8889e06014e9d9a.jpg)
410
+ Figure 9. Mix of distributions.
411
+
412
+ # A.6. Data Mix
413
+
414
+ Moreover, there is a question of whether the draft model, once adapted to the new distribution, might lose its prior knowledge. To probe this, we conducted an experiment mixing 2k prompts each from the Gsm8k and Alpaca-finance datasets. During online serving, for the initial 2k requests, we only update the model based on data from the Gsm8k dataset. For the subsequent half of the requests, we restrict updates solely to data from the Alpaca-finance dataset. We then provide the average token acceptance rates for all requests, segmented by their data source (Gsm8k versus Alpaca-finance). As depicted in Figure 9, the token acceptance rate for Gsm8k increases as the draft model is exposed to more data. Conversely, the acceptance rate $(\alpha)$ for the Alpaca-finance dataset remains consistent. This is anticipated since we only update the draft model using Gsm8k data. In the latter half of the dataset, the token acceptance rate for the Alpaca-finance dataset also shows an uptrend. Intriguingly, the rate for Gsm8k remains consistent, suggesting that the draft model retains its learned knowledge without showing signs of forgetting.
415
+
416
+ # A.7. Real Workloads
417
+
418
+ Arena Dataset For expedited experimental evaluation, we randomly sample a subset with 10K records from LMSYS-Chat-1M (Zheng et al., 2023b), a comprehensive real-world LLM conversation dataset. This dataset encompasses interactions with 25 models spanning from April to August 2023 and features conversations in over 150 languages. For all experiments, we only pick conversations for Vicuna models.
419
+
420
+ # A.8. Various Degrees of Distribution Shifts
421
+
422
+ In this section, we experimented to evaluate if OSD can maintain a high token acceptance rate amidst varying degrees of distribution shifts. We conduct simulations to replicate both abrupt and gradual distribution changes. In the abrupt shift scenario, we merge the Gsm8k and Spider datasets, each containing 2,000 records, without any transitional phase. Conversely, for gradual distribution shift, we introduce a probabilistic blend of the two datasets. Here, the likelihood of a record originating from the Gsm8k dataset decreases linearly from $100\%$ to $0\%$ as we progress from the first to the 4,000th record, while the probability of it coming from the Spider dataset increases correspondingly. This results in a smooth transition from Gsm8k to Spider data.
423
+
424
+ We measure the token acceptance rate by averaging it over the most recent 100 records. Our findings show a notable dip in the token acceptance rate at the juncture of the two datasets (around the 2,000th record) for the abrupt shift case. However, the acceptance rate quickly recovers. In the case of the gradual shift, the decline in the token acceptance rate is much less
425
+
426
+ ![](images/fad7b3e8542441ca837df6027f6a8f1d7ad342036d809f803b192ecaa9ed8aa5.jpg)
427
+ Figure 10. We divided the time into ten equal segments. For each segment, the percentage indicates the share of queries relative to the total within that specific interval. The left image graphically represents the evolution of query distribution among various languages over these periods. In contrast, the right image categorizes these queries by topic, showcasing their topical distribution varying over time. discernible, indicating that OSD can indeed effectively adapt to progressive changes in the data distribution by consistently maintaining a high token acceptance rate.
428
+
429
+ ![](images/252a038fc80a189b12186b4e16619d34cd2c8d5ead05f4200d48fdebf1780ec2.jpg)
430
+
431
+ ![](images/a02c5912637c765b4b5c66d96b33af620a0183a3f33d4c062547c102abdb39b0.jpg)
432
+ Figure 11. Vary degrees of distribution shift.
433
+
434
+ Table 6. Top 15 tokens with the most recall/precision improvement across datasets. We ignore _ before tokens, which represents space in the LLaMA tokenizer.
435
+
436
+ <table><tr><td>Dataset</td><td>Spider</td><td>Gsm8k</td><td>Alpaca-Finance</td><td>Code-Python</td></tr><tr><td>Tokens with the great-est precision increase</td><td>AV, SELECT, first, ⟨EOS⟩, template, SUM, G, COUNT, \n, city, WHERE, &#x27;;&#x27; (, IST, id</td><td>⟨EOS⟩, &gt;&gt;, +, To, &lt;&lt;, this, =, %, know, are, We, calculate, be, The, have</td><td>1, Here, ( , ;, provide, depends, However, goals, amount, 3, there, The, \n, personal, will</td><td>”, ( , Here, python, , how, doc, snippet, import, based, { , Python, This, ;, you</td></tr><tr><td>Tokens with the great-est recall increase</td><td>SELECT, *, FROM, ( , IST, *), \n, COUNT, G, first, WHERE, ⟨EOS⟩, IN, ;, MAX, ;</td><td>start, &gt;&gt;, &lt;&lt;, +, find, how, we, =, fore, To, so, \, ⟨EOS⟩, then, let</td><td>general, 1, several, This, de-pends, Here, provide, How-ever, goals, over, ( , If, amount, it, can</td><td>Here, This, snippet, &quot;&quot;, , how, python, ( , takes, Python, you, doc, an, import, def</td></tr></table>
437
+
438
+ Table 7. Measured execution time/speedup and theoretical execution time/speedup. Original means inference without speculative decoding. The numbers are measured on a single A100-80G with batch size = 1 and draft token length $k = 8$ .
439
+
440
+ <table><tr><td></td><td>Original</td><td>OSD, α = 0.5</td><td>OSD, α = 0.6</td><td>OSD, α = 0.7</td><td>OSD, α = 0.8</td><td>OSD, α = 0.9</td></tr><tr><td colspan="7">Vicuna-33B + TinyLLaMA-1.1B (c = 0.08)</td></tr><tr><td>Measured time in ms/token (speedup)</td><td>51.09</td><td>39.90 (1.28 ×)</td><td>35.48 (1.44 ×)</td><td>30.96 (1.65 ×)</td><td>25.42 (2.01 ×)</td><td>19.43 (2.63 ×)</td></tr><tr><td>Theoretical time in ms/token (speedup)</td><td>51.09</td><td>39.00 (1.31 ×)</td><td>32.12 (1.59 ×)</td><td>26.07 (1.96 ×)</td><td>20.77 (2.46 ×)</td><td>16.38 (3.12 ×)</td></tr><tr><td colspan="7">Vicuna-7B + LLaMA-160M (c = 0.13)</td></tr><tr><td>Measured time in ms/token (speedup)</td><td>13.21</td><td>13.85 (0.95 ×)</td><td>11.39 (1.17 ×)</td><td>10.20 (1.3 ×)</td><td>7.84 (1.68 ×)</td><td>5.17 (2.55 ×)</td></tr><tr><td>Theoretical time in ms/token (speedup)</td><td>13.21</td><td>13.48 (0.98 ×)</td><td>10.92 (1.21 ×)</td><td>8.41 (1.57 ×)</td><td>6.23 (2.12 ×)</td><td>4.40 (3.00 ×)</td></tr></table>
441
+
442
+ # A.9. Theoretical and Measured Latency
443
+
444
+ In this section, we compare the theoretical speedup calculated with Formula 5 and measured speedup. As shown in Table 7, the observed speedup closely aligns with the theoretical expectations. Slow sampling can be the reason for the discrepancies. Speculative decoding necessitates additional sampling steps, as the draft model generates preliminary tokens. For optimal performance, the sampling process must be expedited. Moreover, to attain significant speedup, the execution time ratio (denoted as $c$ ) between the draft and target models should be minimized. However, in practical implementations, the overall execution time for the draft model is disproportionately affected by kernel launch overheads and Python-related delays, resulting in slower-than-anticipated performance.
445
+
446
+ A.9.1. GENERATION LENGTH AND SPEEDUP
447
+
448
+ <table><tr><td>Generation length</td><td>α = 0.5</td><td>α = 0.6</td><td>α = 0.7</td><td>α = 0.8</td><td>α = 0.9</td></tr><tr><td>16</td><td>1.22</td><td>1.37</td><td>1.52</td><td>2.01</td><td>2.40</td></tr><tr><td>32</td><td>1.23</td><td>1.41</td><td>1.52</td><td>2.05</td><td>2.42</td></tr><tr><td>64</td><td>1.23</td><td>1.41</td><td>1.53</td><td>2.05</td><td>2.43</td></tr><tr><td>128</td><td>1.24</td><td>1.42</td><td>1.53</td><td>2.05</td><td>2.43</td></tr><tr><td>256</td><td>1.25</td><td>1.45</td><td>1.54</td><td>2.07</td><td>2.46</td></tr><tr><td>512</td><td>1.25</td><td>1.48</td><td>1.61</td><td>2.12</td><td>2.57</td></tr><tr><td>1024</td><td>1.27</td><td>1.52</td><td>1.66</td><td>2.17</td><td>2.56</td></tr><tr><td>2048</td><td>1.29</td><td>1.55</td><td>1.73</td><td>2.24</td><td>2.70</td></tr></table>
449
+
450
+ In this section, we test the effect of generation length on measured speedup, we conduct the following experiments in llama.cpp. With our implementation of OSD, we fix the batch size at 1, prefix length at 512, draft token length at 5. We vary the generation length from 16 to 2048, and evaluate speedup at different token acceptance rate alpha. The teacher and student models used are Vicuna-7B-v1.5 and Llama-160M respectively.
451
+
452
+ From the Table 9, we see that the measured speedup does increase at each token acceptance rate as generation length increases from 16 to 2048. This is because, at greater generation lengths, each decoding step executed by the teacher model becomes increasingly more memory-intensive. Employing a student model can thus reduce the time ratio $c$ in equation (1), representing a single run comparison between the teacher and student models, thereby achieving a greater speedup. However, the data presented in the table reveals that the impact of extending generation length on speedup is not as pronounced as the effect of enhancing the token acceptance rate. This suggests that improvements in token acceptance rate are more effective in achieving significant speedups than simply increasing generation length.
453
+
454
+ # A.9.2. DRAFT MODEL EXECUTION TIME
455
+
456
+ To verify that when the draft model is small, updating the draft model (including the forward and backward pass) is much less expensive than inference on the target model, we measure the execution time of updating the draft model and the large model inference time (prompt_len=64, generation_len=128) on a single A100-80G with Huggingface Transformer library (hft, 2023). Assuming we update the draft model every eight iterations $(k = 8)$ , the forward execution time is $24.96 / 0.12 = 208$ times longer than the time spent updating the draft model for the (160M, 7B) pair, and $55.12 / 0.67 = 82.3$ times longer for the (1.1B, 33B) pair.
457
+
458
+ Table 8. Generation length and measure speedup across different token acceptance rates.
459
+
460
+ <table><tr><td>Model Pairs</td><td>Draft forward + backward + update time (s)</td><td>Target forward time (s) of</td><td>Target forward time (s) of k iterations (k=8)</td><td>Draft model update time (s) every k iterations (k=8)</td></tr><tr><td>(160M, 7B)</td><td>0.12</td><td>3.12</td><td>24.96</td><td>0.12</td></tr><tr><td>(1.1B, 33B)</td><td>0.67</td><td>6.89</td><td>55.12</td><td>0.67</td></tr></table>
461
+
462
+ Table 9. Generation length and measure speedup across different token acceptance rates.
onlinespeculativedecoding/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ea243fca1b7751dd7e2cca670e5bf0fd170482d953d8b360f78696eba5d6b897
3
+ size 704784
onlinespeculativedecoding/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:030925fc6837d9daf762b6ec298a80953732cfa02df472e99d6c00c52a6f0391
3
+ size 638012
onlinevariationalsequentialmontecarlo/be0a007f-a784-40d2-81e2-222d2d20bc76_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:37a909a9d9cfcd6aeb704276ee1b5f4bf6939cbffb9f0cef18193aff8f39ad59
3
+ size 192410
onlinevariationalsequentialmontecarlo/be0a007f-a784-40d2-81e2-222d2d20bc76_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dc0414e2745b18f1e0b55ccf7be66bf184db464c6b3d481efbb79928e14b08a7
3
+ size 220957
onlinevariationalsequentialmontecarlo/be0a007f-a784-40d2-81e2-222d2d20bc76_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba3ffb61e2ea99483ca45868da3fd2d2953ebf84eb1606c3b8220d287270bb4a
3
+ size 9479444
onlinevariationalsequentialmontecarlo/full.md ADDED
The diff for this file is too large to render. See raw diff
 
onlinevariationalsequentialmontecarlo/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3956c04ef329ff88930a41db4a878580baa0e03cf52cda2fa69cbe0f17d59275
3
+ size 1559774
onlinevariationalsequentialmontecarlo/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:117d7eeab5de8ed55d780079f29dc1e8911f0d1bb8a0c18974350ae0fffdee48
3
+ size 1210883
openadhocteamworkwithcooperativegametheory/e57b0fbd-0a7c-426d-8b15-78c5ef14ac69_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7be57eab58dc1adaa7daa50daa25670aca5008e98364467f1c56cba20896b894
3
+ size 230269
openadhocteamworkwithcooperativegametheory/e57b0fbd-0a7c-426d-8b15-78c5ef14ac69_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:73e1c2b8bbee3dbe548bb4d14e240bbc02f555f35071759a57464a94f3ea38d6
3
+ size 267825