Papers › Long-Short Transformer: Efficient Transformers for Language and Vision

Long-Short Transformer: Efficient Transformers for Language and Vision

5 Jul 2021NeurIPS 2021 12arXiv:2107.02192archive 2025-07-28

Chen Zhu, Wei Ping, Chaowei Xiao, Mohammad Shoeybi, Tom Goldstein, Anima Anandkumar, Bryan Catanzaro

Transformers have achieved success in both language and vision domains. However, it is prohibitively expensive to scale them to long sequences such as long documents or high-resolution images, because self-attention mechanism has quadratic time and memory complexities with respect to the input sequence length. In this paper, we propose Long-Short Transformer (Transformer-LS), an efficient self-attention mechanism for modeling long sequences with linear complexity for both language and vision tasks. It aggregates a novel long-range attention with dynamic projection to model distant correlations and a short-term attention to capture fine-grained local correlations. We propose a dual normalization strategy to account for the scale mismatch between the two attention mechanisms. Transformer-LS can be applied to both autoregressive and bidirectional models without additional complexity. Our method outperforms the state-of-the-art models on multiple tasks in language and vision domains, including the Long Range Arena benchmark, autoregressive language modeling, and ImageNet classification. For instance, Transformer-LS achieves 0.97 test BPC on enwik8 using half the number of parameters than previous method, while being faster and is able to handle 3x as long sequences compared to its full-attention version on the same hardware. On ImageNet, it can obtain the state-of-the-art results (e.g., a moderate size of 55.8M model solely trained on 224x224 ImageNet-1K can obtain Top-1 accuracy 84.1%), while being more scalable on high-resolution images. The source code and models are released at https://github.com/NVIDIA/transformer-ls .

PaperPDFConference PDFCodeCode Syntology ran

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="2107.02192")

Code

Syntology Ran 4 of 4 code samples harvested from 2 repositories linked to this paper; 0 have no recorded run. Of those that ran: 2 ran · violated contract; 1 ran · our draft was wrong; 1 ran with no contract checked.

By repository: official repository: 1 sample from 1 repository, 1 ran; community (archive-listed): 1 sample from 1 repository, 1 ran; 2 identical to code first harvested elsewhere. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

NVIDIA/transformer-ls officialmentioned in papermentioned on GitHubjax report
lucidrains/long-short-transformer mentioned on GitHubpytorch report

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

4 samples harvested; 4 ran; 0 honoured the contract we drafted; 0 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.

2ran · violated contract
1ran · our draft was wrong
1ran

Licence: 2 of the 4 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 2 repositories linked to this paper, official or community; each sample names its own and says which. Some samples are identical code Syntology first harvested from another repository; for those, this paper's copy is not located and its licence is not recorded. “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.

AttentionLS NVIDIA/transformer-ls/imagenet/models/layers/transformer_ls.py official repository ran MIT (permissive) · c1c6a8ede6989ad3 · report
pad_to_multiple lucidrains/long-short-transformer/long_short_transformer/long_short_transformer.py community (archive-listed) ran · our draft was wrong MIT (permissive) · cf60f4efa3554792 · report
default identical code first harvested elsewhere ran · violated contract fingerprinted licence of this copy not recorded · 60fff7c3c400d7ff · report
exists identical code first harvested elsewhere ran · violated contract licence of this copy not recorded · aa5486a3650902d8 · report

Tasks

Language ModelingLanguage Modelling

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Language Modelling Text8 Transformer-LS (small) Bit per Character (BPC) 1.09 #7 of 24 Archive leaderboard report
Language Modelling Text8 dev Transformer-LS (small) Bit per Character (BPC) 1.03 #1 of 1 Archive leaderboard report
Language Modelling enwik8 Transformer-LS (large) Bit per Character (BPC) 0.97 #9 of 42 Archive leaderboard report
Language Modelling enwik8 Transformer-LS (large) Number of params 110M #9 of 42 Archive leaderboard report
Language Modelling enwik8 Transformer-LS (small) Bit per Character (BPC) 0.99 #16 of 42 Archive leaderboard report
Language Modelling enwik8 dev Transformer-LS (small) Bit per Character (BPC) 1.01 #1 of 1 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

Absolute Position EncodingsAdamAttentionBPEDense ConnectionsDropoutLabel SmoothingLayer NormalizationLinear LayerMulti-Head AttentionPosition-Wise Feed-Forward LayerResidual ConnectionSoftmaxTransformer

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