LLMs 处理列表时使用通用过滤头
LLMs Process Lists With General Filter Heads
AI总结:
本研究揭示了LLMs在处理列表任务时通过通用过滤头实现过滤操作的机制,展示了其与函数式编程中过滤策略的相似性。
摘要:
我们研究了大型语言模型(LLMs)在处理列表任务中的机制,并发现LLMs已经学习到一种紧凑的因果表示,用于编码一种通用的过滤操作,这种操作与函数式编程中的通用“过滤”函数相似。通过在多样化的列表处理任务上进行因果中介分析,我们发现少量的注意力头,我们称之为过滤头,在特定的标记上将过滤谓词的紧凑表示编码在其查询状态中。我们证明这种谓词表示是通用且可移植的:它可以被提取并重新应用,以在不同的集合上执行相同的过滤操作,这些集合以不同的格式、语言甚至在不同的任务中呈现。然而,我们还发现,Transformer语言模型可以在某些情况下采用不同的过滤策略:即立即评估项目是否满足谓词,并将此中间结果作为标志直接存储在项目表示中。我们的结果表明,Transformer LMs可以发展出人类可解释的抽象计算操作的实现,这些实现以令人惊讶的方式类似于传统函数式编程模式中使用的策略。
英文摘要:
We investigate the mechanisms underlying a range of list-processing tasks in LLMs, and we find that LLMs have learned to encode a compact, causal representation of a general filtering operation that mirrors the generic "filter" function of functional programming. Using causal mediation analysis on a diverse set of list-processing tasks, we find that a small number of attention heads, which we dub filter heads, encode a compact representation of the filtering predicate in their query states at certain tokens. We demonstrate that this predicate representation is general and portable: it can be extracted and reapplied to execute the same filtering operation on different collections, presented in different formats, languages, or even in tasks. However, we also identify situations where transformer LMs can exploit a different strategy for filtering: eagerly evaluating if an item satisfies the predicate and storing this intermediate result as a flag directly in the item representations. Our results reveal that transformer LMs can develop human-interpretable implementations of abstract computational operations that generalize in ways that are surprisingly similar to strategies used in traditional functional programming patterns.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。