Update README.md
Browse files
README.md
CHANGED
@@ -7,7 +7,7 @@ tags: []
|
|
7 |
|
8 |
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
|
10 |
-
|
11 |
|
12 |
## Model Details
|
13 |
|
@@ -15,22 +15,22 @@ tags: []
|
|
15 |
|
16 |
<!-- Provide a longer summary of what this model is. -->
|
17 |
|
18 |
-
This
|
19 |
|
20 |
-
- **Developed by:**
|
21 |
- **Funded by [optional]:** [More Information Needed]
|
22 |
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:**
|
24 |
-
- **Language(s) (NLP):**
|
25 |
-
- **License:**
|
26 |
-
- **Finetuned from model [optional]:**
|
27 |
|
28 |
### Model Sources [optional]
|
29 |
|
30 |
<!-- Provide the basic links for the model. -->
|
31 |
|
32 |
-
- **Repository:**
|
33 |
-
- **Paper [optional]:**
|
34 |
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
## Uses
|
@@ -41,25 +41,25 @@ This is the model card of a 🤗 transformers model that has been pushed on the
|
|
41 |
|
42 |
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
|
44 |
-
|
45 |
|
46 |
### Downstream Use [optional]
|
47 |
|
48 |
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
|
50 |
-
|
51 |
|
52 |
### Out-of-Scope Use
|
53 |
|
54 |
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
55 |
|
56 |
-
|
57 |
|
58 |
## Bias, Risks, and Limitations
|
59 |
|
60 |
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
|
62 |
-
|
63 |
|
64 |
### Recommendations
|
65 |
|
@@ -71,7 +71,75 @@ Users (both direct and downstream) should be made aware of the risks, biases and
|
|
71 |
|
72 |
Use the code below to get started with the model.
|
73 |
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
## Training Details
|
77 |
|
@@ -79,20 +147,34 @@ Use the code below to get started with the model.
|
|
79 |
|
80 |
<!-- This should link to a Dataset 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. -->
|
81 |
|
82 |
-
|
83 |
|
84 |
### Training Procedure
|
85 |
|
86 |
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
|
88 |
-
|
89 |
|
90 |
-
|
91 |
|
|
|
92 |
|
93 |
#### Training Hyperparameters
|
94 |
|
95 |
-
- **Training regime:**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
#### Speeds, Sizes, Times [optional]
|
98 |
|
@@ -110,7 +192,7 @@ Use the code below to get started with the model.
|
|
110 |
|
111 |
<!-- This should link to a Dataset Card if possible. -->
|
112 |
|
113 |
-
|
114 |
|
115 |
#### Factors
|
116 |
|
@@ -122,7 +204,7 @@ Use the code below to get started with the model.
|
|
122 |
|
123 |
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
|
125 |
-
|
126 |
|
127 |
### Results
|
128 |
|
@@ -130,7 +212,7 @@ Use the code below to get started with the model.
|
|
130 |
|
131 |
#### Summary
|
132 |
|
133 |
-
|
134 |
|
135 |
## Model Examination [optional]
|
136 |
|
@@ -196,4 +278,4 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
|
|
196 |
|
197 |
## Model Card Contact
|
198 |
|
199 |
-
[More Information Needed]
|
|
|
7 |
|
8 |
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
|
10 |
+
This model is a fine-tuned version of Qwen2.5-0.5B-Instruct, trained using Generative Reinforcement Policy Optimization (GRPO) on the gsm8k math dataset. It is designed to solve math problems by generating reasoning steps and answers in a specific XML format.
|
11 |
|
12 |
## Model Details
|
13 |
|
|
|
15 |
|
16 |
<!-- Provide a longer summary of what this model is. -->
|
17 |
|
18 |
+
This model card describes a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
19 |
|
20 |
+
- **Developed by:** HarleyCoops
|
21 |
- **Funded by [optional]:** [More Information Needed]
|
22 |
- **Shared by [optional]:** [More Information Needed]
|
23 |
+
- **Model type:** Causal Language Model
|
24 |
+
- **Language(s) (NLP):** English
|
25 |
+
- **License:** Apache 2.0
|
26 |
+
- **Finetuned from model [optional]:** Qwen/Qwen2.5-0.5B-Instruct
|
27 |
|
28 |
### Model Sources [optional]
|
29 |
|
30 |
<!-- Provide the basic links for the model. -->
|
31 |
|
32 |
+
- **Repository:** https://github.com/HarleyCoops/TrainingRun
|
33 |
+
- **Paper [optional]:** https://arxiv.org/abs/2309.16676 (Qwen paper)
|
34 |
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
## Uses
|
|
|
41 |
|
42 |
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
|
44 |
+
The model is intended for solving math problems presented in English. It generates reasoning steps and an answer, formatted in XML tags. It can be used as a standalone tool for math problem-solving or integrated into a larger application.
|
45 |
|
46 |
### Downstream Use [optional]
|
47 |
|
48 |
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
|
50 |
+
The model can be further fine-tuned on other math datasets or used as a component in a more complex system that requires mathematical reasoning.
|
51 |
|
52 |
### Out-of-Scope Use
|
53 |
|
54 |
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
55 |
|
56 |
+
The model is specifically trained for math problem-solving. It may not perform well on tasks outside of this domain, such as general language understanding or generation. It may also struggle with math problems that require knowledge outside of the training data.
|
57 |
|
58 |
## Bias, Risks, and Limitations
|
59 |
|
60 |
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
|
62 |
+
The model's performance is limited by the quality and quantity of the training data. It may exhibit biases present in the gsm8k dataset. The model's ability to generalize to unseen math problems is also limited.
|
63 |
|
64 |
### Recommendations
|
65 |
|
|
|
71 |
|
72 |
Use the code below to get started with the model.
|
73 |
|
74 |
+
```python
|
75 |
+
# Import necessary libraries
|
76 |
+
import torch
|
77 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
78 |
+
|
79 |
+
# First, load the base model architecture
|
80 |
+
base_model = "Qwen/Qwen2.5-0.5B-Instruct"
|
81 |
+
model = AutoModelForCausalLM.from_pretrained(
|
82 |
+
base_model,
|
83 |
+
torch_dtype=torch.bfloat16,
|
84 |
+
device_map="auto",
|
85 |
+
trust_remote_code=True
|
86 |
+
)
|
87 |
+
|
88 |
+
# Load the fine-tuned weights
|
89 |
+
checkpoint_path = "outputs/Qwen-0.5B-GRPO/checkpoint-1868" # Specific checkpoint folder
|
90 |
+
model = AutoModelForCausalLM.from_pretrained(
|
91 |
+
checkpoint_path,
|
92 |
+
torch_dtype=torch.bfloat16,
|
93 |
+
device_map="auto",
|
94 |
+
trust_remote_code=True
|
95 |
+
)
|
96 |
+
|
97 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
98 |
+
checkpoint_path,
|
99 |
+
trust_remote_code=True
|
100 |
+
)
|
101 |
+
|
102 |
+
# Rest of the inference code remains the same
|
103 |
+
SYSTEM_PROMPT = """
|
104 |
+
Respond in the following format:
|
105 |
+
<reasoning>
|
106 |
+
...
|
107 |
+
</reasoning>
|
108 |
+
<answer>
|
109 |
+
...
|
110 |
+
</answer>
|
111 |
+
"""
|
112 |
+
|
113 |
+
def solve_math_problem(question: str):
|
114 |
+
prompt = [
|
115 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
116 |
+
{"role": "user", "content": question}
|
117 |
+
]
|
118 |
+
|
119 |
+
input_text = tokenizer.apply_chat_template(
|
120 |
+
prompt,
|
121 |
+
tokenize=False,
|
122 |
+
add_generation_prompt=True
|
123 |
+
)
|
124 |
+
|
125 |
+
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
|
126 |
+
outputs = model.generate(
|
127 |
+
**inputs,
|
128 |
+
max_new_tokens=200,
|
129 |
+
temperature=0.7,
|
130 |
+
num_return_sequences=1,
|
131 |
+
pad_token_id=tokenizer.pad_token_id,
|
132 |
+
eos_token_id=tokenizer.eos_token_id
|
133 |
+
)
|
134 |
+
|
135 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
136 |
+
return response
|
137 |
+
|
138 |
+
# Test with a sample problem
|
139 |
+
test_question = "A train travels at 60 miles per hour. If the journey is 270 miles long, how many hours will the trip take?"
|
140 |
+
print("\nQuestion:", test_question)
|
141 |
+
print("\nResponse:", solve_math_problem(test_question))
|
142 |
+
```
|
143 |
|
144 |
## Training Details
|
145 |
|
|
|
147 |
|
148 |
<!-- This should link to a Dataset 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. -->
|
149 |
|
150 |
+
The model was trained on the gsm8k dataset, which contains a set of grade school math problems.
|
151 |
|
152 |
### Training Procedure
|
153 |
|
154 |
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
155 |
|
156 |
+
The model was fine-tuned using Generative Reinforcement Policy Optimization (GRPO). The training process involved defining reward functions to encourage correct answers and proper formatting.
|
157 |
|
158 |
+
#### Preprocessing [optional]
|
159 |
|
160 |
+
The dataset was preprocessed to format the questions and answers in a conversational prompt format.
|
161 |
|
162 |
#### Training Hyperparameters
|
163 |
|
164 |
+
- **Training regime:** bf16 mixed precision
|
165 |
+
- **Learning Rate:** 5e-6
|
166 |
+
- **Adam Beta1:** 0.9
|
167 |
+
- **Adam Beta2:** 0.99
|
168 |
+
- **Weight Decay:** 0.1
|
169 |
+
- **Warmup Ratio:** 0.1
|
170 |
+
- **LR Scheduler Type:** cosine
|
171 |
+
- **Per Device Train Batch Size:** 1
|
172 |
+
- **Gradient Accumulation Steps:** 4
|
173 |
+
- **Number of Generations:** 16
|
174 |
+
- **Max Prompt Length:** 256
|
175 |
+
- **Max Completion Length:** 200
|
176 |
+
- **Number of Train Epochs:** 1
|
177 |
+
- **Max Grad Norm:** 0.1
|
178 |
|
179 |
#### Speeds, Sizes, Times [optional]
|
180 |
|
|
|
192 |
|
193 |
<!-- This should link to a Dataset Card if possible. -->
|
194 |
|
195 |
+
The model was evaluated on the gsm8k dataset.
|
196 |
|
197 |
#### Factors
|
198 |
|
|
|
204 |
|
205 |
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
206 |
|
207 |
+
The primary metric is the correctness of the generated answer. Additional metrics include adherence to the specified XML format.
|
208 |
|
209 |
### Results
|
210 |
|
|
|
212 |
|
213 |
#### Summary
|
214 |
|
215 |
+
[More Information Needed]
|
216 |
|
217 |
## Model Examination [optional]
|
218 |
|
|
|
278 |
|
279 |
## Model Card Contact
|
280 |
|
281 |
+
[More Information Needed]
|