Skip to main content
QUICK REVIEW

[Paper Review] TaCL: Improving BERT Pre-training with Token-aware Contrastive Learning

Yixuan Su, Fangyu Liu|arXiv (Cornell University)|Nov 7, 2021
Natural Language Processing TechniquesComputer Science11 citations
TL;DR

This paper proposes TaCL, a novel continual pre-training method that improves BERT's token representations through token-aware contrastive learning. By contrasting masked token representations from a student model against reference representations from a frozen teacher model, TaCL learns more isotropic and discriminative token embeddings, leading to consistent performance gains across diverse English and Chinese NLU benchmarks without additional data.

ABSTRACT

Masked language models (MLMs) such as BERT and RoBERTa have revolutionized the field of Natural Language Understanding in the past few years. However, existing pre-trained MLMs often output an anisotropic distribution of token representations that occupies a narrow subset of the entire representation space. Such token representations are not ideal, especially for tasks that demand discriminative semantic meanings of distinct tokens. In this work, we propose TaCL (Token-aware Contrastive Learning), a novel continual pre-training approach that encourages BERT to learn an isotropic and discriminative distribution of token representations. TaCL is fully unsupervised and requires no additional data. We extensively test our approach on a wide range of English and Chinese benchmarks. The results show that TaCL brings consistent and notable improvements over the original BERT model. Furthermore, we conduct detailed analysis to reveal the merits and inner-workings of our approach.

Motivation & Objective

  • To address the anisotropic distribution of token representations in pre-trained BERT models, which limits their discriminative power.
  • To improve the quality of general-purpose token-level representations for transfer learning in NLU tasks.
  • To develop a fully unsupervised continual pre-training method that enhances representation diversity and discriminability at the token level.
  • To demonstrate that token-level contrastive learning yields greater benefits than existing sentence-level contrastive approaches on downstream NLU tasks.
  • To provide empirical and ablation analysis on the inner workings of the proposed method and its impact on representation space geometry.

Proposed method

  • A student model is initialized from a pre-trained BERT and continually fine-tuned using three objectives: masked language modeling (MLM), next sentence prediction (NSP), and a new TaCL contrastive loss.
  • A frozen teacher model processes the original, unmasked input sequence to produce reference representations for each token.
  • The TaCL loss contrasts the student’s representation of a masked token with the teacher’s representation of the same token (positive) and with representations of other tokens in the same sequence (negative), using cosine similarity.
  • The contrastive objective is defined as: $\mathcal{L}_{\textup{TaCL}} = -\sum_{i=1}^{n}\mathds{1}(\tilde{x}_{i})\log\frac{\exp(\textup{sim}(\tilde{h}_{i},h_{i})/\tau)}{\sum_{j=1}^{n}\exp(\textup{sim}(\tilde{h}_{i},h_{j})/\tau)}$, where $\mathds{1}(\tilde{x}_{i})$ is 1 if token $i$ is masked.
  • The overall loss combines TaCL, MLM, and NSP: $\mathcal{L} = \mathcal{L}_{\textup{TaCL}} + \mathcal{L}_{\textup{MLM}} + \mathcal{L}_{\textup{NSP}}$.
  • The method is fully unsupervised and uses only the original pre-training corpus, with no additional data required.

Experimental results

Research questions

  • RQ1Can contrastive learning at the token level improve the discriminative quality of BERT’s representations?
  • RQ2Does learning isotropic token representations lead to better performance on diverse NLU benchmarks?
  • RQ3How does TaCL compare to state-of-the-art sentence-level contrastive learning methods in terms of downstream transfer performance?
  • RQ4What is the impact of TaCL on the geometric structure of the learned representation space?
  • RQ5Can the proposed method improve performance on both English and low-resource Chinese NLU tasks?

Key findings

  • TaCL achieves consistent and notable improvements over BERT across a wide range of English and Chinese NLU benchmarks, including GLUE, SQuAD 1.1, SQuAD 2.0, and various NER and CWS tasks.
  • On the GLUE benchmark, TaCL improves BERT-base’s average score from 85.4 to 86.7, with gains on 7 out of 9 tasks, including a 2.1-point increase on CoLA and a 1.3-point gain on SST-2.
  • On SQuAD 1.1, TaCL improves BERT-base’s F1 from 91.8 to 92.6 and EM from 88.5 to 89.2, demonstrating strong gains on extractive QA.
  • On Chinese NER tasks, TaCL achieves a 2.1-point F1 improvement on Ontonotes and a 1.8-point gain on Resume compared to BERT-base.
  • Self-similarity matrix visualizations confirm that TaCL produces more isotropic and discriminative token representations than BERT, with better separation between distinct tokens.
  • Ablation studies show that the TaCL objective is the primary driver of performance gains, and that the method outperforms sentence-level contrastive learning on token-level downstream tasks.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.