Longformer: The Long-Document Transformer

Longformer: трансформер для длинных документов
Matthew E. Peters, Iz Beltagy, Arman Cohan
2020-04-10

LongformerLongformer-Encoder-Decoder (LED)TriviaQAWikiHoparXiv summarizationcharacter-level language modelingenwik8global attentionlinear-scaling attentionlocal windowed attentionlong-document transformerpretraining and finetuningtext8
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.
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.

Longformer model (a Transformer variant with linear-scaling attention for long documents)

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
Access Type
Author Information
Authors
Matthew E. Peters
Iz Beltagy
Arman Cohan
Explore further
Open the scid.ai AI chat with a ready-made request: it will find papers on a similar topic and help build a literature review.
Find similar papers in the chat
Make a presentation
100%