CERT: Contrastive Self-supervised Learning for Language Understanding

Hongchao Fang, Pengtao XiearXiv 2020

Abstract

Pretrained language models such as BERT and GPT have demonstrated significant effectiveness in natural language understanding. However, existing pretraining approaches primarily utilize auxiliary predictive tasks defined at the token level, which may fail to capture sentence-level semantics comprehensively. To address this, we propose CERT (Contrastive self-supervised Encoder Representations from Transformers), a framework that pretrains language representation models using contrastive self-supervised learning at the sentence level. CERT creates augmentations of original sentences via back-translation and finetunes a pretrained language encoder by predicting whether two augmented sentences originate from the same source. Evaluated on 11 tasks in the GLUE benchmark, CERT outperforms BERT on 7 tasks and achieves a higher overall average score.

Introduction

While the advent of models like BERT has revolutionized NLP, their reliance on "word-centric" pretraining tasks—such as Masked Language Modeling (MLM)—often overlooks high-level sentence semantics. If a model only learns by predicting local word patterns, it may struggle with tasks requiring a global understanding of a sentence's meaning.

CERT adapts Contrastive Self-supervised Learning (CSSL), a technique highly successful in Computer Vision (e.g., MoCo, SimCLR), for Natural Language Understanding. By shifting the focus from individual tokens to whole-sentence semantics, CERT provides a more robust representation of language.

Methodology

The CERT framework follows a flexible, three-stage pipeline that can be integrated into any standard NLP workflow.

The CERT training pipeline: standard BERT pretraining, sentence-level CSSL pretraining, and task-specific fine-tuning.

1. Standard Pretraining

The process begins with a vanilla pretrained language model, such as BERT-base, which provides a foundation of token-level understanding.

2. CERT Pretraining (CSSL)

This stage is the core innovation of the framework. The model is further trained on unlabeled text from a target task using a contrastive objective:

  • Augmentation via Back-Translation: To create different "views" of the same data, CERT translates an English sentence into a bridge language (e.g., German or Chinese) and then back into English. This generates a paraphrase that preserves semantic meaning while altering syntax.
  • Momentum Contrast (MoCo): To ensure computational efficiency, CERT utilizes the MoCo framework. It maintains a queue of previously encoded sentences (keys), and the model learns to identify which key in the queue corresponds to the back-translated version of the current query sentence.
  • Contrastive Loss: The model is penalized if it cannot distinguish the correct positive pair from thousands of unrelated "negative" sentences in the queue.
The contrastive learning architecture in CERT, employing a momentum encoder and a queue-based mechanism to efficiently calculate contrastive loss.

3. Fine-tuning

Finally, the model is fine-tuned on the specific labeled data of the target task, benefiting from the enhanced semantic representations learned during the CSSL phase.

Experimental Setup and Results

The authors evaluated CERT on the GLUE (General Language Understanding Evaluation) benchmark, encompassing 11 diverse tasks including sentiment analysis (SST-2), linguistic acceptability (CoLA), and natural language inference (MNLI, RTE).

Key Findings

  • Superior Performance: CERT outperformed BERT on 7 out of 11 GLUE tasks, achieving an overall average score of 80.7 compared to BERT's 80.5.
  • Low-Resource Efficacy: The most significant improvements were observed in smaller datasets. For instance, on the RTE (Recognizing Textual Entailment) task, CERT improved the score from 70.1 to 71.2. This suggests that sentence-level contrastive learning acts as a powerful regularizer, preventing overfitting to word-level quirks when data is scarce.
  • Augmentation Quality: Comparison with Easy Data Augmentation (EDA)—which uses simple word swapping or deletion—showed that back-translation is significantly more effective. This confirms that "global" semantic changes are superior to "local" noise for contrastive learning in NLP.

Discussion and Future Work

CERT demonstrates that sentences should be treated as "first-class citizens" in language modeling. By forcing the model to match a sentence with its back-translated counterpart, it learns representations invariant to syntactic changes but sensitive to core meaning.

Despite its success, some limitations remain. On the CoLA task, CERT showed domain sensitivity, performing better on validation than on test sets. Future research will explore ranking-based losses and more complex augmentation tasks, such as predicting the original order of shuffled augmented sentences, to further refine global semantic understanding.

Summary updated

Abstract

Pretrained language models such as BERT, GPT have shown great effectiveness in language understanding. The auxiliary predictive tasks in existing pretraining approaches are mostly defined on tokens, thus may not be able to capture sentence-level semantics very well. To address this issue, we propose CERT: Contrastive self-supervised Encoder Representations from Transformers, which pretrains language representation models using contrastive self-supervised learning at the sentence level. CERT creates augmentations of original sentences using back-translation. Then it finetunes a pretrained language encoder (e.g., BERT) by predicting whether two augmented sentences originate from the same sentence. CERT is simple to use and can be flexibly plugged into any pretraining-finetuning NLP pipeline. We evaluate CERT on 11 natural language understanding tasks in the GLUE benchmark where CERT outperforms BERT on 7 tasks, achieves the same performance as BERT on 2 tasks, and performs worse than BERT on 2 tasks. On the averaged score of the 11 tasks, CERT outperforms BERT. The data and code are available at https://github.com/UCSD-AI4H/CERT
BibTeX
@misc{fang2020cert,
  author = {Hongchao Fang and Pengtao Xie},
  title = {{CERT: Contrastive Self-supervised Learning for Language Understanding}},
  year = {2020},
  eprint = {2005.12766},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2005.12766},
}
Figure