On the Benefits of Rank in Attention Layers

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Amsel, Noah, Yehudai, Gilad, Bruna, Joan
Format: Preprint
Publié: 2024
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866929432343609344
author Amsel, Noah
Yehudai, Gilad
Bruna, Joan
author_facet Amsel, Noah
Yehudai, Gilad
Bruna, Joan
contents Attention-based mechanisms are widely used in machine learning, most prominently in transformers. However, hyperparameters such as the rank of the attention matrices and the number of heads are scaled nearly the same way in all realizations of this architecture, without theoretical justification. In this work we show that there are dramatic trade-offs between the rank and number of heads of the attention mechanism. Specifically, we present a simple and natural target function that can be represented using a single full-rank attention head for any context length, but that cannot be approximated by low-rank attention unless the number of heads is exponential in the embedding dimension, even for short context lengths. Moreover, we prove that, for short context lengths, adding depth allows the target to be approximated by low-rank attention. For long contexts, we conjecture that full-rank attention is necessary. Finally, we present experiments with off-the-shelf transformers that validate our theoretical findings.
format Preprint
id arxiv_https___arxiv_org_abs_2407_16153
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle On the Benefits of Rank in Attention Layers
Amsel, Noah
Yehudai, Gilad
Bruna, Joan
Machine Learning
Attention-based mechanisms are widely used in machine learning, most prominently in transformers. However, hyperparameters such as the rank of the attention matrices and the number of heads are scaled nearly the same way in all realizations of this architecture, without theoretical justification. In this work we show that there are dramatic trade-offs between the rank and number of heads of the attention mechanism. Specifically, we present a simple and natural target function that can be represented using a single full-rank attention head for any context length, but that cannot be approximated by low-rank attention unless the number of heads is exponential in the embedding dimension, even for short context lengths. Moreover, we prove that, for short context lengths, adding depth allows the target to be approximated by low-rank attention. For long contexts, we conjecture that full-rank attention is necessary. Finally, we present experiments with off-the-shelf transformers that validate our theoretical findings.
title On the Benefits of Rank in Attention Layers
topic Machine Learning
url https://arxiv.org/abs/2407.16153