Minimal Grammars as Supervision for DSL Generation

David Vella Zarb, Geoff Parks, Timoleon Kipouros


Abstract
Language models approach saturation on general-purpose code benchmarks but routinely fail on domain-specific languages (DSLs), where paired training data is scarce and regularities learned from mainstream languages transfer poorly. We propose augmenting each training example with a minimal grammar: the subset of DSL productions needed to derive the target program, typically 2–20% of the full grammar. This provides a strong structural prior, and we fine-tune the model to generate the program conditioned on the query and grammar. We predict grammars at inference via retrieval: a frontier model is prompted with (query, grammar) pairs, annotated with a chain-of-thought trace. Across five benchmarks spanning semantic parsing (SMCalFlow, GeoQuery, Overnight) and hardware description languages (HDLs) (Verilog, SPICE), our method improves over grammar-free fine-tuning on three open-weight backbones. Gains reach 36.8pp of program accuracy on SMCalFlow, with consistent improvements on HDLs. Applied to in-context learning, our predicted grammars raise GPT-5.5 accuracy on SMCalFlow from 51.4% (grammar prompting) to 94.3%, with similar gains for Claude Opus 4.7. Ablations rule out the extra training tokens as the source of these gains.
Anthology ID:
2026.emnlp-main.1435
Volume:
Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing
Month:
October
Year:
2026
Address:
Budapest, Hungary
Editors:
Hung-Yi Lee, Sunipa Dev, Jessy Li, Desmond Elliott
Venue:
EMNLP
SIG:
SIGDAT
Publisher:
Association for Computational Linguistics
Note:
Pages:
32782–32802
Language:
URL:
https://aclanthology.org/2026.emnlp-main.1435/
DOI:
Bibkey:
Cite (ACL):
David Vella Zarb, Geoff Parks, and Timoleon Kipouros. 2026. Minimal Grammars as Supervision for DSL Generation. In Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing, pages 32782–32802, Budapest, Hungary. Association for Computational Linguistics.
Cite (Informal):
Minimal Grammars as Supervision for DSL Generation (Zarb et al., EMNLP 2026)
Copy Citation:
PDF:
https://aclanthology.org/2026.emnlp-main.1435.pdf