Chunk, Align, Select: A Simple Long-sequence Processing Method for Transformers

Jiawen Xie, Pengyu Cheng, Xiao Liang, Yong Dai, Nan Du

Abstract: Although dominant in natural language processing, transformer-based models still struggle with long-sequence processing, due to the computational costs of their self-attention operations, which increase exponentially as the length of the input sequence grows. To address this challenge, we propose a Simple framework to enhance the long-content processing of off-the-shelf pre-trained transformers via three steps: Chunk, Align, and Select (SimCAS). More specifically, we first divide each long-sequence input into a batch of chunks, then align the inter-chunk information during the encoding steps, and finally, select the most representative hidden states from the encoder for the decoding process. With our SimCAS, the computation and memory costs can be reduced to linear complexity. In experiments, we demonstrate the effectiveness of the proposed method on various real-world long-text summarization and reading comprehension tasks, in which SimCAS significantly outperforms prior long-sequence processing baselines.

Introduction

The Transformer architecture has revolutionized natural language processing, yet it faces a fundamental limitation: the quadratic computational complexity ($O(N^2)$) of its self-attention mechanism. As input sequences grow, memory and processing time requirements become prohibitive. Existing solutions generally fall into two categories: modifying the attention mechanism (e.g., sparse attention), which often requires retraining and can degrade short-text performance, or processing text in isolated chunks, which sacrifices global context.

This paper introduces SimCAS (Chunk, Align, Select), a "plug-and-play" framework designed to enable off-the-shelf Transformers to process sequences up to 350,000 tokens with linear complexity. SimCAS maintains global context through inter-chunk alignment and optimizes efficiency via a reinforcement learning-based token selector.

Methodology: The SimCAS Framework

The SimCAS framework operates through three distinct stages to bridge the gap between efficiency and global context:

  1. Chunk: The long input is divided into manageable segments. Special Start ([S]) and End ([E]) tokens are added to each chunk to facilitate boundary communication.
  2. Align (Sequential Batch Alignment): To maintain global context without $O(N^2)$ attention, SimCAS synchronizes information across chunks at every encoder layer. It calculates the average representation of all [S] and [E] tokens across the batch, using these global averages to update individual chunk representations. This allows information to "flow" between distant parts of the document during encoding.
  3. Select (Token Selector): To reduce the load on the decoder, a small selector model—trained via Proximal Policy Optimization (PPO)—identifies the most salient hidden states from the encoder. This selector is rewarded based on how effectively the chosen tokens assist the decoder in generating accurate outputs, using cross-attention scores as a fine-grained guide.
The SimCAS architecture: Chunking input, aligning information across chunks via SBA, and selecting key tokens for the decoder.

Experimental Results

SimCAS was evaluated across seven long-context datasets, including single-document summarization (arXiv, PubMed, GovReport, SummScreen), multi-document summarization (Multi-News, WCEP), and reading comprehension (NarrativeQA).

Performance and Efficiency

SimCAS consistently outperformed strong baselines like LED, LongT5, and BigBird. On the GovReport dataset, BART-base enhanced with SimCAS achieved a ROUGE-1 score of 59.30, significantly higher than the standard BART-base score of 51.72.

A standout result was observed on the NarrativeQA dataset, which features extremely long inputs (averaging 121k tokens). As shown in the figure below, SimCAS demonstrated substantial improvements in F1 and Exact Match (EM) scores compared to prior chunking baselines like SLED.

Performance comparison on NarrativeQA: SimCAS significantly outperforms BART and SLED baselines in both F1 and EM scores.

Beyond performance, SimCAS exhibits linear scaling. The authors successfully performed inference on a 350k token sequence on a single NVIDIA V100 GPU. Furthermore, the model remains "backward compatible," functioning as a standard Transformer for short inputs by bypassing the chunking and selection steps.

Sample Efficiency

In low-resource settings (training on only 10 or 100 examples), SimCAS demonstrated significantly better performance than LED. This suggests that the token selection policy helps the model focus on high-value information even when training data is scarce.

Discussion and Conclusion

While SimCAS enables massive context windows during inference, training remains constrained by GPU memory (limited to 16k tokens in this study). Future research will explore the framework's effectiveness on larger Large Language Models (LLMs) and its application to non-textual domains such as bioinformatics.

In conclusion, SimCAS provides a simple yet effective method for extending the context window of pre-trained Transformers. By combining parallel processing with lightweight global alignment and intelligent token selection, it achieves state-of-the-art results on long-text tasks while maintaining linear complexity.

Summary updated

BibTeX
@inproceedings{xie2024chunk,
  author = {Jiawen Xie and Pengyu Cheng and Xiao Liang and Yong Dai and Nan Du},
  title = {{Chunk, Align, Select: A Simple Long-sequence Processing Method for Transformers}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  url = {https://openreview.net/forum?id=CLTW1LrKzz},
}
Figure