arXiv:2412.12276cs.CLcs.AI2024-12ICML被引 9

揭示大模型如何通过编码任务向量实现上下文学习

Emergence and Effectiveness of Task Vectors in In-Context Learning: An Encoder Decoder Perspective

  • 用编码-解码框架分析模型如何生成任务向量
  • 任务编码质量直接预测上下文学习表现
  • 早层微调比晚层更有效提升任务编码能力

自回归Transformer通过上下文学习(ICL)展现自适应学习能力,但其机制尚不明确。已有研究指出模型在表征中以向量形式表示ICL任务。本文基于编码-解码框架,研究模型在预训练过程中如何形成任务向量,并探究其编码质量对ICL性能的预测作用。在合成ICL任务上,我们分析小型Transformer的训练动态,发现任务编码与解码能力同步涌现:当模型将不同潜在任务(如“找出句子中的第一个名词”)编码为可区分的表征时,也同时构建出条件解码算法并提升ICL表现。该现象在不同规模的预训练模型(Gemma-2 2B/9B/27B、Llama-3.1 8B/70B)及OLMo-7B的预训练过程均得到验证。进一步发现,从表征中推断的任务编码质量可有效预测ICL性能,且令人意外的是,微调早期层比微调后期层更能提升任务编码与性能。这些实证发现为理解大模型成功与失败模式提供了新视角。

原文摘要 · Abstract (English)

Autoregressive transformers exhibit adaptive learning through in-context learning (ICL), which begs the question of how. Prior works have shown that transformers represent the ICL tasks as vectors in their representations. In this paper, we leverage the encoding-decoding framework to study how transformers form task vectors during pretraining and how their task encoding quality predicts ICL task performance. On synthetic ICL tasks, we analyze the training dynamics of a small transformer and report the coupled emergence of task encoding and decoding. As the model learns to encode different latent tasks (e.g., "Finding the first noun in a sentence.") into distinct, separable representations, it concurrently builds conditional decoding algorithms and improves its ICL performance. We validate this phenomenon across pretrained models of varying scales (Gemma-2 2B/9B/27B, Llama-3.1 8B/70B) and over the course of pretraining in OLMo-7B. Further, we demonstrate that the quality of task encoding inferred from representations predicts ICL performance, and that, surprisingly, finetuning the earlier layers can improve the task encoding and performance more than finetuning the latter layers. Our empirical insights shed light into better understanding the success and failure modes of large language models via their representations.

上下文学习任务向量模型机制预训练

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。