Active Learning by Acquiring Contrastive Examples

Katerina Margatina, Giorgos Vernikos, Loïc Barrault, Nikolaos Aletras

Abstract

Katerina Margatina, Giorgos Vernikos, Loïc Barrault, Nikolaos Aletras. Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing.

2021.

Introduction

Active Learning (AL) aims to reduce the cost of data annotation by selecting the most informative examples for human labeling. Traditional AL strategies generally fall into two categories: uncertainty sampling, which selects points the model is most unsure about, and diversity sampling, which aims for broad coverage of the feature space. However, uncertainty sampling can be prone to selecting outliers, while diversity sampling may pick "easy" examples that provide little new information.

The authors introduce Contrastive Active Learning (CAL), a hybrid acquisition function designed to bridge this gap. CAL selects unlabeled examples that are representative of the data distribution (similar in feature space to existing training data) but yield maximally different model predictions compared to their neighbors.

Contrastive Active Learning (CAL)

The core idea of CAL is to identify "contrastive examples"—points that lie near the model's decision boundary but are also representative of the underlying data distribution.

Conceptual illustration of Contrastive Active Learning (CAL).

The CAL algorithm follows a four-step process:

  1. Neighbor Identification: For each candidate $x_p$ in the unlabeled pool, the algorithm finds its $k$-nearest neighbors in the labeled training set. Similarity is determined by the Euclidean distance between BERT [CLS] token embeddings.
  2. Divergence Computation: The current model predicts class probabilities for $x_p$ and its $k$ neighbors.
  3. Scoring: The acquisition score is the average Kullback–Leibler (KL) divergence between the predictive distribution of $x_p$ and those of its neighbors.
  4. Selection: The pool is ranked by this score, and the top-scoring examples are selected for annotation.

By selecting points that look like the training data but produce divergent predictions, CAL effectively "guides" uncertainty sampling toward representative regions of the feature space.

Experimental Setup

CAL was evaluated across seven diverse NLP datasets covering four major tasks:

  • Sentiment Analysis: IMDB, SST-2.
  • Topic Classification: AGNEWS, DBPEDIA, PUBMED.
  • Natural Language Inference (NLI): QNLI.
  • Paraphrase Detection: QQP.

The study also assessed robustness in out-of-distribution (OOD) scenarios, such as training on SST-2 and testing on IMDB, or training on QQP and testing on TWITTERPPDB.

Results and Discussion

CAL consistently matches or exceeds the performance of state-of-the-art AL baselines. It is particularly effective on datasets like DBPEDIA, PUBMED, and AGNEWS.

Performance of CAL compared to baselines across seven NLP datasets.

Key findings include:

  • Robustness: CAL demonstrates superior performance in OOD settings. For instance, on the SST-2 to IMDB transfer task, CAL achieved 79.0% accuracy, outperforming Entropy (75.38%) and ALPS (77.06%).
  • Representativeness: Analysis shows that CAL selects examples that are nearly as uncertain as those chosen by pure entropy sampling but are significantly more representative of the overall data distribution.
  • Efficiency: Unlike complex hybrid methods that require expensive clustering, CAL relies on KNN search. While still computationally demanding, it scales linearly with pool size and is highly parallelizable.

Ablation studies confirmed the "Contrastive Hypothesis": a strategy selecting points most similar to their neighbors (the opposite of CAL) performed worse than random sampling, proving that local disagreement is the primary driver of learning.

Conclusion

CAL offers a practical and effective approach to active learning for Transformer-based models. While it relies on the quality of the underlying feature encoder (e.g., BERT), it provides a robust mechanism for selecting informative, representative data. Future work may focus on further optimizing the computational overhead of the KNN search and refining the selection process to better handle potential outliers.

Summary updated

BibTeX
@inproceedings{margatina2021active,
  author = {Katerina Margatina and Giorgos Vernikos and Loïc Barrault and Nikolaos Aletras},
  title = {{Active Learning by Acquiring Contrastive Examples}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  url = {https://openreview.net/forum?id=otA6upyHJjL},
}
Figure