[Paper Review] At Which Training Stage Does Code Data Help LLMs Reasoning?
This paper investigates when code data most effectively enhances reasoning in large language models (LLMs), finding that pre-training with mixed code-text data significantly boosts general reasoning ability, while instruction-tuning with code data enhances task-specific reasoning. A dynamic mixing strategy further improves step-by-step reasoning learning, offering key insights for training efficient, reasoning-capable 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}.
Motivation & Objective
- To determine at which training stage code data most effectively improves LLM reasoning capabilities.
- To evaluate the impact of code data on both general and task-specific reasoning across diverse domains.
- To analyze whether code data introduces negative transfer or performance degradation on non-reasoning tasks.
- To explore the effectiveness of dynamic mixing strategies between code and text data during training.
- To provide open-source models and code to support further research in reasoning-capable LLMs.
Proposed method
- Pre-training LLMs on pure text data versus a mixture of code and text data to assess general reasoning gains.
- Instruction-tuning models using only text data versus text-code mixed data to evaluate task-specific reasoning improvements.
- Applying a dynamic mixing strategy that gradually increases code data proportion during training to simulate step-by-step reasoning learning.
- Evaluating models across six reasoning tasks in five domains: logical, code, legal, scientific, and analogical reasoning.
- Conducting controlled experiments with identical model architectures and training objectives to ensure fair comparison.
- Releasing trained model weights and code to enable reproducibility and further research.
Experimental results
Research questions
- RQ1At which training stage—pre-training, instruction-tuning, or both—does code data most effectively improve LLM reasoning?
- RQ2Does introducing code data during pre-training lead to negative transfer on non-reasoning tasks?
- RQ3Can code data in the instruction-tuning phase enhance model performance on task-specific reasoning benchmarks?
- RQ4How does a dynamic mixing strategy of code and text data affect reasoning capability during training?
- RQ5To what extent does code data improve reasoning without degrading performance on common-sense or comprehension tasks?
Key findings
- Pre-training with a mixture of code and text data significantly enhances general reasoning capability across multiple domains, with minimal to no negative transfer on other tasks.
- Instruction-tuning with code data improves task-specific reasoning, particularly in code and logical reasoning tasks, enabling better instruction following.
- The dynamic mixing strategy of code and text data during training facilitates step-by-step learning of reasoning abilities, improving model generalization.
- On non-reasoning tasks such as NLI and reading comprehension (e.g., DuReader), code data introduction has little to no negative impact, with some tasks showing slight performance gains.
- In the DuReader task, performance slightly decreased when code data was introduced, possibly due to model confusion between code and natural language patterns, suggesting a need for larger-scale training to resolve.
- The study demonstrates that code data is a critical component for reasoning enhancement, with optimal impact when strategically introduced at both pre-training and instruction-tuning stages.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.