A Simple and Plug-and-play Method for Unsupervised Sentence Representation Enhancement

Lingfeng Shen, Haiyun Jiang, Lemao Liu, Shuming ShiarXiv 2023 · DOI

Introduction

In modern Natural Language Processing (NLP), sentence embeddings—dense vector representations of text—are fundamental to tasks like semantic search, clustering, and information retrieval. However, generating high-quality embeddings without large-scale labeled data remains a significant challenge. Pre-trained models like BERT often suffer from anisotropy, where embeddings are confined to a narrow cone in the vector space, leading to high correlation and poor discriminative power.

Furthermore, these "raw" embeddings are typically contaminated by two forms of redundancy:

  1. Sentence-level redundancy: Noise introduced by trivial, high-frequency words (e.g., "the", "a", "of") that do not contribute to the core semantic meaning.
  2. Corpus-level redundancy: A shared global bias across the entire dataset that makes distinct sentences appear artificially similar.

To address these issues, we introduce RepAL (Representation ALchemy), a training-free, post-processing method designed to refine sentence embeddings by systematically subtracting these redundant signals.

The RepAL Framework

RepAL is a "plug-and-play" refinement process that requires zero additional training. It enhances a raw embedding $f(x_i)$ by applying a simple subtraction-based formula:

$$v'_i = f(x_i) - \lambda_1 \cdot v^*_i - \lambda_2 \cdot \hat{v}$$

Components of Refinement

  • Sentence-level Refinement ($v^*_i$): This component targets sentence-specific noise. The method uses TF-IDF to identify "keywords" within a sentence. These keywords are masked, and the remaining "trivial" words are passed through the encoder. The resulting vector $v^*_i$ represents the semantic noise inherent to that specific sentence structure.
  • Corpus-level Refinement ($\hat{v}$): This represents the global bias, calculated as the average embedding of all sentences in the target corpus. Subtracting this helps mitigate anisotropy by centering the distribution.
  • Adaptive Weighting ($\lambda_1, \lambda_2$): These hyper-parameters balance the removal of local and global noise, allowing the method to adapt to different models and datasets.

Performance Benchmarks

RepAL was evaluated across a diverse set of benchmarks, including Chinese datasets (ATEC, BQ, LCQMC, PAWSX, STS-B) and English STS tasks (2012–2016). The results demonstrate that RepAL consistently improves performance across various architectures, from vanilla BERT to highly optimized contrastive models like SimCSE.

Table 1: Performance of RepAL across various Chinese NLP benchmarks and model baselines.

As shown in Table 1, the improvements are particularly striking for base models. For instance, vanilla Chinese BERT saw an absolute average improvement of 4.65%. Even for strong baselines like Sim-BERT, which already incorporates advanced training techniques, RepAL provided a further boost of 0.88%.

Component Analysis

To understand the contribution of each refinement step, we conducted ablation studies. These experiments confirm that both sentence-level and corpus-level subtractions are vital for maximizing embedding quality.

Table 3: Ablation study showing the impact of sentence-level and corpus-level refinement.

In Table 3, "w/o Sen" refers to the removal of sentence-level refinement, while "w/o Cor" refers to the removal of corpus-level refinement. The data indicates that while corpus-level refinement often provides a larger initial boost for vanilla models by addressing anisotropy, the sentence-level refinement is crucial for capturing the fine-grained semantic core of the text.

Conclusion and Future Work

RepAL offers a computationally efficient, training-free solution for enhancing sentence representations. Its ability to improve a wide range of models across multiple languages makes it a versatile tool for NLP practitioners.

Future research may focus on making the method more task-adaptive, as different downstream applications (e.g., sentiment analysis vs. document retrieval) may define "redundancy" differently. Additionally, replacing TF-IDF with more context-aware keyword extraction methods could further improve the precision of sentence-level noise modeling.

Summary updated

BibTeX
@misc{shen2023simple,
  author = {Lingfeng Shen and Haiyun Jiang and Lemao Liu and Shuming Shi},
  title = {{A Simple and Plug-and-play Method for Unsupervised Sentence Representation Enhancement}},
  year = {2023},
  eprint = {2305.07824},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.07824},
}
Figure