Add library_name and paper metadata

#1
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +47 -126
README.md CHANGED
@@ -1,180 +1,104 @@
1
  ---
2
- license: mit
 
3
  language:
4
  - en
 
5
  metrics:
6
  - accuracy
7
- base_model:
8
- - Qwen/Qwen2.5-32B-Instruct
9
  pipeline_tag: text-generation
 
10
  tags:
11
  - optimization
 
12
  ---
13
 
14
  <h2 align="center"> Solver-Informed RL: Grounding Large Language Models for Authentic Optimization Modeling</h2>
15
  <p align="center">
16
- <!-- Yitian Chen<sup>*</sup>, Jingfan Xia<sup>*</sup>, Siyu Shao<sup></sup>, Dongdong Ge<sup>†</sup>, Yinyu Ye
17
- <br>
18
- <div align='center'>
19
- <sup>*</sup>Equal Contribution, <sup>†</sup>Corresponding Authors
20
- </div>
21
- <p align="center">
22
- <b>Cardinal Operations, China</b><br>
23
- <b>Shanghai University of Finance and Economics</b><br>
24
- <b>The University of Hong Kong</b><br>
25
- <b>Antai School of Economics and Management, Shanghai Jiao Tong University</b><br>
26
- <b>Department of Management Science and Engineering, Stanford University</b>
27
- </p> -->
28
  <p align="center" style="white-space: nowrap;">
29
  <a href="https://arxiv.org/abs/2505.11792" style="display: inline-block;"><img src='https://img.shields.io/badge/Paper-SIRL-red'></a>
30
- <a href="[https://huggingface.co/chenyitian-shanshu/SIRL](https://huggingface.co/chenyitian-shanshu/SIRL)" style="display: inline-block;"><img src='https://img.shields.io/badge/Model-%F0%9F%A4%97%20HuggingFace-yellow'></a>
31
- <a href="[https://modelscope.cn/models/oneday88/SIRL-7B](https://modelscope.cn/models/oneday88/SIRL-7B)" style="display: inline-block;"><img src="https://img.shields.io/static/v1?label=Model&message=ModeScope&color=green"></a>
32
- <a href="[https://github.com/Cardinal-Operations/SIRL](https://github.com/Cardinal-Operations/SIRL)" style="display: inline-block;"><img src='https://img.shields.io/badge/Github-SIRL-blue'></a>
33
  </p>
34
  </p>
35
 
 
 
36
  ## Updates
37
 
38
  - **2025.09.19** - [Our paper](https://neurips.cc/virtual/2025/poster/119660) has been accepted for a poster presentation at NeurIPS 2025! 🔥
39
- - **2025.09.28** - [SIRL-Qwen2.5-32B-COPT](https://huggingface.co/chenyitian-shanshu/SIRL-COPT32B), which leverages the COPT optimization solver, is publicly available on Hugging Face and ModelScope. This model integrates the COPT solver and achieves performance comparable to [SIRL-Qwen2.5-32B-Gurobi](https://huggingface.co/chenyitian-shanshu/SIRL-Gurobi32B) across all optimization benchmarks.
40
- - **2025.09.09** - [SIRL-Qwen2.5-32B-Gurobi](https://huggingface.co/chenyitian-shanshu/SIRL-Gurobi32B), which leverages the Gurobi optimization solver, is publicly available on Hugging Face and ModelScope. This model integrates the Gurobi solver and achieves state-of-the-art performance, surpassing OpenAI-o3 and Deepseek-v3, and is comparable to Deepseek-R1 across various optimization benchmarks.
41
- - **2025.09.02** - We performed a quick correction on the NL4OPT, IndustryOR, MAMO-ComplexLP, and MAMO-EasyLP dataset. We encourage other researchers to use these revised versions for their future work on LLMs for optimization modeling. A detailed description of the correction process can be found here [Benchmark Data Descriptions](https://github.com/Cardinal-Operations/SIRL/tree/main/test_data/). Users can also access the cleaned dataset on the Hugging Face Hub at: https://huggingface.co/datasets/chenyitian-shanshu/ORLMBenchmark.
42
- - **2025.07.28** - [SIRL-Qwen2.5-7B-COPT](https://huggingface.co/chenyitian-shanshu/SIRL/tree/main/Copt) ,which leverages the COPT optimization solver, is publicly available on Hugging Face and ModelScope.
43
- - **2025.05.20** - [SIRL-Qwen2.5-7B-Gurobi](https://huggingface.co/chenyitian-shanshu/SIRL/tree/main) ,which leverages the Gurobi optimization solver, is publicly available on Hugging Face and ModelScope.
44
  - **2025.05.17** - SIRL paper published on arXiv: [Solver-Informed Reinforcement Learning for Optimization Modeling](https://arxiv.org/abs/2505.11792).
45
 
46
-
47
- ## Overview & Examples
48
- We introduce **SIRL (Solver-Informed Reinforcement Learning)**, a novel reasoning paradigm that integrates solver feedback with reinforcement learning to train large language models (LLMs) for optimization modeling. This approach represents the first application of Reinforcement Learning with Verifiable Reward (RLVR) in the domain of optimization modeling, enabling LLMs to generate accurate mathematical formulations and code generations from natural language descriptions. SIRL leverages solver outputs to iteratively refine model performance.
49
- Our SIRL-Qwen2.5-32B model surpasses the performance of DeepSeek-V3 and OpenAI-O3 on optimization modeling benchmarks,demonstrating the effectiveness of our approach.
50
-
51
- Currently, we offer LLM model checkpoints that seamlessly integrate with both Gurobi and COPT optimization solver.
52
- COPT (Cardinal Optimizer) is a mathematical optimization solver for large-scale optimization problems developed by Cardinal Operations, and it includes high-performance solvers for LP, MIP, NLP and so on.
53
- To explore its full functionalities or to request a trial, please visit the official website: www.shanshu.ai/copt.
54
-
55
- ## Model Release
56
-
57
- The checkpoints of [SIRL-Qwen2.5-7B-Gurobi](https://huggingface.co/chenyitian-shanshu/SIRL-Gurobi), [SIRL-Qwen2.5-7B-COPT](https://huggingface.co/chenyitian-shanshu/SIRL-COPT), [SIRL-Qwen2.5-32B-Gurobi](https://huggingface.co/chenyitian-shanshu/SIRL-Gurobi32B) and [SIRL-Qwen2.5-32B-COPT](https://huggingface.co/chenyitian-shanshu/SIRL-COPT32B) are avaiable on Hugging Face and Model Scope.
58
- Looking ahead, we aim to develop our next-generation LLM models to tackle a broader range of general optimization and mathematical tasks.
59
-
60
- | Solver Type | Hugging Face | ModelScope |
61
- |---------------------|---------------- | ---|
62
- | Gurobi-7B | [SIRL-Qwen2.5-7B-Gurobi](https://huggingface.co/chenyitian-shanshu/SIRL-Gurobi) | [SIRL-Qwen2.5-7B-Gurobi](https://modelscope.cn/models/oneday88/SIRL-7B) |
63
- | Gurobi-32B | [SIRL-Qwen2.5-32B-Gurobi](https://huggingface.co/chenyitian-shanshu/SIRL-Gurobi32B) | [SIRL-Qwen2.5-32B-Gurobi](https://modelscope.cn/models/oneday88/sirl-qwen2-5-32b-gurobi) |
64
- | COPT-7B | [SIRL-Qwen2.5-7B-COPT](https://huggingface.co/chenyitian-shanshu/SIRL-COPT) | [SIRL-Qwen2.5-7B-COPT](https://modelscope.cn/models/oneday88/sirl-qwen2-5-7b-copt) |
65
- | COPT-32B | [SIRL-Qwen2.5-32B-COPT](https://huggingface.co/chenyitian-shanshu/SIRL-COPT32B) | [SIRL-Qwen2.5-32B-COPT](https://modelscope.cn/models/oneday88/sirl-qwen2-5-32b-copt) |
66
 
67
  ## Performance
68
 
69
- We evaluated the performance of the proposed SIRL framework on four benchmarks: NL4OPT, MAMO, IndustryOR and OptMATH.
70
- Performance is assessed based on the pass@1 accuracy(acc). Following the rigorous evaluation protocol proposed by OptMATH, a solution is considered valid if the relative error is less than 1e-6.
71
- The performance metrics for [SIRL](https://huggingface.co/chenyitian-shanshu/SIRL) are as follows. The highest results are highlighted in bold.
72
-
73
- | Types | Models | NL4OPT | MAMO Easy fixed | MAMO Complex fixed | IndustryOR | OptMATH_166 | OptiBench | Macro AVG |
74
- |---------------|-------------------|--------|-----------|--------------|------------|---------|-----------|-----------|
75
- | Baseline | GPT-4 | 89.0%* | 87.3%* | 49.3%* | 33.0%* | 16.6%* | 68.6%* | 57.4%* |
76
- | | Deepseek-V3 | 95.9%* | 88.3%* | 50.2% | 37.0%* | 44.0% | **71.6%*** | 64.5%* |
77
- | | DeepSeek-R1 | 82.4% | 87.2% | **67.9%** | **45.0%** | 40.4% | 66.4% | 61.9% |
78
- | | OpenAI-O3 | 69.4% | 77.1% | 51.2% | 44.0% | 44.0% | 58.6% | 57.38% |
79
- | Agent-based | OptiMUS | 78.8%* | 77.0%* | 43.6%* | 31.0%* | 20.2%* | 45.8%* | 49.4%* |
80
- | Offline-learning | ORLM-LLaMA-3-8B | 85.7%* | 82.3%* | 37.4%* | 24.0%* | 2.6%* | 51.1%* | 47.2%* |
81
- | | LLMOpt-Qwen2.5-14B | 80.3%* | 89.5%* | 44.1%* | 29.0%* | 12.5%* | 53.8%* | 51.1%* |
82
- | | OptMATH-Qwen2.5-7B | 94.7%* | 86.5%* | 40.8% | 20.0%* | 24.4%* | 57.9%* | 55.8%* |
83
- | | OptMATH-Qwen2.5-32B | 95.9%| 89.9%| 54.1%| 31.0% |34.7% |66.1% |62.0% |
84
- | Gurobi-7B | SIRL-Qwen2.5-7B-Gurobi | 96.3%* | 91.7% | 51.7% | 33.0% | 30.5% | 58.0% | 60.2% |
85
- | Gruobi-32B | SIRL-Qwen2.5-32B-Gurobi | 98.0% | 94.6%| 61.1% |42.0% |**45.8%** |67.4% |68.2% |
86
- | COPT-7B | SIRL-Qwen2.5-7B-COPT| 95.1% | 92.1% | 53.1% | 31.0% | 29.5% | 58.3% | 58.9%|
87
- | COPT-32B | SIRL-Qwen2.5-32B-COPT | **98.4%** | **94.7%** | **72.4%** | 41.0% | 39.8% | 64.1% | **68.4%** |
88
-
89
- *Note:* Values marked with "*" are from original or reproduced papers with the criterion: relative error < 10⁻⁶.
90
-
91
- The code to reproduce these results can be found in our [Jupyter Notebook](https://github.com/Cardinal-Operations/SIRL/blob/main/reproduce_gurobi.ipynb).
92
 
93
  ## Inference
94
 
95
  ### Setup
96
- To get started, clone SIRL and install the required packages in the github:
97
 
98
  ```shell
99
  pip install -r requirements.txt
100
  ```
101
 
102
- Make sure that you have already apply for the license of solvers such as Gurobi or COPT.
103
-
104
- We recommend using the following prompt template which can be found in [rule_prompt_utils.py](https://github.com/Cardinal-Operations/SIRL/blob/main/rule_prompt_utils.py). Please replace the {question} with any natural language OR question.
105
 
106
- ### Quick start
107
-
108
- Below is a simple example for model inference:
109
 
110
  ```python
111
  from transformers import AutoTokenizer
112
- from rule_prompt_utils import gurobi_prompt_temp
113
  from utils import extract_code_block, extract_obj
114
  from vllm import SamplingParams, LLM
115
  from langchain.prompts import PromptTemplate
116
  import subprocess
117
 
118
  # Load model and parameters
119
- model = LLM("chenyitian-shanshu/SIRL-COPT32B",
120
- tensor_parallel_size=1,
121
- trust_remote_code=True)
122
- tokenizer = AutoTokenizer.from_pretrained("chenyitian-shanshu/SIRL-COPT32B")
123
  sampling_params = SamplingParams(
124
- n=1,
125
- temperature=0.5,
126
- top_p=0.95,
127
- max_tokens=8192,
128
- repetition_penalty=1.02
129
- )
130
-
131
- # Load question. Here is just an example. Users can replace this with datasets they want to test
132
  question = "An industrial tire company delivers large tires for equipment to remote engineering sites either by cargo planes or ultrawide trucks. Each cargo plane can transport 10 tires per trip and costs $1000. Each ultrawide truck can transport 6 tires per trip and costs $700. The company needs to transport at least 200 tires and has available $22000. Because most remote sites don't have proper airports, the number of plane trips cannot exceed the number of ultrawide truck trips. How many trips of each should be done to minimize the total number of trips?"
133
 
134
- # Load prompt templete
135
- zeroshot_prompt_system = PromptTemplate.from_template(gurobi_prompt_temp['system'])
136
- zeroshot_prompt_user = PromptTemplate.from_template(gurobi_prompt_temp['user'])
137
- prompt =[{"role": "system",
138
- "content": zeroshot_prompt_system.format().strip() },
139
- {"role": "user",
140
- "content": zeroshot_prompt_user.format(question=question).strip() }]
141
 
142
  # Generate Response
143
  text = tokenizer.apply_chat_template(prompt, tokenize=False, add_generation_prompt=True)
144
- response = model.generate(text,sampling_params)
145
  response_text = response[0].outputs[0].text
146
- code_snippet = extract_code_block(response_text,'gurobi')
147
- result = subprocess.run(['python3', '-c', code_snippet], capture_output=True, text=True, timeout=100)
148
- obj = extract_obj(result.stdout,'gurobi')
149
- print(response_text)
150
- print('optimal value is', obj)
151
- ```
152
-
153
- ## Test Dataset
154
- We evaluate the performance of our trained model on multiple datasets
155
- which include NL4OPT, MAMO, IndustryOR, OptMATH.
156
- Minor errors exist within these testing datasets.
157
- To address this, we rigorously reviewed and corrected the test sets of these benchmarks, updating the questions and corresponding answers to ensure the integrity of our evaluation, with a specific focus on the NL4OPT and IndustryOR dataset. The datasets are available at [https://github.com/Cardinal-Operations/SIRL/tree/main/test_data](https://github.com/Cardinal-Operations/SIRL/tree/main/test_data).
158
 
159
- ### Data Structure
160
-
161
- Each dataset is organized in a `jsonl` file, with each line containing an independent data entry. Each entry includes:
162
- - `en_question`: A string description of the optimization problem.
163
- - `en_answer`: The ground truth objective function value (float). The answers of infeasible problems are "No Best Solution" or "-99999"
164
-
165
- An example from NL4OPT:
166
-
167
- ```json
168
- {
169
- "en_question": "A company needs to minimize shipping costs across 5 warehouses with varying demands...",
170
- "en_answer": 1250.50,
171
- }
172
  ```
173
 
174
-
175
-
176
  ## Citation
177
- If you find SILR useful or relevant to your research, please consider citing our paper:
178
 
179
  ```bibtex
180
  @article{chen2025solver,
@@ -183,7 +107,4 @@ If you find SILR useful or relevant to your research, please consider citing our
183
  journal={arXiv preprint arXiv:2505.11792},
184
  year={2025}
185
  }
186
- ```
187
-
188
-
189
-
 
1
  ---
2
+ base_model:
3
+ - Qwen/Qwen2.5-32B-Instruct
4
  language:
5
  - en
6
+ license: mit
7
  metrics:
8
  - accuracy
 
 
9
  pipeline_tag: text-generation
10
+ library_name: transformers
11
  tags:
12
  - optimization
13
+ arxiv: 2505.11792
14
  ---
15
 
16
  <h2 align="center"> Solver-Informed RL: Grounding Large Language Models for Authentic Optimization Modeling</h2>
17
  <p align="center">
 
 
 
 
 
 
 
 
 
 
 
 
18
  <p align="center" style="white-space: nowrap;">
19
  <a href="https://arxiv.org/abs/2505.11792" style="display: inline-block;"><img src='https://img.shields.io/badge/Paper-SIRL-red'></a>
20
+ <a href="https://huggingface.co/chenyitian-shanshu/SIRL" style="display: inline-block;"><img src='https://img.shields.io/badge/Model-%F0%9F%A4%97%20HuggingFace-yellow'></a>
21
+ <a href="https://modelscope.cn/models/oneday88/SIRL-7B" style="display: inline-block;"><img src="https://img.shields.io/static/v1?label=Model&message=ModeScope&color=green"></a>
22
+ <a href="https://github.com/Cardinal-Operations/SIRL" style="display: inline-block;"><img src='https://img.shields.io/badge/Github-SIRL-blue'></a>
23
  </p>
24
  </p>
25
 
26
+ This repository contains the **SIRL-Qwen2.5-32B-COPT** model, presented in the paper [Solver-Informed RL: Grounding Large Language Models for Authentic Optimization Modeling](https://huggingface.co/papers/2505.11792).
27
+
28
  ## Updates
29
 
30
  - **2025.09.19** - [Our paper](https://neurips.cc/virtual/2025/poster/119660) has been accepted for a poster presentation at NeurIPS 2025! 🔥
31
+ - **2025.09.28** - **SIRL-Qwen2.5-32B-COPT**, which leverages the COPT optimization solver, is publicly available! This model integrates the COPT solver and achieves performance comparable to the Gurobi version across all optimization benchmarks.
 
 
 
 
32
  - **2025.05.17** - SIRL paper published on arXiv: [Solver-Informed Reinforcement Learning for Optimization Modeling](https://arxiv.org/abs/2505.11792).
33
 
34
+ ## Overview
35
+ We introduce **SIRL (Solver-Informed Reinforcement Learning)**, a novel reasoning paradigm that integrates solver feedback with reinforcement learning to train large language models (LLMs) for optimization modeling. This approach represents the first application of Reinforcement Learning with Verifiable Reward (RLVR) in the domain of optimization modeling, enabling LLMs to generate accurate mathematical formulations and code generations from natural language descriptions. SIRL leverages solver outputs (including syntax, feasibility, and solution quality) to iteratively refine model performance.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  ## Performance
38
 
39
+ Performance is assessed based on the pass@1 accuracy. Following the protocol proposed by OptMATH, a solution is considered valid if the relative error is less than 1e-6.
40
+
41
+ | Models | NL4OPT | MAMO Easy fixed | MAMO Complex fixed | IndustryOR | OptMATH_166 | Macro AVG |
42
+ |-------------------|--------|-----------|--------------|------------|---------|-----------|
43
+ | GPT-4 | 89.0%* | 87.3%* | 49.3%* | 33.0%* | 16.6%* | 57.4%* |
44
+ | Deepseek-V3 | 95.9%* | 88.3%* | 50.2% | 37.0%* | 44.0% | 64.5%* |
45
+ | **SIRL-Qwen2.5-32B-COPT** | **98.4%** | **94.7%** | **72.4%** | 41.0% | 39.8% | **68.4%** |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
  ## Inference
48
 
49
  ### Setup
50
+ To get started, clone the [SIRL repository](https://github.com/Cardinal-Operations/SIRL) and install the required packages:
51
 
52
  ```shell
53
  pip install -r requirements.txt
54
  ```
55
 
56
+ Ensure you have a valid license for the **COPT (Cardinal Optimizer)** solver.
 
 
57
 
58
+ ### Quick Start (vLLM)
 
 
59
 
60
  ```python
61
  from transformers import AutoTokenizer
62
+ from rule_prompt_utils import copt_prompt_temp
63
  from utils import extract_code_block, extract_obj
64
  from vllm import SamplingParams, LLM
65
  from langchain.prompts import PromptTemplate
66
  import subprocess
67
 
68
  # Load model and parameters
69
+ model_id = "chenyitian-shanshu/SIRL-COPT32B"
70
+ model = LLM(model_id, tensor_parallel_size=1, trust_remote_code=True)
71
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
72
+
73
  sampling_params = SamplingParams(
74
+ n=1,
75
+ temperature=0.5,
76
+ top_p=0.95,
77
+ max_tokens=8192,
78
+ repetition_penalty=1.02
79
+ )
80
+
 
81
  question = "An industrial tire company delivers large tires for equipment to remote engineering sites either by cargo planes or ultrawide trucks. Each cargo plane can transport 10 tires per trip and costs $1000. Each ultrawide truck can transport 6 tires per trip and costs $700. The company needs to transport at least 200 tires and has available $22000. Because most remote sites don't have proper airports, the number of plane trips cannot exceed the number of ultrawide truck trips. How many trips of each should be done to minimize the total number of trips?"
82
 
83
+ # Load prompt template
84
+ zeroshot_prompt_system = PromptTemplate.from_template(copt_prompt_temp['system'])
85
+ zeroshot_prompt_user = PromptTemplate.from_template(copt_prompt_temp['user'])
86
+ prompt =[{"role": "system", "content": zeroshot_prompt_system.format().strip() },
87
+ {"role": "user", "content": zeroshot_prompt_user.format(question=question).strip() }]
 
 
88
 
89
  # Generate Response
90
  text = tokenizer.apply_chat_template(prompt, tokenize=False, add_generation_prompt=True)
91
+ response = model.generate(text, sampling_params)
92
  response_text = response[0].outputs[0].text
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
+ # Extract and run code
95
+ code_snippet = extract_code_block(response_text, 'copt')
96
+ result = subprocess.run(['python3', '-c', code_snippet], capture_output=True, text=True, timeout=100)
97
+ obj = extract_obj(result.stdout, 'copt')
98
+ print('Optimal value is', obj)
 
 
 
 
 
 
 
 
99
  ```
100
 
 
 
101
  ## Citation
 
102
 
103
  ```bibtex
104
  @article{chen2025solver,
 
107
  journal={arXiv preprint arXiv:2505.11792},
108
  year={2025}
109
  }
110
+ ```