nielsr HF Staff commited on
Commit
b3069a9
·
verified ·
1 Parent(s): 7eea7f4

Add pipeline tag, library and license

Browse files

This PR adds the missing `pipeline_tag`, `library_name`, and infers the license. This improves discoverability and clarifies the model's usage.

Files changed (1) hide show
  1. README.md +99 -3
README.md CHANGED
@@ -1,10 +1,106 @@
1
  ---
 
 
2
  datasets:
3
  - QizhiPei/MathFusionQA
4
  language:
5
  - en
6
- base_model:
7
- - mistralai/Mistral-7B-v0.1
 
8
  ---
9
 
10
- Paper: [MathFusion: Enhancing Mathematic Problem-solving of LLM through Instruction Fusion](https://arxiv.org/abs/2503.16212)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ base_model:
3
+ - mistralai/Mistral-7B-v0.1
4
  datasets:
5
  - QizhiPei/MathFusionQA
6
  language:
7
  - en
8
+ pipeline_tag: question-answering
9
+ library_name: transformers
10
+ license: apache-2.0
11
  ---
12
 
13
+ # MathFusion: Enhancing Mathematic Problem-solving of LLM through Instruction Fusion
14
+
15
+ [![Paper](https://img.shields.io/badge/📄-Paper-red)](https://arxiv.org/abs/2503.16212)
16
+ [![License](https://img.shields.io/github/license/QizhiPei/MathFusion)](https://github.com/QizhiPei/MathFusion/blob/main/LICENSE)
17
+ [![HuggingFace](https://img.shields.io/badge/🤗%20HuggingFace-Data%20&%20Models-green)](https://huggingface.co/collections/QizhiPei/mathfusion-67d92b8e505635db1baf20bb)
18
+
19
+ We introduce MathFusion, a novel framework that enhances mathematical reasoning through cross-problem instruction synthesis. MathFusion implements this through three fusion strategies:
20
+ 1. **Sequential Fusion**, which chains related problems to model solution dependencies.
21
+ 2. **Parallel Fusion**, which combines analogous problems to reinforce conceptual understanding.
22
+ 3. **Conditional Fusion**, which creates context-aware selective problems to enhance reasoning flexibility.
23
+
24
+ ![](imgs/MathFusion.png)
25
+
26
+ MathFusion achieves substantial improvements in mathematical reasoning while maintaining hight data efficiency, boosting performance by 18.0 points in accuracy across diverse benchmarks while requiring **only 45K additional synthetic instructions**. Further combination of MathFusion and DART-Math yields SOTA performance
27
+
28
+ ![](imgs/results.png)
29
+
30
+ We release the MathFusionQA dataset and three MathFusion models fine-tuned on this dataset.
31
+
32
+ | Dataset/Model | MATH | CollegeMath | DeepMind-Mathematics | HuggingFace🤗 |
33
+ | - | :-: | :-: | :-: | :-: |
34
+ | MathFusionQA | - | - | - | [link](https://huggingface.co/datasets/QizhiPei/MathFusionQA) |
35
+ | DeepSeekMath-7B-MathFusion | 53.4 | 39.8 | 65.8 | [link](https://huggingface.co/QizhiPei/DeepSeekMath-7B-MathFusion) |
36
+ | Mistral-7B-MathFusion | 41.6 | 24.3 | 39.2 | [link](https://huggingface.co/QizhiPei/Mistral-7B-MathFusion) |
37
+ | Llama3-8B-MathFusion | 46.5 | 27.9 | 43.4 | [link](https://huggingface.co/QizhiPei/Llama3-8B-MathFusion) |
38
+
39
+ ## 🎯 Quick Start
40
+ Install the dependencies:
41
+
42
+ ```bash
43
+ conda create -n mathfusion python=3.10
44
+ conda activate mathfusion
45
+ # Install Pytorch according to your CUDA version
46
+ pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121
47
+ # Install LLaMA-Factory
48
+ git clone https://github.com/hiyouga/LLaMA-Factory.git
49
+ cd LLaMA-Factory
50
+ git checkout v0.9.1
51
+ pip install transformers==4.46.1 accelerate==0.34.2 deepspeed==0.15.4
52
+ pip install -e ".[torch,metrics]"
53
+ # Install packages for evaluation
54
+ pip install flash-attn==2.7.3 --no-build-isolation
55
+ pip install sympy==1.12.1 antlr4-python3-runtime==4.11.1 pebble word2number boto3 triton==2.3.1
56
+ pip install vllm==0.5.3.post1
57
+ # Install latex2sympy
58
+ cd ../evaluation/latex2sympy
59
+ pip install -e .
60
+ cd ..
61
+ # Install dart-math evaluation
62
+ pip install -e .
63
+ ```
64
+
65
+ ## 📚 Data
66
+ Load the data from [MathFusionQA](https://huggingface.co/datasets/QizhiPei/MathFusionQA), then convert each split to `.json` file according to [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory). The training prompt template is:
67
+ ```
68
+ "Question: {query}
69
+ Answer:"
70
+ ```
71
+
72
+ ## 🤖 Training
73
+ Our training codes depend on [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory).
74
+ ```bash
75
+ # Corresponding to splits in MathFusionQA
76
+ export DATASET=gsm8k_original,math_original,gsm8k_sequential,math_sequential,gsm8k_parallel,math_parallel,gsm8k_conditional,math_conditional
77
+ # The path of base model
78
+ export MODEL_PATH=pretrained_model_path
79
+ export RUN_NAME=sft_mathfusion
80
+ bash train/train.sh
81
+ ```
82
+
83
+ ## 📊 Evaluation
84
+ Our evaluation codes are adapted from [Qwen2.5-Math](https://github.com/QwenLM/Qwen2.5-Math) (for in-domain datasets) and [DART-Math](https://github.com/hkust-nlp/dart-math) (for out-of-domain datasets).
85
+ You need to first download the model from HuggingFace, or SFT the model on your own. Then run the following evaluation script:
86
+ ```bash
87
+ export MODEL_NAME=your_sft_model_path
88
+ bash test.sh
89
+ ```
90
+
91
+ ## 🙏 Acknowledgements
92
+ Many thanks to
93
+ * [DART-Math](https://github.com/hkust-nlp/dart-math)
94
+ * [Qwen2.5-Math](https://github.com/QwenLM/Qwen2.5-Math)
95
+ * [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory/tree/main)
96
+
97
+ ## Citation
98
+ If you find our code, model, or data are useful, please kindly cite our [paper](https://arxiv.org/abs/2503.16212):
99
+ ```
100
+ @article{mathfusion,
101
+ title={MathFusion: Enhancing Mathematic Problem-solving of LLM through Instruction Fusion},
102
+ author={Qizhi Pei and Lijun Wu and Zhuoshi Pan and Yu Li and Honglin Lin and Chenlin Ming and Xin Gao and Conghui He and Rui Yan},
103
+ journal={arXiv preprint arXiv:2503.16212},
104
+ year={2025}
105
+ }
106
+ ```