[论文解读] At Which Training Stage Does Code Data Help LLMs Reasoning?
本文研究了代码数据在何种情况下最有效地增强大语言模型(LLMs)的推理能力,发现使用混合代码-文本数据进行预训练可显著提升模型的通用推理能力,而使用代码数据进行指令微调则能增强任务特定的推理能力。动态混合策略进一步提升了逐步推理的学习效果,为训练高效、具备推理能力的LLMs提供了关键洞见。
Large Language Models (LLMs) have exhibited remarkable reasoning capabilities and become the foundation of language technologies. Inspired by the great success of code data in training LLMs, we naturally wonder at which training stage introducing code data can really help LLMs reasoning. To this end, this paper systematically explores the impact of code data on LLMs at different stages. Concretely, we introduce the code data at the pre-training stage, instruction-tuning stage, and both of them, respectively. Then, the reasoning capability of LLMs is comprehensively and fairly evaluated via six reasoning tasks in five domains. We critically analyze the experimental results and provide conclusions with insights. First, pre-training LLMs with the mixture of code and text can significantly enhance LLMs' general reasoning capability almost without negative transfer on other tasks. Besides, at the instruction-tuning stage, code data endows LLMs the task-specific reasoning capability. Moreover, the dynamic mixing strategy of code and text data assists LLMs to learn reasoning capability step-by-step during training. These insights deepen the understanding of LLMs regarding reasoning ability for their application, such as scientific question answering, legal support, etc. The source code and model parameters are released at the link:~\url{https://github.com/yingweima2022/CodeLLM}.
研究动机与目标
- 确定在哪个训练阶段引入代码数据最能有效提升LLM的推理能力。
- 评估代码数据在不同领域中对通用推理和任务特定推理的影响。
- 分析代码数据是否会在非推理任务上引入负迁移或性能下降。
- 探索在训练过程中代码与文本数据动态混合策略的有效性。
- 提供开源模型和代码,以支持对具备推理能力的LLMs的进一步研究。
提出的方法
- 在纯文本数据与代码-文本混合数据上进行LLM的预训练,以评估通用推理能力的提升效果。
- 使用仅文本数据与文本-代码混合数据进行指令微调,以评估任务特定推理能力的改进情况。
- 采用一种动态混合策略,在训练过程中逐步增加代码数据的比例,以模拟逐步推理能力的学习过程。
- 在五个领域(逻辑、代码、法律、科学和类比推理)的六个推理任务上评估模型表现。
- 通过使用相同模型架构和训练目标的受控实验,确保比较的公平性。
- 发布训练好的模型权重和代码,以支持可复现性与进一步研究。
实验结果
研究问题
- RQ1在预训练、指令微调或两者阶段中,代码数据在哪一阶段最能有效提升LLM的推理能力?
- RQ2在预训练阶段引入代码数据是否会导致非推理任务上的负迁移?
- RQ3在指令微调阶段引入代码数据能否提升模型在任务特定推理基准上的表现?
- RQ4在训练过程中,代码与文本数据的动态混合策略如何影响模型的推理能力?
- RQ5代码数据在不降低常识性或理解性任务表现的前提下,能在多大程度上提升推理能力?
主要发现
- 使用代码与文本混合数据进行预训练,能显著提升模型在多个领域中的通用推理能力,且对其他任务的影响极小甚至没有负迁移。
- 使用代码数据进行指令微调可提升任务特定推理能力,尤其在代码和逻辑推理任务中表现更优,有助于更好地遵循指令。
- 在训练过程中采用代码与文本数据的动态混合策略,有助于逐步学习推理能力,从而提升模型的泛化能力。
- 在非推理任务(如自然语言推理和阅读理解,例如DuReader)中,引入代码数据几乎不会产生负面影响,部分任务甚至出现轻微性能提升。
- 在DuReader任务中,引入代码数据后性能略有下降,可能是因为模型在代码与自然语言模式之间产生混淆,提示需要更大规模的训练以解决此问题。
- 本研究证明,代码数据是提升推理能力的关键因素,若在预训练和指令微调阶段战略性地引入,可实现最佳效果。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。