[论文解读] Large Language Models Are Latent Variable Models: Explaining and Finding Good Demonstrations for In-Context Learning
本文提出一个用于上下文内学习的贝叶斯隐变量框架,使用小型语言模型学习任务概念并选择示例以迁移到更大型的语言模型,在八个 NLP 数据集和 GSM8K 上得到验证。
In recent years, pre-trained large language models (LLMs) have demonstrated remarkable efficiency in achieving an inference-time few-shot learning capability known as in-context learning. However, existing literature has highlighted the sensitivity of this capability to the selection of few-shot demonstrations. Current understandings of the underlying mechanisms by which this capability arises from regular language model pretraining objectives remain disconnected from the real-world LLMs. This study aims to examine the in-context learning phenomenon through a Bayesian lens, viewing real-world LLMs as latent variable models. On this premise, we propose an algorithm to select optimal demonstrations from a set of annotated data with a small LM, and then directly generalize the selected demonstrations to larger LMs. We demonstrate significant improvement over baselines, averaged over eight GPT models on eight real-world text classification datasets. We also demonstrate the real-world usefulness of our algorithm on GSM8K, a math word problem dataset. Our empirical findings support our hypothesis that LLMs implicitly infer a latent variable containing task information.
研究动机与目标
- 在现实世界的LLM中,将上下文内学习作为对潜在任务/概念变量的推断进行动机阐述。
- 提出一个实用的两步算法:用小型LM进行潜在概念学习,并为更大型LLM进行示例选择。
- 在贝叶斯最优框架下对示例选择进行理论证明并在多数据集和模型上进行实证验证。
- 展示所学概念标记和示例在不同大型语言模型之间的可迁移性。
提出的方法
- 用编码任务和格式信息的潜在变量 theta 来建模文本生成。
- 每个任务引入 c 个新的概念标记以表示 theta,并仅微调它们的嵌入其余模型参数被冻结。
- 将示例选择表述为最大化后验概率 P(theta | demonstrations, test input) 的目标,并用可处理的目标函数进行近似。
- 通过提示微调训练概念标记以最小化交叉熵损失,使 P(Y|theta,X) 与数据对齐。
- 通过计算并对其推断的 theta 概概率进行排名,选取前 k 个示例,然后在更大型的LLMs中使用相同的示例。
- 示例在小型LM(如 GPT2-large)上学习/调优,并在不再进行再训练的情况下迁移到更大型的LM。
实验结果
研究问题
- RQ1一个捕捉任务和格式信息的潜在变量 theta 是否能够解释现实世界的LLM 中的上下文内学习?
- RQ2用小型LM学习任务特定的概念标记是否能实现对更大型LLM 有效的示例选择并实现迁移?
- RQ3基于推断 theta 的示例选择与基线中的均匀或基于相似性的做法在多样任务中有何差异?
- RQ4所提出的方法在模型规模和任务领域上是否鲁棒,包括像 GSM8K 这样的复杂任务?
主要发现
- 基于学习的潜在概念的示例选择显著提升了八个NLP数据集以及多种GPT家族模型的上下文内学习效果。
- 用小型LM学习任务概念标记使得示例可以迁移到更大规模的LLM,而无需重新训练大型模型。
- 该方法在8个数据集上优于均匀和基于相似性的基线,显示出相对于基线的平均相对改进(论文中报告为 12.5%)。
- 在GSM8K上,该方法也取得了强劲结果,且当示例是从潜在概念中学习时,大型模型获益更多。
- 用 GPT2-large 学习的示例对其他模型(包括 GPT-3 变体、LLaMA、OPT 等)具有良好的泛化能力,表明跨模型的可迁移性。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。