Abstract
This research introduces a unified, two-step evaluation pipeline designed to measure the linear additive compositionality of embeddings across diverse modalities, including words, sentences, and knowledge graphs. By combining Canonical Correlation Analysis (CCA) with a leave-one-out reconstruction test, the study reveals that modern embeddings—even those generated by highly non-linear models like GPT and Llama—retain significant levels of interpretable, additive structure. This compositionality typically peaks in the mid-to-late layers of transformer architectures before declining in the final layers as representations specialize for specific training objectives.
Introduction
In the early era of representation learning, static word embeddings like Word2Vec gained prominence for their apparent linear compositionality, famously illustrated by the analogy king - man + woman = queen. However, subsequent critiques suggested these examples were often cherry-picked and lacked broad generalizability. In contrast, modern state-of-the-art (SOTA) transformer models (e.g., BERT, GPT, Llama) and graph neural networks produce highly contextualized embeddings. While these models are exceptionally expressive, their lack of explicit constraints on how meaning shifts across contexts makes them opaque and difficult to interpret.
The central challenge addressed in this work is the lack of rigorous, modality-agnostic metrics to quantify the extent to which modern embeddings are constructed by linearly adding the meanings of their constituent parts. The authors formalize a statistical framework to measure linear additive compositionality across different architectures, layers, and training stages.
Methodology
The authors propose a two-step diagnostic pipeline to evaluate compositionality without being tied to a specific model architecture:
- Assessing Linearity via Canonical Correlation Analysis (CCA): The researchers define a binary "attribute matrix" representing human-interpretable concepts (e.g., specific locations in a sentence or a user's demographic traits) and a continuous "embedding matrix" containing the model-generated vectors. CCA is employed to identify latent linear correlations between these two distinct spaces.
- Quantifying Additive Generalization (Leave-One-Out): To test if an embedding space is truly compositional, the authors evaluate whether an unseen entity's embedding can be predicted by summing the vectors of its individual attributes. Using a Leave-One-Out (LOO) approach, they learn a linear mapping from attributes to embeddings on a training subset and attempt to reconstruct held-out embeddings. Performance is measured using L2 Loss, Cosine Similarity, and Retrieval Accuracy (Hits@K).
To ensure statistical rigor, all results are compared against a baseline established via Monte Carlo simulations, where attribute-embedding pairings are randomly permuted.
Experimental Setup
The framework was evaluated across three distinct modalities:
- Sentences: Using the Schema-Guided Dialogue (SGD) dataset, sentences were annotated with concepts (e.g., genre, location) and embedded using SBERT, GPT (text-embedding-3-small), and Llama-2-7b.
- Knowledge Graphs (KG): Using the MovieLens 1M dataset, graph embeddings were trained on user-movie ratings, while demographic data (age, gender, occupation) served as the attribute matrix.
- Words: WordNet and MorphoLex were used to provide semantic and syntactic structures (roots/suffixes) for GoogleNews Word2Vec embeddings.
Key Insights
The Evolution of Compositionality
The study finds that additive compositionality is a learned skill that emerges and solidifies as training progresses. In models like MultiBERTs, the ability to generalize additive concepts improves steadily over thousands of training steps.
Layer-wise Dynamics in Transformers
Analysis of SBERT reveals a distinct "compositionality curve": linear structure increases through early layers, peaks around layer 4 or 5, and drops sharply in the final layer. This suggests that middle layers capture general semantic relationships, while the final layer warps the vector space to optimize for the model's specific output objective.
Persistence in Large Language Models
Despite the massive scale and non-linear attention mechanisms of LLMs like GPT and Llama, these models continue to encode conceptual components in a manner that can be additively decomposed. For instance, Llama achieved a cosine similarity of 0.9355 for real attribute pairings compared to 0.8153 for permuted baselines.
Identifying Non-Linear Phenomena
The framework also serves as a diagnostic tool for identifying where linear models fail. High reconstruction residuals (errors) often flag complex linguistic features—such as idioms, sarcasm, or heavy contextual dependencies—that cannot be captured by simple addition.
Results Summary
- Sentences: SBERT achieved a retrieval accuracy (Hits@5) of 0.59 for reconstructed embeddings, significantly higher than the 0.04 baseline.
- Knowledge Graphs: User embeddings generalized demographic attributes with remarkable precision, reaching a Hits@1 accuracy of 0.94.
- Words: While Word2Vec embeddings outperformed random chance in decomposing roots and suffixes (0.44 cosine similarity), the absolute values were lower than other modalities, suggesting much of the semantic information in static word vectors remains non-linear.
Limitations and Future Work
The current framework relies on human-defined attributes; if these are incomplete or poorly defined, the results may not fully reflect the model's internal logic. Additionally, the method is strictly limited to linear additive compositionality and does not account for non-linear mappings. Future research will explore dimensionality reduction techniques to handle high-dimensional models like Llama more efficiently and extend the analysis to morphologically rich, non-English languages.
Summary updated