Differentiable Data Augmentation for Contrastive Sentence Representation Learning

Tianduo Wang, Wei LuEMNLP 2022

Introduction

Learning universal sentence embeddings—vectors that capture semantic meaning—is a cornerstone of Natural Language Processing. Contrastive learning has emerged as the leading paradigm, where models are trained to pull "positive pairs" (semantically similar sentences) together while pushing unrelated ones apart. However, the quality of these embeddings is heavily dependent on Data Augmentation (DA).

In text, traditional discrete DA (like word deletion or replacement) often compromises grammatical integrity or semantic meaning. While methods like SimCSE use dropout as a minimal augmentation, they lack "hard positives"—pairs that are semantically identical but significantly different in representation. To address this, the authors introduce DiffAug, a method that performs differentiable data augmentation in the model's continuous hidden space using learnable "prefixes."

Methodology: The DiffAug Framework

DiffAug shifts data augmentation from the discrete input space to the differentiable space of a Transformer's hidden layers. Instead of altering the text, the model prepends two distinct sets of learnable "prefix" vectors to the self-attention layers. These prefixes act as steerable prompts, creating different "views" of the same sentence.

The Two-Stage Tuning Strategy

A critical contribution of this work is the discovery that prefixes and the language model cannot be trained jointly from scratch. The authors propose a two-stage process to ensure compatibility:

The two-stage tuning strategy: Stage 1 warms up the prefixes to be module-compatible with the frozen language model before joint fine-tuning in Stage 2.
  1. Stage 1: Prefix-tuning. The pre-trained language model (e.g., BERT) is frozen. Only the prefixes are trained on Natural Language Inference (NLI) data to align them with the model's internal weight distribution.
  2. Stage 2: Joint tuning. Both the prefixes and the language model are fine-tuned together using a contrastive loss.

Key Insights: Why DiffAug Works

The success of DiffAug stems from two primary factors: module compatibility and increased representation challenge.

Achieving a "Module-Compatible" State

Randomly initialized prefixes have a significantly different weight variance compared to a pre-trained model. Without Stage 1, joint training often leads to vanishing gradients. Stage 1 brings the prefixes into a distribution compatible with the model's weights (measured by weight convergence $\kappa$).

Empirical evidence showing (a) increased representation divergence (delta) compared to dropout and (b) weight convergence (kappa) during Stage 1 training.

Harder Positives through Divergence

By using two different prefixes, DiffAug generates views with higher representation divergence ($\delta$) than simple dropout. This creates "harder" positives, forcing the model to learn more robust and generalized semantic features rather than relying on surface-level similarities.

Experimental Results

The model was evaluated on seven standard Semantic Textual Similarity (STS) tasks using Wikipedia and NLI datasets.

  • State-of-the-Art Performance: DiffAug outperformed previous leaders like SimCSE and PromptBERT. On the STS-Benchmark, it achieved a score of 82.42, compared to SimCSE's 81.57.
  • High Label Efficiency: DiffAug is remarkably effective in low-data regimes. Using only 1% of labeled data, it achieved an average STS score of 80.42, surpassing several baseline methods that utilized 100% of the data.
  • Parameter Efficiency: The prefixes add only about 0.3% more parameters to the base model, making it a highly efficient upgrade.

Limitations and Future Outlook

While effective, DiffAug introduces some computational overhead, requiring approximately 1.8x more training time than SimCSE due to the two-stage process. Additionally, performance is sensitive to the duration of Stage 1 training; finding the optimal point of compatibility without overfitting is essential. Future research may extend this differentiable augmentation approach to other NLP tasks such as domain adaptation or low-resource translation.

Summary updated

BibTeX
@inproceedings{wang2022differentiable,
  author = {Tianduo Wang and Wei Lu},
  title = {{Differentiable Data Augmentation for Contrastive Sentence Representation Learning}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  doi = {10.18653/v1/2022.emnlp-main.520},
}
Figure