LLaMoCo: Instruction Tuning of Large Language Models for Optimization Code Generation

Zeyuan Ma,Hongshu Guo,Jiacheng Chen,Guojun Peng,Zhiguang Cao,Yining Ma,Yue-Jiao Gong
2024-03-05
Abstract:Recent research explores optimization using large language models (LLMs) by either iteratively seeking next-step solutions from LLMs or directly prompting LLMs for an optimizer. However, these approaches exhibit inherent limitations, including low operational efficiency, high sensitivity to prompt design, and a lack of domain-specific knowledge. We introduce LLaMoCo, the first instruction-tuning framework designed to adapt LLMs for solving optimization problems in a code-to-code manner. Specifically, we establish a comprehensive instruction set containing well-described problem prompts and effective optimization codes. We then develop a novel two-phase learning strategy that incorporates a contrastive learning-based warm-up procedure before the instruction-tuning phase to enhance the convergence behavior during model fine-tuning. The experiment results demonstrate that a CodeGen (350M) model fine-tuned by our LLaMoCo achieves superior optimization performance compared to GPT-4 Turbo and the other competitors across both synthetic and realistic problem sets. The fine-tuned model and the usage instructions are available at https://anonymous.4open.science/r/LLaMoCo-722A.
Optimization and Control,Artificial Intelligence,Computation and Language,Machine Learning,Neural and Evolutionary Computing,Software Engineering
What problem does this paper attempt to address?
The problem that this paper attempts to solve is how to use large - scale language models (LLMs) to generate efficient optimizer code for specific optimization problems. Existing methods usually solve optimization problems by iteratively requesting solutions from LLMs or directly obtaining optimization programs from LLMs, but these methods have limitations such as low operational efficiency, high sensitivity to prompt design, and lack of domain - specific knowledge. To solve these problems, the paper proposes LLaMoCo, which is the first instruction - tuning framework for adapting LLMs to solve optimization problems in a code - to - code manner. LLaMoCo builds a comprehensive instruction set containing well - described problem prompts and effective optimization code, and develops a novel two - stage learning strategy, that is, a pre - warming process based on contrastive learning before the instruction - tuning stage to enhance the convergence behavior during model fine - tuning. Experimental results show that the CodeGen (350M) model tuned by LLaMoCo has better optimization performance on synthetic and real - world problem sets than GPT - 4 Turbo and other competitors.