Compositional Generalization in NLP: Can LLMs Truly Reason?

You type a command into an AI assistant. It handles the standard request perfectly. But what happens when you ask it to do something it has never seen before, using words it knows in a new combination? This is the core question of Compositional Generalization in natural language processing. It asks whether machines can understand the rules of language well enough to apply them to novel situations, or if they are just memorizing patterns.

For years, researchers have debated this. The consensus shifted dramatically between 2018 and 2026. Early neural networks failed hard at this task. Today’s Large Language Models (LLMs) seem to ace many tests, but only when we guide them correctly. Are they truly reasoning systematically, like humans? Or are they clever statistical parrots? Let’s look at the evidence.

What Is Compositional Generalization?

At its heart, compositional generalization is about building meaning from parts. If you know what "red" means and what "circle" means, you instantly understand "red circle." You don’t need to have seen that specific phrase before. This principle, often traced back to formal semantics, requires a system to recombine known components according to learned rules.

In NLP, this translates to handling new combinations of familiar primitives. A model should be able to parse "jump twice and run" even if it has only ever seen "run twice and jump." Humans do this effortlessly. For decades, artificial intelligence struggled with it. The gap between human ability and machine performance was stark. Standard sequence-to-sequence models could achieve near-perfect accuracy on data similar to their training set-often hitting 96-99% success rates. But when tested on held-out combinations that required true rule application, their accuracy would collapse to 16-35%. This phenomenon became known as the systematicity gap.

The Benchmark Landscape: Testing Systematicity

To measure this capability, researchers created rigorous synthetic datasets. These aren’t just random sentences; they are carefully designed traps for models that rely on memorization rather than logic. Four major benchmarks dominate this field.

Key Benchmarks for Compositional Generalization
Benchmark Release Year Primary Focus Key Challenge Metric
SCAN 2018 Navigation commands mapped to action sequences Length extrapolation and new primitive combinations
CFQ 2020 Semantic parsing over Freebase knowledge base Compound Divergence (MCD splits)
COGS 2020 Syntactic structures and lexical items Generalization sets with missing argument structures
gSCAN 2020 Grounded language understanding in grid worlds Novel visual property combinations (e.g., size + color)

SCAN, introduced by Brenden Lake and Marco Baroni, uses simple navigation instructions. It tests if a model can handle longer sequences or new verbs combined with modifiers like "twice." While early models failed here, newer approaches have made significant strides.

CFQ (Compositional Freebase Questions) raised the stakes. Released by Google Research, it contains around 240,000 question-query pairs. Its key innovation is the "compound divergence" metric. This measures how different the training distribution is from the test distribution. High divergence means the test questions use combinations of predicates and arguments rarely or never seen in training. As compound divergence increases, baseline model accuracy drops sharply.

COGS focuses on syntax. Created by Kim and Linzen, it tests if models can generalize syntactic alternations, like dative shifts, that were excluded from training. In 2020, LSTM and Transformer architectures scored 96-99% on in-distribution tests but plummeted to 16-35% on the generalization set. This instability highlighted a lack of structural bias in standard neural nets.

gSCAN adds a visual layer. It grounds language in a grid world, requiring models to identify objects based on descriptions like "small red circle." If the model has only seen "small" and "red" separately, can it combine them correctly when both appear together for the first time? Standard architectures struggle here, proving that compositional issues exist across modalities, not just in text.

Hand unlocking AI reasoning capabilities with prompt key

How LLMs Changed the Game

Between 2022 and 2025, the narrative shifted. Large foundation models began showing surprising competence. But it wasn’t magic-it was method. Researchers discovered that prompting strategies could unlock systematic behavior in LLMs without massive retraining.

One breakthrough technique is "least-to-most" prompting. Instead of asking the model to solve a complex problem directly, you break it down into subproblems. By guiding the LLM through smaller steps, you force it to apply rules sequentially. A 2023 study showed that dynamic least-to-most prompting achieved 99.7% accuracy on SCAN and 95.0% on CFQ MCD splits. Remarkably, this used only about 1% of the original training data as examples in the prompt.

This suggests that LLMs possess latent systematic capabilities. They already know the rules implicitly from pretraining. Prompting acts as a switch, activating these rules for novel tasks. On COGS, similar techniques reached 99.2% accuracy on generalization tests. This is comparable to, or better than, strong supervised baselines that used full datasets.

However, decoding strategies matter too. A 2023 project found that using top-p sampling (nucleus sampling) improved sequence-level accuracy on compositional datasets by several percentage points compared to greedy decoding. Small tweaks in how we generate text can significantly impact measured systematicity.

The Limits of Current Systems

Despite these wins, skepticism remains valid. Success on synthetic benchmarks doesn’t always translate to robust real-world reasoning. Newer evaluations probe deeper.

The STaR benchmark (Systematic Relational Reasoning), introduced in 2025, tests abstract rule inference. Many popular LLMs perform above random chance but fail to achieve high accuracy. They struggle to infer and apply relational rules consistently. This indicates partial, not complete, systematic reasoning.

Another framework, Scylla, measures "critical complexity." This is the point where a model’s performance transitions from generalization to memorization. Studies show that while frontier models handle deeper chains of reasoning better than older ones, they still hit limits. Systematicity is a graded capacity linked to model scale and architecture, not an all-or-nothing trait.

The Thematic Generalization Benchmark V2 highlights another failure mode: over-generalization. When asked to infer a narrow theme from examples, LLMs often pick broader categories that cover more surface features but miss the specific rule. They prioritize superficial similarity over precise logical adherence.

Developer defending against hallucinations and distribution shifts

Why Does This Matter for Developers?

If you build applications with LLMs, compositional generalization failures cause real bugs. Your chatbot might work fine for common queries but hallucinate answers when users combine intents in unusual ways. Distribution shifts-like longer inputs or novel operator combinations-are common in production environments.

Reproducing benchmark results requires care. Random seeds, temperature settings, and prompt templates can swing accuracy by 6-8 percentage points. Don’t trust a single run. Always test your model against high-divergence splits, not just easy random splits.

Implementing compositional checks involves downloading public benchmarks like SCAN or CFQ. You’ll need familiarity with PyTorch or TensorFlow for supervised setups, or API access for LLM prompting. Key skills include prompt engineering and statistical evaluation across different compositional regimes. Watch out for data leakage between train and test sets, which can artificially inflate scores.

Future Directions and Expert Consensus

Experts agree that standard neural sequence models lack inherent structural biases for strict compositionality. They approximate systematic behavior through scale and data diversity. Kim and Linzen argued in 2020 that higher accuracy on COGS would require stronger structural biases than Transformers provide. That view holds weight today, even with larger models.

Progress likely depends on integrating explicit syntax or typed semantics into architectures. Dynamic, procedurally generated test sets may prevent leaderboard gaming. Connecting formal compositional evaluations with domain-specific benchmarks, like medical LLM reviews, will ensure gains in synthetic settings translate to reliability in critical fields.

The answer to "Can LLMs reason systematically?" is nuanced. Yes, they can under controlled conditions with careful prompting. No, they are not fully robust against complex relational demands yet. Compositional evaluation remains an active, strategic research frontier.

What is the difference between in-distribution and out-of-distribution testing in NLP?

In-distribution testing evaluates a model on data drawn from the same probability distribution as its training data. Out-of-distribution (or compositional) testing evaluates on data with novel combinations of known elements. Models often score high on the former but low on the latter, revealing a lack of true systematic understanding.

Why do LLMs fail at compositional generalization despite being so large?

LLMs learn statistical correlations rather than explicit symbolic rules. Without strong structural biases, they tend to memorize frequent patterns. When faced with rare combinations, they default to these memorized templates instead of applying the underlying grammar rules systematically.

What is 'least-to-most' prompting?

It is a prompting strategy that breaks a complex problem into simpler sub-problems. The model solves each sub-problem sequentially, using the previous solution as context for the next. This decomposition helps LLMs apply rules step-by-step, improving performance on compositional tasks.

Are there commercial tools specifically for measuring compositional generalization?

As of 2026, most tools are open-source research assets like SCAN, CFQ, and COGS repositories. There isn't a dominant standalone commercial market for these benchmarks. Evaluation is typically integrated into broader LLM benchmarking suites or done via custom scripts using Python libraries.

How does 'compound divergence' affect model performance?

Compound divergence measures the difference between training and test distributions regarding combinations of primitives. Higher divergence values indicate more novel combinations in the test set. Model accuracy typically decreases linearly or sharply as compound divergence increases, highlighting poor systematic generalization.

Write a comment