How do Transformer Embeddings Represent Compositions? A Functional Analysis

Aishik Nagar, Ishaan Rawal, Mansi Dhanania, Cheston Tan · 2025

Read How do Transformer Embeddings Represent Compositions? A Functional Analysis by Aishik Nagar, Ishaan Rawal, Mansi Dhanania, Cheston Tan (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2506-00914.txt.

Introduction

Do word vectors add? Aishik Nagar, Ishaan Singh Rawal, Mansi Dhanania, and Cheston Tan test in 2025 how the codes inside language models build a phrase from its parts. They fed compound words to six models of how parts combine, from plain sums to learned bends. A straight-line fit won the day, with plain sums a hair behind. Most new embedding models proved strongly additive in this sense.

One old name broke the pattern: BERT's codes mixed parts far less cleanly. A made-up set of plain adjective-noun pairs, where the true mix is open to see, backed the main finds. The team chart the result as good news for search and match tools built on sums. It also gives a clean test any new code model can be run through.

Catalog record

CREATORAishik Nagar, Ishaan Rawal, Mansi Dhanania, Cheston Tan
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE53 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2506-00914

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

How do Transformer Embeddings Represent Compositions? A Functional Analysis Aishik Nagar, Ishaan Rawal, Mansi Dhanania, Cheston Tan Abstract Compositionality is a key aspect of human intelligence, essential for reasoning and generalization. While transformer-based models have become the de facto standard for many language modeling tasks, little is known about how they represent compound words, and whether these representations are compositional. In this study, we test compositionality in Mistral, OpenAI Large, and Google embedding models, and compare them with BERT. First, we evaluate compositionality in the representations by examining six diverse models of compositionality (addition, multiplication, dilation, regression, etc.). We find that ridge regression, albeit linear, best accounts for compositionality. Surprisingly, we find that the classic vector addition model performs almost as well as any other model. Next, we verify that most embedding models are highly compositional, while BERT shows much poorer compositionality. We verify and visualize our findings with a synthetic dataset consisting of fully transparent adjective-noun compositions. Overall, we present a thorough investigation of compositionality. 1 Introduction Large Language Models (LLMs) have emerged as the de facto standard for language generation and modeling tasks Zhao et al. 2023 , largely due to their superior generalization abilities compared to earlier models like BERT Devlin et al. 2019a . One key factor contributing to this generalizability is compositionality – the ability to form new concepts by combining known ones Fodor and Lepore 2002 . However, testing the compositionality of these models is challenging. Previous works on transformer models have mostly relied on performance on benchmarks as proxies for compositional generalization Johnson et al. 2017 ; Yu et al. 2022 , but such numbers can be often misleading Rawal et al. 2024 . Thus, representation analysis, like that in Fig. 1 , can provide insights about the inner workings of a model. Thus, we conduct representation-centric analyses to verify the compositionality of transformer models. Figure 1: Linear concept transformation functions ( female and royal ) used to transform the representations of nouns Ethayarajh et al. 2019 . While a substantial body of literature exists on the functional compositionality of Vector Space Models (VSMs) Mitchell and Lapata 2008 ; Baroni and Zamparelli 2010 , such understanding of transformer models, which also rely on the distributional hypothesis Firth 1957 , remains limited. Additionally, exploring differences in how current models comprehend compositionality is crucial. To address these, we adopt a functional approach to investigate the compositionality of transformer-based embedding models. We focus on embedding models, due to their widespread use in applications like Retrieval-Augmented Generation Lewis et al. 2020 and vector databases Han et al. 2023 . The primary goal of this work is specifically to analyze how transformer models represent constitutuents of compound words, and how these token-level representations relate to the embedding generated for the entire compound word, taken as context. Transformer models excel at generating contextual embeddings, which differ fundamentally from static embeddings traditionally used in vector space models (VSMs). This context-dependent embedding generation allows transformer models to represent higher-order semantic features, such as semantic dominance and transparency, which emerge naturally in language usage. For example, the model might have learned that the term "Red Cross," although literally composed of "red" and "cross," frequently carries an organization-like meaning distinct from a purely additive combination of its constituents, resulting in a lower similarity between their consituent representations and the compound, regardless of the method of tokenization. While it may seem intuitive that transformer models represent compound words as weighted averages of their constituent parts, the non-linear and multi-layered nature of these models makes composition far less predictable Templeton et al. 2024 . Tokenized compounds (e.g., “blue” + “tooth”) are not always interpreted in a compositional way, and may instead be mapped to distinct, non-compositional meanings based on learned context Haber and Poesio 2024 ; Grindrod 2024 . This ambiguity—especially for polysemous or rare compounds—motivates a closer examination of whether transformer embeddings respect compositionality in practice. Compound words are a significant aspect of natural language. In English, compound words account for approximately 4% of the total vocabulary in large corpora like the British National Corpus Biber et al. 1999 . Language models often fail to generalize to novel compounds or properly encode existing ones Cordeiro et al. 2016 and if a model struggles with word-level composition, it may face challenges with more complex structures Lake et al. 2017 . Understanding how models handle lexical composition is therefore foundational for scaling up to phrases and sentences. Adjective-noun compositions and compound words have been widely studied as tests of compositionality Reddy et al. 2011 ; Baroni and Zamparelli 2010 . They allow studying semantic composition in a controlled setting, minimizing syntactic variability. Although seemingly simple, two-word compounds and compositions can present significant challenges. For example, ladybird is a beetle unrelated to female birds. Red ball refers to a red-colored ball, whereas chocolate ball refers to a ball made of chocolate. Moreover, humans often create novel compositions, such as deepfake , which first appeared in 2018. As such, we focus on two-word compounds and adjective-noun compositions. We extend the study of functional compositionality in VSMs to embedding models, by testing six compositionality models for combining constituent word embeddings to generate the embedding of their composition. We find that (i) ridge regression can effectively explain compositionality in these models, and (ii) current models are significantly more compositional than BERT. We also test the generalizability of our method on novel compound words created through data augmentation. Finally, we test the properties of the models on the LADEC dataset and on our Simple Adjective-Noun Compositions (SANC) dataset to (iii ) investigate and visualize the underlying mechanics. 2 Related Works Coil and Shwartz 2023 questioned whether language models possess the ability to understand noun compounds. They inferred that GPT-3 was able to correctly understand the implicit relation between two nouns in compound words such as chocolate crocodile , and conclude that it denotes a crocodile-shaped chocolate due to the large amount of data it has access to through the web corpus. Another study, by Buijtelaar and Pezzelle 2023 , utilized human judgement to evaluate two psycholinguistic measures of compound semantic analysis, namely, lexeme meaning dominance and semantic transparency. This work demonstrated that BERT resembled human intuition in terms of semantic measures, especially when provided sufficient context to the data inputted. Turney and Pantel 2010 and Bullinaria and Levy 2012 ’s work on Distributional Semantic Models (DSMs) is discussed in appendix A.1 . Compositional Distributional Models. Mitchell and Lapata 2008 explored various compositional distributional models that derive vectors for phrases by composing the vectors of their constituent words. Their work on additive and multiplicative models provided a foundational understanding of how simple algebraic operations could approximate the meaning of phrases. Baroni and Zamparelli 2010 extended this by introducing the lexical function model, treating adjectives as functions mapping noun vectors to phrase vectors. Word Embeddings and Neural Networks. The advent of word embeddings, such as Word2Vec Mikolov et al. 2013 and BERT Devlin et al. 2019b , provided dense, context-sensitive representations of words. These models have been instrumental in capturing subtle semantic nuances and have been widely used for various NLP tasks. Recent works on variational autoencoders for semantic analysis, such as Kingma

Read the complete text