揭示少样本提示如何通过加法组合与注意力重加权构建模型函数向量
How Few-Shot Examples Add Up: A Causal Decomposition of Function Vectors in In-Context Learning

- 将少样本示例的函数向量线性叠加,形成整体任务方向
- 上下文影响注意力分配,使更清晰的示例主导最终决策
- 发现查询-键对齐是提升函数向量质量的关键机制
在上下文学习(ICL)中,模型能仅凭少量示例完成新任务,但其内在机制仍不清晰。本文发现,n-shot 函数向量(FV)可被各示例的子函数向量线性近似,表明示例贡献具有可加性和可组合性。进一步发现,模型会根据已有示例动态调整注意力,优先关注信息量高、歧义低的示例。通过因果分解,分离出查询-键路由与值更新的作用,结果显示:查询-键对齐在模糊场景下对函数向量质量提升最为稳定;而值传递的影响则更为多样。该研究统一了线性叠加与上下文感知重加权,提供了可验证的少样本提示机制解释。
原文摘要 · Abstract (English)
In-context learning (ICL) excels at new tasks from minimal examples, yet we still lack a mechanistic explanation of how few-shot prompts shape a model's function vector (FV)--a causal activation direction that drives task behavior on the ICL query. Across tasks and models, an $n$-shot FV is well-approximated by a linear combination of example-level sub-FVs, suggesting additive and composable contributions from individual demonstrations. Beyond additivity, we show that models contextualize individual examples' representations based on prior examples to adaptively reweight which demonstrations dominate the FV: attention shifts toward examples that are more informative and less ambiguous under the context. Finally, a causal decomposition separates Query-Key routing from Value updates, finding that contextualization's most consistent contributions to FV quality arise from Query-Key alignment--particularly in ambiguous settings--while Value-mediated effects are more heterogeneous. Together, these results unify additive superposition with context-dependent attention reweighting into a mechanistic, testable account of how few-shot prompts implement tasks.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。