Shuffle & Divide: Contrastive Learning for Long Text

Joonseok Lee, Seongho Joe, Kyoungwon Park, Bogun Kim, Hoyoung Kang, Jaeseon Park, Youngjune GwonICPR 2022

Abstract

Researchers from Samsung SDS have introduced Shuffle & Divide (SaD), a simple yet remarkably effective self-supervised learning method for long-form text. By shuffling a document's sentences and splitting them into two "sub-documents," the model learns to group similar topics together without any human-labeled data. This approach generates "strong" augmentations that challenge the model more effectively than traditional methods, outperforming previous state-of-the-art unsupervised methods by over 20% on standard benchmark datasets.

Introduction

In Natural Language Processing (NLP), pre-training massive models like BERT on unlabeled text is common, but downstream tasks like topic classification typically require expensive, human-labeled datasets for fine-tuning. Contrastive learning—a technique where a model compares "positive" pairs (similar items) against "negative" pairs (dissimilar items)—has revolutionized computer vision. However, applying this to text is difficult; simple word swaps can change meaning entirely, and weak augmentations like back-translation often fail to provide enough variance for robust training. SaD addresses this by providing a method to generate effective strong augmentations specifically for long documents.

Methods

The core of the proposal is the Shuffle & Divide (SaD) pretext task, designed to preserve thematic consistency while disrupting narrative flow.

  1. Shuffle: A long document is tokenized into individual sentences which are then randomly shuffled. For long-form text, the overall topic remains consistent even when the sentence order is randomized.
  2. Divide: The shuffled sentences are split into two separate sub-documents ($d'$ and $d''$).
The Shuffle & Divide process: individual sentences ($s_n$) are shuffled and then split into two sub-documents ($d'_n$ and $d''_n$) to create a positive pair.
  1. Contrastive Update: These sub-documents are treated as a positive pair. A BERT-based encoder with a Mean Pooling layer is trained to pull the embeddings of $d'$ and $d''$ closer in vector space while pushing them away from other documents in the mini-batch (the "negatives").
  2. Clustering: Post-training, Spherical k-means is used to cluster the resulting document vectors for classification.
The contrastive learning framework: sub-document pairs are passed through an encoder to calculate contrastive loss against other documents in the batch.

Datasets and Results

The method was evaluated on four standard benchmarks: 20 Newsgroups (20NG), Reuters-21578, BBC, and BBCSport. Preprocessing involved removing headers and metadata to ensure the model learned from content rather than formatting.

SaD achieved significant improvements in unsupervised accuracy (ACC):

  • 20 Newsgroups: Reached 68.34% ACC, a 20.94% improvement over previous state-of-the-art methods.
  • Reuters: Achieved 58.17% ACC, outperforming existing graph-based and embedding-based models.
  • BBC/BBCSport: Achieved exceptionally high performance, exceeding 95% and 98% accuracy respectively.
  • Supervised Boost: When used as a pre-training step, SaD-initialized models reached 87.88% accuracy on 20NG, outperforming standard vanilla BERT (83.54%).

Key Insights

  • Semantic Conservation: Sentence-level shuffling preserves semantic units, allowing the model to focus on thematic content rather than syntax.
  • Strong Augmentation: Shuffling provides a sufficiently "strong" change to force the model to learn robust features, whereas word-level changes are often too "weak."

Limitations and Future Work

SaD requires documents to have at least 4 sentences, making it less suitable for short-form text like tweets. Additionally, extreme class imbalance remains a challenge for unsupervised clustering. Future work may explore applying SaD to document retrieval and summarization tasks where global context is critical.

Summary updated

BibTeX
@inproceedings{lee2022shuffle,
  author = {Joonseok Lee and Seongho Joe and Kyoungwon Park and Bogun Kim and Hoyoung Kang and Jaeseon Park and Youngjune Gwon},
  title = {{Shuffle \& Divide: Contrastive Learning for Long Text}},
  booktitle = {ICPR},
  year = {2022},
}
Figure