Training LLM s for Optimization Modeling via Iterative Data Synthesis and Structured Validation (2025)

Abstract: Large Language Models (LLMs) have revolutionized various domains but encounter substantial challenges in tackling optimization modeling tasks for Operations Research (OR), particularly when dealing with complex problem. In this work, we propose Step-Opt-Instruct, a framework that augments existing datasets and generates high-quality fine-tuning data tailored to optimization modeling. Step-Opt-Instruct employs iterative problem generation to systematically increase problem complexity and stepwise validation to rigorously verify data, preventing error propagation and ensuring the quality of the generated dataset. Leveraging this framework, we fine-tune open-source LLMs, including LLaMA-3-8B and Mistral-7B, to develop Step-Opt—a model that achieves state-of-the-art performance on benchmarks such as NL4OPT, MAMO, and IndustryOR. Extensive experiments demonstrate the superior performance of Step-Opt, especially in addressing complex OR tasks, with a notable 17.01% improvement in micro average accuracy on difficult problems. These findings highlight the effectiveness of combining structured validation with gradual problem refinement to advance the automation of decision-making processes using LLMs. The code and dataset are available at https://github.com/samwu-learn/Step.

## introduction operations research (or) is a valuable discipline for addressing complex decision-making problems, widely applied in fields such as economics, engineering, and computer science @xcite @xcite . effective implementation of or involves two essential steps: modeling real-world problems and solving them. despite significant advancements in solution techniques and the development of more efficient solvers, constructing appropriate models remains a challenge. such a task requires formulating natural language descriptions into mathematical models, which is labor-intensive and demands domain-specific expertise as well as a deep understanding of modeling methodologies. these requirements greatly restrict the broader application of or, particularly in real-world scenarios. recent developments in large language models (llms) have enhanced the feasibility of automating optimization modeling. approaches like chainof-experts (coe) @xcite and @xcite employ well-crafted prompts and multi-agent systems to enhance the construction of optimization models and corresponding programs. however, these approaches rely on general-purpose llms, which, though powerful, are not specifically tailored for or, limiting their effectiveness in addressing specialized challenges. additionally, the need to upload sensitive data poses additional privacy concerns. in response, orlm @xcite presents an alternative by fine-tuning open-source llms using a dataset of 30k examples generated from 686 industry cases. while this improves the model's performance for or modeling, orlm remains semi-automated, requiring significant manual postprocessing to achieve satisfactory results. moreover, its prompt design lacks the precision needed to manage problem complexity and diversity, resulting in suboptimal outputs. furthermore, modeling errors are not identified in real-time, allowing inaccuracies to persist and propagate. while rule-based post-processing can address minor errors, it often fails to rectify deeper logical and structural issues, further compromising data quality. utilizing high-quality training data is vital for improving the modeling capabilities of llms. however, current methods not only rely heavily on manual post-processing but also struggle to ensure data reliability. to address these limitations, we propose an approach from two primary perspectives. first, we enhance the prompt design and introduce an iterative problem generation, as shown in figure 1 . this method incrementally increases the complexity and scope of the problems, allowing the dataset to retain varying levels of difficulty and breadth. this diversity plays a crucial role in improving the model's generalization capabilities, as wizardlm @xcite suggested. second, we incorporate a stepwise validation mechanism that performs real-time checks throughout the generation process, effectively filtering out low-quality or erroneous data. this prevents errors from entering and propagating through the seed dataset. we refer to this framework as step-opt-instruct. our framework eliminates the need for post-processing, enabling fully automated generation while reducing api costs by utilizing only high-quality data for future iterations. ## method this section outlines the proposed framework. as depicted in figure 2 , it comprises two primary components: generators and a stepwise validation mechanism. the details of the generators are provided in sec. 3.2, while the stepwise validation mechanism is detailed in sec. 3.3.