Language models still get agreement wrong in many languages. Agreement is the rule that a verb, adjective or pronoun must match the number, gender, person or noun class of some other word. The matching word is often far away, and it is determined by sentence structure, not by whichever noun happens to be closest. Classical linguistics has two old tools for exactly this. Feature percolation passes a word's grammatical attributes up to the phrase it heads, so a phrase like "the keys to the old cabinet" carries the plural of "keys", not the singular of "cabinet". Constraint Grammar resolves ambiguity by elimination: every word starts with all its possible analyses, and rules delete the analyses that are contradicted by context. We propose combining them into a small external module that runs beside an unmodified language model during generation. We call it a percolated feature sieve.
The sieve tracks, for each open phrase in the text generated so far, the set of agreement feature bundles that phrase could still carry. When the model is about to produce a word that must agree with that phrase, the sieve lowers the probability of word forms that contradict every surviving bundle. The core bet has two parts. First, keeping sets of candidate features, in Constraint Grammar style, lets the sieve act without a full, reliable parse of free text. Second, routing features along heads rather than along the linear string is what keeps the sieve from making harmful edits. We test the idea where agreement errors are actually common: morphologically rich, lower-resource languages. We compare it against the cheap alternatives a skeptic would reach for first.
Core Claim
Current grammar-constrained decoding enforces only the shape of the output. Grammar-Constrained Decoding for Structured NLP Tasks without Finetuning masks tokens so that the output belongs to a context-free grammar. It reaches 100% well-formed parse trees, against roughly 64% for unconstrained LLaMA, but its parses still trail supervised parsers. The authors note that structural masking does not improve the model's grasp of syntax. GRAMMAR-LLM guarantees validity with pushdown automata and likewise admits "valid but incorrect" outputs. Neither carries agreement features across constituents.
At the other extreme, Composition, Attention, or Both? shows that recursive subtree composition acts as a "syntactic filter". Composition lets grammatical number percolate into phrase representations. A 16.6M-parameter Composition Attention Grammar reaches 83.8% on SyntaxGym, against 48.1% for a same-size Transformer. The cost is weeks of non-parallelizable training, and the result offers no hard guarantee.
Our claim sits between these. For agreement specifically, the information the recursive model learns to percolate is small and symbolic: a handful of feature values attached to phrase heads. It can therefore be tracked outside the network as decoding state. An agreement constraint applied at time $t$ depends only on this state. So the sieve knows exactly which continuations remain consistent, with no sampling of futures.
This is the part that differs from Grammar-Aligned Decoding. That work shows local masking distorts the model's distribution and fixes it by estimating expected future grammaticality from up to 2,000 samples. For agreement, the future constraint is carried by the percolated state and needs no estimate.
How the Sieve Works
Three ingredients are reused from older work.
The first is the elimination discipline of Constraint Grammar as a Framework for Parsing Running Text. Each generated word keeps a "cohort", the set of all its readings from a morphological analyzer. Rules REMOVE readings only when context contradicts them, so ambiguity is kept rather than guessed. Karlsson reports that context rules prune 95–97% of English morphological ambiguity. The Swahili systems in Disambiguation of morphological analysis in Bantu languages and Optimizing disambiguation in Swahili report 99.8–99.9% precision on news text. That precision is why we trust the sieve's eliminations more than a single-best parse.
The second is head-driven percolation, as in the compound-agreement treatments in Towards a Linguistic Treatment of Compounds in a Machine Translation Environment and the realizational split in Relational-Realizational Parsing. Under percolation, a phrase inherits the features of its head, not of its modifiers.
The third is the idea from Structural Disambiguation with Constraint Propagation that parsing can be constraint filtering over candidate head links rather than tree construction. We use a light, incremental, projective version restricted to a few relations: subject–predicate, determiner/adjective–noun, and relative-pronoun–antecedent.
Concretely, after each word the sieve updates two things. It updates the candidate head links for the open constituents and the feature sets percolated along those links. Let $S_t$ be the set of feature bundles still possible for the constituent that the next word must agree with. Let $v(w) \in \{0,1\}$ indicate that every reading of candidate word $w$ contradicts every bundle in $S_t$. The sieve reweights the model's next-token distribution $p$ as
$$p'(w) \propto p(w)\, \exp(-\lambda\, v(w)),$$
where $\lambda \ge 0$ is a strength parameter; $\lambda \to \infty$ gives a hard mask. Two cautious policies inherited from Constraint Grammar apply. The sieve acts only when $S_t$ is non-empty and the governing head link is unambiguous. Otherwise it leaves $p$ untouched. Subword tokens are handled by checking the prefix-closure of word forms, in the way GRAMMAR-LLM handles tokenization boundaries.
The rule-engineering bottleneck that both Karlsson and Maruyama flag is addressed by inducing the agreement relations automatically from Universal Dependencies treebanks. For each language we learn which dependency relations share which feature values between dependent and head. We keep only relations whose co-occurrence is near-categorical in the training split. This is the same kind of derivation of head information from UD that Integrating Headedness Information into an Auto-generated Multilingual CCGbank performs for semantics. That paper also warns us that about 48% of its conversion errors trace to source annotation noise, so induced rules are filtered by a categoricity threshold. We also measure the sieve's own false-removal rate.
Research Program
The work has three stages.
First, we build the rule induction and the incremental sieve for a set of languages. The set spans rich agreement (Slavic gender and case, Bantu noun class where analyzers and treebanks are available) and a contrast set where agreement is thin. The sieve plugs into Hugging Face decoding through the logits-processor interface already used by epfl-dlab/GCD.
Second, we build a generation evaluation. Minimal-pair benchmarks score two given sentences, so a sieve applied there would simply be deciding the answer itself; that is circular. We therefore convert benchmark items into prefix-continuation tasks. The prefix stops just before the agreeing word, and the model generates freely. An independent analyzer and held-out annotators then judge whether the generated word agrees, and whether it is a real, fluent choice rather than a forced odd form.
Third, we analyze when the sieve helps. We track model size, language resource level, attractor distance, and analyzer error rate.
Baselines
The naive reference point is unconstrained decoding with the same model, prompts and sampling settings. On the scoring side, the file gives a benchmark anchor for how good current models are at agreement. On MultiBLiMP 1.0 the best of 42 models reach "around 90% on average" on forced-choice agreement pairs. The file gives no per-language numbers, so we will recompute per-language scores for our chosen models before any intervention. On English, BLiMP reports GPT-2 at 83.0% overall and over 99% on some agreement subsets. This tells us English agreement is largely solved at scale and is not where our claim will live. For the generation task itself, there is no reported result on Lacuna for prefix-continuation agreement accuracy, so our own unconstrained runs are the reference.
The strongest competitor that uses no linguistic structure is best-of-$k$ rejection. The procedure samples $k$ continuations, checks each post hoc with the same analyzer and induced rules, and returns the most probable consistent one. It uses our exact checker, so any win by the sieve must come from acting during generation rather than from the checker's knowledge. We run it at matched forward-pass budgets: $k$ is chosen so its total compute equals the sieve's single pass plus overhead, and also at $4\times$ that budget. The sieve beats it only if it achieves at least equal agreement accuracy at the matched budget with no worse fluency. A tie at a much lower budget still counts as a practical win. There is no reported result on Lacuna for best-of-$k$ on agreement.
The strongest distribution-correcting method is ASAp from Grammar-Aligned Decoding, fed the same agreement constraints. Its reported gain is a 38% geomean increase in correct solutions over standard grammar-constrained decoding on INV-BV program synthesis with Mistral-7B. It has not been evaluated on natural-language agreement. We give it its published sample budgets and compare accuracy, divergence from the unconstrained model's distribution, and wall-clock latency. The GCD paper reports a 1–4 ms per-token overhead for its masking; this is the latency scale the sieve should stay near.
The fine-tuning competitor is LoRA adaptation on UD-derived text in each target language, with a tuning budget equal to the compute spent on building the sieve plus a sweep of $\lambda$. We also report LoRA plus the sieve, since the two are complementary if both help.
The key ablation is a linear sieve with identical rules and analyzer. It swaps percolation along head links for the nearest-preceding-noun heuristic that flat Constraint Grammar windows or n-gram filters approximate. If the linear sieve matches the percolated one, head-driven propagation is not doing the work. A second ablation replaces cautious set-based elimination with a single-best incremental parse. This tests whether keeping ambiguity is what prevents harmful masks.
Why not just…?
Why not just scale the model? Scale does fix agreement in high-resource English: BLiMP reports GPT-2 above 99% on some agreement subsets. Evidence that it does not fix it everywhere comes from MultiBLiMP 1.0, where the average ceiling is around 90% across 101 languages, with weaker results for lower-resource languages and after instruction tuning. Composition, Attention, or Both? shows that structure can beat parameter count, since its 16.6M model outperforms GPT-2 on SyntaxGym. We take the threat seriously and measure the sieve's gain as a function of model size across the Pythia suite on English SyntaxGym agreement-across-clauses suites, and across multilingual model sizes. We expect the gain to vanish for large models in high-resource languages. The claim holds only if it persists for lower-resource languages at the largest sizes we can run.
Why not just fine-tune on agreement-rich data? This is a real threat. Adaptation is cheap and needs no external module at inference. Grammar-Aligned Decoding reports that QLoRA-tuned models still suffer distortion under constrained decoding, but that concerns formal grammars, not agreement. The matched-budget LoRA baseline settles it directly. If LoRA alone reaches the sieve's accuracy per language with equal fluency, we will report that the sieve is useful only where treebank data is too small to fine-tune on. Our lowest-resource languages test exactly that regime.
Why not just sample several outputs and keep one that agrees? Best-of-$k$ with our checker is the most dangerous alternative, because it uses the same linguistic knowledge without touching the model's distribution mid-generation. Its weakness should appear when agreement errors are frequent and correlated across samples. In that case many samples share the model's attractor error, and $k$ must grow large. The matched-compute comparison, reported separately on the high-error subset, is the decisive test. If best-of-$k$ wins at matched compute, the contribution reduces to the induced checker, and we will say so.
Why not just use a flat surface filter? Linguistic Steganography Using Automatically Generated Paraphrases found that Google 5-gram filters reach high precision but lose recall, and that adding a CCG check raised grammaticality accuracy from 61.5% to 68.3%. BLiMP found 5-gram models poor across all phenomena. The linear-sieve ablation is our own direct test. On attractor items, a flat rule should push the model toward agreeing with the wrong noun, so it should reduce accuracy relative to doing nothing.
Proposed Experiments
The primary experiment runs the prefix-continuation task on per-language MultiBLiMP-derived items. The items are split so that no sentence or lemma used for rule induction appears at test time. We report agreement accuracy judged by an independent analyzer plus a human sample, intervention rate, KL divergence from the unconstrained distribution, and per-token latency. Fluency is measured as perplexity of the continuation under a larger held-out model, with a small blind human acceptability study.
The English diagnostic uses SyntaxGym agreement suites with intervening clauses through the syntaxgym tooling (SyntaxGym), converted to generation, across Pythia sizes. Here the 48.1% same-size Transformer versus 83.8% Composition Attention Grammar gap gives a known regime where small sequence models fail. A robustness experiment injects controlled analyzer and head-link errors and measures how quickly the cautious sieve degrades, compared with the single-best-parse ablation.
Four results would decide the question. The percolated sieve must beat the linear sieve on attractor items, or head propagation is unnecessary. It must match or beat best-of-$k$ and ASAp at matched or lower compute, or acting during generation is unnecessary. It must retain a gain over LoRA in the lowest-resource languages, or fine-tuning suffices. And its false-removal rate must stay low enough that human acceptability does not drop, or the Constraint Grammar precision assumption fails outside curated news text.
References
- Grammar-Constrained Decoding for Structured NLP Tasks without Finetuning
- GRAMMAR-LLM: Grammar-Constrained Natural Language Generation
- Composition, Attention, or Both?
- Grammar-Aligned Decoding
- Constraint Grammar as a Framework for Parsing Running Text
- Disambiguation of morphological analysis in Bantu languages
- Optimizing disambiguation in Swahili
- Towards a Linguistic Treatment of Compounds in a Machine Translation Environment
- Relational-Realizational Parsing
- Structural Disambiguation with Constraint Propagation
- Integrating Headedness Information into an Auto-generated Multilingual CCGbank for Improved Semantic Interpretation
- MultiBLiMP 1.0: A Massively Multilingual Benchmark of Linguistic Minimal Pairs
- BLiMP: The Benchmark of Linguistic Minimal Pairs for English
- Linguistic Steganography Using Automatically Generated Paraphrases
- SyntaxGym: An Online Platform for Targeted Evaluation of Language Models