Metamodel-Guided LLM Decoding for Consistent DSL Generation
Boqi Chen, Aren A. Babikian, Jos\'e Antonio Hern\'andez L\'opez
Key points
From the paper's conclusion- These results show that metamodel-guided decoding is an effective approach for enforcing DSL consistency during decoding across diverse DSLs and LLM scales.
Abstract
Large language models (LLMs) are increasingly used to generate software engineering artifacts written in domain-specific languages (DSLs). Correct DSL instances usually must comply with not only the concrete syntax but also the abstract syntax defined by a metamodel augmented with semantic well-formedness constraints. Existing constrained decoding approaches typically guarantee compliance only with concrete syntax or with a limited set of semantic constraints expressed over the generated text, making metamodel-level constraint consistency difficult to enforce during generation. We present MeMoDecode: a decoding framework that enforces a DSL's concrete syntax, abstract syntax, and well-formedness constraints jointly. Specifically, whenever the LLM generates a complete metamodel concept, MeMoDecode incrementally maps the current output to a partial model and verifies whether it can still be completed into a consistent instance. We combine MeMoDecode with a simple retry mechanism that resumes decoding from the most recent completable snapshot whenever an inconsistency is detected. Under a sound backend verifier, MeMoDecode never performs worse than grammar-constrained decoding on alignment metrics satisfying natural assumptions. Across four DSLs and six open-weight LLMs ranging from 0.6B to 70B parameters, MeMoDecode achieves the highest consistency, improving consistency by 23% on average over unconstrained decoding and by 8% on average over grammar-constrained decoding. It also improves benchmark performance while incurring only modest runtime overhead. These results show that metamodel-guided decoding is an effective approach for enforcing DSL consistency during decoding across diverse DSLs and LLM scales.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- DSL-Bench: Evaluating and Explaining LLM Code Generation Across Domain-Specific LanguagesarXiv · 2026
- Lookahead-Then-Verify: Reliable Constrained Decoding for Diffusion LLMs under Context-Free GrammarsProceedings of the ACM on Software Engineering · 2026
- DConstrain: Compiling Context-Parameterized Transitions for Diffusion Language Model Constrained DecodingarXiv · 2026
- From Language-Specific to Cross-DSL: Semantic-Role-Guided Model Completion with LLMsarXiv · 2026
- From Grammar Deltas to Token Masks: Incremental Constrained Decoding under Runtime Grammar EvolutionarXiv · 2026
- AGDecode: Semantic Attribute Grammar Derivatives for Safety-Constrained Decoding of Large Language ModelsarXiv · 2026