GrammarRL: Effective Grammar-Constrained Decoding via Reinforcement Learning
On the map: Deep reinforcement learning methods → RL training of language and agent models
Abstract (arXiv)
Grammar-constrained generation guarantees syntactic validity, but can substantially degrade semantic quality when the model's preferred outputs are poorly aligned with the imposed grammar. This trade-off is particularly severe when the prompt is underspecified or the model has limited instruction-following ability. Beam search can partially mitigate these failures by exploring multiple valid sequences, but its computational cost grows with beam width, while sequence-level probability is only an imperfect proxy for semantic quality. We introduce GrammarRL, a label-free reinforcement learning method that adapts language models to grammar constraints without requiring annotated data. GrammarRL optimizes the model using two complementary self-supervised rewards derived from its own likelihoods: a direct reward, measuring how likely the constrained output is given the input, and a reverse reward, measuring how well the input can be reconstructed from the generated output. We optimize these rewards with a Reinforce Leave-One-Out (RLOO) objective over groups of grammar-constrained rollouts, augmented with the top-1 beam-search hypothesis and regularized towards a frozen base model. We evaluate GrammarRL on sign language gloss translation, hierarchical text classification, and named entity recognition using Llama models ranging from 1B to 8B parameters. GrammarRL consistently outperforms constrained greedy decoding, with an average improvement of 9.8 points and gains of up to 22.8 BLEU. It matches or outperforms beam search on two of the three tasks while preserving greedy-decoding inference cost. Ablations further show that the two rewards are complementary: either reward alone can underperform the untrained baseline, whereas their combination consistently improves upon it.
Key facts. No citing papers in the map yet (data through 14 Oct 2026). Placed in RL training of language and agent models, one of 15 directions in Deep reinforcement learning methods. Builds on 26 of its 31 references that are in the map. First posted on arXiv 30 Sep 2026.
Builds on
26 of 31 references.
Closest ancestors · 1
Same direction, newest first
Other references · 25
- 2021LoRA: Low-Rank Adaptation of Large Language Modelscited by 14,380
- 2024DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Modelscited by 9,379
- 2019The Curious Case of Neural Text Degenerationcited by 2,916
- 2021PICARD: Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Modelscited by 411
- 2023Efficient Guided Generation for Large Language Modelscited by 200
- 2023Grammar-Constrained Decoding for Structured NLP Tasks without Finetuningcited by 197
- 2022Synchromesh: Reliable code generation from pre-trained language modelscited by 156
- 2021NeuroLogic A*esque Decoding: Constrained Text Generation with Lookahead Heuristicscited by 154
- 2017HDLTex: Hierarchical Deep Learning for Text Classificationcited by 106
- 2024Guiding LLMs The Right Way: Fast, Non-Invasive Constrained Generationcited by 101
- 2024Let Me Speak Freely? A Study on the Impact of Format Restrictions on Performance of Large Language Modelscited by 96
- 2018Leveraging Grammar and Reinforcement Learning for Neural Program Synthesiscited by 84
13 more
- 2023Sequential Monte Carlo Steering of Large Language Models using Probabilistic Programscited by 80
- 2024SynCode: LLM Generation with Grammar Augmentationcited by 69
- 2024Grammar-Aligned Decodingcited by 54
- 2025Syntactic and Semantic Control of Large Language Models via Sequential Monte Carlocited by 46
- 2025CRANE: Reasoning with constrained LLM generationcited by 38
- 2019Simple and Effective Noisy Channel Modeling for Neural Machine Translationcited by 37
- 2025Fast Controlled Generation from Language Models with Adaptive Weighted Rejection Samplingcited by 21
- 2021From Paraphrasing to Semantic Parsing: Unsupervised Semantic Parsing via Synchronous Semantic Decodingcited by 14
- 2024Controllable Generation via Locally Constrained Resamplingcited by 11
- 2026Mitigating Bias in Locally Constrained Decoding via Tractable Proposalscited by 8
- 2025AdapTrack: Constrained Decoding without Distorting LLM's Output Intentcited by 3
- 2026Future Validity is the Missing Statistic: From Impossibility to Phi-Estimation for Grammar-Faithful Speculative Decodingcited by 2
- 2026The Alignment Problem in Constrained Code Generationcited by 1
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2026SignRAG: Unified Retrieval-Augmented Gloss-Free Sign Language Translation
- 2026Adaptive Decoding via Test-Time Policy Learning for Self-Improving Generation
- 2022Is Reinforcement Learning (Not) for Natural Language Processing: Benchmarks, Baselines, and Building Blocks for Natural Language Policy Optimization
- 2026Minimally Invasive Steering of Language Models
- 2025Text2Grad: Reinforcement Learning from Natural Language Feedback
- 2026Reference-Free Reinforcement Learning Fine-Tuning for MT: A Seq2Seq Perspective
- 2024DeAL: Decoding-time Alignment for Large Language Models
- 2023Language Model Self-improvement by Reinforcement Learning Contemplation