Compositionality is the principle that the meaning of a complex expression is built from the meanings of its parts and the way those parts are put together. It is arguably the single most powerful feature of human language: you have never heard the sentence “the purple walrus borrowed my stapler,” yet you understand it instantly, because you know the words and you know the grammatical rules that combine them. This capacity shows up not just in language but in how we see objects, hear music, and design software. It also turns out to be one of the hardest things for artificial intelligence to replicate, which is why researchers across half a dozen fields keep circling back to it.
The Core Idea and Why It Matters
At its simplest, compositionality means the whole is a predictable function of the parts. “Red ball” means what “red” means plus what “ball” means, assembled by the rule that English adjectives modify the nouns they precede. Scale that up and you get an unlimited ability to produce and understand sentences you have never encountered before. You can describe a scene, give instructions, tell a lie, or invent a fictional world, all by snapping together familiar pieces according to familiar patterns.
This unlimited creative capacity is sometimes called “productivity,” and it rests on a related property called “systematicity.” If you can understand “the dog chased the cat,” you can also understand “the cat chased the dog.” The ability to think one thought implies the ability to think structurally related thoughts. That symmetry was a major argument, raised in the late 1980s, for why the mind must use combinatorial, structured representations rather than unstructured associations. The reasoning was that if mental representations have parts that can be rearranged, systematicity follows naturally; if they don’t, the symmetry is a coincidence that needs explaining every time it appears.1Cognition. Connectionism and cognitive architecture: A critical analysis Decades later, cognitive scientists still debate the exact architecture, but the observation that cognition is systematic remains one of the strongest pieces of evidence for compositional structure in the mind.2PubMed Central. Systematicity and a Categorical Theory of Cognitive Architecture: Universal Construction in Context
How Children Pick It Up
If compositionality is the engine of language, children rev that engine remarkably early. Studies using preferential-looking tasks, where toddlers are shown two videos while a sentence plays, have found that English-learning children between roughly 17 and 19 months already use word order to figure out who is doing what to whom. In one well-known experiment, children heard sentences like “Big Bird is tickling Cookie Monster” while watching two videos: one matching that word order and one with the roles reversed. The toddlers looked longer at the matching video, suggesting they were already using the grammatical rule that the first noun is the agent.3Philosophical Transactions of the Royal Society B. The acquisition of compositional meaning
Even so, well-controlled evidence for full-blown compositional abilities in infants remains scarce. A recent review concludes that while some studies suggest children begin understanding specific multiword combinations during their second year, the key mental operation underlying compositionality, applying a function to an argument (like applying “red” to “ball”), can actually be observed in the first year of life, before and even outside of language.4Annual Review of Developmental Psychology. The Development of Compositionality in Language and Thought That finding hints at something important: compositionality may not be a language-specific ability that children acquire. It may be a more general cognitive capacity that language inherits.
Cross-linguistic research adds texture here. The way children learn to combine spatial and temporal concepts varies by language. A study comparing Polish-, English-, and Finnish-speaking children found a clear interaction between language and the dimension being expressed, meaning the compositional rules children learn are shaped by the particular language they hear, not just by universal conceptual development.5First Language. Spatial and temporal systems in child language and thought: a cross-linguistic study
What Happens in the Brain When You Combine Words
Neuroscience has started to pinpoint where and when the brain performs compositional operations. Using magnetoencephalography (MEG), researchers have measured what happens when people plan to say a simple phrase like “red tree” versus just “red” or just “tree.” The act of combining an adjective with a noun produces distinct neural activity in two regions: the ventromedial prefrontal cortex and the left anterior temporal lobe. These effects kick in fast, roughly 180 milliseconds after the person sees the cue, suggesting that combination starts almost as soon as the individual words are accessed.6PubMed. Building phrases in language production: an MEG study of simple composition
Follow-up work showed that this combinatory processing can be primed. When people repeatedly produce similar adjective-noun phrases, the anterior temporal cortex responds faster to the next one, but only if the phrases share an adjective. Single-word repetition alone doesn’t produce the same priming, and simply viewing pictures without naming them doesn’t trigger it either. The priming effects are also very early, beginning between 100 and 150 milliseconds after a picture appears, indicating they reflect the initial stages of planning a combinatory message rather than some later, deliberative process.7PubMed Central. The priming of basic combinatory responses in MEG In other words, the brain has dedicated circuitry for snapping meanings together, and it gets faster with practice.
When a Language Invents Itself
One of the most compelling demonstrations that compositionality is a deep property of human cognition comes from cases where a language springs up from scratch. Al-Sayyid Bedouin Sign Language arose in an isolated community in the Negev desert with a high rate of hereditary deafness. Within a single generation of its inception, this new language developed systematic grammatical structure, including highly regular word order marking who does what to whom.8PubMed Central. The emergence of grammar: systematic structure in a new language Nobody sat down and designed these rules. The community’s signers converged on compositional structure because that is what human communication naturally gravitates toward when people need to express an open-ended range of meanings.
Computational models of cultural transmission help explain why. In “iterated learning” simulations, one generation of learners produces output that becomes the training data for the next generation. When the input is noisy or incomplete, as it always is for real children learning language, the pressure of being learned and re-learned over generations pushes the system toward compositional structure. Models show that compositionality is, in effect, language’s adaptation to the poverty of the stimulus: because learners never hear every possible utterance, they are better off learning rules for combining parts than memorizing whole expressions.9PubMed. Iterated learning: a framework for the emergence of language Recent work with deep neural networks confirms that multiple generations of iterated learning produce compositional generalization that outperforms a single network trained with standard methods.10PubMed Central. Compositionality and systematicity emerge from iterated learning in deep linear networks
Do Animals Have It
If compositionality comes so naturally to humans, why don’t we see it in other species? The short answer is that animals get partway there but stop short of the real thing. Many species combine signals in meaningful ways. Certain birds string alarm calls together in fixed orders. Some primates use call sequences that convey something neither call means on its own. But reviews of the evidence find that while animal communication can have meaning-bearing combinatorial and sometimes compositional features, there is no evidence for the open-ended generativity or hierarchical nesting that defines human compositionality.11PubMed Central. Syntax and compositionality in animal communication: Evolutionary roots of syntax
Chimpanzees offer an instructive case. Wild chimps produce a call combination, “alarm-huu” followed by “waa-bark,” specifically when encountering snakes. Playback experiments found that other chimps responded differently to this combination than to either call alone: in half the playback trials, subjects approached the speaker and displayed typical snake-defense behavior like climbing a tree and scanning the ground. The combination appears to be a concatenation of two independently occurring units that is meaningful to receivers.12Nature Communications. Call combinations and compositional processing in wild chimpanzees That is genuinely interesting, but it is still a fixed, single combination for a specific situation, not a productive system that could express any thought by rearranging parts. The gap between “alarm-huu + waa-bark means snake” and “the purple walrus borrowed my stapler” is enormous.
Why Artificial Intelligence Keeps Stumbling
Compositionality has become one of AI’s most revealing failure modes. Large language models can answer individual factual questions impressively, but when they need to chain two facts together, performance often drops. Studies have documented systematic failures in basic “two-hop” reasoning, where the model needs to combine just two pieces of information across documents. Performance gets worse as the compositional depth increases or as distractors are added. The weakness extends to math problems the model can solve individually but fails to solve when they are composed into a multi-step problem.13arXiv. Large Language Model Reasoning Failures
The problem is not new. Earlier benchmarks designed to test compositional generalization found that state-of-the-art machine learning methods show limited ability to generalize compositionally, and that there is a strong negative relationship between the novelty of a compound expression and the model’s accuracy on it.14arXiv. Measuring Compositional Generalization: A Comprehensive Method on Realistic Data In plain terms: the more a test sentence differs from training data in how familiar pieces are put together, the worse the model does, even if it knows all the individual pieces.
There are theoretical reasons to think neural networks can, in principle, represent compositional structure. Research has shown that recurrent neural networks sometimes implicitly compile symbolic structures into a mathematical form called tensor product representations, which combine role information (like position in a sequence) with filler information (like which word fills that position).15arXiv. RNNs Implicitly Implement Tensor Product Representations But “can in principle” and “does reliably in practice” are very different things, and the gap between them is where most of today’s AI failures live.
The Problem of Idioms
Not everything in language is compositional. Idioms are the classic counterexample: “kick the bucket” means to die, and you cannot get there by combining the meanings of “kick,” “the,” and “bucket.” Idioms are a reminder that compositionality is a default strategy, not an ironclad law. Real language uses it most of the time and then cheerfully violates it when a fixed expression does the job better.
How do language models handle these exceptions? Research tracing the internal circuitry of transformer models during idiom processing has found distinct computational patterns. Certain attention heads, dubbed “Idiom Heads,” activate frequently across different idiomatic expressions. Earlier layers of processing enhance attention between the tokens that make up the idiom, a phenomenon the researchers call “augmented reception,” allowing the model to recognize the fixed phrase and bypass the normal compositional route.16arXiv. Anatomy of an Idiom: Tracing Non-Compositionality in Language Models The brain likely does something analogous. Studies of people with aphasia have found that many of the errors they make when producing compound words are morphemic, meaning they show access to the constituent parts of the compound. But the likelihood of getting a compound right also depends heavily on semantic transparency, how clearly the parts’ meanings relate to the whole’s meaning.17Language Sciences. The lexical representation of compound words in English: evidence from aphasia Transparent compounds like “bookshelf” are easier to recover than opaque ones like “humbug,” which suggests the brain maintains both a compositional route and a memorized-whole route and uses whichever one works.
Compositionality in Music
Language is not the only domain where humans build complex structures by combining smaller parts according to rules. Music does something strikingly similar. Chords relate to each other within a key through hierarchical dependencies: a chord’s function can depend on chords that appeared several measures earlier, not just the one immediately before it. Brain imaging work has shown that listeners process these long-distance musical dependencies in much the same way they process syntactic dependencies in sentences. When researchers presented Bach chorales alongside modified versions that preserved local note-to-note transitions but disrupted the deeper hierarchical structure, brain responses differed between regular and irregular versions in both musicians and non-musicians.18PubMed Central. Processing of hierarchical syntactic structure in music The finding suggests that hierarchical structure processing is not exclusive to language but is a more general capacity of human cognition.
More recent work has gone further, showing that formal music-theory models of hierarchical syntax predict fluctuations in theta-band brain activity in key language-related areas such as the angular gyrus, superior temporal gyrus, and Heschl’s gyrus, as well as their right-hemisphere counterparts.19PubMed. Hierarchical syntax model of music predicts theta power during music listening The overlap between language and music processing regions does not mean music and language are the same thing. But it does mean the brain repurposes its compositional machinery across domains, which reinforces the idea that compositionality is a general-purpose cognitive strategy rather than a language-only trick.
Compositionality in Vision and Biology
Your visual system also relies on compositional principles. When you recognize a chair, you are not matching the entire object against a stored template. You are recognizing parts, a seat, legs, a back, and their spatial arrangement. Evidence from perceptual psychology indicates that human visual shape representation is part-based, with specific geometric factors determining how vision parses shapes into parts and evaluates how prominent each part is.20Advances in Psychology. Part-Based Representations of Visual Shape and Implications for Visual Cognition Computer vision systems have capitalized on this insight: learning hierarchical, compositional object models from images vastly reduces the complexity of recognition, because the same parts recombine across different categories rather than each category needing its own description from scratch.21PubMed. Learning the compositional nature of visual object categories for recognition
Biology itself is compositional at the molecular level. Proteins are built from domains, modular structural units that fold and function semi-independently. Through evolution, domain fusions and fissions reshuffle these units into new combinations, and this combinatorial process is fundamentally responsible for the complexity of the protein world.22Structure. Evolutionary Mechanics of Protein Domains in the Three Superkingdoms of Life Researchers have even applied mathematical frameworks originally designed for compositional semantics in language to protein function, computing what a protein does based on the functions of its domains and the rules that link them.23arXiv. A Categorical Compositional Distributional Modelling for the Language of Life When the same formal principle works for sentences, visual objects, and molecular biology, it starts to look less like a feature of any one domain and more like a deep organizational principle that complex systems converge on.
Compositionality in Robotics and Software Design
If you want a robot to generalize, compositionality is increasingly the strategy of choice. A robot trained to “pick up the red cup” and separately trained to “place an object on the shelf” should, in principle, be able to “pick up the red cup and place it on the shelf” without seeing that specific combined task during training. In practice, getting this to work has been difficult. Recent approaches tackle the problem by synthesizing training demonstrations that combine known subtasks in novel ways. One method tested on a simulation benchmark achieved gains of over 50 percentage points on spatially and goal-related out-of-distribution tasks compared to standard training, while maintaining solid performance on familiar tasks.24arXiv. Unleashing More Actions via Action Compositional Training for VLA Models
Another line of research gives robots an internal “imagination” that is compositional. By learning a world model that is factored into components, a robot can combine previously seen elements in new ways to generate video predictions of what would happen if it carried out a novel instruction. This factored approach substantially outperforms single, monolithic models on unseen goals and has been used to enable successful robot execution in simulation.25arXiv. RoboDreamer: Learning Compositional World Models for Robot Imagination The lesson from robotics mirrors the lesson from evolutionary linguistics: systems that break the world into reusable parts and combine them flexibly are far more capable than systems that try to learn every situation as a separate whole.
Software engineering landed on the same insight decades ago. Category theory, a branch of mathematics concerned with structure and composition, has been used to formalize how parallel and distributed software systems can be modularized. The modularization techniques obey algebraic properties that make complex systems tractable by assembling them from well-understood, reusable components.26Science of Computer Programming. Categorical semantics of parallel program design Whether we are talking about words in a sentence, domains in a protein, or modules in a codebase, the pattern is the same: define your parts, define your combination rules, and an enormous space of possibilities opens up without the cost of specifying each one individually.

