Unsupervised Document Embedding via Contrastive Augmentation

Dongsheng Luo, Wei Cheng, Jingchao Ni, Wenchao Yu, Xuchao Zhang, Bo Zong, Yanchi Liu, Zhengzhang Chen, Dongjin Song, Haifeng Chen, Xiang Zhang

TL;DR

The paper introduces DECA (Document Embedding via Contrastive Augmentation), a simple yet highly effective unsupervised framework that learns document representations by combining contrastive learning with data augmentation. Surprisingly, the authors find that simple, word-level stochastic augmentations vastly outperform complex sentence-level transformations, allowing DECA to outperform state-of-the-art unsupervised methods and even rival fully-supervised models.

What Problem Does This Paper Address?

Learning high-quality document embeddings—compact vector representations of text—is essential for downstream tasks like sentiment analysis, information retrieval, and clustering. While supervised methods perform well, labeled data is expensive and scarce. Unsupervised methods are highly desirable but suffer from a "data scarcity" problem at the document level: the specific words chosen in a document only represent a single, impoverished projection of its underlying semantic meaning.

Existing unsupervised approaches struggle to capture semantic invariance (the idea that a document's core meaning shouldn't change if you paraphrase it). The authors set out to solve this by leveraging contrastive self-supervised learning, a technique that has revolutionized computer vision but remains tricky to apply effectively to document-level NLP.

Methods

The authors propose DECA (Document Embedding via Contrastive Augmentation), which consists of three main components:

  1. Stochastic Data Augmentation Module: Generates a modified version of an input document ($\tilde{D}_i$). The authors systematically evaluate five techniques:
  2. Synonym Replacement (via WordNet or PPDB)
  3. Negative-Antonym-based Replacement (e.g., replacing "exceptionally strong" with "exceptionally not impotent")
  4. Uninformative Word Replacement (swapping low-frequency words with high-frequency synonyms)
  5. Back-Translation (translating to another language and back)
  6. Document Encoder: DECA primarily uses Doc2vecC as its backbone encoder, which computes document embeddings by averaging word embeddings. It also experiments with BERT ([CLS] token embedding) as an alternative backbone.
  7. Contrastive Learning Framework: DECA feeds both the original and augmented documents into the encoder and applies a contrastive loss (using either the SimCLR or SimSiam architectures). The loss forces the model to maximize the similarity between a document and its paraphrase (positive pairs) while minimizing similarity to other documents in the batch (negative pairs).
Figure 1: An illustration of the DECA framework. xi and ˜xi are the BoW representations of an input docu- ment Di and the corresponding augmented document ˜Di, respectively. f(·) is the encoder function to learn compact representations for documents. hi and ˜hi are compact representations of Di and ˜Di, respectively.

Datasets

The framework was evaluated across six diverse, standard NLP benchmark datasets:

  • R8 & R52: Subsets of the Reuters-21578 news newswire dataset.
  • MR: A movie review dataset for sentiment analysis (short, single-sentence documents).
  • Ohsumed: A medical literature database from MEDLINE.
  • 20news: The classic 20 Newsgroups document classification dataset.
  • IMDB: A large-scale dataset of 100,000 movie reviews.

Key Insights and Ideas

  • Word-Level Swaps Beat Document-Level Paraphrasing: Intuitively, one might think that document-level back-translation would yield the best semantic variants. However, the authors discovered that simple word-level manipulations (like synonym or antonym replacement) perform significantly better. Back-translation introduces unconstrained noise that can degrade unsupervised embedding quality.
  • The Dictionary Constraint is Vital: For word-level substitutions to work in an unsupervised setting, replacements must be strictly constrained to words already inside the vocabulary. Without this "dictionary constraint," performance drops sharply.
  • Heavy Transformers Struggle in Unsupervised Contrastive Setups: Without fine-tuning on labels, massive models like BERT and Longformer underperformed compared to simpler methods like Doc2vecC. This is primarily due to memory limitations: contrastive learning frameworks like SimCLR require very large batch sizes to find good negative samples. On an 11GB GPU, BERT's batch size can only be set to 2, causing the contrastive framework to fail.

Key Results

Linear Classification

DECA (using Doc2vecC + SimCLR) achieved the lowest error rates on 5 out of 6 datasets. Notably, it reduced absolute classification error rates by up to 6.4% over the standard Doc2vecC baseline on the Ohsumed dataset. Remarkably, DECA matched or outperformed TextGCN, a state-of-the-art fully supervised graph convolutional network method, on several benchmarks.

Performance comparison of classification error rates across various baselines and DECA variants.

Clustering

Evaluated using Normalized Mutual Information (NMI) via $k$-means clustering, DECA achieved the best performance across all four tested datasets, yielding a relative performance gain of up to 7.6% over the next-best baseline.

Performance comparison using clustering Normalized Mutual Information (NMI).

Limitations and Future Work

The primary limitation highlighted in the paper revolves around hardware and model scaling. While Transformer-based models (like BERT) are powerful, their massive memory footprint restricts the batch size to a minimum during contrastive training, severely harming performance.

The authors note that sophisticated, sparse-attention models like Longformer or BigBird are orthogonal to DECA and could theoretically be integrated. Future work will likely explore how to efficiently scale contrastive document augmentation to these larger architectures without running into out-of-memory errors.

Summary updated

BibTeX
@misc{luo2021unsupervised,
  author = {Dongsheng Luo and Wei Cheng and Jingchao Ni and Wenchao Yu and Xuchao Zhang and Bo Zong and Yanchi Liu and Zhengzhang Chen and Dongjin Song and Haifeng Chen and Xiang Zhang},
  title = {{Unsupervised Document Embedding via Contrastive Augmentation}},
  year = {2021},
  eprint = {2103.14542},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2103.14542},
}
Figure