Skip to content
AI News HubLIVE
Original source2 min read

GRID: Grammar-Railed Decoding for Enterprise SQL Generation

Summary

GRID is a grammar-constrained decoding engine that uses LALR(1) parser states as mask keys to ensure syntactically valid SQL output with role-based access control, provable guarantees, constant per-token cost, and a hash-chained audit trail. On Spider, constrained decoding boosts execution accuracy by +13 points at 0.5B, and a checker-guided repair lifts a 7B model to 94.5% executable.

SourcearXiv AIAuthor: Mohsen Arjmandi
GRID: Grammar-Railed Decoding for Enterprise SQL Generation
Report an error

The correction channel is not available yet. You can copy the article reference below for later.

Correction instructions
Read article

[Submitted on 11 Jul 2026]

Title:GRID: Grammar-Railed Decoding for Enterprise SQL Generation

View a PDF of the paper titled GRID: Grammar-Railed Decoding for Enterprise SQL Generation, by Mohsen Arjmandi

View PDF HTML (experimental)

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.

Comments: 18 pages, 3 figures. Extended version; a condensed version is under review at KDD 2027

Subjects:

Artificial Intelligence (cs.AI); Computation and Language (cs.CL); Formal Languages and Automata Theory (cs.FL); Programming Languages (cs.PL)

ACM classes: I.2.7; F.4.2; H.2

Cite as: arXiv:2607.11951 [cs.AI]

(or arXiv:2607.11951v1 [cs.AI] for this version)

https://doi.org/10.48550/arXiv.2607.11951

arXiv-issued DOI via DataCite (pending registration)

Submission history

From: Mohsen Arjmandi [view email] [v1] Sat, 11 Jul 2026 19:25:23 UTC (32 KB)

Full-text links:

Access Paper:

View a PDF of the paper titled GRID: Grammar-Railed Decoding for Enterprise SQL Generation, by Mohsen Arjmandi

View PDF

HTML (experimental)

TeX Source

view license

Current browse context:

cs.AI

new | recent | 2026-07

Change to browse by:

cs cs.CL cs.FL cs.PL

References & Citations

NASA ADS

Google Scholar

Semantic Scholar

Loading...

Data provided by:

Bibliographic Tools

Bibliographic and Citation Tools

Bibliographic Explorer Toggle

Bibliographic Explorer (What is the Explorer?)

Connected Papers Toggle

Connected Papers (What is Connected Papers?)

Litmaps Toggle

Litmaps (What is Litmaps?)

scite.ai Toggle

scite Smart Citations (What are Smart Citations?)

Code, Data, Media

Code, Data and Media Associated with this Article

alphaXiv Toggle

alphaXiv (What is alphaXiv?)

Links to Code Toggle

CatalyzeX Code Finder for Papers (What is CatalyzeX?)

DagsHub Toggle

DagsHub (What is DagsHub?)

GotitPub Toggle

Gotit.pub (What is GotitPub?)

Huggingface Toggle

Hugging Face (What is Huggingface?)

ScienceCast Toggle

ScienceCast (What is ScienceCast?)

Demos

Demos

Replicate Toggle

Replicate (What is Replicate?)

Spaces Toggle

Hugging Face Spaces (What is Spaces?)

Spaces Toggle

TXYZ.AI (What is TXYZ.AI?)

Related Papers

Recommenders and Search Tools

Link to Influence Flower

Influence Flower (What are Influence Flowers?)

Core recommender toggle

CORE Recommender (What is CORE?)

Author

Venue

Institution

Topic

About arXivLabs

arXivLabs: experimental projects with community collaborators

arXivLabs is a framework that allows collaborators to develop and share new arXiv features directly on our website.

Both individuals and organizations that work with arXivLabs have embraced and accepted our values of openness, community, excellence, and user data privacy. arXiv is committed to these values and only works with partners that adhere to them.

Have an idea for a project that will add value for arXiv's community? Learn more about arXivLabs.

Which authors of this paper are endorsers? | Disable MathJax (What is MathJax?)

Key points and analysis

Article intelligence

EngineersAdvanced

Key points

  • Masks on LALR(1) parser states instead of token sequences, ensuring grammatical correctness.
  • Role-based access control compiled into grammar, making forbidden verbs/identifiers unreachable at mask level.
  • Rust kernels achieve median per-token mask of 3.6–6.7 μs, outperforming llguidance with zero false rejects.
  • Hash-chained audit trail allows bit-identical replay with 100% tamper detection.

Highlights and analysis are generated automatically and may contain errors. Check the original source.