Skip to main content
QUICK REVIEW

[论文解读] In-Context Learning Creates Task Vectors

Roee Hendel, Mor Geva|arXiv (Cornell University)|Oct 24, 2023
Topic Modeling被引用 4
一句话总结

本文提出,大语言模型(LLMs)中的上下文学习(ICL)通过将演示压缩为单一任务向量来运作,该向量随后调节模型对查询的输出。作者证明,ICL可被视为一种假设类学习机制,其中任务向量捕获任务规则,从而在无需直接访问演示的情况下实现准确预测,且在多个模型和任务上均得到实证验证。

ABSTRACT

In-context learning (ICL) in Large Language Models (LLMs) has emerged as a powerful new learning paradigm. However, its underlying mechanism is still not well understood. In particular, it is challenging to map it to the "standard" machine learning framework, where one uses a training set $S$ to find a best-fitting function $f(x)$ in some hypothesis class. Here we make progress on this problem by showing that the functions learned by ICL often have a very simple structure: they correspond to the transformer LLM whose only inputs are the query $x$ and a single "task vector" calculated from the training set. Thus, ICL can be seen as compressing $S$ into a single task vector $\boldsymbolθ(S)$ and then using this task vector to modulate the transformer to produce the output. We support the above claim via comprehensive experiments across a range of models and tasks.

研究动机与目标

  • 为了理解大语言模型(LLMs)中上下文学习(ICL)的内在机制,尽管其在实践中表现成功,但其机理仍不甚明了。
  • 通过识别ICL运作的假设类,将ICL映射到正式的学习理论框架中。
  • 研究ICL是否可分解为两个阶段:从演示中学习任务向量,随后将其应用于查询。
  • 验证任务向量是否捕获了独立于输入演示的有意义且可解释的任务特定语义信息。
  • 探讨该机制对LLM高效且可解释地适应新任务的启示。

提出的方法

  • 提出ICL的假设类视角,即模型从演示S中学习任务向量θ(S),且该过程独立于查询x。
  • 定义两部分机制:(1) 一个‘学习算法’𝒜,用于从S计算θ(S);(2) 一个‘规则应用’f,使用θ(S)和x生成输出,且不直接访问S。
  • 利用仅解码器结构的Transformer中的注意力机制,提取在处理S和x后作为隐藏状态表示的任务向量。
  • 通过线性投影将任务向量投影到词汇空间,以解释其语义内容。
  • 在包括翻译、词义消歧和算术推理在内的多样化NLP任务上训练并评估该方法。
  • 将基于任务向量的方法与标准ICL及基线模型的性能进行比较,以验证其有效性与泛化能力。
Figure 1: ICL as learning in a Hypothesis Class. In ICL, one provides an LLM with a prompt including demonstrations $S$ of some task, and a query $x$ . The model generates the output for $x$ (here “Yellow”). We show that the underlying process can be broken down into two parts: $\mathcal{A}$ , a “le
Figure 1: ICL as learning in a Hypothesis Class. In ICL, one provides an LLM with a prompt including demonstrations $S$ of some task, and a query $x$ . The model generates the output for $x$ (here “Yellow”). We show that the underlying process can be broken down into two parts: $\mathcal{A}$ , a “le

实验结果

研究问题

  • RQ1LLMs中的上下文学习能否被形式化为一种假设类学习机制,即单一任务向量θ(S)编码来自演示S的规则?
  • RQ2任务向量θ(S)是否独立于查询x,使其可应用于任何新查询而无需重新处理S?
  • RQ3即使任务特定术语未出现在输入中,任务向量θ(S)是否仍包含关于任务的有意义且可解释的语义信息?
  • RQ4该任务向量方法是否能在不同模型和任务间保持高精度的同时实现泛化?
  • RQ5在多样化任务上,基于任务向量的方法与标准ICL及基线模型的性能相比如何?

主要发现

  • 任务向量θ(S)成功捕获了来自演示S的底层规则,使得在无需直接访问S的情况下也能对未见查询实现准确预测。
  • 在翻译任务中,模型使用任务向量实现了96%的准确率,表明其能从少量示例中实现强大泛化。
  • 在法语到英语翻译任务中,任务向量投影的顶级词包括'English'和'translate',表明该向量编码了输入中未出现的语义任务信息。
  • 在'现在时转过去时'任务中,模型实现了95%的准确率,表明其在多种语言转换中均表现出稳健性能。
  • 该方法在模型间具有泛化能力,在LLaMA 13B、GPT-3及其他模型上于多个任务中均取得优异结果。
  • 任务向量方法为ICL提供了机制性解释,表明LLMs将演示压缩为单一、可解释的向量,该向量调节模型的行为。
Figure 2: Separating $\mathcal{A}$ and $f$ . To make $\boldsymbol{\theta}$ independent of the query $x$ , we use a dummy query ( $x^{\prime}=\mbox{Plum}$ ) and use the representation of $\rightarrow$ at the $L^{th}$ layer as $\boldsymbol{\theta}$ . The vector $\boldsymbol{\theta}$ is then patched at
Figure 2: Separating $\mathcal{A}$ and $f$ . To make $\boldsymbol{\theta}$ independent of the query $x$ , we use a dummy query ( $x^{\prime}=\mbox{Plum}$ ) and use the representation of $\rightarrow$ at the $L^{th}$ layer as $\boldsymbol{\theta}$ . The vector $\boldsymbol{\theta}$ is then patched at

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。