Abstract
This paper proposes a simple test for compositionality (i.e., literal usage) of a word or phrase in a context-specific way. The test is computationally simple, relying on no external resources and only uses a set of trained word vectors. Experiments show that the proposed method is competitive with state of the art and displays high accuracy in context-specific compositionality detection of a variety of natural language phenomena (idiomaticity, sarcasm, metaphor) for different datasets in multiple languages. The key insight is to connect compositionality to a curious geometric property of word embeddings, which is of independent interest.
1. Introduction
In Natural Language Processing (NLP), "compositionality" refers to the principle that the meaning of a phrase is derived from the sum of its parts. For instance, the phrase "bad egg" is compositional when describing a literal rotten egg, but non-compositional (idiomatic) when referring to a troublesome individual. Distinguishing between these uses is challenging as it depends heavily on immediate context. Traditional methods often rely on global document context or extensive external resources like Wiktionary and labeled datasets, which limits their applicability to low-resource languages or specific phenomena like sarcasm and metaphor. This work introduces a resource-independent, unsupervised geometric test to determine if a phrase is used literally based on its local linguistic neighborhood.
2. Methodology
The proposed method leverages the geometric properties of word embeddings, treating the context of a sentence as a low-dimensional subspace rather than a single average vector.
2.1 Context Subspace Construction
For a given sentence, content words (excluding function words) are represented as embedding vectors. Principal Component Analysis (PCA) is applied to these vectors to identify the top $m$ directions (typically $m \approx 3$) that capture the most variance. This defines the "context subspace."
2.2 Compositionality Scoring
The target phrase's vector embedding is projected onto this context subspace. The compositionality score is defined as the cosine similarity between the original phrase vector and its projection. A high score indicates the phrase aligns with the geometric neighborhood of its context, suggesting literal usage. Conversely, a low score identifies the phrase as a geometric outlier, indicating figurative, sarcastic, or idiomatic meaning.
3. Experimental Evaluation
The method was evaluated across diverse tasks, including multi-word expression (MWE) compositionality, lexical idiomaticity, sarcasm detection, and metaphor identification.
3.1 Results and Performance
The PCA-based subspace approach demonstrated significant improvements over baseline methods. As shown in Table 1, the method achieved 86.1% accuracy for English and 88.3% for Chinese using multi-sense embeddings (MSSG), significantly outperforming simple averaging techniques.
3.2 Sarcasm and Metaphor Detection
The geometric test successfully distinguished sarcastic usage in social media data. For words like "nice" or "good," sarcastic contexts consistently yielded lower compositionality scores compared to literal contexts, as the figurative meaning deviates from the literal context subspace.
In metaphor detection, the model achieved an F1 score of 0.806 on Subject-Verb-Object (SVO) structures using only a few subspace-derived features, rivaling complex state-of-the-art systems.
4. Discussion
The "Geometry of Compositionality" reveals that literal language "lives" within a low-dimensional linear subspace formed by surrounding context words. This language-agnostic property allows for effective detection of non-compositional language without language-specific rules or external dictionaries. However, the method's performance is sensitive to sentence length, as very short sentences may lack sufficient context to form a stable subspace. Future work may explore the impact of embedding quality and automated hyperparameter tuning across different linguistic domains.
Summary updated