Intermediate Fine-Tuning Improves Mathematical Reasoning in Smaller Models

Neeraj Gangwar, Suma Bhat, Nickvash KaniMATH-AI @ NeurIPS 2024

TL;DR

This paper introduces "intermediate fine-tuning" as a strategy to boost the mathematical reasoning capabilities of smaller language models. By first fine-tuning a model on a synthetically generated arithmetic dataset before training it on a dedicated reasoning dataset, they achieve significant accuracy improvements without sacrificing performance on other tasks.

What Problem Does This Paper Address?

Large language models (LLMs) have shown remarkable proficiency in complex reasoning tasks, including mathematical problem-solving. However, adapting smaller models to achieve similar performance has been a persistent challenge. This is partly due to the limited size and scope of existing mathematical reasoning datasets, which often lack sufficient examples to capture the nuances of mathematical logic. While knowledge distillation from larger models and data augmentation techniques have shown promise, this paper explores a different avenue: leveraging a related, but simpler, task as a stepping stone.

Methods

The core innovation here is intermediate fine-tuning. The authors propose a two-stage fine-tuning process:

  1. Intermediate Fine-Tuning: The model is first trained on a synthetically generated arithmetic dataset. This dataset is created programmatically, making it resource-efficient to generate. It includes basic arithmetic operations, fractions, and percentages, with operand sizes limited to avoid complexity beyond what's needed for typical reasoning tasks.
  2. Downstream Fine-Tuning: After the intermediate stage, the model is then fine-tuned on a mathematical reasoning dataset (like GSM8k).

This approach is framed within the context of transfer learning, where intermediate fine-tuning aims to bridge the gap between a model's general pre-trained knowledge and the specific demands of the target reasoning task.

Datasets

  • Arithmetic Dataset: Programmatically generated, containing approximately 1.3 million examples of basic arithmetic, fractions, and percentages. This dataset is designed to be easily created and to cover foundational computational skills.
  • GSM8k (Original): The standard GSM8k dataset, used for the primary reasoning task. The authors use a subset of 6961 examples for training.
  • GSM8k (Distilled): An expanded version of GSM8k, created by using Mistral-7B to generate multiple solutions for each question and then filtering for correctness. This dataset contains about 175,000 examples.
  • Evaluation Datasets:
    • MultiArith: Focuses on basic arithmetic operations.
  • ASDiv: Features diverse language usage patterns in word problems.
  • SVAMP: Includes problems with varying structures to prevent heuristic-based solutions.

Key Insights and Ideas

  • Arithmetic as a Foundation: The paper strongly suggests that mastering basic arithmetic operations, even through synthetic data, provides a crucial foundation that significantly aids performance on more complex mathematical reasoning tasks.
  • Programmatic Data Generation is Key: The ability to generate a high-quality intermediate dataset programmatically is a major advantage, circumventing the costly manual effort typically required for dataset curation in NLP.
  • No Harm to Out-of-Domain Generalization: A critical finding is that intermediate fine-tuning on arithmetic does not negatively impact performance on other mathematical reasoning datasets (MultiArith, ASDiv, SVAMP). In fact, it seems to improve out-of-domain generalization.
  • When to Stop Intermediate Training is Tricky: While intermediate fine-tuning is beneficial, the paper notes that simply achieving high accuracy on the arithmetic task doesn't guarantee the best performance on the reasoning task. Deciding the optimal stopping point for intermediate training remains an open challenge.

Key Results

The paper reports significant accuracy improvements on the GSM8k test set using intermediate fine-tuning:

  • GSM8k (Original) Training Set: An average improvement of 6.3% with greedy decoding.
  • GSM8k (Distilled) Training Set: An average improvement of 14.2% with greedy decoding.

These gains were observed for both FlanT5-Base and FlanT5-Large models. Importantly, the models fine-tuned with the intermediate step showed better performance on out-of-domain datasets like MultiArith, ASDiv, and SVAMP compared to models fine-tuned directly on GSM8k.

Limitations and Future Work

The authors acknowledge several limitations:

  • Determining Optimal Intermediate Training: It's challenging to pinpoint the exact number of epochs for intermediate fine-tuning or which checkpoint to select for the subsequent reasoning task fine-tuning.
  • Task Specificity: While arithmetic is effective, identifying other suitable intermediate tasks or programmatically generating datasets for them remains an area for exploration.
  • Dataset Scope: The current evaluation is primarily on GSM8k. Extending the approach to other mathematical reasoning datasets like MATH is suggested.

Future work could focus on developing better heuristics for selecting intermediate training checkpoints and exploring a wider range of intermediate tasks to further enhance the applicability of this technique.

Summary updated

BibTeX
@inproceedings{gangwar2024intermediate,
  author = {Neeraj Gangwar and Suma Bhat and Nickvash Kani},
  title = {{Intermediate Fine-Tuning Improves Mathematical Reasoning in Smaller Models}},
  booktitle = {MATH-AI @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=wzaMGXiOEy},
}
Figure