How do Transformer Embeddings Represent Compositions? A Functional Analysis

Aishik Nagar, Ishaan Singh Rawal, Mansi Dhanania, Cheston Tan

Introduction

While Transformer-based models have become the standard for modern natural language processing, the internal "geometry" of their representations remains a subject of intense study. A fundamental question in linguistics and AI is compositionality: the ability to construct complex meanings from simpler constituent parts. In classical Vector Space Models (VSMs), this was often achieved through simple algebraic operations. However, modern Transformers generate contextual embeddings through deep, non-linear architectures, leading many to wonder if the resulting compound representations are unpredictable "black boxes."

This research investigates whether modern embedding models (such as Mistral and OpenAI's Large models) represent compound words in a predictable, structured manner, or if they have moved away from the linear compositionality seen in earlier models.

Methodology: A Functional Approach

The authors utilize a functional analysis framework to evaluate compositionality. They define composition as a mathematical function $f(u, v) = \hat{w}$, where $u$ and $v$ represent the embeddings of the constituent parts (e.g., "book" and "store") and $\hat{w}$ is the predicted embedding of the compound ("bookstore").

To find the most accurate mapping, the study tested six distinct compositionality models:

  1. Simple Addition: Basic vector summation.
  2. Weighted Addition: A linear combination using learned weights.
  3. Multiplication: Element-wise multiplication.
  4. Dilation: Stretching one vector in the direction of the other.
  5. Ridge Regression: A linear mapping that learns an optimal transformation.
  6. Multi-Layer Perceptron (MLP): A non-linear neural network approach.

The accuracy of these functions was measured by comparing the predicted vector ($\hat{w}$) to the model's actual output for the compound ($w$) using Cosine Similarity and Jensen-Shannon (JS) Divergence.

Data and Experimental Setup

The study employed three primary datasets to capture different aspects of lexical composition:

  • LADEC: A dataset of approximately 9,000 English compound words with human-annotated semantic ratings.
  • LADEC-NC (Novel Compounds): A newly introduced dataset of 10,000 synthetic, "never-seen-before" compounds (e.g., "zoodough") designed to test if compositionality is a generalized capability or merely the result of memorizing training data.
  • SANC (Simple Adjective-Noun Compositions): A systematic dataset of 625 pairs (e.g., "metal papaya") used to evaluate rule-based, transparent combinations.

Key Insights

The Triumph of Linearity

One of the most striking findings is that Ridge Regression (a linear model) consistently outperformed the non-linear MLP. This suggests that the embedding spaces of modern Transformers are naturally structured to support linear operations. This inherent linearity makes these models far more interpretable than their complex architectures might suggest.

The Power of Simple Addition

Simple vector addition—the most basic form of composition—performed nearly as well as complex regression models. For modern LLMs, the "sum of the parts" provides a remarkably accurate approximation of the whole compound, with cosine similarities hovering between 0.85 and 0.89.

The BERT Gap

The research highlights a significant performance gap between older models like BERT and modern LLMs. BERT demonstrated much poorer compositionality, likely due to its bidirectional architecture and Masked Language Modeling (MLM) objective. While modern models achieved JS Divergence scores above 0.80, BERT lagged significantly behind (0.29–0.50), suggesting that newer training objectives and scales better foster structured representation spaces.

Compositionality as an Emergent Property

Crucially, the models performed just as well on novel compounds (LADEC-NC) as they did on established English words. This indicates that compositionality is an emergent property of the Transformer architecture and its training regime, rather than a byproduct of seeing specific compounds during pre-training.

Conclusion and Future Directions

The study concludes that modern Transformer embeddings represent compound concepts in a highly predictable and linear fashion. This structured geometry allows for the prediction of compound vectors with high accuracy (~0.92 cosine similarity using Ridge Regression).

However, the authors note several areas for future work. The current study focuses on two-word compounds; it remains to be seen if these linear rules hold for more complex phrases or full sentences. Additionally, while the study identifies that modern models are more compositional than BERT, the specific cause—whether it be training volume, the autoregressive objective, or model scale—requires further controlled experimentation.

Summary updated

BibTeX
@inproceedings{nagar2025how,
  author = {Aishik Nagar and Ishaan Singh Rawal and Mansi Dhanania and Cheston Tan},
  title = {{How do Transformer Embeddings Represent Compositions? A Functional Analysis}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure