GRID: Grammar-Railed Decoding for Enterprise SQL Generation
- URL: http://arxiv.org/abs/2607.11951v1
- Date: Sat, 11 Jul 2026 19:25:23 GMT
- Title: GRID: Grammar-Railed Decoding for Enterprise SQL Generation
- Abstract summary: We present GRID (Grammar-Railed Decoding), a grammar-constrained decoding engine.<n>It uses advanced LALR(1) itself as a viable oracle.<n>Four guarantees (soundness, completeness, termination, and near-constant per-token cost) are stated with explicit preconditions.
- Score: 0.0
- License: http://creativecommons.org/licenses/by/4.0/
- Abstract: Large language models can write SQL, but enterprise deployment demands more than plausible text: outputs must be syntactically valid, must respect per-role and per-schema policy, must carry provable (not best-effort) guarantees, must not slow down as generations grow, and must leave a compliance-grade record of every decision. We present GRID (Grammar-Railed Decoding), a grammar-constrained decoding engine that keys exact next-token masks on parser configurations (lexer scan state x LALR(1) stack) rather than on token sequences, and uses the incrementally advanced LALR(1) parser itself as a viable-prefix oracle. LLM tokens are bridged to grammar terminals by a byte-level trie walk with a context-independent/context-dependent split that makes cache-key soundness hold by construction. Role-based access control is compiled into the language: role projections subset the grammar's productions and schema lexicons restrict identifier terminals, so forbidden verbs and identifiers are unreachable at mask level. Four guarantees (soundness, completeness, termination, and near-constant per-token cost) are stated with explicit preconditions and each paired with a test or benchmark. Rust kernels bring the per-token mask to a 3.6-6.7 us median, ahead of llguidance at p50 and p90 on two tokenizers with zero false rejects; per-token guard cost is position-flat at n=16,000. On Spider, constrained decoding is worth +13 execution-accuracy points at 0.5B, and one checker-guided repair pass over the provably mask-unenforceable residue (column-level policy) lifts a 7B model to 94.5% executable. A hash-chained per-token audit trail replays bit-identically with 100% tamper detection. We state plainly what the mask cannot do (distribution faithfulness, column-level RBAC, non-LALR(1) languages) and where measured cost remains.
Related papers
- Dependency-Aware Revocable Decoding for Efficient Diffusion Large Language Model Inference [26.756607509798382]
Dependency-Aware Revocable Decoding (DARD) is a training-free framework that separates tokens into masked, candidate, and unmasked states.<n>DARD consistently improves the speed-quality frontier over recent decoding methods.
arXiv Detail & Related papers (2026-08-27T03:34:47Z) - The Parser Already Knows: Lightweight Bias Correction in Constrained Decoding [30.042720796822085]
Grammar Constrained Decoding (GCD) forces Language Models (LMs) to produce syntactically valid outputs by masking out non-conforming tokens at each step.<n>Online sampling restores this distribution, but it requires computationally expensive iterative resampling.<n>We propose a lightweight, offline-trained logit correction conditioned on this syntactic and lexical state together with candidate next tokens.
arXiv Detail & Related papers (2026-08-10T18:52:43Z) - Weave of Formal Thought [51.56484100374058]
We introduce Weave of Formal Thought (WoFT), a paradigm uniting rigorous syntactic validation with learned structural representations.<n>We present a latent-variable fine-tuning method training the language model to interleave non-terminal grammar symbols directly into generation.<n>For Python, fine-tuning StarCoder2-3B with our RWS objective reduces per-token cross-entropy by 14.3% relative to a text-only SFT baseline.
arXiv Detail & Related papers (2026-06-24T15:58:11Z) - CODEBLOCK: Learning to Supervise Code at the Right Granularity [32.949996770189834]
We propose a structure-aware sparse supervision framework that selects structure-complete code evidence rather than isolated tokens.<n>Experiments show that CodeBlock achieves stronger average pass@1 than full-token SFT and competitive selection baselines.
arXiv Detail & Related papers (2026-06-10T04:46:04Z) - MaskForge: Structure-Aware Adaptive Attacks for Jailbreaking Diffusion Large Language Models [53.05463623673949]
MaskForge is a fully black-box adaptive attack that casts dLLM red-teaming as optimized search over a growing library of structural patterns.<n>It achieves an average attack success rate of 79.3%, a 17.6% improvement over the strongest competing dLLM baseline.
arXiv Detail & Related papers (2026-06-01T18:10:21Z) - SimSD: Simple Speculative Decoding in Diffusion Language Models [61.33773959352141]
Diffusion large language models (dLLMs) offer faster inference through parallel or blockwise decoding.<n>Their masked language modeling formulation remains incompatible with standard token-level speculative decoding.<n>We propose a speculative decoding algorithm for dLLMs, named SimSD, that equips dLLMs with temporally valid token-level contexts.<n>Our method achieves up to 7.46x higher decoding throughput while maintaining and even improving average generation quality.
arXiv Detail & Related papers (2026-06-01T17:46:46Z) - Attention Meets Reachability: Structural Equivalence and Efficiency in Grammar-Constrained LLM Decoding [0.2864713389096699]
We study grammar-constrained decoding (GCD) as a coupling between an autoregressive next-token distribution and a reachability over a pushdown system compiled from a context-free grammar (CFG)<n>We define decoding-cost equivalence classes of grammars and prove existence of minimal-SAC representatives within bounded rewrite families.
arXiv Detail & Related papers (2026-03-04T11:49:55Z) - Residual Context Diffusion Language Models [90.07635240595926]
Residual Context Diffusion (RCD) is a module that converts discarded token representations into contextual residuals and injects them back for the next denoising step.<n>RCD consistently improves frontier dLLMs by 5-10 points in accuracy with minimal extra computation overhead.
arXiv Detail & Related papers (2026-01-30T13:16:32Z) - Broken Tokens? Your Language Model can Secretly Handle Non-Canonical Tokenizations [83.93566096400723]
We find that instruction-tuned models retain up to 93.4% of their original performance when given a randomly sampled tokenization.<n>Character-level segmentation improves string manipulation and code understanding tasks by up to +14%.<n>Right-aligned digit grouping enhances large-number arithmetic by +33%.
arXiv Detail & Related papers (2025-06-23T18:02:26Z) - Flexible and Efficient Grammar-Constrained Decoding [5.671312847528642]
Grammar-constrained decoding (GCD) can guarantee that LLM outputs matches such rules.<n>Existing GCD algorithms require tens of minutes to preprocess common grammars.<n>We present a new GCD algorithm together with an implementation that offers 17.71x faster offline preprocessing than existing approaches.
arXiv Detail & Related papers (2025-02-07T17:35:17Z) - Not all tokens are created equal: Perplexity Attention Weighted Networks for AI generated text detection [49.15148871877941]
Next-token distribution outputs offer a theoretically appealing approach for detection of large language models (LLMs)<n>We propose the Perplexity Attention Weighted Network (PAWN), which uses the last hidden states of the LLM and positions to weight the sum of a series of features based on metrics from the next-token distribution across the sequence length.<n>PAWN shows competitive and even better performance in-distribution than the strongest baselines with a fraction of their trainable parameters.
arXiv Detail & Related papers (2025-01-07T17:00:49Z)
This list is automatically generated from the titles and abstracts of the papers in this site.
This site does not guarantee the quality of this site (including all information) and is not responsible for any consequences.