Saved in:
Bibliographic Details
Main Authors: Graef, Nils, Wasielewski, Andrew
Format: Preprint
Published: 2025
Subjects:
Online Access:https://arxiv.org/abs/2503.05840
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866909634399305728
author Graef, Nils
Wasielewski, Andrew
author_facet Graef, Nils
Wasielewski, Andrew
contents Slim attention shrinks the context memory size by 2x for transformer models with MHA (multi-head attention), which can speed up inference by up to 2x for large context windows. Slim attention is an exact, mathematically identical implementation of the standard attention mechanism and therefore doesn't compromise model accuracy. In other words, slim attention losslessly compresses the context memory by a factor of 2. For encoder-decoder transformers, the context memory size can be reduced even further: For the Whisper models for example, slim attention reduces the context memory by 8x, which can speed up token generation by 5x for batch size 64 for example. And for the T5-11B model for example, the memory can be reduced by 32x because its MHA projection dimension is larger than the embedding dimension. See https://github.com/OpenMachine-ai/transformer-tricks for code and more transformer tricks, and https://www.youtube.com/watch?v=uVtk3B6YO4Y for this paper's YouTube video.
format Preprint
id arxiv_https___arxiv_org_abs_2503_05840
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Slim attention: cut your context memory in half without loss -- K-cache is all you need for MHA
Graef, Nils
Wasielewski, Andrew
Machine Learning
Slim attention shrinks the context memory size by 2x for transformer models with MHA (multi-head attention), which can speed up inference by up to 2x for large context windows. Slim attention is an exact, mathematically identical implementation of the standard attention mechanism and therefore doesn't compromise model accuracy. In other words, slim attention losslessly compresses the context memory by a factor of 2. For encoder-decoder transformers, the context memory size can be reduced even further: For the Whisper models for example, slim attention reduces the context memory by 8x, which can speed up token generation by 5x for batch size 64 for example. And for the T5-11B model for example, the memory can be reduced by 32x because its MHA projection dimension is larger than the embedding dimension. See https://github.com/OpenMachine-ai/transformer-tricks for code and more transformer tricks, and https://www.youtube.com/watch?v=uVtk3B6YO4Y for this paper's YouTube video.
title Slim attention: cut your context memory in half without loss -- K-cache is all you need for MHA
topic Machine Learning
url https://arxiv.org/abs/2503.05840