Function Vectors in Large Language Models
作者: Eric Todd, Millicent L. Li, Arnab Sen Sharma, Aaron Mueller, Byron C. Wallace, David Bau
分类: cs.CL, cs.LG
发布日期: 2023-10-23 (更新: 2024-02-25)
备注: ICLR 2024. 52 pages, 30 figures, 23 tables. Code and data at https://functions.baulab.info
💡 一句话要点
提出函数向量机制以增强大语言模型的任务执行能力
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 函数向量 大语言模型 自回归变换器 任务执行 上下文学习 注意力机制 因果分析
📋 核心要点
- 现有的大语言模型在处理复杂任务时,缺乏有效的内部表示机制,导致任务执行的鲁棒性不足。
- 论文提出了一种函数向量(FV)机制,通过少数注意力头传递任务的紧凑表示,增强了模型的任务执行能力。
- 实验结果表明,FV在多种任务和模型中表现出强因果效应,尤其在中间层,显示出良好的上下文适应性。
📝 摘要(中文)
我们报告了一种简单的神经机制,该机制在自回归变换器语言模型中将输入-输出函数表示为向量。通过对多种上下文学习任务进行因果中介分析,我们发现少数注意力头传递了紧凑的任务表示,称为函数向量(FV)。FV对上下文变化具有鲁棒性,能够在零样本和自然文本等输入上触发任务执行。我们在多个任务、模型和层次上测试FV,发现中间层具有强因果效应。我们还研究了FV的内部结构,发现虽然它们通常包含编码函数输出空间的信息,但仅凭这些信息不足以重构FV。最后,我们测试了FV中的语义向量组合,发现它们在一定程度上可以相加以创建触发新复杂任务的向量。我们的研究表明,可以从大型语言模型中显式提取紧凑的因果内部向量表示。
🔬 方法详解
问题定义:本论文旨在解决大语言模型在执行复杂任务时的内部表示不足问题,现有方法无法有效捕捉任务的输入-输出关系,导致鲁棒性差。
核心思路:论文提出函数向量(FV)作为一种新的表示机制,通过少数注意力头传递任务的紧凑表示,从而增强模型在不同上下文中的任务执行能力。
技术框架:整体架构包括输入处理、注意力机制、函数向量提取和任务执行四个主要模块。输入通过自回归变换器进行处理,注意力机制用于提取FV,最后根据FV触发相应的任务执行。
关键创新:最重要的技术创新在于提出了函数向量这一概念,能够在多种上下文中有效触发任务执行,与现有方法相比,FV提供了一种更为紧凑和鲁棒的任务表示方式。
关键设计:在参数设置上,论文对注意力头的选择进行了优化,采用特定的损失函数以确保FV的有效性,同时在网络结构上进行了调整,以增强中间层的因果效应。
🖼️ 关键图片
📊 实验亮点
实验结果显示,函数向量在多个任务中表现出强因果效应,尤其在中间层,能够有效触发任务执行。与基线模型相比,FV在零样本和自然文本设置下的任务执行能力显著提升,展示了其在多样化上下文中的鲁棒性。
🎯 应用场景
该研究的潜在应用领域包括自然语言处理、对话系统和智能助手等。通过增强大语言模型的任务执行能力,能够提升其在实际应用中的表现,尤其是在复杂任务和多样化上下文下的适应性。未来,该机制可能为更高效的模型设计和任务执行提供新的思路。
📄 摘要(原文)
We report the presence of a simple neural mechanism that represents an input-output function as a vector within autoregressive transformer language models (LMs). Using causal mediation analysis on a diverse range of in-context-learning (ICL) tasks, we find that a small number attention heads transport a compact representation of the demonstrated task, which we call a function vector (FV). FVs are robust to changes in context, i.e., they trigger execution of the task on inputs such as zero-shot and natural text settings that do not resemble the ICL contexts from which they are collected. We test FVs across a range of tasks, models, and layers and find strong causal effects across settings in middle layers. We investigate the internal structure of FVs and find while that they often contain information that encodes the output space of the function, this information alone is not sufficient to reconstruct an FV. Finally, we test semantic vector composition in FVs, and find that to some extent they can be summed to create vectors that trigger new complex tasks. Our findings show that compact, causal internal vector representations of function abstractions can be explicitly extracted from LLMs. Our code and data are available at https://functions.baulab.info.