arXiv:2505.00661cs.CLcs.AI2025-05被引 55

对比微调与上下文学习,发现前者在推理泛化上更弱,后者更灵活。

On the generalization of language models from in-context learning and finetuning: a controlled study

  • 用新数据集控制测试,隔离预训练知识,对比微调与上下文学习的泛化能力。
  • 在数据匹配条件下,上下文学习比微调更能灵活处理关系反转和逻辑推理。
  • 提出在微调数据中加入上下文推理痕迹,显著提升模型泛化性能。

大型语言模型表现出令人兴奋的能力,但在微调后可能展现出异常狭窄的泛化能力。例如,它们可能无法对训练过的关联进行简单反转,或基于已有信息做出基本逻辑推断。这些在微调中未能泛化事实信息的失败,会严重限制模型的推理能力。相比之下,语言模型的上下文学习(ICL)展现出不同的归纳偏置和演绎推理能力。本文探索了基于上下文学习与微调的学习在泛化和演绎推理上的差异。为此,我们构建了若干新型数据集,用于评估并提升模型从新数据中对事实信息进行泛化的潜力。这些数据集设计为清晰的泛化测试,通过将数据集中的知识与预训练知识分离。我们向预训练的大模型暴露这些数据集的受控子集——通过ICL或微调——并在需要不同类型的泛化任务的测试集上评估其表现。结果表明,在数据匹配设置下,上下文学习在多种推理类型上比微调更具灵活性(尽管我们也发现一些对先前研究的修正,如在更大知识结构中微调能泛化到关系反转)。基于此,我们提出一种方法:在微调数据中添加上下文推理痕迹,以增强微调的泛化能力。实验显示该方法在多个数据集分片和其他基准上均提升了泛化效果。研究结果对理解语言模型不同学习模式带来的泛化特性具有意义,并为实际提升模型性能提供了路径。

原文摘要 · Abstract (English)

Large language models exhibit exciting capabilities, yet can show surprisingly narrow generalization from finetuning. E.g. they can fail to generalize to simple reversals of relations they are trained on, or fail to make simple logical deductions based on trained information. These failures to generalize factual information from fine-tuning can significantly hinder the reasoning capabilities of these models. On the other hand, language models' in-context learning (ICL) shows different inductive biases and deductive reasoning capabilities. Here, we explore these differences in generalization and deductive reasoning between in-context- and fine-tuning-based learning. To do so, we constructed several novel datasets to evaluate and improve models' abilities to make generalizations over factual information from novel data. These datasets are designed to create clean tests of generalization, by isolating the knowledge in the dataset from that in pretraining. We expose pretrained large models to controlled subsets of the information in these datasets -- either through ICL or fine-tuning -- and evaluate their performance on test sets that require various types of generalization. We find overall that in data-matched settings, ICL can generalize several types of inferences more flexibly than fine-tuning (though we also find some qualifications of prior findings, such as cases when fine-tuning can generalize to reversals embedded in a larger structure of knowledge). We build on these findings to propose a method to enable improved generalization from fine-tuning: adding in-context reasoning traces to finetuning data. We show that this method improves generalization across various splits of our datasets and other benchmarks. Our results have implications for understanding the generalization afforded by different modes of learning in language models, and practically improving their performance.

语言模型泛化能力上下文学习微调

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