注意力与可达性相结合:在语法约束下LLM解码的结构等价与效率
Attention Meets Reachability: Structural Equivalence and Efficiency in Grammar-Constrained LLM Decoding
AI总结:
本文研究了语法约束解码中结构等价与效率问题,提出结构歧义成本度量,并推导了硬掩码解码的精确扭曲界,结合Transformer架构并连接到性能模型与自动语法优化。
摘要:
我们研究了语法约束解码(GCD)作为自回归下一个token分布与一个在推导文法编译后的推导系统上的可达性 oracle 之间的耦合。我们证明了一个 oracle 不变性定理:语言等价的语法会为每个前缀诱导相同的可接受下一个token集合,因此相同的logit掩码,但可以产生可证明不同的编译状态空间和在线歧义成本。我们给出了对于经典 $a^n b^n$ 语言在冗余非终端委托下的精确控制状态膨胀计数,并引入了一个从左到右的结构歧义成本(SAC),衡量每个token的增量打包解析森林增长。对于两个等价的语法,SAC在右递归下为每个token是 $O(1)$,但在连接下为 $Θ(t^2)$ 每个token和 $Θ(n^3)$ 累积。我们建立了引擎无关的下界:任何正确、检索高效、解析保持的在线掩码引擎必须在特定的常数大小CFG家族上产生 $Ω(t^2)$ 的每个token的工作量,无条件在此模型内。我们定义了解码成本等价类的语法,并证明在受限制的重写家族中存在最小SAC代表。最后,我们通过Doob $h$-变换定义了真正的条件采样器,并推导了硬掩码解码的精确一步KL和总变分扭曲界,以生存概率分布在可接受下一个token中的扩展为参数。我们把这些结果与Transformer和专家混合架构相结合,以词汇量、活跃状态集和束宽为参数推导延迟包络,并将SAC连接到基于仪器的预测性能模型和自动语法优化。
英文摘要:
We study grammar-constrained decoding (GCD) as a coupling between an autoregressive next-token distribution and a reachability oracle over a pushdown system compiled from a context-free grammar (CFG). We prove an oracle invariance theorem: language-equivalent grammars induce identical admissible next-token sets for every prefix, hence identical logit masks, yet can yield provably different compiled state spaces and online ambiguity costs. We give exact control-state blowup counts for the canonical $a^n b^n$ language under redundant nonterminal delegation, and introduce a left-to-right structural ambiguity cost (SAC) measuring incremental packed-parse-forest growth per token. For two equivalent grammars over all finite strings, SAC is $O(1)$ per token under right-recursion but $Θ(t^2)$ per token and $Θ(n^3)$ cumulatively under concatenation. We establish engine-independent lower bounds: any sound, retrieval-efficient, parse-preserving online masking engine must incur $Ω(t^2)$ work per token on a specific constant-size CFG family, unconditionally within this model. We define decoding-cost equivalence classes of grammars and prove existence of minimal-SAC representatives within bounded rewrite families. Finally, we characterize the true conditional sampler via a Doob $h$-transform and derive sharp one-step KL and total-variation distortion bounds for hard-masked decoding in terms of survival-probability spread among admissible next tokens. We integrate these results with Transformer and Mixture-of-Experts architectures, derive latency envelopes in terms of vocabulary size, active state sets, and beam width, and connect SAC to instrumentation-based predictive performance models and automated grammar optimization.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。