Papers › H-Transformer-1D: Fast One-Dimensional Hierarchical Attention for Sequences

H-Transformer-1D: Fast One-Dimensional Hierarchical Attention for Sequences

25 Jul 2021ACL 2021 5arXiv:2107.11906archive 2025-07-28

Zhenhai Zhu, Radu Soricut

We describe an efficient hierarchical method to compute attention in the Transformer architecture. The proposed attention mechanism exploits a matrix structure similar to the Hierarchical Matrix (H-Matrix) developed by the numerical analysis community, and has linear run time and memory complexity. We perform extensive experiments to show that the inductive bias embodied by our hierarchical attention is effective in capturing the hierarchical structure in the sequences typical for natural language and vision tasks. Our method is superior to alternative sub-quadratic proposals by over +6 points on average on the Long Range Arena benchmark. It also sets a new SOTA test perplexity on One-Billion Word dataset with 5x fewer model parameters than that of the previous-best Transformer-based models.

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.11906")

Code

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

By repository: community (archive-listed): 10 samples from 2 repositories, 5 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

lucidrains/h-transformer-1d mentioned on GitHubpytorchMIT 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

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

1ran · violated contract
3ran · our draft was wrong
1ran
5unverified

Licence: 0 of the 10 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. “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.

HTransformer1DRotaryEmbedding jinmang2/hierarchical-transformer-1d/src/modeling_htransformer1d.py community (archive-listed) ran · metamorphic tier: deterministic fingerprinted MIT (permissive) · e3b0303428abb577 · report
eval_decorator lucidrains/h-transformer-1d/h_transformer_1d/autoregressive_wrapper.py community (archive-listed) ran · our draft was wrong MIT (permissive) · c16aee9490eb8729 · report
exists lucidrains/h-transformer-1d/h_transformer_1d/autoregressive_wrapper.py community (archive-listed) ran · violated contract MIT (permissive) · aa5486a3650902d8 · report
flip_every_two jinmang2/hierarchical-transformer-1d/src/modeling_htransformer1d.py community (archive-listed) ran · our draft was wrong fingerprinted MIT (permissive) · 8a5b2cb4b5962883 · report
top_k lucidrains/h-transformer-1d/h_transformer_1d/autoregressive_wrapper.py community (archive-listed) ran · our draft was wrong fingerprinted MIT (permissive) · 3b65d5d77510c964 · report
HTransformer1DAttention jinmang2/hierarchical-transformer-1d/src/modeling_htransformer1d.py community (archive-listed) unverified MIT (permissive) · 0264a115409ab8db · report
layer_drop lucidrains/h-transformer-1d/h_transformer_1d/reversible.py community (archive-listed) unverified MIT (permissive) · a5d582ae0f1134fb · report
masked_aggregate lucidrains/h-transformer-1d/h_transformer_1d/h_transformer_1d.py community (archive-listed) unverified MIT (permissive) · b651f49b40613305 · report
route_args lucidrains/h-transformer-1d/h_transformer_1d/reversible.py community (archive-listed) unverified MIT (permissive) · 1f7d4befc2e41402 · report
shift lucidrains/h-transformer-1d/h_transformer_1d/h_transformer_1d.py community (archive-listed) unverified MIT (permissive) · f73845c2459404f2 · report

Tasks

Inductive BiasLanguage Modelling

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Language Modelling One Billion Word H-Transformer-1D Nr=16 (Base) Number of params 53M #26 of 27 Archive leaderboard report
Language Modelling One Billion Word H-Transformer-1D Nr=16 (Base) Validation perplexity 23.95 #26 of 27 Archive leaderboard report
Language Modelling One Billion Word H-Transformer-1D Nr=16 (Large) Number of params 144M #27 of 27 Archive leaderboard report
Language Modelling One Billion Word H-Transformer-1D Nr=16 (Large) Validation perplexity 20.25 #27 of 27 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