Poolingformer: Long Document Modeling with Pooling Attention

Hang Zhang, Yeyun Gong, Yelong Shen, Weisheng Li, Jiancheng Lv, Nan Duan, Weizhu Chen

TL;DR

The Transformer architecture, while powerful, struggles with long documents due to its quadratic computational complexity. Poolingformer introduces a novel two-level attention mechanism that significantly reduces this complexity by using a sliding window at the first level and a pooling attention at the second, achieving state-of-the-art results on long-document question answering and summarization tasks.

What Problem Does This Paper Address?

The Transformer architecture, a cornerstone of modern NLP, relies on self-attention to process text. However, the computational and memory requirements of self-attention scale quadratically with the input sequence length ($O(n^2)$). This makes it prohibitively expensive to process long documents, typically limiting models to sequences of 512 tokens. This limitation hinders performance on tasks that inherently require understanding extended contexts, such as answering questions from lengthy articles or summarizing entire research papers. Existing solutions often involve approximations or specialized attention patterns that can either sacrifice performance or are difficult to integrate with pre-trained models.

Methods

Poolingformer tackles the long-document challenge with a novel two-level attention schema:

  1. First Level: Sliding Window Attention: This level employs a standard sliding window attention. Each token only attends to its immediate neighbors within a defined window size ($w_1$). This captures local context efficiently and keeps the complexity linear with respect to the sequence length ($O(n)$).
  2. Second Level: Pooling Attention: To increase the receptive field without incurring quadratic costs, this level uses a larger window size ($w_2$). Crucially, it then applies a pooling operation to the key and value vectors within this larger window. This pooling compresses the information, reducing the number of tokens that need to be attended to. The paper explores various pooling strategies, including mean, max, and a novel lightweight dynamic convolution (LDConv).

A residual connection is used to combine the outputs of both attention levels, preserving information from both local and broader contexts. For specific tasks like Question Answering, where question tokens are vital for all document tokens, a task-specific global attention mechanism is integrated into the first level, allowing global tokens to attend to all document tokens.

Datasets

The paper evaluates Poolingformer on several benchmark datasets:

  • Natural Questions (NQ): A dataset for question answering, focusing on finding answer spans (short and long) within Wikipedia articles.
  • TyDi QA: A multilingual question answering dataset covering 11 languages, also requiring passage and minimal answer span predictions.
  • arXiv: A dataset for abstractive summarization of scientific papers, using paper abstracts as summaries.

Key Insights and Ideas

  • Two-level attention as a sweet spot: The core idea is to combine the efficiency of local attention with a mechanism that expands receptive fields without quadratic cost. The pooling attention in the second level is key to achieving this balance.
  • Pooling for efficiency: By pooling key and value vectors, Poolingformer effectively reduces the computational burden of attending to long sequences, making linear complexity ($O(n)$) achievable.
  • Preserving local context: The first-level sliding window attention ensures that fine-grained local information isn't lost, which is crucial for many NLP tasks.
  • Task-specific global attention: The ability to easily incorporate global attention for specific tokens (like questions) highlights the flexibility of the proposed architecture.
  • Trade-off in layer replacement: Replacing all Transformer layers with Poolingformer layers can sometimes degrade performance, suggesting a careful balance is needed between leveraging the new mechanism and retaining the knowledge from pre-trained models.

Key Results

Poolingformer achieves state-of-the-art results across multiple challenging long-document tasks:

  • NQ Long Answer: Achieved an F1 score of 79.8, outperforming the previous best by 1.9 points.
  • TyDi QA Passage Answer: Achieved an F1 score of 79.5, an improvement of 1.9 points.
  • TyDi QA Minimal Answer: Achieved an F1 score of 67.7, an improvement of 1.6 points.
  • arXiv Summarization: Demonstrated superior performance, outperforming previous methods with input lengths of 4K and 16K, and achieving better accuracy and complexity than LED.

Limitations and Future Work

  • Compatibility with Pre-trained Models: The authors note that replacing all layers with Poolingformer can lead to performance degradation, suggesting a need for careful integration to avoid "catastrophic forgetting" of pre-trained knowledge. They found that replacing a subset of layers (e.g., 6th-8th) yielded the best results.
  • Pooling Strategy Exploration: While LDConv and MAX pooling showed promising results, a more comprehensive study of different pooling and fusion approaches is suggested for future work.
  • Theoretical Analysis: The paper calls for theoretical analysis of the proposed multi-level attention compared to classical single-level self-attention.
  • Broader Applications: Future work could extend Poolingformer to other modalities like image and music processing.

Summary updated

BibTeX
@inproceedings{zhang2021poolingformer,
  author = {Hang Zhang and Yeyun Gong and Yelong Shen and Weisheng Li and Jiancheng Lv and Nan Duan and Weizhu Chen},
  title = {{Poolingformer: Long Document Modeling with Pooling Attention}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
  url = {https://openreview.net/forum?id=Gt9pv3GPQiR},
}
Figure