vix.ing · top · new · best · stats

WGRAMMAR: Leverage Prior Knowledge to Accelerate Structured Decoding

2025/07/22 by Ran Wang, Xiaoxuan Liu, Wang, Ran +9 · 1 citation
Computer Science · #Algorithms and Data Compression #Artificial Intelligence (cs.AI) #Code (set theory) #Decoding methods #FOS: Computer and information sciences #Grammar #Leverage (statistics) #Set (abstract data type) #Source code #Speedup

paper · pdf · doi:10.48550/arxiv.2507.16768

published in arXiv (Cornell University) (Cornell University)

openalex publication_date 2025/07/22 · openalex created_date 2025/10/10 · openalex updated_date 2026/08/05

Abstract

Structured decoding enables large language models (LLMs) to generate outputs in formats required by downstream systems, such as HTML or JSON. However, existing methods suffer from efficiency bottlenecks due to grammar compilation, state tracking, and mask creation. We observe that many real-world tasks embed strong prior knowledge about output structure. Leveraging this, we propose a decomposition of constraints into static and dynamic components -- precompiling static structures offline and instantiating dynamic arguments at runtime using grammar snippets. Instead of relying on pushdown automata, we employ a compositional set of operators to model regular formats, achieving lower transition latency. We introduce wgrammar, a lightweight decoding engine that integrates domain-aware simplification, constraint decomposition, and mask caching, achieving up to 250x speedup over existing systems. wgrammar's source code is publicly available at https://github.com/wrran/wgrammar.

Citations

Cited by

Related