Speculative decoding is a successful technique speeding up inference of a target autoregressive language model via a fast drafter model. Lossy speculative decoding allows a drift with respect to the target to further improve speed. Interestingly, it has been observed experimentally that the resulting model can also beat the target quality-wise. Our paper formally proves how such a feat is possible with a formal approach to lossy speculative decoding called mentored decoding. To get there, we connect inference to a celebrated ML training theory, boosting, and proceed via the generalization of mentored decoding to the whole set of f-divergences. We uncover key properties of mentored decoding, among which (i) the particularly appealing geometric nature of the total variation case, (ii) simple approximations for any f-divergence in direct relation with boosting compliance, and (iii) a divergence independentO(n) space and O(sort(n)) time data structure built on drafter and target outputs, which allows to query the optimal parameters of the dual problem in O(logn) time and constructing optimal mentored distributions in O(n) time for any f-divergence.
Figures & tables
Figure 1: Example of optimal solutions for the TV-MD problem with n=3 tokens in Δ3 , as intersection (thick segment) between the two L1 balls centered in p and q (in color red and blue ) whose radii define D and the optimal objective value for the total variation divergences in ( f -MD-1 ). The shaded area is set [min{p,q},max{p,q}]∩Δ3 (see text).
Figure 2: Illustration of the definition of clampset(z,A,B) ( 10 ) (in red ) when A<B are intervals (figured by rectangles) and z (thick vertical bar) moves along the real line (see text).
Figure 3: Plots of logt (left) and expt (right), for t=0,1/4,1/2,3/4,1 in black curves where thickness increases with t (see text).
Figure 4: In the Δ3 simplex (same setting as Figure 1 ), we illustrate Theorem 3.13 and Lemma 5.2 . The thick dark line is the set of mentored distributions built from querying QueryCBreakpoints in Algorithm 3 . The bend represents a mentored distribution corresponding to a breakpoint in \textscc(p,q) . We display the couple (a,b) corresponding to the mentored distribution π . Finally, for a set of four f -divergences (rKL = reverse KL), we display that π is also the optimal solution in all \textscmdf(p,q;.) because it is the intersection between the TV-ball defining the optimal objective and the f -divergence ball defining the constraint activated in f -MD.
Table 1: f -divergences used in our toy simulations; we recall fTV(z)=.∣z−1∣/2 (see text).
Table 2: Left: curve of points (a~,b~) in C(p,q) from Lemma 5.3 , showing it is strictly increasing and continuous. Right: curves showing the corresponding f -divergence bound D in ( f -MD-2 ) ( f -MD-1 ) as a function of the optimal acceptance probability P\mboxacc(MD) , for several f -divergences. Remark that for all except TV2 , the right derivative at P\mboxacc(SD) is indeed zero and the divergence stays close to 0 even past >10% increase acceptance probability P\mboxacc(MD) (see text).
Table 3: For each of the f -divergence plots in Table 2 (Right), we plot the divergence as a function of P\mboxacc(MD) , and in filled green the interval of min and max values corresponding to ( 42 ) in Theorem 3.12 , over a range of P\mboxacc(MD) which covers P\mboxacc(SD) ( red dot) to P\mboxacc(SD) increased by 25 % (see text).
Table 4: Top: plots of the f -divergence bound D in \textscmdf(p,q;D) as a function of a ( Left ) and b ( Right ), exemplifying Theorem 3.12 . Bottom: plots of the optimal acceptance probability P\mboxacc(MD) as a function of a ( Left ) and b ( Right ), exemplifying Theorem 3.12 (see text).
Table 5: Left: curve giving the boosting bound coefficient k=.(1+a)/(1−b) (Theorem 4.8 ) as a function of the acceptance probability P\mboxacc(MD) ; remark that k remains close to 1 even for substantial increase of the acceptance probability compared to the speculative decoding solution. Right: curve giving coefficient k as a function of a (see text).
Table 6: Mentored distribution (thick purple curve) and acceptance probability ( purple area) when p (thin blue curve) and q (thin red curve) are discretized from Beta distributions. The values under each plot are b and P\mboxacc(MD) (in parentheses, see text).