arXiv:cs.CL· I\c{s}{\i}l \"Ozg\"u, Yaoxuan Wu, Guy Van den Broeck, Miryung Kim·· 3 小时前AI 评分41
SHIM:用解析器状态做轻量偏置校正的语法约束解码
The Parser Already Knows: Lightweight Bias Correction in Constrained Decoding
AI 导读
研究者提出 SHIM,一种离线训练的轻量校正方法,利用 Grammar Constrained Decoding(GCD)工具已维护的解析器和词法状态,修正 LM 的下一 token 概率,使其分布更接近语法条件下的模型自身分布。
正文
Abstract:Grammar Constrained Decoding (GCD) forces Language Models (LMs) to produce syntactically valid outputs by masking out non-conforming tokens at each step. However, because masking only checks whether each token is valid so far, the resulting distribution over complete outputs diverges from the LM's own distribution conditioned on the grammar, biasing generation toward valid but suboptimal outputs. Online sampling can restore this distribution, but only through costly iterative resampling. Our key insight is that the parser and lexer states that GCD tools already maintain carry a strong signal about future grammatical validity. We introduce SHIM, a lightweight, offline-trained correction of the LM's next-token probabilities, conditioned on this syntactic and lexical state together with candidate next tokens. Since GCD tools already compute these states, SHIM leaves the LM itself untouched. Across bit-vector and text-to-SQL grammars, this correction substantially narrows the gap to the LM's grammar-conditioned distribution compared to masking and online sampling, while running at nearly masking's speed. Even a variant that sees only the next token can improve on both baselines, making SHIM usable with GCD tools that do not expose their parser state.
| Comments: | 10 pages, 5 figures |
| Subjects: | Computation and Language (cs.CL); Machine Learning (cs.LG) |
| ACM classes: | I.2.7; F.4.2 |
| Cite as: | arXiv:2608.10137 [cs.CL] |
| (or arXiv:2608.10137v2 [cs.CL] for this version) | |
| https://doi.org/10.48550/arXiv.2608.10137 arXiv-issued DOI via DataCite |
Submission history
From: Işıl Özgü [view email]
[v1]
Mon, 10 Aug 2026 18:52:43 UTC (233 KB)
[v2]
Wed, 7 Oct 2026 00:39:27 UTC (235 KB)
来源:arXiv:cs.CL · arxiv.org