Efficient Classification of Long Documents Using Transformers

Hyunji Hayley Park, Yogarshi Vyas, Kashif ShahACL 2022

Introduction

Transformer-based models like BERT have revolutionized natural language processing, but they face a significant architectural hurdle: the self-attention mechanism scales quadratically with input length. Consequently, most standard implementations are capped at 512 tokens—roughly a single page of text. While many "efficient" Transformer variants have been proposed to handle longer documents like legal filings or books, this study provides a critical benchmark, comparing these sophisticated architectures against simple, often overlooked baselines.

Methodology: Beyond Standard Truncation

The researchers evaluated four primary approaches to handling long sequences:

  1. BERT (Truncation): The standard baseline that simply processes the first 512 tokens and discards the rest.
  2. Longformer: Employs sparse attention patterns to achieve linear complexity, allowing for inputs up to 4,096 tokens.
  3. ToBERT: A hierarchical model that processes 200-token chunks independently before aggregating them via an additional Transformer layer.
  4. CogLTX: A multi-stage model that identifies and extracts salient sentences for classification.

Crucially, the authors introduced two "deceptively simple" baselines to test if "smart" selection is actually necessary: BERT+TextRank (using unsupervised ranking to select sentences) and BERT+Random (simply appending random sentences from the document to the initial 512 tokens).

Experimental Setup and Stress Tests

The models were tested across diverse datasets including Hyperpartisan (news bias), 20NewsGroups (forum posts), EURLEX-57K (legal), and CMU Book Summary (genre). To isolate the models' ability to handle long-range dependencies, the authors created two "stress test" datasets:

  • Inverted EURLEX: Legal documents were reversed, moving the typically informative headers to the end of the input.
  • Paired Book Summary: Two distinct summaries were concatenated, requiring the model to identify signals from multiple distant locations.

Results: Performance vs. Complexity

The results challenge the assumption that architectural complexity inherently leads to better performance. As shown in the performance table below, no single model dominated across all tasks.

Table 1: Performance comparison across various datasets. Note the competitive performance of the BERT+Random baseline.

Surprisingly, the BERT+Random baseline outperformed sophisticated models like CogLTX and ToBERT on the standard EURLEX (73.22%) and Book Summary (59.36%) tasks. While Longformer excelled on Hyperpartisan (95.69%) and the Paired Book Summary (57.76%), its advantages were not universal, and it struggled significantly on the standard EURLEX task.

The Hidden Cost of Efficiency

A key contribution of this paper is the analysis of computational overhead. While models like Longformer and CogLTX are theoretically more efficient for long sequences in terms of asymptotic complexity, their practical implementation reveals a high cost.

Table 2: Comparison of training time, inference time, and GPU memory usage relative to a standard BERT baseline.

As seen in Table 2, CogLTX required over 100 times the training time of the standard BERT baseline, yet often yielded lower accuracy. Furthermore, both Longformer and ToBERT necessitated double the GPU memory (32GB vs <16GB), posing significant practical hurdles for deployment.

Conclusion

This "reality check" reveals that the "lead bias" in many NLP datasets—where the most important information is at the beginning—often masks the limitations of simple truncation. However, it also demonstrates that complex "efficient" Transformers frequently fail to outperform simple sentence-selection baselines despite massive increases in computational cost. The authors conclude that future research must adopt more rigorous baselines and focus on datasets where long-range information is truly indispensable for the task.

Summary updated

BibTeX
@inproceedings{park2022efficient,
  author = {Hyunji Hayley Park and Yogarshi Vyas and Kashif Shah},
  title = {{Efficient Classification of Long Documents Using Transformers}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.acl-short.79},
}
Figure