arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2503.23814cs.LG
收藏

线性自注意力在上下文学习中的一种扩展

An extension of linear self-attention for in-context learning

Faculty of Education, Mie University(三重大学教育学部)

Katsuyuki Hagiwara

AI总结:

本文针对线性自注意力在上下文学习中的矩阵计算局限性,提出通过引入偏置矩阵进行扩展,使其能输出常数、输入及多矩阵乘积,并据此启发式构造了岭回归的批量梯度下降实现。

摘要:

上下文学习是transformers的一个显著特性,也是近期研究的焦点。注意力机制是transformers的关键组件,其中注意力矩阵对句子中词与词之间的关系进行编码,并作为句子中词的权重。该机制对于捕获语言表示非常有效。然而,朴素的self-attention是否适用于一般任务的上下文学习是值得怀疑的,因为self-attention所实现的计算在矩阵乘法方面具有一定的限制。事实上,在考虑计算算法的启发式实现时,我们可能需要适当的输入形式设计。本文在线性self-attention的情况下,通过为输入在权重矩阵之外引入一个偏置矩阵来对其进行扩展。尽管扩展很简单,但扩展后的线性self-attention可以输出任意常数矩阵、输入矩阵以及输入中两个或三个矩阵的乘积。注意,第二个性质意味着它可以作为skip connection。因此,通过连接扩展后的线性self-attention组件,可以实现灵活的矩阵操作。作为使用扩展线性self-attention的实现示例,我们在合理的输入形式下,展示了ridge regression的批量型梯度下降的启发式构造。

英文摘要:

In-context learning is a remarkable property of transformers and has been the focus of recent research. An attention mechanism is a key component in transformers, in which an attention matrix encodes relationships between words in a sentence and is used as weights for words in a sentence. This mechanism is effective for capturing language representations. However, it is questionable whether naive self-attention is suitable for in-context learning in general tasks, since the computation implemented by self-attention is somewhat restrictive in terms of matrix multiplication. In fact, we may need appropriate input form designs when considering heuristic implementations of computational algorithms. In this paper, in case of linear self-attention, we extend it by introducing a bias matrix in addition to a weight matrix for an input. Despite the simple extension, the extended linear self-attention can output any constant matrix, input matrix and multiplications of two or three matrices in the input. Note that the second property implies that it can be a skip connection. Therefore, flexible matrix manipulations can be implemented by connecting the extended linear self-attention components. As an example of implementation using the extended linear self-attention, we show a heuristic construction of a batch-type gradient descent of ridge regression under a reasonable input form.

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

↑