HyperAIHyperAI

Command Palette

Search for a command to run...

3 months ago

Random Feature Attention

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

Random Feature Attention

Abstract

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.

Benchmarks

BenchmarkMethodologyMetrics
language-modelling-on-wikitext-103Rfa-Gate-Gaussian-Stateful (Small)
Test perplexity: 30.5
Validation perplexity: 29.4
language-modelling-on-wikitext-103Rfa-Gate-Gaussian-Stateful (Big)
Test perplexity: 23.5
Validation perplexity: 22
machine-translation-on-iwslt2014-germanRfa-Gate-arccos
BLEU score: 34.4
machine-translation-on-wmt2014-english-frenchRfa-Gate-arccos
BLEU score: 39.2
Hardware Burden:
Operations per network pass:
machine-translation-on-wmt2014-english-germanRfa-Gate-arccos
BLEU score: 28.2
Hardware Burden:
Operations per network pass:

Build AI with AI

From idea to launch — accelerate your AI development with free AI co-coding, out-of-the-box environment and best price of GPUs.

AI Co-coding
Ready-to-use GPUs
Best Pricing
Get Started

Hyper Newsletters

Subscribe to our latest updates
We will deliver the latest updates of the week to your inbox at nine o'clock every Monday morning
Powered by MailChimp
Random Feature Attention | Papers | HyperAI