Disentangled Contrastive Learning for Learning Robust Textual Representations

Xiang Chen, Xin Xie, Zhen Bi, Hongbin Ye, Shumin Deng, Ningyu Zhang, Huajun Chen

Abstract

Transformer-based models, while powerful, often lack robustness against minor textual perturbations. Traditional contrastive learning methods address this by aligning positive pairs and separating negative pairs, but they face challenges in NLP due to the difficulty of sampling high-quality negatives. We present Disentangled Contrastive Learning (DCL), which decouples the contrastive objective into feature alignment and feature uniformity. By utilizing momentum representation consistency and power normalization, DCL achieves superior performance on benchmarks like GLUE and SQuAD without explicit negative sampling.

Introduction: The Robustness Challenge in NLP

Despite the success of models like BERT, they remain susceptible to small, imperceptible changes in input text, such as synonym swaps or typos. This lack of robustness is a significant hurdle for real-world deployment. Contrastive learning has emerged as a promising solution, teaching models to map similar sentences (positive pairs) to nearby representations while pushing different sentences (negative pairs) apart.

However, applying contrastive learning to NLP is non-trivial. Unlike computer vision, where a "cat" is distinctly not a "car," randomly sampled "negative" sentences in NLP may be semantically similar to the anchor, introducing noise that degrades training. This "negative sampling" problem often leads to sub-optimal representations.

Methodology: Disentangled Contrastive Learning (DCL)

To overcome the negative sampling problem, DCL disentangles the contrastive objective into two independent sub-tasks: Feature Alignment and Feature Uniformity.

Overview of the DCL framework, illustrating the disentanglement of alignment (attract) and uniformity (repel) tasks.

1. Feature Alignment via Momentum Representation Consistency

The alignment task ensures that a sentence and its augmented version (e.g., via synonym replacement) map to similar points in the feature space. DCL employs a teacher-student architecture. A "student" Transformer is updated via backpropagation, while a "teacher" (momentum) Transformer is updated as an exponential moving average (EMA) of the student. This provides a stable target for consistency, ensuring that perturbations do not drastically shift the representation.

2. Feature Uniformity via Power Normalization

To prevent "representation collapse"—where the model maps all inputs to a single point to satisfy the alignment objective—the features must be distributed uniformly across a unit hypersphere. DCL achieves this through Power Normalization. By leveraging the unit quadratic mean of activations, Power Normalization implicitly treats other samples in a batch as negatives. This forces the model to focus on unique features of each sentence, maintaining diversity in the representation space without explicit negative labels.

Experimental Results

The researchers evaluated DCL across several major benchmarks, including GLUE, SQuAD 1.1, SNLI, and DialogRE. Robustness was specifically tested using invariance testing (CheckList) and adversarial attacks (PWWS).

Performance comparison on the GLUE benchmark under normal and robust settings.

As shown in the results, DCL consistently outperforms vanilla BERT and BERT with standard data augmentation. On the GLUE benchmark, DCL achieved an average score of 83.0, compared to 82.3 for BERT. More importantly, in "Robust" settings where inputs are intentionally perturbed, DCL maintains a significant performance edge. For instance, on the CoLA task under adversarial attack, DCL scored 48.2 compared to BERT's 47.0, demonstrating its superior ability to handle noise.

Key Insights and Future Directions

A central finding of this work is that normalization can act as an implicit form of contrast. By removing common-mode features shared across a mini-batch, Power Normalization forces the model to learn what makes each sentence distinct. Furthermore, disentangling alignment from uniformity allows for more effective optimization of each property than a single, combined loss function.

While DCL shows great promise, future work could explore more sophisticated data augmentation strategies, such as back-translation. Additionally, investigating the application of DCL in non-Euclidean (e.g., Hyperbolic) spaces may yield even more robust textual representations suited for the hierarchical nature of language.

Summary updated

BibTeX
@inproceedings{chen2021disentangled,
  author = {Xiang Chen and Xin Xie and Zhen Bi and Hongbin Ye and Shumin Deng and Ningyu Zhang and Huajun Chen},
  title = {{Disentangled Contrastive Learning for Learning Robust Textual Representations}},
  booktitle = {CICAI},
  year = {2021},
  url = {https://openreview.net/forum?id=N4jv8UnD7ug},
}
Figure