Large Language Models can Contrastively Refine their Generation for Better Sentence Representation Learning

Huiming Wang, Zhaodonghui Li, Liying Cheng, De Wen Soh, Lidong Bing

Introduction

Sentence representation learning is a fundamental task in natural language processing, aiming to map sentences into a high-dimensional vector space where semantic similarity corresponds to geometric proximity. The current state-of-the-art approach relies on contrastive learning, which optimizes model parameters by pulling "positive" pairs (semantically similar sentences) together and pushing "negative" pairs (semantically different sentences) apart.

However, the effectiveness of contrastive learning is highly dependent on the quality of the training data. It is notoriously sensitive to noise; for instance, if a pair labeled as a contradiction is actually a paraphrase, the model's performance can degrade significantly. While Large Language Models (LLMs) offer a promising avenue for generating synthetic training data, they often suffer from hallucinations or fail to strictly follow complex instructions, such as generating a precise contradiction. This "garbage in, garbage out" challenge has limited the utility of LLMs as automated data annotators for sentence embeddings.

The MultiCSR Framework

To address these limitations, the authors introduce MultiCSR (Multi-level Contrastive Sentence Representation), a framework designed to refine LLM-generated data at three distinct stages: generation, selection, and training.

The three-stage MultiCSR framework: Contrastive Generation, Self-Curation, and Contrastive In-Batch Training.

Stage 1: Contrastive Generation

Rather than relying on standard prompting, MultiCSR employs "Contrastive Decoding." This technique steers the LLM by comparing the logits (raw probability scores) of a target instruction (e.g., "Write a paraphrase") against a "noisy" or opposite instruction (e.g., "Write a contradiction"). By subtracting the influence of the noisy instruction from the target distribution, the model is forced to produce outputs that more strictly adhere to the intended semantic logic, effectively reducing instruction-following errors.

Stage 2: Self-Curation (Contrastive Sentence Pair Construction)

After generation, the LLM serves as its own quality controller. It calculates semantic similarity scores for the generated pairs. Only triplets consisting of a Premise, an Entailment, and a Contradiction that satisfy specific mathematical thresholds for quality are retained. This filtering process ensures that only high-fidelity data enters the training pipeline.

Stage 3: Contrastive In-Batch Training

During the fine-tuning of the embedding model (e.g., BERT or RoBERTa), MultiCSR addresses the "false negative" problem. In standard contrastive learning, all other samples in a batch are treated as negatives. However, in high-quality synthetic datasets, a random sample might accidentally be semantically similar to the anchor. Stage 3 uses a pre-trained model to identify and mask these false negatives, preventing the model from learning incorrect semantic distinctions.

Experimental Results

The framework was evaluated using premises from the Natural Language Inference (NLI) dataset as seeds. Performance was measured across Semantic Textual Similarity (STS) benchmarks from 2012 to 2016 and the STS-Benchmark.

Performance comparison of MultiCSR against various baselines across STS tasks.

As shown in the results table, MultiCSR achieved state-of-the-art performance. Using a RoBERTa-base backbone, it reached a Spearman’s correlation of 81.62% on STS tasks, significantly outperforming strong baselines like SimCSE (76.57%) and even methods relying on ChatGPT (80.74%).

Key Insights

  • Quality Over Scale: A refined Flan-T5-XL (3B parameters) using MultiCSR can produce superior training data compared to the much larger ChatGPT. This highlights that rigorous data quality control can compensate for smaller model sizes.
  • Robustness Across Languages: The method demonstrated significant gains in low-resource settings. For Tagalog, MultiCSR improved accuracy from 72.6% to 84.2%, proving its utility beyond English.
  • Efficiency: The self-curation stage results in a smaller, higher-quality training set, which reduces the computational overhead of training the final embedding model without sacrificing performance.

Conclusion and Future Work

MultiCSR demonstrates that LLMs can be highly effective "teachers" for sentence representation models when their outputs are contrastively refined. By addressing noise at multiple levels, the framework enables smaller open-source models to surpass the performance of proprietary giants.

Future research may explore applying these refinement techniques to more complex data types, such as long-form Wikipedia articles, and developing automated methods for tuning the similarity thresholds used in the self-curation stage.

Summary updated

BibTeX
@inproceedings{wang2024large,
  author = {Huiming Wang and Zhaodonghui Li and Liying Cheng and De Wen Soh and Lidong Bing},
  title = {{Large Language Models can Contrastively Refine their Generation for Better Sentence Representation Learning}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.naacl-long.436},
}
Figure