Papers › Random Feature Attention

Random Feature Attention

3 Mar 2021ICLR 2021 1arXiv:2103.02143archive 2025-07-28

Hao Peng, Nikolaos Pappas, Dani Yogatama, Roy Schwartz, Noah A. Smith, Lingpeng Kong

Transformers are state-of-the-art models for a variety of sequence modeling tasks. At their core is an attention function which models pairwise interactions between the inputs at every timestep. While attention is powerful, it does not scale efficiently to long sequences due to its quadratic time and space complexity in the sequence length. We propose RFA, a linear time and space attention that uses random feature methods to approximate the softmax function, and explore its application in transformers. RFA can be used as a drop-in replacement for conventional softmax attention and offers a straightforward way of learning with recency bias through an optional gating mechanism. Experiments on language modeling and machine translation demonstrate that RFA achieves similar or better performance compared to strong transformer baselines. In the machine translation experiment, RFA decodes twice as fast as a vanilla transformer. Compared to existing efficient transformer variants, RFA is competitive in terms of both accuracy and efficiency on three long text classification datasets. Our analysis shows that RFA's efficiency gains are especially notable on long sequences, suggesting that RFA will be particularly useful in tasks that require working with large inputs, fast decoding speed, or low memory footprints.

PaperPDFConference PDFMethod as code

In Syntology View this paper on Syntology, its page in Syntology's graph. That page lists the repositories linked to the paper, the abstract and the calls for agents.

Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

Syntology holds a reference implementation of RFA, generated from the paper text (not the authors' code), at level 3 on Syntology's ladder: V2 “two implementations GENERATED from the paper's signature and spec agree numerically (1e-6) on fixture inputs” “neither of the two ever read the authors' own code, so V2 measures how unambiguously the paper specifies the method, not fidelity to the authors' implementation (measured 2026-09-11, commit 75eaa77: cross_checked_by is a second LLM on 2,628 of 2,831 served samples)”; V3 “paper-derived property tests pass on both of those same two generations.” (quoted from Syntology's server card). For this implementation, level 3 is recorded, but its report lists no property test that passed on both. No rung compares this code against the authors' implementation. For agents: get_reference_implementation(name='RFA') (how to connect); the free check have('2103.02143') needs no token.

For agents, on Syntology's MCP service (how to connect):

Code

No code repository is listed for this paper in the archive or in Syntology's graph.

Code Syntology ran Syntology

Not run by Syntology. Nothing on this page verifies that the listed code works.

Method as code Syntology

What Syntology's graph records as this paper's claimed method, lifted into code: each assembly names its bricks (functions and classes), each with its own role and its own verification level. An assembly is not a check that the code implements the method correctly or reproduces the paper's results. Levels are each brick's own verification level in Syntology's graph (level 0: no recorded run), listed brick by brick and never combined into one level; “ran” means the brick executed on a synthesized input, not that its output is correct, and the instrument figure counts failures of Syntology's instrument, not of the code. For a generated assembly, an independent peer is a second implementation generated separately from the same paper text; neither implementation read the authors' code. At level 2 the two agreed numerically on the fixture's inputs; level 3 is recorded when property tests derived from the paper also passed on both, and each level 3 card prints how many its report lists. A generated assembly's label was set when its code was generated for the method, and no model judged it; its card prints it as "by construction" or "not judged by a model". Where an assembly's phrase has no constructed figure, a brick that ran is not among the harvested samples this build reads, and whether a brick's run only constructed an object is read from that brick's harvested sample, so the figure was not counted; it does not say there were none.

1 assembly on this paper: 0 harvested, 1 generated.

generated Assembly for RFA (graph method: RFA), generated from the paper text, not the repository's code. 1 brick; individually on a fixture: 1 ran (1 with no instrument failure: 1 honoured, 0 violated, 0 with no contract checked; 0 where Syntology's instrument failed) · 0 unverified. Ran end-to-end against an independent peer; level 3 is recorded, but its report lists no property test that passed on both.

label matches by construction: the code was generated for this method (not judged by a model)

  1. rfa_cross_attention entry · level 3 · ran · honoured contract · 60276ac8f266338565317a525d5aa54b9e92067902cb1b23c5f992fedcbb422a

Each brick ends with its code_sha256, Syntology's identity for that exact code; click one to copy the get_code call that returns it. For agents, on Syntology's MCP service: assembly(arxiv_id="2103.02143") returns these assemblies with each brick's role and wiring (how to connect).

Tasks

Language ModelingLanguage ModellingMachine TranslationText ClassificationTranslationtext-classification

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Language Modelling WikiText-103 Rfa-Gate-Gaussian-Stateful (Big) Test perplexity 23.5 #52 of 89 Archive leaderboard report
Language Modelling WikiText-103 Rfa-Gate-Gaussian-Stateful (Big) Validation perplexity 22 #52 of 89 Archive leaderboard report
Language Modelling WikiText-103 Rfa-Gate-Gaussian-Stateful (Small) Test perplexity 30.5 #70 of 89 Archive leaderboard report
Language Modelling WikiText-103 Rfa-Gate-Gaussian-Stateful (Small) Validation perplexity 29.4 #70 of 89 Archive leaderboard report
Machine Translation IWSLT2014 German-English Rfa-Gate-arccos BLEU score 34.4 #28 of 34 Archive leaderboard report
Machine Translation WMT2014 English-French Rfa-Gate-arccos BLEU score 39.2 #39 of 57 Archive leaderboard report
Machine Translation WMT2014 English-German Rfa-Gate-arccos BLEU score 28.2 #47 of 91 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

Softmax

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