C ontrol M ath: Controllable Data Generation Promotes Math Generalist Models (2024)

Abstract: Utilizing large language models (LLMs) for data augmentation has yielded encouraging results in mathematical reasoning. However, these approaches face constraints in problem diversity, potentially restricting them to in-domain/distribution data generation. To this end, we propose **ControlMath**, an iterative method involving an equation-generator module and two LLM-based agents. The module creates diverse equations, which the Problem-Crafter agent then transforms into math word problems. The Reverse-Agent filters and selects high-quality data, adhering to the “less is more” principle. This approach enables the generation of diverse math problems, not limited to specific domains or distributions. As a result, we collect ControlMathQA, which involves 190k math word problems. Extensive results prove that combining our dataset with in-domain datasets like GSM8K can help improve the model’s mathematical ability to generalize, leading to improved performance both within and beyond specific domains.

## introduction currently, mathematical reasoning @xcite @xcite is regarded as the one of the most challenging areas for current large language models (llms). typically, prompting-based approaches @xcite are common ways to improve the mathematical abilities of closed-source llms. these methods design different prompts for these llms to solve multi-step and complicated math problems, setting a high benchmark and demonstrating the potential of llms in tackling sophisticated mathematical problems. recently, the focus has shifted towards improving the capabilities of smaller, open-source llms figure 1 : we train llama 2-7b model @xcite with different training corpus and present results in out-of-domain/distribution datasets: gsm8k-hard @xcite , svamp-hard @xcite , dm-polynomials and probability subdatasets @xcite . figure 1 showcases the effects of in-domain data augmentation using metamath on the gsm8k dataset. metamath achieves a significant performance boost on gsm8k, increasing accuracy by over 20%. however, when tested on out-of-domain datasets like svamp-hard, dm-polynomials, and dm-probability, the model's performance drops sharply, sometimes even below the baseline trained only on gsm8k. notably, on the gsm8k-hard dataset, which only varies the distributions of the numbers, there is also a substantial decline in accuracy. this highlights that while metamath improves in-domain performance, it struggles to generalize to more diverse or challenging datasets. moreover, another critical oversight in previous approaches is the inclusion of low-quality or redundant samples in augmented datasets. although methods like metamath have significantly expanded original datasets from 14k to 400k, concerns remain about the quality and utility of all generated samples. some samples may be of low quality or redundant, failing to contribute meaningfully to the model's learning process and increasing useless training costs @xcite . this highlights the need for an effective strategy to filter out ineffective training samples, a challenge still unaddressed in mathematical reasoning. to address the above challenges, we propose a simple and iterative approach for controllable mathematical data generation, termed controlmath. the core concept is from equation to math word problem and the essence of control lies in two primary perspectives: (1) controllable equation generation: by specifying requirements such as reasoning steps, designed operators, and numerical ranges, we generate corresponding equations through an equation generation module. the frontier llm-based problem-crafter agent then creates mathematical word problems based on these equations, ensuring control over the diversity and distribution of the final set of problems. (2) adaptively efficient data selection: this is achieved through a problem rewriter-agent to ensure the effectiveness of the training samples. this agent rewrites the generated mathematical problems to create variations. both the original and rewritten problems are fed to the llm; if the llm solves both correctly, it indicates that this generated problem does not contribute to further learning and can be discarded. this approach mimics human cognitive learning, where redundant information does not enhance learning efficiency. filtering out redundant samples allows us to focus on the most benefi-cial data, enhancing overall training efficiency. the overview of our approach is presented in figure 2 . by controlling the generation and selection of training samples, our method embodies the principle of "less is more", focusing on quality over quantity to enable stronger models with smaller datasets. to prove its effectiveness, we curate a dataset-controlmathqa-comprising approximately 190k training samples. by seamlessly integrating this dataset with established gsm8k and metamath datasets, we embark on training llms. our empirical results prove the resulting generalist llms clearly show significant performance improvements in both in-domain and out-of-domain datasets, as shown in figure 1 . in general, our contributions are summarized as follows: question: a group of people went to an amusement park. 37 of them were children and 47 were adults. they split the total number of people into two groups and added 18 more people to one of the groups. this group was then divided equally among six rides. how many people rode on each ride? ## controlmath the primary motivation behind controlmath is to address the challenges of overfitting and inefficiency in training llms for mathematical reasoning tasks. to achieve this, controlmath employs a three-step approach involving two specialized agents and one python function module. in this section, we present the details of controlmath. ## experiments in this section, we first present the details of our implementation, including data generation, training settings. then we show the main results of different backbones with controlmathqa. ## conclusion in this paper, we propose a new data augmentation approach for mathematical reasoning, called controlmath. the core of this approach lies into two lines: 1) it first utilizes an equation generation module to control the distributions of the generated equations. then a probelm-crafter agent generates the math word problems based on these equations. 2) it introduces a problem-rewriter agent to help ensure the effectiveness of the generated samples, filtering out redundant ones. our approach could generate diverse problems and focus on quality over quantity to enable stronger math generalist models with smaller data. the resulting dataset, controlmathqa, could help llms obtain improvements in both in-domain and out-ofdomain datasets. future works include expanding the size of controlmathqa and exploring other strategies to select more efficient data.