Abstract
Unsupervised sentence representation learning has progressed through contrastive learning and data augmentation methods such as dropout masking. Despite this progress, sentence encoders are still limited to using only an input sentence when predicting its semantic vector. In this work, we show that the semantic meaning of a sentence is also determined by nearest-neighbor sentences that are similar to the input sentence. Based on this finding, we propose a novel unsupervised sentence encoder, RankEncoder. RankEncoder predicts the semantic vector of an input sentence by leveraging its relationship with other sentences in an external corpus, as well as the input sentence itself. We evaluate RankEncoder on semantic textual benchmark datasets. From the experimental results, we verify that 1) RankEncoder achieves 80.07% Spearman’s correlation, a 1.1% absolute improvement compared to the previous state-of-the-art performance, 2) RankEncoder is universally applicable to existing unsupervised sentence embedding methods, and 3) RankEncoder is specifically effective for predicting the similarity scores of similar sentence pairs.
Introduction: The "Tunnel Vision" of Sentence Encoders
In Natural Language Processing (NLP), unsupervised sentence representation learning aims to map sentences into a vector space where semantic similarity corresponds to geometric proximity. While methods like SimCSE have achieved significant success using contrastive learning, they often suffer from a form of "tunnel vision." These models typically determine a sentence's position in vector space based solely on the input sentence and its internal features, ignoring the broader linguistic neighborhood.
However, the semantic identity of a sentence is inherently relational. As shown in Figure 1, standard vector similarity can sometimes fail to align with human intuition. While two sentences (a and b) might appear closer in a raw vector space, their relationships to a broader neighborhood of sentences (global context) can reveal that sentence 'a' is actually more semantically similar to sentence 'c'. By ignoring this relational context, current models miss critical semantic nuances, especially for sentences that are semantically similar but lexically distinct.
The RankEncoder Framework
To address this limitation, we propose RankEncoder, a framework that shifts the focus from absolute vector coordinates to relative rankings within an external corpus. The core idea is that if two sentences are semantically similar, they should "rank" sentences in a large external corpus in a similar order.
1. Rank Vectors and Normalization
For any input sentence, RankEncoder calculates its similarity to every sentence in a large external corpus (e.g., 100,000 Wikipedia sentences) using a base encoder. This results in a "rank vector" $\vec{r}$. To make these rankings useful for training, the model applies a specific normalization function $g$. This transformation ensures that the inner product of two normalized rank vectors is mathematically equivalent to the Spearman’s rank correlation between the original rankings, providing a robust measure of semantic similarity.
2. Training and Filtering
As illustrated in Figure 2, the RankEncoder training process involves several key steps:
- Rank Encoding: Generating normalized rank vectors $\vec{u}$ for batch sentences against the semantic vector space of the corpus.
- Sentence Pair Filtering: To reduce noise and focus on semantically challenging cases, the model filters sentence pairs based on their similarity scores $s_{ij}$. It specifically targets pairs within a threshold $[\tau_l, \tau_u]$, focusing the model on "hard" cases where semantic nuance matters most.
- RankEncoder Loss: The model is trained using a Mean Squared Error (MSE) loss ($l_r$) that encourages the learned sentence encoder $E$ to produce embeddings whose cosine similarity matches the similarity scores derived from the rank vectors.
Key Results and Insights
We evaluated RankEncoder across seven standard Semantic Textual Similarity (STS) benchmarks. The results demonstrate that RankEncoder is a powerful, universally applicable enhancement for existing encoders.
- New State-of-the-Art: RankEncoder achieved an average Spearman’s correlation of 80.07% across STS tasks, representing a 1.1% absolute improvement over the previous state-of-the-art (SNCSE).
- Universal Applicability: The framework consistently boosted performance across various base models, including SimCSE and PromptBERT. For instance, on the STS12 dataset, it provided a significant 4.21% improvement over the base SNCSE model.
- Efficiency: Despite the additional ranking step, the inference overhead is minimal. Inference time increases by only approximately 1.8% compared to a standard BERT-base model, making it highly practical for real-world use.
Conclusion
RankEncoder demonstrates that the semantic meaning of a sentence is deeply tied to its relationship with a broader linguistic context. By leveraging an external corpus to generate robust rank-based representations, RankEncoder overcomes the limitations of traditional unsupervised encoders. Its ability to improve uniformity in the embedding space while maintaining high alignment makes it a versatile tool for advancing unsupervised sentence representation learning.
Summary updated