arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2405.14660cs.LGcs.AIcs.CL
收藏

隐式上下文学习

Implicit In-context Learning

Rutgers University(罗格斯大学)

Zhuowei Li, Zihao Xu, Ligong Han, Yunhe Gao, Song Wen, Di Liu, Hao Wang, Dimitris N. Metaxas

AI总结:

提出隐式上下文学习(I2CL),通过上下文向量注入残差流,以零样本推理成本实现少样本性能,并增强任务相似性检测与迁移学习。

摘要:

上下文学习(ICL)使大型语言模型(LLMs)能够在推理时通过前缀几个演示示例快速适应未见过的任务。尽管其具有多功能性,但与零样本学习相比,ICL 产生了大量的计算和内存开销,并且对演示示例的选择和顺序敏感。在这项工作中,我们引入了隐式上下文学习(I2CL),一种创新的范式,将 ICL 的推理成本降低到零样本学习的水平,同时信息损失最小。I2CL 的操作方式是:首先从演示示例中生成一个压缩的向量表示,即上下文向量;然后通过将上下文向量和查询激活的线性组合注入回模型的残差流中,进行推理时干预。在三个模型架构上的九个真实世界任务上的实证评估表明,I2CL 在零样本推理成本下实现了少样本级别的性能,并且对演示示例的变化表现出鲁棒性。此外,I2CL 促进了任务标识的新表示,增强了任务相似性检测并促进了有效的迁移学习。我们还对 I2CL 进行了全面的分析和消融研究,提供了对其内部机制的更深入见解。代码可在 https://github.com/LzVv123456/I2CL 获取。

英文摘要:

In-context Learning (ICL) empowers large language models (LLMs) to swiftly adapt to unseen tasks at inference-time by prefixing a few demonstration examples before queries. Despite its versatility, ICL incurs substantial computational and memory overheads compared to zero-shot learning and is sensitive to the selection and order of demonstration examples. In this work, we introduce Implicit In-context Learning (I2CL), an innovative paradigm that reduces the inference cost of ICL to that of zero-shot learning with minimal information loss. I2CL operates by first generating a condensed vector representation, namely a context vector, extracted from the demonstration examples. It then conducts an inference-time intervention through injecting a linear combination of the context vector and query activations back into the model's residual streams. Empirical evaluation on nine real-world tasks across three model architectures demonstrates that I2CL achieves few-shot level performance at zero-shot inference cost, and it exhibits robustness against variations in demonstration examples. Furthermore, I2CL facilitates a novel representation of task-ids, enhancing task similarity detection and fostering effective transfer learning. We also perform a comprehensive analysis and ablation study on I2CL, offering deeper insights into its internal mechanisms. Code is available at https://github.com/LzVv123456/I2CL.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑