论文标题
变压器进纸层是钥匙值记忆
Transformer Feed-Forward Layers Are Key-Value Memories
论文作者
论文摘要
前馈层构成了变压器模型参数的三分之二,但它们在网络中的作用仍然不足。我们表明,基于变压器的语言模型中的馈电层是键值记忆,其中每个键都与训练示例中的文本模式相关,并且每个值都会在输出词汇上引起分布。我们的实验表明,学到的模式是人类的,并且下层倾向于捕获浅模式,而高层则学习了更多的语义。这些值通过诱导将概率质量集中在令牌上的输出分布来补充键的输入模式,尤其是在每个模式之后,尤其是在上层中。最后,我们证明了馈电层的输出是其记忆的组成,随后通过残留连接在整个模型的层中进行了完善,以产生最终的输出分布。
Feed-forward layers constitute two-thirds of a transformer model's parameters, yet their role in the network remains under-explored. We show that feed-forward layers in transformer-based language models operate as key-value memories, where each key correlates with textual patterns in the training examples, and each value induces a distribution over the output vocabulary. Our experiments show that the learned patterns are human-interpretable, and that lower layers tend to capture shallow patterns, while upper layers learn more semantic ones. The values complement the keys' input patterns by inducing output distributions that concentrate probability mass on tokens likely to appear immediately after each pattern, particularly in the upper layers. Finally, we demonstrate that the output of a feed-forward layer is a composition of its memories, which is subsequently refined throughout the model's layers via residual connections to produce the final output distribution.