PEFT
English
Mathematical Reasoning
akjindal53244 commited on
Commit
9cd2843
·
verified ·
1 Parent(s): 9672d8e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +177 -185
README.md CHANGED
@@ -3,199 +3,65 @@ library_name: peft
3
  base_model: mistralai/Mistral-7B-v0.1
4
  ---
5
 
6
- # Model Card for Model ID
 
 
 
 
 
 
 
 
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
 
 
10
 
 
11
 
12
  ## Model Details
13
 
14
- ### Model Description
15
-
16
- <!-- Provide a longer summary of what this model is. -->
17
-
18
-
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Shared by [optional]:** [More Information Needed]
22
- - **Model type:** [More Information Needed]
23
- - **Language(s) (NLP):** [More Information Needed]
24
- - **License:** [More Information Needed]
25
- - **Finetuned from model [optional]:** [More Information Needed]
26
-
27
- ### Model Sources [optional]
28
-
29
- <!-- Provide the basic links for the model. -->
30
-
31
- - **Repository:** [More Information Needed]
32
- - **Paper [optional]:** [More Information Needed]
33
- - **Demo [optional]:** [More Information Needed]
34
-
35
- ## Uses
36
-
37
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
38
-
39
- ### Direct Use
40
-
41
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
42
-
43
- [More Information Needed]
44
-
45
- ### Downstream Use [optional]
46
-
47
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
48
-
49
- [More Information Needed]
50
-
51
- ### Out-of-Scope Use
52
-
53
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
54
-
55
- [More Information Needed]
56
-
57
- ## Bias, Risks, and Limitations
58
-
59
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
60
-
61
- [More Information Needed]
62
-
63
- ### Recommendations
64
-
65
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
66
-
67
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
68
-
69
- ## How to Get Started with the Model
70
-
71
- Use the code below to get started with the model.
72
-
73
- [More Information Needed]
74
-
75
- ## Training Details
76
-
77
- ### Training Data
78
-
79
- <!-- This should link to a Data Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
80
-
81
- [More Information Needed]
82
-
83
- ### Training Procedure
84
-
85
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
86
-
87
- #### Preprocessing [optional]
88
-
89
- [More Information Needed]
90
-
91
-
92
- #### Training Hyperparameters
93
-
94
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
95
-
96
- #### Speeds, Sizes, Times [optional]
97
-
98
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
99
-
100
- [More Information Needed]
101
-
102
- ## Evaluation
103
-
104
- <!-- This section describes the evaluation protocols and provides the results. -->
105
 
106
- ### Testing Data, Factors & Metrics
107
-
108
- #### Testing Data
109
-
110
- <!-- This should link to a Data Card if possible. -->
111
-
112
- [More Information Needed]
113
-
114
- #### Factors
115
-
116
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
117
-
118
- [More Information Needed]
119
-
120
- #### Metrics
121
-
122
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
123
-
124
- [More Information Needed]
125
-
126
- ### Results
127
-
128
- [More Information Needed]
129
-
130
- #### Summary
131
-
132
-
133
-
134
- ## Model Examination [optional]
135
-
136
- <!-- Relevant interpretability work for the model goes here -->
137
-
138
- [More Information Needed]
139
-
140
- ## Environmental Impact
141
-
142
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
143
-
144
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
145
-
146
- - **Hardware Type:** [More Information Needed]
147
- - **Hours used:** [More Information Needed]
148
- - **Cloud Provider:** [More Information Needed]
149
- - **Compute Region:** [More Information Needed]
150
- - **Carbon Emitted:** [More Information Needed]
151
-
152
- ## Technical Specifications [optional]
153
-
154
- ### Model Architecture and Objective
155
-
156
- [More Information Needed]
157
-
158
- ### Compute Infrastructure
159
-
160
- [More Information Needed]
161
-
162
- #### Hardware
163
-
164
- [More Information Needed]
165
-
166
- #### Software
167
-
168
- [More Information Needed]
169
-
170
- ## Citation [optional]
171
-
172
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
173
-
174
- **BibTeX:**
175
-
176
- [More Information Needed]
177
-
178
- **APA:**
179
-
180
- [More Information Needed]
181
-
182
- ## Glossary [optional]
183
-
184
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
185
-
186
- [More Information Needed]
187
-
188
- ## More Information [optional]
189
-
190
- [More Information Needed]
191
-
192
- ## Model Card Authors [optional]
193
-
194
- [More Information Needed]
195
-
196
- ## Model Card Contact
197
 
198
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
 
200
 
201
  ## Training procedure
@@ -217,3 +83,129 @@ The following `bitsandbytes` quantization config was used during training:
217
 
218
 
219
  - PEFT 0.6.0.dev0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  base_model: mistralai/Mistral-7B-v0.1
4
  ---
5
 
6
+ ---
7
+ license: mit
8
+ language:
9
+ - en
10
+ tags:
11
+ - Mathematical Reasoning
12
+ datasets:
13
+ - akjindal53244/Arithmo-Data
14
+ ---
15
 
16
+ # Model Card for Model ID
17
 
18
+ [![Code License](https://img.shields.io/badge/Code%20License-Apache_2.0-green.svg)](CODE_LICENSE)
19
+ [![Model Weight License](https://img.shields.io/badge/Model%20Weights%20License-Apache_2.0-green.svg)](LICENSE)
20
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/release/python-390/)
21
 
22
+ **P.S.:** Please reach out to [Ashvini Jindal](https://www.linkedin.com/in/ashvini-jindal-26653262/) if you would be interested in supporting compute need. We are looking for small-scale support so we'd appreciate any kind of help! :)
23
 
24
  ## Model Details
25
 
26
+ **Arithmo2-7B-adapter** is LoRA adapter for **Arithmo2-7B** model. **Arithmo2-7B** is improved version of [Arithmo-Mistral-7B](https://huggingface.co/akjindal53244/Arithmo-Mistral-7B) model and is trained to reason and answer mathematical problems and is also capable of writing a Python program that upon execution prints answer to the question. We used [Mistral-7B](https://huggingface.co/mistralai/Mistral-7B-v0.1) as a base model and used **QLoRA to fine-tune it on a single GPU**.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
+ ### Model Description
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
+ - **Project GitHub Page:** https://github.com/akjindal53244/Arithmo-Mistral-7B
31
+ - **Developed by:** [Ashvini Kumar Jindal](https://www.linkedin.com/in/ashvini-jindal-26653262/)
32
+ - **Funded by:** self-work
33
+ - **Model type:** fine-tuned using QLoRA on Single GPU
34
+ - **Language(s) (NLP):** English
35
+ - **Finetuned from model:** mistralai/Mistral-7B-v0.1
36
+
37
+ ## Results
38
+
39
+ Arithmo2-7B is improved version of [Arithmo-Mistral-7B](https://huggingface.co/akjindal53244/Arithmo-Mistral-7B) model and is competitive with full fine-tuned state-of-the-art 7B Mathematical Reasoning models. Refer to [Comparing Arithmo-Mistral-7B with other LLM models](https://github.com/akjindal53244/Arithmo-Mistral-7B/tree/master#comparing-arithmo-mistral-7b-with-other-llm-models) section for more details.
40
+
41
+ <table>
42
+ <thead>
43
+ <tr>
44
+ <th>Prompt Approach</th>
45
+ <th>GSM8k</th>
46
+ <th>MATH</th>
47
+ </tr>
48
+ </thead>
49
+ <tbody>
50
+ <tr>
51
+ <td>Zero-Shot CoT</td>
52
+ <td><b>76.4</b></td>
53
+ <td><b>27.2</b></td>
54
+ </tr>
55
+ <tr>
56
+ <td>Zero-Shot PoT</td>
57
+ <td><b>74.2</b></td>
58
+ <td>-</td>
59
+ </tr>
60
+ </tbody>
61
+ </table>
62
+
63
+ - **Zero-Shot CoT**: On providing a question as prompt, model generates reasoning steps to solve the question along with answer. We check if answer matches with ground-truth.
64
+ - **Zero-Shot PoT**: We prompt the model to generate a Python program for the given question. During inference, we execute the Python program generated by the model and check if the program output matches with ground-truth answer.
65
 
66
 
67
  ## Training procedure
 
83
 
84
 
85
  - PEFT 0.6.0.dev0
86
+
87
+
88
+
89
+ ## Installation
90
+
91
+ ```
92
+ pip install transformers >=4.34.0
93
+ pip install accelerate
94
+ pip install sentencepiece
95
+ pip install protobuf
96
+
97
+ # If you are GPU poor like me
98
+ pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
99
+
100
+ # If you have a GPU.
101
+ pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu118
102
+ pip install scipy
103
+ pip install bitsandbytes
104
+ ```
105
+
106
+
107
+ ## How to query the model
108
+
109
+ ```
110
+ # Set `run_model_on_gpu` to `False` if you are running on CPU. Model will generate reasoning steps with answer for your question. If you want to generate Python program, uncomment line-69 that adds a Python prompt.
111
+ # This script automatically does formatting for you, so you just need to type question (eg: `What is 2+2?`) without any prefix like `Question:`, etc.**
112
+
113
+ $ python query_model.py
114
+ ```
115
+ **Note:** Above script automatically does formatting for you, so you just need to type question (eg: `What is 2+2?`) without any prefix like `Question:`, etc. Checkout [query_model.py](https://github.com/akjindal53244/Arithmo-Mistral-7B/blob/master/query_model.py) for more details. <br><br>
116
+
117
+ ##### Sample Input:
118
+ ```
119
+ Question: There are total 10 children. I have to give 1 apple to first child, 2 apples to second child, 3 apples to third child, and so on. How many apples do I need?
120
+ ```
121
+ ##### Model Output:
122
+ ```
123
+ Answer: The total number of apples needed is the sum of the first 10 positive integers.
124
+ This can be calculated using the formula for the sum of an arithmetic series:
125
+ \[S = \frac{n}{2}(a_1 + a_n),\]
126
+ where $S$ is the sum, $n$ is the number of terms, $a_1$ is the first term, and $a_n$ is the last term.
127
+ In this case, $n = 10$, $a_1 = 1$, and $a_n = 10$.
128
+ Plugging these values into the formula, we get:
129
+ \[S = \frac{10}{2}(1 + 10) = 5(11) = \boxed{55}.\]
130
+ The answer is: 55
131
+ ```
132
+
133
+ Arithmo2-7B is trained with same format as [Arithmo-Mistral-7B](https://huggingface.co/akjindal53244/Arithmo-Mistral-7B):
134
+ #### CoT Format (generate reasoning steps with answer):
135
+ ```
136
+ Question: <question>
137
+
138
+ Answer:
139
+ ```
140
+
141
+ #### PoT Format (generate a python program):
142
+ ```
143
+ Question: <question> <python_prompt>
144
+
145
+ Answer:
146
+ ```
147
+ It will perform best if queried in this way with your own script.
148
+
149
+ ## Comparing Arithmo2-7B with other LLM models.
150
+ Results for all models except `Arithmo2-7B` are taken from [MetaMath](https://github.com/meta-math/MetaMath/blob/main/README.MD) repository.
151
+
152
+ | Model | GSM8k Pass@1 | MATH Pass@1 | Fine-tuning |
153
+ |---------------------|--------------|-------------|-------------|
154
+ | MPT-7B | 6.8 | 3.0 |
155
+ | Falcon-7B | 6.8 | 2.3 |
156
+ | LLaMA-1-7B | 11.0 | 2.9 |
157
+ | LLaMA-2-7B | 14.6 | 2.5 |
158
+ | MPT-30B | 15.2 | 3.1 |
159
+ | LLaMA-1-13B | 17.8 | 3.9 |
160
+ | GPT-Neo-2.7B | 19.5 | -- |
161
+ | Falcon-40B | 19.6 | 2.5 |
162
+ | Baichuan-chat-13B | 23.9 | -- |
163
+ | Vicuna-v1.3-13B | 27.6 | -- |
164
+ | LLaMA-2-13B | 28.7 | 3.9 |
165
+ | InternLM-7B | 31.2 | -- |
166
+ | ChatGLM-2-6B | 32.4 | -- |
167
+ | GPT-J-6B | 34.9 | -- |
168
+ | LLaMA-1-33B | 35.6 | 3.9 |
169
+ | LLaMA-2-34B | 42.2 | 6.24 |
170
+ | RFT-7B | 50.3 | -- |
171
+ | LLaMA-1-65B | 50.9 | 10.6 |
172
+ | Qwen-7B | 51.6 | -- |
173
+ | WizardMath-7B | 54.9 | 10.7 |
174
+ | LLaMA-2-70B | 56.8 | 13.5 |
175
+ | WizardMath-13B | 63.9 | 14.0 |
176
+ | MetaMath-7B | 66.5 | 19.8 |
177
+ | MetaMath-13B | 72.3 | 22.4 |
178
+ | Arithmo-Mistral-7B Zero-Shot PoT | 71.2 | -- | SFT: 4-bit QLoRA |
179
+ | Arithmo-Mistral-7B Zero-Shot CoT | 74.7 | 25.3 | SFT: 4-bit QLoRA |
180
+ | MetaMath-Mistral-7B | 77.7 | 27.2 | SFT: Full fine-tuned |
181
+ | 🔥 **Arithmo2-7B Zero-Shot PoT** | **74.2** | -- | **SFT: 4-bit QLoRA** |
182
+ | 🔥 **Arithmo2-7B Zero-Shot CoT** | **76.4** | **27.2** | **SFT: 4-bit QLoRA** |
183
+
184
+
185
+ If you are interested in reproducing the results, visit https://github.com/akjindal53244/Arithmo-Mistral-7B#reproducing-results section.
186
+
187
+ <h2 id="References">References</h2>
188
+
189
+ ```
190
+ @article{yu2023metamath,
191
+ title={MetaMath: Bootstrap Your Own Mathematical Questions for Large Language Models},
192
+ author={Yu, Longhui and Jiang, Weisen and Shi, Han and Yu, Jincheng and Liu, Zhengying and Zhang, Yu and Kwok, James T and Li, Zhenguo and Weller, Adrian and Liu, Weiyang},
193
+ journal={arXiv preprint arXiv:2309.12284},
194
+ year={2023}
195
+ }
196
+
197
+ @article{Yue2023mammoth,
198
+ title={MAmmoTH: Building math generalist models through hybrid instruction tuning},
199
+ author={Xiang Yue, Xingwei Qu, Ge Zhang, Yao Fu, Wenhao Huang, Huan Sun, Yu Su, and Wenhu Chen},
200
+ journal={arXiv preprint arXiv:2309.05653},
201
+ year={2023}
202
+ }
203
+
204
+ @article{mishra2022lila,
205
+ title={Lila: A unified benchmark for mathematical reasoning},
206
+ author={Swaroop Mishra, Matthew Finlayson, Pan Lu, Leonard Tang, Sean Welleck, Chitta Baral, Tanmay Rajpurohit, Oyvind Tafjord, Ashish Sabharwal, Peter Clark, and Ashwin Kalyan},
207
+ journal={arXiv preprint arXiv:2210.17517},
208
+ year={2022}
209
+ }
210
+
211
+ ```