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

大型语言模型如何进行上下文学习?上下文头的查询和键矩阵是度量学习的双塔

How do Large Language Models Learn In-Context? Query and Key Matrices of In-Context Heads are Two Towers for Metric Learning

The University of Manchester(曼彻斯特大学);National Centre for Text Mining(国家文本挖掘中心)

Zeping Yu, Sophia Ananiadou

AI总结:

本文研究了ICL机制,发现干预1%的“上下文头”显著影响准确率,提出其查询和键矩阵构成度量学习的双塔来计算相似度,并据此解释了多数标签偏置和近因偏置,提出方法分别降低这两种偏置22%和17%。

摘要:

我们研究了在具有语义无关标签("foo"/"bar")的句子分类任务上的上下文学习(ICL)机制。我们发现,仅对1%的头(命名为“上下文头”)进行干预,就会使ICL准确率从87.6%显著下降到24.4%。为了理解这一现象,我们分析了这些头中的值-输出向量,发现每个标签位置的向量包含相应标签的大量信息。此外,我们观察到预测从"foo"向"bar"的转变,是由于这些头在"foo"和"bar"位置的注意力分数分别减少和增加所致。因此,我们提出了关于ICL的假设:在上下文头中,值-输出矩阵提取标签特征,而查询-键矩阵计算最后位置的特征与每个标签位置特征之间的相似度。查询和键矩阵可以被视为双塔,用于学习最后位置特征与标签位置处每个演示之间的相似性度量。利用这一假设,我们解释了ICL中的多数标签偏置和近因偏置,并提出了两种方法分别将这两种偏置降低了22%和17%。

英文摘要:

We investigate the mechanism of in-context learning (ICL) on sentence classification tasks with semantically-unrelated labels ("foo"/"bar"). We find intervening in only 1\% heads (named "in-context heads") significantly affects ICL accuracy from 87.6\% to 24.4\%. To understand this phenomenon, we analyze the value-output vectors in these heads and discover that the vectors at each label position contain substantial information about the corresponding labels. Furthermore, we observe that the prediction shift from "foo" to "bar" is due to the respective reduction and increase in these heads' attention scores at "foo" and "bar" positions. Therefore, we propose a hypothesis for ICL: in in-context heads, the value-output matrices extract label features, while the query-key matrices compute the similarity between the features at the last position and those at each label position. The query and key matrices can be considered as two towers that learn the similarity metric between the last position's features and each demonstration at label positions. Using this hypothesis, we explain the majority label bias and recency bias in ICL and propose two methods to reduce these biases by 22\% and 17\%, respectively.

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

↑