Introduction
Masked Language Models (MLMs) like BERT have significantly advanced Natural Language Understanding (NLU). However, they suffer from a geometric flaw known as anisotropy. In an anisotropic representation space, token embeddings cluster into a narrow "cone" rather than spreading out isotropically. This lack of discriminative power makes it difficult for models to distinguish fine-grained semantic meanings. While sentence-level contrastive learning has been explored, it often neglects or degrades individual token representations. This paper introduces Token-aware Contrastive Learning (TaCL) to address this gap.
Methodology: The TaCL Framework
TaCL employs a continual pre-training setup using a Student-Teacher framework. Both models are initialized from a pre-trained BERT, but the Teacher's parameters are frozen while the Student is trained.
As shown in Figure 1, the Student receives a masked sequence, while the Teacher receives the original unmasked sequence. The TaCL objective requires the Student to maximize the similarity between its representation of a masked token and the Teacher’s corresponding "reference" representation (the positive pair). Simultaneously, it must minimize similarity with all other tokens in the same sequence (negative pairs). The final training objective combines TaCL loss with standard MLM and Next Sentence Prediction (NSP) losses: $$\mathcal{L} = \mathcal{L}_{TaCL} + \mathcal{L}_{MLM} + \mathcal{L}_{NSP}$$
Experimental Setup
The authors validated TaCL across English and Chinese benchmarks using standard Wikipedia corpora for continual pre-training:
- English Benchmarks: The GLUE suite (8 classification/regression tasks) and SQuAD (1.1 and 2.0) for machine reading comprehension.
- Chinese Benchmarks: Named Entity Recognition (Ontonotes, MSRA, Resume, Weibo) and Chinese Word Segmentation (PKU, CityU, AS).
Results and Discussion
TaCL consistently outperforms BERT and "BERT+MT" (a baseline with extended training) across nearly all metrics.
As detailed in Figure 6, TaCL-base achieved an average GLUE score of 81.2 (vs. BERT's 79.6) and an F1 score of 77.5 on SQuAD 2.0. In Chinese NER, TaCL improved the Ontonotes F1 score from 80.23 to 82.42.
Key Insights
- Isotropy and Performance: Empirical evidence suggests that spreading out token representations in the vector space (increasing isotropy) directly leads to better performance on downstream NLU tasks.
- Intra-Sequence Negatives: By using other tokens in the same sequence as negative samples, TaCL forces the model to learn what makes a specific token unique relative to its immediate context.
- Layer-wise Evolution: TaCL representations exhibit higher self-similarity in intermediate layers but significantly lower similarity in the final layer compared to BERT, suggesting the model works harder in the final layer to differentiate tokens.
Conclusion
TaCL effectively mitigates anisotropy in BERT by encouraging more discriminative token-level representations through a student-teacher contrastive objective. While it requires an additional continual pre-training phase, the resulting performance gains across diverse NLU tasks demonstrate its value. Future work may extend this approach to other architectures like RoBERTa or explore sub-word and character-level contrastive granularities.
Summary updated