跳到正文
arXiv cs.AI· John Zhang, Silky Arora·· 2 小时前AI 评分44

Grammar-as-a-Drafter(GaaD):让语法成为第二个 drafter,提升结构化输出投机解码的每步 token 数

Grammar-as-a-Drafter: More Tokens per Speculative Decoding Step on Grammar-Constrained Structured Outputs

AI 导读

论文提出 Grammar-as-a-Drafter(GaaD),将语法作为投机解码中的第二个 drafter,在验证前把 drafter 提案与语法强制 token 合并为宽度 $K$ 的草稿行,GRAMMAR 草稿验证时无需计算 logits。

正文 · 原文

View PDF HTML (experimental)

Abstract:Speculative decoding speeds up generation by letting a lightweight drafter propose tokens that the target model verifies in one forward pass. Under structured outputs (JSON schemas, regular expressions, tool-call formats), the drafter works against a constraint it does not know, so its proposals for keys, delimiters, and indentation are often rejected or invalid, even though the grammar engine already knows the next tokens.
We present Grammar-as-a-Drafter (GaaD), which makes the grammar a second drafter. Before each verify step, the scheduler merges the drafter's proposal with grammar-forced tokens (out-degree 1 in the grammar automaton) into one draft row of width $K$ (which can exceed the drafter's proposal length $K_M$): matching tokens are promoted to GRAMMAR, the proposal is truncated where it disagrees, and grammar tokens fill the remaining slots. The verify step accepts GRAMMAR drafts without computing their logits, composing with any drafter without adding kernels or compilation on the critical path. Because grammars fix text rather than tokens, accepting canonical GRAMMAR drafts with probability 1 preserves grammar validity but can shift the output distribution relative to grammar-masked decoding.
We implement GaaD in vllm-torchtpu and an independent Rust serving runtime, and evaluate it on TPU v7x with MTP, DFlash, and n-gram drafters on a JSON character-profile benchmark. GaaD raises average acceptance length from 2.06 to 5.43 for MTP (Qwen3.5-0.8B; 1.99 to 5.31 on Qwen3.5-35B-A3B), 1.57 to 4.13 for DFlash, and 1.30 to 3.64 for n-gram (Qwen3-4B), decoding 2.66-2.81x faster at batch size 1 and 1.14-1.70x faster at batch size 64. In the Rust runtime, MTP with GaaD is 2.23x faster on Qwen3.5-0.8B and 2.02x on Qwen3.5-397B-A17B-FP8 (1.22-1.69x at high concurrency). Under mixed traffic, GaaD finishes workloads 1.03-1.23x sooner while modestly raising plain-text TPOT.
Comments: 12 pages, 4 figures, 6 tables. Implementation: this https URL
Subjects: Computation and Language (cs.CL); Artificial Intelligence (cs.AI)
Cite as: arXiv:2611.28349 [cs.CL]
  (or arXiv:2611.28349v2 [cs.CL] for this version)
  https://doi.org/10.48550/arXiv.2611.28349

arXiv-issued DOI via DataCite

Submission history

From: John Zhang [view email]
[v1] Fri, 20 Nov 2026 22:00:38 UTC (24 KB)
[v2] Tue, 24 Nov 2026 03:21:22 UTC (19 KB)

来源:arXiv cs.AI · arxiv.org