David Vella Zarb

Author directory

2026

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.