ImageNet classification with deep convolutional neural networks
Alex Krizhevsky, Ilya Sutskever et al.
5.7k
Citations
764
Influential Citations
arXiv.org
Venue
2020
Year
Introduces a linearly scalable attention mechanism, allowing handling texts of exteded length.
Standard Transformer models suffer from quadratic self-attention complexity, limiting their input length to typically 512 tokens. This is a critical bottleneck for tasks like document classification, question answering over long articles, or summarization of entire books. Longformer directly tackles this by proposing a sparse attention pattern that scales linearly with sequence length, making it feasible to process documents with tens of thousands of tokens without sacrificing performance.
Longformer replaces the full self-attention matrix with a combination of three attention patterns:
Sliding Window Attention: Each token attends only to a fixed-size window of neighboring tokens (e.g., 512 tokens). Multiple stacked layers create a large effective receptive field, similar to CNNs.
Dilated Sliding Window: To further expand the receptive field without increasing computation, gaps are introduced in the window (dilation rate d). This allows tokens to attend to farther-away positions with fewer operations.


To implement this efficiently, Longformer uses two separate sets of linear projections: one for sliding window attention (Qs, Ks, Vs) and one for global attention (Qg, Kg, Vg). The global projections are initialized from the local ones, allowing the model to specialize each attention type during fine-tuning.
For autoregressive language modeling, the authors use dilated sliding window attention with varying window sizes across layers: small windows in lower layers capture local patterns, while larger windows in higher layers build global representations. Lower layers avoid dilation to maximize local context learning.
Training proceeds in phases: starting with short sequences (2,048 tokens) and small windows, then doubling both sequence length and window size while halving the learning rate across five phases, ending with sequences of 23,040 tokens. This staged approach keeps training efficient.
Longformer is evaluated on long-document tasks using sequences up to 32,256 tokens. It achieves state-of-the-art results on several benchmarks, including coreference resolution and question answering, while using significantly less memory and compute than full-attention baselines. The model is pretrained by continuing from RoBERTa with masked language modeling on a corpus of long documents, adding position embeddings up to 4,096 tokens. A variant with frozen RoBERTa weights (only training new position embeddings) also performs well, demonstrating the plug-and-play nature of the attention pattern.
For sequence-to-sequence tasks, Longformer-Encoder-Decoder (LED) is introduced, initialized from BART. The encoder uses the efficient local+global attention, while the decoder uses full self-attention over encoded tokens and previously decoded positions. Position embeddings are extended to 16K tokens.

Longformer was a landmark paper that made long-context transformers practical. Its sparse attention pattern inspired many subsequent works (e.g., BigBird, Sparse Transformers) and enabled applications like long-document summarization, legal document analysis, and scientific paper understanding. By showing that pretrained models can be adapted with minimal changes, Longformer lowered the barrier for practitioners to handle longer sequences. The paper's clear design choices—sliding window, dilation, and global attention—remain a standard reference point for efficient transformer architectures.
Alex Krizhevsky, Ilya Sutskever et al.
Ashish Vaswani, Noam Shazeer et al.
Douglas M. Bates, Martin Mächler et al.
Diederik P. Kingma, Jimmy Ba