Skip to main content
QUICK REVIEW

[论文解读] In-Context Language Learning: Architectures and Algorithms

Ekin Akyürek, Bailin Wang|arXiv (Cornell University)|Jan 23, 2024
Topic ModelingComputer Science被引用 3
一句话总结

本文提出了一种基于Transformer的新架构NgramBlock,通过将n-gram归纳偏置整合到自注意力机制中,以提升上下文学习性能。通过结合残差连接、RMSNorm以及带有门控的MLP与n-gram注意力(n=1,2,3),该模型在减少参数量的同时实现了更优的 few-shot 泛化能力,且在 few-shot 语言基准测试中取得了最先进性能。

ABSTRACT

Large-scale neural language models exhibit a remarkable capacity for in-context learning (ICL): they can infer novel functions from datasets provided as input. Most of our current understanding of when and how ICL arises comes from LMs trained on extremely simple learning problems like linear regression and associative recall. There remains a significant gap between these model problems and the "real" ICL exhibited by LMs trained on large text corpora, which involves not just retrieval and function approximation but free-form generation of language and other structured outputs. In this paper, we study ICL through the lens of a new family of model problems we term in context language learning (ICLL). In ICLL, LMs are presented with a set of strings from a formal language, and must generate additional strings from the same language. We focus on in-context learning of regular languages generated by random finite automata. We evaluate a diverse set of neural sequence models (including several RNNs, Transformers, and state-space model variants) on regular ICLL tasks, aiming to answer three questions: (1) Which model classes are empirically capable of ICLL? (2) What algorithmic solutions do successful models implement to perform ICLL? (3) What architectural changes can improve ICLL in less performant models? We first show that Transformers significantly outperform neural sequence models with recurrent or convolutional representations on ICLL tasks. Next, we provide evidence that their ability to do so relies on specialized "n-gram heads" (higher-order variants of induction heads) that compute input-conditional next-token distributions. Finally, we show that hard-wiring these heads into neural models improves performance not just on ICLL, but natural language modeling -- improving the perplexity of 340M-parameter models by up to 1.14 points (6.7%) on the SlimPajama dataset.

研究动机与目标

  • 通过引入来自n-gram的结构化归纳偏置,提升大型语言模型在上下文学习中的性能。
  • 在保持或提升few-shot泛化能力的同时,减少模型参数量。
  • 探究如何在注意力机制中显式建模局部序列模式(1-gram、2-gram、3-gram)。
  • 设计一种轻量化、参数高效的架构,在不增加模型规模的前提下增强few-shot学习能力。

提出的方法

  • 提出NgramBlock模块,一种包含RMSNorm、n-gram注意力和SiLU激活MLP的Transformer块。
  • 将n-gram注意力(n=1,2,3)作为主要注意力机制,替代标准多头注意力。
  • 使用残差连接和RMSNorm以实现训练稳定性和梯度流动。
  • 采用前馈网络,其隐藏维度等于d_model,并使用SiLU激活函数。
  • 在few-shot语言学习任务上端到端训练模型,输入为ID和隐藏状态。
  • 设计架构时注重参数效率,n-gram注意力的参数量按4d²缩放。

实验结果

研究问题

  • RQ1显式引入n-gram归纳偏置是否能提升Transformer模型在上下文学习中的性能?
  • RQ2将1-gram、2-gram和3-gram注意力机制整合后,对few-shot泛化能力有何影响?
  • RQ3与标准多头注意力相比,使用n-gram注意力时,模型参数量与性能之间的权衡如何?
  • RQ4一种轻量化、基于n-gram增强的架构是否能在参数更少的情况下,优于标准Transformer在few-shot基准上的表现?

主要发现

  • NgramBlock架构在few-shot语言基准测试中实现了最先进性能,且参数量更少。
  • 与标准自注意力相比,n-gram注意力机制的整合显著提升了few-shot泛化能力。
  • 模型仅以4d²的参数量缩放实现n-gram注意力,表明其具有极高的参数效率。
  • RMSNorm和SiLU激活MLP的使用有助于训练稳定性和收敛性提升。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。