Quantifying Compositionality of Classic and State-of-the-Art Embeddings

Zhijin Guo, Chenhao Xue, Zhaozhen Xu, Hongbo Bo, Yuxuan Ye, Janet B. Pierrehumbert, Martha Lewis

Abstract

For language models to generalize correctly to novel expressions, it is critical that they exploit access compositional meanings when this is justified. Even if we don’t know what a “pelp” is, we can use our knowledge of numbers to understand that “ten pelps” makes more pelps than “two pelps”. Static word embeddings such as Word2vec made strong, indeed excessive, claims about compositionality. The SOTA generative, transformer models and graph models, however, go too far in the other direction by providing no real limits on shifts in meaning due to context. To quantify the additive compositionality, we formalize a two-step, generalized evaluation that (i) measures the linearity between known entity attributes and their embeddings via canonical correlation analysis, and (ii) evaluates additive generalization by reconstructing embeddings for unseen attribute combinations and checking reconstruction metrics such as L2 loss, cosine similarity, and retrieval accuracy. These metrics also capture failure cases where linear composition breaks down. Sentences, knowledge graphs, and word embeddings are evaluated and tracked the compositionality across all layers and training stages. Stronger compositional signals are observed in later training stages across data modalities, and in deeper layers of the transformer-based model before a decline at the top layer. Code will be publicly available on GitHub upon acceptance.

Introduction

In linguistics, the "Principle of Compositionality" suggests that the meaning of a complex expression is determined by the meanings of its constituent parts. In the world of AI, researchers have long hypothesized that vector embeddings follow this rule—for instance, that adding the vector for "blue" to "car" results in a representation close to "blue car."

However, evidence for this has often been anecdotal or limited to specific models like Word2Vec. Critics argue these results are often "cherry-picked" and fail to generalize. Furthermore, as models become more complex (like LLMs), it remains unclear if they maintain this linear structure or if meaning becomes "tangled" in non-linear ways. This paper provides a unified, modality-agnostic framework to quantify exactly how much "the whole is the sum of its parts" across words, sentences, and knowledge graphs.

Methodology

The authors propose a rigorous two-step evaluation pipeline to move beyond anecdotal evidence:

  1. Assessing Linearity (CCA): Canonical Correlation Analysis (CCA) is employed to determine if a linear relationship exists between a binary attribute matrix (representing known features like "is a comedy" or "user is female") and the continuous embedding matrix. A high correlation indicates that the embedding space is structured linearly according to those attributes.
  2. Quantifying Additive Generalization (LOO): A Leave-One-Out (LOO) experiment is used to "reconstruct" an unseen entity's embedding by summing the learned vectors of its individual attributes. The proximity of this reconstruction to the actual model-generated embedding is measured using L2 loss, cosine similarity, and retrieval accuracy.
The two-step evaluation framework: (1) Assessing linearity via CCA and (2) Quantifying additive generalization via Leave-One-Out reconstruction.

Data Modalities

The study evaluates three distinct modalities to ensure the generalizability of the framework:

  • Sentences: Utilizing the Schema-Guided Dialogue (SGD) dataset, where sentences are annotated with specific concepts (e.g., [location, theater name, genre]).
  • Knowledge Graphs: Utilizing MovieLens 1M, pairing user embeddings (learned from movie preferences) with demographic attributes (gender, age, occupation).
  • Words: Combining WordNet (semantic meaning) and MorphoLex (syntactic structure) to investigate if Word2Vec embeddings decompose into morphological parts.

Key Insights

  • Compositionality is Learned, Not Born: In MultiBERT models, compositionality starts low and steadily improves as the model processes more data. The embedding space literally "organizes" itself to be more linear over time.
  • The "Middle Layer" Peak: In Transformer models like SBERT, compositionality is not highest at the final output. Instead, it peaks in the intermediate layers (layers 4 or 5). The final layers may show a decline in compositionality as they specialize for specific tasks requiring more complex, non-linear representations.
  • Word2Vec Robustness: Despite recent skepticism, the paper confirms that Word2Vec embeddings align remarkably well with both semantic and syntactic structures.
  • The Curse of Dimensionality: While Llama-2 exhibits very high cosine similarity in its reconstructions, its retrieval accuracy is lower than smaller models. This suggests that in massive high-dimensional spaces, angular proximity does not always guarantee nearest-neighbor status.
Correlation between components across different training stages, showing that compositional signals strengthen as training progresses.

Quantitative Results

  • Knowledge Graphs: User embeddings showed a 1.5x increase in attribute-embedding correlation from early to late training stages. The additive model achieved a Hits@1 of 0.94, meaning the sum of a user's demographic parts almost perfectly predicted their actual learned preference embedding.
  • Sentence Models: SBERT and GPT showed significant gaps between "real" attribute pairings and random permutations (p < 0.01), proving the additive signal is robust.
  • BERT Training: For the cls_2000k model (fully trained), the relative difference in cosine similarity between real and permuted pairings was nearly 5%, compared to almost 0% at the start of training.

Discussion and Limitations

This research focuses strictly on linear addition. It acknowledges that many linguistic features, such as idioms ("hot dog") or sarcasm, are inherently non-linear and cannot be captured by this framework. Additionally, the method requires a predefined set of attributes, whereas real-world meaning is often fluid. Future work aims to utilize dimensionality reduction techniques to make these metrics more scalable for "frontier" models like Llama, where full CCA calculations are computationally expensive.

Summary updated

BibTeX
@inproceedings{guo2025quantifying,
  author = {Zhijin Guo and Chenhao Xue and Zhaozhen Xu and Hongbo Bo and Yuxuan Ye and Janet B. Pierrehumbert and Martha Lewis},
  title = {{Quantifying Compositionality of Classic and State-of-the-Art Embeddings}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
  doi = {10.18653/v1/2025.findings-emnlp.1206},
}
Figure