arXiv:2410.06735cs.CLcs.AI2024-10EMNLP被引 7

用编程语言训练大模型,逻辑推理能力更强

Which Programming Language and What Features at Pre-training Stage Affect Downstream Logical Inference Performance?

  • 从头训练模型,对比10种编程语言与自然语言的预训练效果
  • 编程语言训练的模型在逻辑任务上显著优于自然语言训练组
  • 程序语法树深度越高,模型逻辑推理能力越强,适合研究基础能力构建

近期大型语言模型在数学与逻辑推理任务中展现出卓越泛化能力。已有研究指出,使用编程语言数据预训练的模型具备较强的数学与推理能力,但这一因果关系尚未经过严格验证。本研究旨在检验预训练阶段使用的编程语言及其特征对下游逻辑推理性能的影响。我们基于十种编程语言(如Python、C、Java)和三种自然语言数据集(Wikipedia、Fineweb、C4),在相同条件下从头训练解码器型语言模型。随后,在无需常识或世界知识的逻辑推理任务FLD和bAbi上以少样本上下文学习方式评估模型表现。结果表明,几乎所有使用编程语言训练的模型均显著优于自然语言训练模型,说明编程语言中蕴含能激发逻辑推理能力的因素。此外,编程语言训练模型在指令遵循方面也表现更优。进一步分析显示,程序解析后生成的抽象语法树深度与逻辑推理性能正相关。这些发现为大模型获取基础推理能力的预训练要素提供了重要启示。

原文摘要 · Abstract (English)

Recent large language models (LLMs) have demonstrated remarkable generalization abilities in mathematics and logical reasoning tasks. Prior research indicates that LLMs pre-trained with programming language data exhibit high mathematical and reasoning abilities; however, this causal relationship has not been rigorously tested. Our research aims to verify which programming languages and features during pre-training affect logical inference performance. Specifically, we pre-trained decoder-based language models from scratch using datasets from ten programming languages (e.g., Python, C, Java) and three natural language datasets (Wikipedia, Fineweb, C4) under identical conditions. Thereafter, we evaluated the trained models in a few-shot in-context learning setting on logical reasoning tasks: FLD and bAbi, which do not require commonsense or world knowledge. The results demonstrate that nearly all models trained with programming languages consistently outperform those trained with natural languages, indicating that programming languages contain factors that elicit logic inference performance. In addition, we found that models trained with programming languages exhibit a better ability to follow instructions compared to those trained with natural languages. Further analysis reveals that the depth of Abstract Syntax Trees representing parsed results of programs also affects logical reasoning performance. These findings will offer insights into the essential elements of pre-training for acquiring the foundational abilities of LLMs.

逻辑推理编程语言预训练

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