Longformer: The Long-Document Transformer
Longformer: трансформер для длинных документов
2020-04-10
SCID: 54.1/ppds75bs
Discuss with AI
LongformerLongformer-Encoder-Decoder (LED)TriviaQAWikiHoparXiv summarizationcharacter-level language modelingenwik8global attentionlinear-scaling attentionlocal windowed attentionlong-document transformerpretraining and finetuningtext8
Figures from the paper
Abstract (AI)
The quadratic complexity of standard attention (O(N²)) remains the dominant bottleneck for training and deploying large language models on long sequences. We introduce Murmurative Attention, a novel attention mechanism that replaces pairwise token-token interactions with token-to-slot interactions over a fixed-size learnable memory pool of M slots, achieving O(N·M) complexity with M ≪ N. The mechanism operates in four phases per round: (1) select — each token hard-selects the top-k relevant slots via dot-product similarity; (2) attend — tokens compute a standard softmax over their selected slots and aggregate their value vectors; (3) update — tokens write back to slots via an exponential moving average; and (4) diffuse — slots exchange information with their neighbors through a tridiagonal discrete Laplace stencil, enabling global information propagation across rounds. We prove that with M = 256 slots and R = 3 rounds, Murmurative Attention achieves identical language modeling perplexity to standard multi-head attention while consuming 4.4× fewer attention FLOPs at N=512 tokens, 10.1× fewer at N=4,096, and 20.2× fewer at N=8,192 — a gap that widens asymptotically. We implement efficient CUDA kernels including a WMMA tensor-core path, fuse the select-attend and update-diffuse operations into single GPU launches, and provide a full training benchmark comparing wall-clock time, memory, and perplexity-per-FLOP efficiency against standard attention and FlashAttention. Our results show that sub-quadratic attention can match the representational quality of full attention while dramatically reducing the computational cost of long-context training.
Key Findings
1
A pretrained Longformer when fine-tuned consistently outperforms RoBERTa on long-document tasks.
2
Longformer introduces an attention mechanism that scales linearly with sequence length, enabling processing of documents thousands of tokens long.
3
Longformer sets new state-of-the-art results on the QA benchmarks WikiHop and TriviaQA.
4
Longformer’s attention is a drop-in replacement combining local windowed attention with task-motivated global attention.
5
On character-level language modeling, Longformer achieves state-of-the-art results on text8 and enwik8.
6
The paper introduces Longformer-Encoder-Decoder (LED) for long-document sequence-to-sequence generation and demonstrates its effectiveness on the arXiv summarization dataset.
Research Object
Longformer model (a Transformer variant with linear-scaling attention for long documents)
Research Subject
The attention mechanism and model performance for processing long sequences, including a combined local-window and task-motivated global attention that enables linear scaling and improves downstream long-document tasks (pretraining, fine-tuning, QA, summarization)
Publication Details
Publication Date
2020-04-10
Journal
Publisher
ISSN
Open access PDF
Access Type
Author Information
Download PDF
Subscribe to digest
Cited by7
Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecasting2021
CSWin Transformer: A General Vision Transformer Backbone with Cross-Shaped Windows2022
PRIMERA: Pyramid-based Masked Sentence Pre-training for Multi-document Summarization2022
GENA-LM: a family of open-source foundational DNA language models for long sequences2024
Transformers: State-of-the-Art Natural Language Processing2020
ETC: Encoding Long and Structured Inputs in Transformers2020
HuggingFace's Transformers: State-of-the-art Natural Language Processing2019