Saved in:
Bibliographic Details
Main Authors: Arora, Simran, Eyuboglu, Sabri, Zhang, Michael, Timalsina, Aman, Alberti, Silas, Zinsley, Dylan, Zou, James, Rudra, Atri, Ré, Christopher
Format: Preprint
Published: 2024
Subjects:
Online Access:https://arxiv.org/abs/2402.18668
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866916646028836864
author Arora, Simran
Eyuboglu, Sabri
Zhang, Michael
Timalsina, Aman
Alberti, Silas
Zinsley, Dylan
Zou, James
Rudra, Atri
Ré, Christopher
author_facet Arora, Simran
Eyuboglu, Sabri
Zhang, Michael
Timalsina, Aman
Alberti, Silas
Zinsley, Dylan
Zou, James
Rudra, Atri
Ré, Christopher
contents Recent work has shown that attention-based language models excel at recall, the ability to ground generations in tokens previously seen in context. However, the efficiency of attention-based models is bottle-necked during inference by the KV-cache's aggressive memory consumption. In this work, we explore whether we can improve language model efficiency (e.g. by reducing memory consumption) without compromising on recall. By applying experiments and theory to a broad set of architectures, we identify a key tradeoff between a model's state size and recall ability. We show that efficient alternatives to attention (e.g. H3, Mamba, RWKV) maintain a fixed-size recurrent state, but struggle at recall. We propose BASED a simple architecture combining linear and sliding window attention. By varying BASED window size and linear attention feature dimension, we can dial the state size and traverse the pareto frontier of the recall-memory tradeoff curve, recovering the full quality of attention on one end and the small state size of attention-alternatives on the other. We train language models up to 1.3b parameters and show that BASED matches the strongest sub-quadratic models (e.g. Mamba) in perplexity and outperforms them on real-world recall-intensive tasks by 6.22 accuracy points. Implementations of linear attention are often less efficient than optimized standard attention implementations. To make BASED competitive, we develop IO-aware algorithms that enable 24x higher throughput on language generation than FlashAttention-2, when generating 1024 tokens using 1.3b parameter models. Code for this work is provided at: https://github.com/HazyResearch/based.
format Preprint
id arxiv_https___arxiv_org_abs_2402_18668
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Simple linear attention language models balance the recall-throughput tradeoff
Arora, Simran
Eyuboglu, Sabri
Zhang, Michael
Timalsina, Aman
Alberti, Silas
Zinsley, Dylan
Zou, James
Rudra, Atri
Ré, Christopher
Computation and Language
Machine Learning
Recent work has shown that attention-based language models excel at recall, the ability to ground generations in tokens previously seen in context. However, the efficiency of attention-based models is bottle-necked during inference by the KV-cache's aggressive memory consumption. In this work, we explore whether we can improve language model efficiency (e.g. by reducing memory consumption) without compromising on recall. By applying experiments and theory to a broad set of architectures, we identify a key tradeoff between a model's state size and recall ability. We show that efficient alternatives to attention (e.g. H3, Mamba, RWKV) maintain a fixed-size recurrent state, but struggle at recall. We propose BASED a simple architecture combining linear and sliding window attention. By varying BASED window size and linear attention feature dimension, we can dial the state size and traverse the pareto frontier of the recall-memory tradeoff curve, recovering the full quality of attention on one end and the small state size of attention-alternatives on the other. We train language models up to 1.3b parameters and show that BASED matches the strongest sub-quadratic models (e.g. Mamba) in perplexity and outperforms them on real-world recall-intensive tasks by 6.22 accuracy points. Implementations of linear attention are often less efficient than optimized standard attention implementations. To make BASED competitive, we develop IO-aware algorithms that enable 24x higher throughput on language generation than FlashAttention-2, when generating 1024 tokens using 1.3b parameter models. Code for this work is provided at: https://github.com/HazyResearch/based.
title Simple linear attention language models balance the recall-throughput tradeoff
topic Computation and Language
Machine Learning
url https://arxiv.org/abs/2402.18668