AI Glossary / Graphs and symbolic AI / Intermediate
Compositional semantics
Definition
Compositional semantics builds the meaning of a complex expression from the meanings of its parts and the structure that combines them. In natural-language processing, it often links a sentence's syntactic analysis to a structured semantic representation. The approach explains why word order, grouping, and grammatical relationships can change meaning even when the words remain the same.
What it means
Knowing the meanings of individual words is not enough to understand every sentence. The expressions Maya follows Noor and Noor follows Maya contain the same names and verb, but they describe different relationships.
Compositional semantics provides rules for combining constituent meanings. A noun phrase may identify an individual or express a quantified condition, while a verb phrase may describe a property that can apply to an individual. Combining them according to the grammar produces a larger interpretation.
The principle does not require one particular grammar or one implementation. It also does not claim that context is irrelevant. Ambiguity, pronoun reference, idioms, and conversational implications require careful modeling beyond a simplistic one-word-one-meaning lookup.
How it works
A system starts with a syntactic analysis that identifies constituents and how they are combined. It associates words or phrases with semantic representations, then applies composition rules along the structure.
In a simple formal treatment, a name denotes an individual and an intransitive verb denotes a property. Combining them applies the property to the individual. More complex treatments use functions and logical representations to handle transitive verbs, modifiers, and quantifiers.
Lambda expressions are one tool for representing meanings with an argument position waiting to be filled. Applying a semantic function to a suitable argument and simplifying the result can build the logical form of a sentence step by step.
The resulting representation can be evaluated against a model, translated into a database query, or passed to another reasoning component. These downstream uses still depend on accurate parsing, lexical choices, and domain definitions. Composition preserves the specified rules; it does not independently validate the intended interpretation.
Three practical examples
1. A language interface converts a restricted request about stored records into a logical form whose argument roles match the sentence structure.
2. A grammar exercise builds the meaning of a sentence from a subject's denotation and a verb phrase's property representation.
3. A semantic parser represents alternative quantifier scopes rather than pretending an ambiguous sentence has only one possible reading.
Think of it this way
Think of assembling a model from labeled components according to a diagram. The labels matter, but so does the arrangement: attaching the same pieces differently can produce a different structure.
The analogy does not make language mechanical in every respect. Context can influence which pieces or interpretations are appropriate, and some expressions need treatment that is richer than their most literal components.
Worked example
Consider the sentence Mira approves a document. Let mira denote one person, document(x) mean that x is a document, and approves(y, x) mean that person y approves object x.
One intended logical reading is: there exists an x such that document(x) AND approves(mira, x). The indefinite phrase introduces an existential requirement, and the grammatical subject fills the approver position.
Now compare a document approves Mira. If the grammar assigns the same predicate roles from the reversed structure, its representation would place a document in the approver position and Mira in the approved-object position. That may be inappropriate for the domain, but it is not the same meaning as the first sentence.
Finally, Mira approves every document requires a universal condition: for every x, if document(x), then approves(mira, x). Changing one word changes the quantificational contribution and therefore the meaning assembled for the whole sentence.
Illustrative case study
Fictional case: Harbor Search builds a controlled-language interface for an internal catalog. Its prototype extracts relevant words but confuses requests asking who reviewed a report with requests asking which report a person reviewed.
The team introduces structured argument roles and composition rules tied to the grammar. It tests pairs of requests using the same words in different arrangements and checks the resulting queries with domain reviewers.
The fictional improvement is a more explicit connection between syntax and query meaning. The team still handles unsupported or ambiguous language separately rather than assuming every grammatical input has one reliable interpretation.
Common misconceptions and mistakes
Compositional semantics is not a bag-of-words method. The way parts combine is central to the principle.
It does not require every word to have exactly one context-independent meaning. Lexical ambiguity can yield several candidate analyses, each with its own composition.
Do not confuse a well-formed logical representation with a true statement. A sentence's meaning can be composed correctly and still be false in the model being considered.
Also distinguish semantic composition from the broader claim that a learned system generalizes compositionally. Building meanings through rules and demonstrating reliable performance on novel combinations are related questions, but they require different evidence.
Business use
For business language interfaces, compositional semantics can make the mapping from a request to a structured query easier to inspect. It is useful when argument roles, negation, or quantifiers materially change the intended operation.
Define the supported language and domain vocabulary, and test contrasting sentence pairs. Reviewers should inspect the assembled meaning or query, not only whether the response sounds plausible. Where multiple analyses remain possible, the interface needs a way to preserve or resolve that ambiguity before relying on the interpretation.
People also ask
Does compositional semantics depend only on word meanings?
No. The structure used to combine those meanings is also essential.
Must it use lambda calculus?
No. Lambda expressions are a useful formal tool, but the compositional principle does not require one specific notation or implementation.
Does it eliminate ambiguity?
No. Different parses or lexical interpretations can produce different composed meanings.
Check your understanding
Why do Mira approves Noor and Noor approves Mira have different meanings despite sharing all their words?
Answer: Their grammatical structure assigns the names to different argument roles. Composition uses those roles, so the resulting relationship is reversed.
Related terms
- Semantic parsing
- Syntax
- compositionality
- logical form
- lambda calculus
- quantifier scope
- lexical semantics
- denotation
- natural-language interface
Learn next
Assign simple meanings to a name and a verb phrase, then combine them into a sentence meaning. Extend the exercise with an indefinite noun phrase and a universal quantifier. Compare the resulting logical forms and identify where structure or lexical choice creates ambiguity.
More in Graphs and symbolic AI
- Complexity analysis - Complexity analysis studies the computational resources required by an algorithm or problem as a function of input size.
- Compliant motion - Compliant motion is robot movement that accommodates contact forces and physical constraints rather than rigidly insisting on an exact free-space trajectory.
- Composition - Composition of substitutions combines successive variable replacements into one substitution with the same overall effect.
- Computable - A function is computable if an algorithm can produce its specified output from each valid input in a finite number of steps.
- Computational graphs - Computational graphs represent calculations as connected operations and intermediate values.
- Computational learning theory - Computational learning theory studies what can be learned from data, under which assumptions, and with what requirements for examples and computation.
Sources
Primary source consulted: Bird, Klein, and Loper, Natural Language Processing with Python, chapter on sentence meaning and compositional semantics, https://www.nltk.org/book/ch10.html . The approval examples and fictional catalog interface are original teaching illustrations. Formal meaning construction is distinguished from truth and broader generalization claims.
Previous: Compositional pattern-producing network Next: Compound Events