Update model card with paper link and Github README content

#1
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +143 -8
README.md CHANGED
@@ -1,14 +1,15 @@
1
  ---
2
- license: apache-2.0
 
3
  language:
4
- - en
 
 
5
  metrics:
6
- - accuracy
7
  pipeline_tag: image-text-to-text
8
- library_name: transformers
9
- base_model:
10
- - OpenGVLab/InternVL2-8B
11
  ---
 
12
  # MathCoder-VL: Bridging Vision and Code for Enhanced Multimodal Mathematical Reasoning
13
 
14
  Repo: [https://github.com/mathllm/MathCoder](https://github.com/mathllm/MathCoder)
@@ -32,7 +33,8 @@ For training and inference code, please refer to [InternVL](https://github.com/O
32
  ### Prompt for TikZ Code Generation
33
 
34
  ```
35
- <image>\nPlease generate the corresponding TikZ code that accurately represents the visual elements in the image. TikZ is a powerful tool for creating vector graphics within LaTeX documents. Your generated code should be precise, well-structured, and should recreate the image as faithfully as possible.
 
36
  ```
37
 
38
  <div align="center">
@@ -42,7 +44,8 @@ For training and inference code, please refer to [InternVL](https://github.com/O
42
  ### Prompt for Python Code Generation
43
 
44
  ```
45
- Please provide the Python code needed to reproduce this image.\n<image>
 
46
  ```
47
 
48
  <div align="center">
@@ -107,4 +110,136 @@ booktitle={The Twelfth International Conference on Learning Representations},
107
  year={2024},
108
  url={https://openreview.net/forum?id=z8TW0ttBPp}
109
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  ```
 
1
  ---
2
+ base_model:
3
+ - OpenGVLab/InternVL2-8B
4
  language:
5
+ - en
6
+ library_name: transformers
7
+ license: apache-2.0
8
  metrics:
9
+ - accuracy
10
  pipeline_tag: image-text-to-text
 
 
 
11
  ---
12
+
13
  # MathCoder-VL: Bridging Vision and Code for Enhanced Multimodal Mathematical Reasoning
14
 
15
  Repo: [https://github.com/mathllm/MathCoder](https://github.com/mathllm/MathCoder)
 
33
  ### Prompt for TikZ Code Generation
34
 
35
  ```
36
+ <image>
37
+ Please generate the corresponding TikZ code that accurately represents the visual elements in the image. TikZ is a powerful tool for creating vector graphics within LaTeX documents. Your generated code should be precise, well-structured, and should recreate the image as faithfully as possible.
38
  ```
39
 
40
  <div align="center">
 
44
  ### Prompt for Python Code Generation
45
 
46
  ```
47
+ Please provide the Python code needed to reproduce this image.
48
+ <image>
49
  ```
50
 
51
  <div align="center">
 
110
  year={2024},
111
  url={https://openreview.net/forum?id=z8TW0ttBPp}
112
  }
113
+ ```
114
+
115
+ # **MathCoder**
116
+ This repo is for "[MathCoder: Seamless Code Integration in LLMs for Enhanced Mathematical Reasoning](https://openreview.net/pdf?id=z8TW0ttBPp)"
117
+
118
+ πŸ”₯πŸ”₯πŸ”₯ We release "[MathCoder-VL: Bridging Vision and Code for Enhanced Multimodal Mathematical Reasoning](https://openreview.net/pdf?id=lclKPTKM9R)"
119
+
120
+
121
+ ## πŸ’₯ News πŸ’₯
122
+
123
+ - **[2025.05.16]** πŸ€— [MathCoder-VL-2B](https://huggingface.co/MathLLMs/MathCoder-VL-2B), [MathCoder-VL-8B](https://huggingface.co/MathLLMs/MathCoder-VL-8B) and [FigCodifier-8B](https://huggingface.co/MathLLMs/FigCodifier) is available now! πŸ”₯πŸ”₯πŸ”₯
124
+ - **[2025.05.16]** Our MathCoder-VL is accepted to ACL 2025 Findings. πŸ”₯πŸ”₯πŸ”₯
125
+ - **[2024.05.20]** πŸ€— [MathCodeInstruct Dataset-Plus](https://huggingface.co/datasets/MathLLMs/MathCodeInstruct-Plus) is available now! πŸ”₯
126
+ - **[2024.04.29]** πŸ€— [MathCodeInstruct Dataset](https://huggingface.co/datasets/MathLLMs/MathCodeInstruct) is available now! πŸ”₯
127
+ - **[2024.02.27]** πŸš€ [MathGenie](https://mathgenie.github.io/) achieves an accuracy of 87.7% on GSM8K and 55.7% on MATH. πŸŽ‰ Congratulations!
128
+ - **[2024.02.27]** The inference and evaluation code for MathCoders is available now.
129
+ - **[2024.01.16]** 🌟 Our [**MathCoder**](https://openreview.net/forum?id=z8TW0ttBPp) and [**CSV**](https://openreview.net/forum?id=c8McWs4Av0) has been accepted at **ICLR 2024**! πŸŽ‰ Cheers!
130
+ - **[2023.10.05]** Our work was featured by [Aran Komatsuzaki](https://twitter.com/arankomatsuzaki). Thanks!
131
+ - **[2023.10.05]** Our 7B models are available at Huggingface now.
132
+ - **[2023.10.05]** Our paper is now accessible at https://arxiv.org/abs/2310.03731.
133
+
134
+ ### Datasets and Models
135
+ Our models are available at Hugging Face now.
136
+
137
+ πŸ€— [MathCodeInstruct Dataset](https://huggingface.co/datasets/MathLLM/MathCodeInstruct)
138
+
139
+ | Base Model: Llama-2 | Base Model: Code Llama |
140
+ |-------------------------------------------------------------------|-----------------------------------------------------------------------|
141
+ | [MathCoder-L-7B](https://huggingface.co/MathLLM/MathCoder-L-7B) | [MathCoder-CL-7B](https://huggingface.co/MathLLM/MathCoder-CL-7B) |
142
+ | [MathCoder-L-13B](https://huggingface.co/MathLLM/MathCoder-L-13B) | [MathCoder-CL-34B](https://huggingface.co/MathLLM/MathCoder-CL-34B) |
143
+
144
+
145
+ ## Training Data
146
+ The models are trained on the [MathCodeInstruct](https://huggingface.co/datasets/MathLLM/MathCodeInstruct) Dataset.
147
+
148
+ <br>
149
+ <div align="center">
150
+ <img src="figures/result.png" width="100%" title="Result Figure">
151
+ </div>
152
+
153
+
154
+ ## **Introduction**
155
+ The recently released GPT-4 Code Interpreter has demonstrated remarkable proficiency in solving challenging math problems, primarily attributed to its ability to seamlessly reason with natural language, generate code, execute code, and continue reasoning based on the execution output. In this paper, we present a method to fine-tune open-source language models, enabling them to use code for modeling and deriving math equations and, consequently, enhancing their mathematical reasoning abilities.
156
+
157
+ We propose a method of generating novel and high-quality datasets with math problems and their code-based solutions, referred to as MathCodeInstruct. Each solution interleaves *natural language*, *code*, and *execution results*.
158
+
159
+ We also introduce a customized supervised fine-tuning and inference approach. This approach yields the MathCoder models, a family of models capable of generating code-based solutions for solving challenging math problems.
160
+
161
+ Impressively, the MathCoder models achieve state-of-the-art scores among open-source LLMs on the MATH (45.2\%) and GSM8K (83.9\%) datasets, substantially outperforming other open-source alternatives. Notably, the MathCoder model not only surpasses ChatGPT-3.5 and PaLM-2 on GSM8K and MATH but also outperforms GPT-4 on the competition-level MATH dataset. The proposed dataset and models will be released upon acceptance.
162
+ <br>
163
+ <div align="center">
164
+ <img src="figures/pipeline.png" width="100%" title="Result Figure">
165
+ </div>
166
+
167
+ ## Usage
168
+
169
+ ### Model deployment
170
+ We use the Text Generation Inference (TGI) to deploy our MathCoders for response generation.
171
+ TGI is a toolkit for deploying and serving Large Language Models (LLMs). TGI enables high-performance text generation for the most popular open-source LLMs, including Llama, Falcon, StarCoder, BLOOM, GPT-NeoX, and T5. Your can follow the guide [here](https://huggingface.co/docs/text-generation-inference/index).
172
+ After successfully installing TGI, you can easily deploy the models using `deploy.sh`.
173
+ ```sh
174
+ model_path="local model path"
175
+
176
+ max_input_tokens=1536
177
+ max_total_tokens=2048
178
+
179
+ set -x
180
+ hostname -I # print the host ip
181
+
182
+ text-generation-launcher --port 8000 \
183
+ --max-batch-prefill-tokens ${max_input_tokens} \
184
+ --max-input-length ${max_input_tokens} \
185
+ --max-total-tokens ${max_total_tokens} \
186
+ --model-id ${model_path}
187
+ ```
188
+
189
+ ### Inference
190
+ We provide a script for inference. Just replace the `ip` and `port` in the following command correctly with the API forwarded by TGI like:
191
+ ```sh
192
+ python inference.py --pnum=4 --outdir=outs/debug --ip=10.119.18.159 --port=8001 --type=test --dataset=GSM8K
193
+ ```
194
+ We also open-source all of the model outputs from our MathCoders under the outs/ folder.
195
+
196
+ ### Evaluation
197
+ To evaluate the predicted answer, run the following command:
198
+ ```sh
199
+ python evaluate.py outs/MathCoder-L-7b/MATH/MATH_test_result-20230917-2026.jsonl
200
+ ```
201
+
202
+ ## **Citation**
203
+
204
+ Please cite the paper if you use our data, model or code.
205
+
206
+ ```
207
+ @inproceedings{
208
+ wang2025mathcodervl,
209
+ title={MathCoder-{VL}: Bridging Vision and Code for Enhanced Multimodal Mathematical Reasoning},
210
+ author={Ke Wang and Junting Pan and Linda Wei and Aojun Zhou and Weikang Shi and Zimu Lu and Han Xiao and Yunqiao Yang and Houxing Ren and Mingjie Zhan and Hongsheng Li},
211
+ booktitle={The 63rd Annual Meeting of the Association for Computational Linguistics},
212
+ year={2025},
213
+ url={https://openreview.net/forum?id=nuvtX1imAb}
214
+ }
215
+ ```
216
+ ```
217
+ @inproceedings{
218
+ lu2025mathcoder2,
219
+ title={MathCoder2: Better Math Reasoning from Continued Pretraining on Model-translated Mathematical Code},
220
+ author={Zimu Lu and Aojun Zhou and Ke Wang and Houxing Ren and Weikang Shi and Junting Pan and Mingjie Zhan and Hongsheng Li},
221
+ booktitle={The Thirteenth International Conference on Learning Representations},
222
+ year={2025},
223
+ url={https://openreview.net/forum?id=1Iuw1jcIrf}
224
+ }
225
+ ```
226
+ ```
227
+ @inproceedings{
228
+ wang2024mathcoder,
229
+ title={MathCoder: Seamless Code Integration in {LLM}s for Enhanced Mathematical Reasoning},
230
+ author={Ke Wang and Houxing Ren and Aojun Zhou and Zimu Lu and Sichun Luo and Weikang Shi and Renrui Zhang and Linqi Song and Mingjie Zhan and Hongsheng Li},
231
+ booktitle={The Twelfth International Conference on Learning Representations},
232
+ year={2024},
233
+ url={https://openreview.net/forum?id=z8TW0ttBPp}
234
+ }
235
+ ```
236
+ ```
237
+ @inproceedings{
238
+ zhou2024solving,
239
+ title={Solving Challenging Math Word Problems Using {GPT}-4 Code Interpreter with Code-based Self-Verification},
240
+ author={Aojun Zhou and Ke Wang and Zimu Lu and Weikang Shi and Sichun Luo and Zipeng Qin and Shaoqing Lu and Anya Jia and Linqi Song and Mingjie Zhan and Hongsheng Li},
241
+ booktitle={The Twelfth International Conference on Learning Representations},
242
+ year={2024},
243
+ url={https://openreview.net/forum?id=c8McWs4Av0}
244
+ }
245
  ```