arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2401.07993cs.LGcs.AI
收藏

Transformer 中的进位算法

Carrying over algorithm in transformers

Institute for Advanced Study(普林斯顿高等研究院)

Jorrit Kruthoff

AI总结:

本文研究 transformer 如何实现加法进位,揭示两层 encoder-only 模型以模块化方式分层完成同位相加与进位,并在小型 decoder-only 及 7B 模型中发现类似机制。

摘要:

加法也许是人们能想到的最简单的算术任务之一,通常使用进位算法来完成。该算法包含两个任务:将同一位置的数字相加,并在必要时进位 1。我们研究 transformer 模型如何实现这一算法,以及上述两个任务如何分配到网络的不同部分。我们首先关注两层 encoder-only 模型,并证明进位算法是以模块化方式实现的。第一层主要负责将同一位置的数字相加。第二层先在 attention 中判断哪些位置需要进位 1,然后在最后的 MLP 中执行 1 的进位。我们提供了一种简单方法,可精确识别哪些神经元负责该任务。这种进位算法的实现出现在两层及三层模型的一系列超参数设置中。对于小型 decoder-only 模型,我们观察到相同的实现,并为该实现存在于三个 7B 大型语言模型中提供了提示性证据。

英文摘要:

Addition is perhaps one of the simplest arithmetic tasks one can think of and is usually performed using the carrying over algorithm. This algorithm consists of two tasks: adding digits in the same position and carrying over a one whenever necessary. We study how transformer models implement this algorithm and how the two aforementioned tasks are allocated to different parts of the network. We first focus on two-layer encoder-only models and show that the carrying over algorithm is implemented in a modular fashion. The first layer is mostly responsible for adding digits in the same position. The second layer first decides, in the attention, which positions need a carried one or not, and then performs the carrying of the one in the final MLP. We provide a simple way of precisely identifying which neurons are responsible for that task. This implementation of the carrying over algorithm occurs across a range of hyperparameters for two as well as three-layer models. For small decoder-only models, we observe the same implementation and provide suggestive evidence for its existence in three 7B large language models.

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

↑