Composition-contrastive Learning for Sentence Embeddings

Sachin Chanchani, Ruihong HuangACL 2023

Abstract

This paper introduces Composition-based Contrastive Learning (CompCSE), a novel unsupervised framework for learning sentence embeddings. Traditional contrastive methods like SimCSE rely on dropout noise for data augmentation, which can lead to superficial feature learning and dimensional collapse. In contrast, CompCSE exploits the linguistic principle of compositionality by decomposing sentences into phrasal constituents and maximizing the alignment between the full sentence and a composition of its parts. Our approach achieves state-of-the-art performance on Semantic Textual Similarity (STS) tasks while demonstrating exceptional training efficiency, often converging in under 15 minutes on a single GPU.

Introduction

Unsupervised sentence representation learning is a cornerstone of modern Natural Language Processing. Contrastive learning, which pulls semantically similar pairs together while pushing dissimilar ones apart, has become the standard approach. However, the effectiveness of these models hinges on the quality of the "positive pairs" used for training. Current state-of-the-art methods like SimCSE use dropout noise as a minimal augmentation. While effective, this approach can encourage the model to rely on superficial cues like sentence length rather than deep semantics.

CompCSE addresses these challenges by leveraging the idea that the meaning of a whole sentence is derived from its parts. By training the model to recognize a sentence as a composition of its constituents, we encourage the learning of deeper semantic structures and more robust representations.

Methodology

The CompCSE framework consists of three main components: decomposition, encoding, and compositional aggregation.

Decomposition and Subsampling

Sentences are first decomposed into "semantic atoms"—phrases or clauses—using either a naive split or a pre-trained discourse parser. To provide the model with a richer set of training examples, we employ various subsampling strategies, creating positive pairs from adjacent, overlapping, or subsuming spans within the sentence.

Overview of subsampling strategies and the contrastive training objective.

Compositional Objective

The full sentence and its constituents are passed through a shared encoder (e.g., BERT or RoBERTa). The resulting representations are then aggregated in the latent space. Empirical results show that averaging constituent vectors works best for BERT-based models, while concatenation is superior for RoBERTa. The model is trained to maximize the similarity between the original sentence vector and this aggregated "composed" vector, effectively performing a form of self-distillation that amplifies contextually relevant features.

Experimental Setup

We trained our models on 1 million randomly sampled sentences from Wikipedia. Evaluation was performed on seven Semantic Textual Similarity (STS) tasks (STS 2012–2016, STS-Benchmark, and SICK-Relatedness), where model predictions are compared against human similarity scores.

Results and Analysis

CompCSE consistently outperformed SimCSE across multiple architectures. On the STS-Benchmark, CompCSE improved the BERT-base score from 76.25 to 78.18, and up to 78.97 with optimized negative sampling.

Training Efficiency

A standout feature of CompCSE is its efficiency. Unlike many successors to SimCSE that add complex auxiliary losses or extra parameters, CompCSE remains simple and fast. It reaches peak performance significantly faster than SimCSE, completing training in under 15 minutes on a single NVIDIA A100 GPU.

Comparison of training convergence between CompCSE (naive partition) and unsupervised SimCSE.

Embedding Space Diversity

Analysis of the embedding space suggests that CompCSE successfully breaks the "length shortcut." By forcing the model to align full sentences with compositions of shorter parts, the model can no longer rely on token count as a proxy for similarity. Visualizations show a more diverse and scattered distribution of embeddings compared to the clusters often seen with dropout-based methods, mitigating the issue of dimensional collapse.

Conclusion

CompCSE demonstrates that incorporating linguistic principles like compositionality into contrastive learning can yield significant improvements in both representation quality and training speed. The success of this simple yet effective augmentation strategy suggests that respecting phrasal structure is key to unlocking better sentence embeddings. Future work will investigate the application of this method to supervised learning and its interaction with other advanced training techniques like prompt-based learning.

Summary updated

BibTeX
@inproceedings{chanchani2023composition,
  author = {Sachin Chanchani and Ruihong Huang},
  title = {{Composition-contrastive Learning for Sentence Embeddings}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-long.882},
}
Figure