Papers › Longformer: The Long-Document Transformer
Longformer: The Long-Document Transformer
Iz Beltagy, Matthew E. Peters, Arman Cohan
Transformer-based models are unable to process long sequences due to their self-attention operation, which scales quadratically with the sequence length. To address this limitation, we introduce the Longformer with an attention mechanism that scales linearly with sequence length, making it easy to process documents of thousands of tokens or longer. Longformer's attention mechanism is a drop-in replacement for the standard self-attention and combines a local windowed attention with a task motivated global attention. Following prior work on long-sequence transformers, we evaluate Longformer on character-level language modeling and achieve state-of-the-art results on text8 and enwik8. In contrast to most prior work, we also pretrain Longformer and finetune it on a variety of downstream tasks. Our pretrained Longformer consistently outperforms RoBERTa on long document tasks and sets new state-of-the-art results on WikiHop and TriviaQA. We finally introduce the Longformer-Encoder-Decoder (LED), a Longformer variant for supporting long document generative sequence-to-sequence tasks, and demonstrate its effectiveness on the arXiv summarization dataset.
In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.
For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2004.05150")
Code
Syntology Ran 15 of 35 code samples harvested from 7 repositories linked to this paper; 20 have no recorded run. Of those that ran: 1 ran · honoured contract; 1 ran · violated contract; 8 ran · our draft was wrong; 5 ran with no contract checked.
By repository: official repository: 11 samples from 1 repository, 9 ran; community (archive-listed): 24 samples from 6 repositories, 6 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.
22 repositories listed; official and paper-mentioned ones first.
Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.
Code Syntology ran Syntology
35 samples harvested; 15 ran; 1 honoured the contract we drafted; 20 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.
Licence: 5 of the 35 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.
Harvested from 7 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.
Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.
Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.
b3689e24866300ad · report
215ac6dd58d2d468 · report
1a6f3f01a17a0b4c · report
54c6929644249d31 · report
755bf82d9fe23d4b · report
4261f70837b75c76 · report
1b7525edcd068b10 · report
1273524f034ce151 · report
3d4e46172b26669c · report
c1eb691dab111921 · report
bec22b3675334717 · report
2893a3bddf619d82 · report
e71d9c8a8cff7aa3 · report
6c89fcd0771cd674 · report
0840d53a3e87bbd0 · report
4d2255c33fd872a1 · report
ca468da77bd87495 · report
e23d4d61b776fd56 · report
083425b2586f0566 · report
56f78e8f5e291c8d · report
3b707d0823eee4d2 · report
cc7b7bd19f2134ba · report
62964c608dfd3d2c · report
be39561477eedbab · report
1d6037ddb5464048 · report
4f4f44d30b573fa8 · report
8a1120aa9e015927 · report
e910798b9dfc1967 · report
9c78ceb4210479cf · report
69ca0d84582f00bd · report
2a87d1deca0f2b1a · report
337700a5796189df · report
e566c3f105753aa6 · report
bce6838014c76d1e · report
e71dea05795c03bf · report
Tasks
Results from the paper archive 2025-07-28
| Task | Dataset | Model | Metric | Value | Rank at snapshot | Leaderboard | Report |
|---|---|---|---|---|---|---|---|
| Language Modelling | Hutter Prize | Longformer Large | Bit per Character (BPC) | 0.99 | #5 of 18 | Archive leaderboard | report |
| Language Modelling | Hutter Prize | Longformer Large | Number of params | 102M | #5 of 18 | Archive leaderboard | report |
| Language Modelling | Hutter Prize | Longformer Small | Bit per Character (BPC) | 1.00 | #6 of 18 | Archive leaderboard | report |
| Language Modelling | Hutter Prize | Longformer Small | Number of params | 41M | #6 of 18 | Archive leaderboard | report |
| Language Modelling | enwik8 | Longformer (30 layers, h=512) | Bit per Character (BPC) | 0.99 | #13 of 42 | Archive leaderboard | report |
| Language Modelling | enwik8 | Longformer (30 layers, h=512) | Number of params | 102M | #13 of 42 | Archive leaderboard | report |
| Language Modelling | enwik8 | Longformer (12 layers, h=512) | Bit per Character (BPC) | 1.00 | #18 of 42 | Archive leaderboard | report |
| Language Modelling | enwik8 | Longformer (12 layers, h=512) | Number of params | 41M | #18 of 42 | Archive leaderboard | report |
| Question Answering | WikiHop | Longformer-large | Test | 81.9 | #2 of 9 | Archive leaderboard | report |
Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.
Methods
Introduced by this paper: Longformer
Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections