arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2310.19676cs.LG
收藏

HyPE:用于相对位置编码的带双曲偏置的注意力机制

HyPE: Attention with Hyperbolic Biases for Relative Positional Encoding

Independent Researcher(独立研究者)

Giorgio Angelotti

AI总结:

本文提出HyPE方法,利用双曲函数编码token相对位置,在不存储$O(L^2)$掩码的情况下为注意力机制施加偏置,兼容FlashAttention-2并支持梯度回传,且可近似ALiBi的注意力偏置以提升长上下文泛化能力。

摘要:

在基于Transformer的架构中,注意力机制本质上对输入序列的token具有排列不变性。为了施加顺序信息,token位置通常采用固定参数或可学习参数的方案进行编码。我们提出双曲位置编码(HyPE),这是一种利用双曲函数性质来编码token相对位置的新方法。该方法在不存储掩码的$O(L^2)$个值的情况下对注意力机制施加偏置,其中$L$为输入序列的长度。HyPE利用初步的拼接操作和矩阵乘法,便于对相对距离进行编码,并间接将偏置纳入softmax计算中。该设计确保与FlashAttention-2兼容,并支持编码中任何潜在可学习参数的梯度反向传播。我们通过分析证明,通过仔细选择超参数,HyPE可以近似ALiBi的注意力偏置,从而为超出预训练期间所见长度的上下文提供有前景的泛化能力。HyPE的实验评估被提出作为未来研究的一个方向。

英文摘要:

In Transformer-based architectures, unmasked self-attention without positional information is permutation-equivariant with respect to the input sequence's tokens. To impose sequential order, token positions are typically encoded using a scheme with either fixed or learnable parameters. We introduce Hyperbolic Positional Encoding (HyPE), a method that utilizes hyperbolic functions' properties to encode tokens' relative positions. This approach biases the attention mechanism without the necessity of storing the $O(L^2)$ values of the bias tensor, with $L$ being the length of the input sequence. HyPE leverages preliminary concatenation operations and matrix multiplications, encoding relative distances by indirectly incorporating biases into the softmax computation. This design supports gradient backpropagation through the encoding and can be used with FlashAttention-2 under the width and scaling conditions below. We analytically demonstrate that, by careful hyperparameter selection, HyPE can approximate the causal attention bias of ALiBi \citep{press2021train} on a bounded range; model generalization beyond the pretraining length remains to be evaluated. The experimental evaluation of HyPE is proposed as a direction for future research.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑