Improve language tag
#2
by
lbourdois
- opened
README.md
CHANGED
@@ -1,99 +1,111 @@
|
|
1 |
-
---
|
2 |
-
library_name: transformers
|
3 |
-
tags:
|
4 |
-
- unsloth
|
5 |
-
- reasoning
|
6 |
-
- mathematics
|
7 |
-
- math
|
8 |
-
datasets:
|
9 |
-
- openai/gsm8k
|
10 |
-
language:
|
11 |
-
-
|
12 |
-
|
13 |
-
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
)
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
Trained on GSM8K mathematics dataset.
|
|
|
1 |
+
---
|
2 |
+
library_name: transformers
|
3 |
+
tags:
|
4 |
+
- unsloth
|
5 |
+
- reasoning
|
6 |
+
- mathematics
|
7 |
+
- math
|
8 |
+
datasets:
|
9 |
+
- openai/gsm8k
|
10 |
+
language:
|
11 |
+
- zho
|
12 |
+
- eng
|
13 |
+
- fra
|
14 |
+
- spa
|
15 |
+
- por
|
16 |
+
- deu
|
17 |
+
- ita
|
18 |
+
- rus
|
19 |
+
- jpn
|
20 |
+
- kor
|
21 |
+
- vie
|
22 |
+
- tha
|
23 |
+
- ara
|
24 |
+
base_model:
|
25 |
+
- Qwen/Qwen2.5-3B-Instruct
|
26 |
+
---
|
27 |
+
|
28 |
+
# Model Card for Model ID
|
29 |
+
|
30 |
+
This is an early experiment using the `GRPOTrainer` and training reasoning models using the Unsloth library. It is not intended for real use, but it should work OK for simple prompt tests and easy mathematics questions.
|
31 |
+
|
32 |
+
(You can run this using the code below on a free Colab/Kaggle basic GPU account for testing.)
|
33 |
+
|
34 |
+
**NOTE:** If you are interested in reasoning models and research in this area, I maintain an up-to-date resource list here : [https://github.com/benjaminzwhite/reasoning-models](https://github.com/benjaminzwhite/reasoning-models)
|
35 |
+
|
36 |
+
- Example query: `"What is the smallest prime number greater than 50 ?"`
|
37 |
+
|
38 |
+
- Example response: `"<reasoning>\nTo find the smallest prime number greater than 50, we can start checking from 51 onwards for primality. A prime number is a number that has no divisors other than 1 and itself. We check each number to see if it's divisible by any number other than 1 and itself.\n</reasoning>\n<answer>\n53\n</answer>"`
|
39 |
+
|
40 |
+
|
41 |
+
## How to Get Started with the Model
|
42 |
+
|
43 |
+
To use this with standard HuggingFace code, I recommend starting with this code (based 95% on the default code shown at the base model page : [https://huggingface.co/Qwen/Qwen2.5-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct))
|
44 |
+
|
45 |
+
```python
|
46 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
47 |
+
|
48 |
+
model_name = "benjaminzwhite/Qwen2.5-3B-Instruct_GSM8K-GRPO_16bit"
|
49 |
+
|
50 |
+
# model loading
|
51 |
+
model = AutoModelForCausalLM.from_pretrained(
|
52 |
+
model_name,
|
53 |
+
torch_dtype="auto",
|
54 |
+
device_map="auto"
|
55 |
+
)
|
56 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
57 |
+
|
58 |
+
# system prompt used during training
|
59 |
+
SYSTEM_PROMPT = """
|
60 |
+
Respond in the following format:
|
61 |
+
<reasoning>
|
62 |
+
...
|
63 |
+
</reasoning>
|
64 |
+
<answer>
|
65 |
+
...
|
66 |
+
</answer>
|
67 |
+
"""
|
68 |
+
|
69 |
+
# your query goes here
|
70 |
+
user_prompt = "What is the smallest prime number greater than 50 ?"
|
71 |
+
|
72 |
+
messages = [
|
73 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
74 |
+
{"role": "user", "content": user_prompt}
|
75 |
+
]
|
76 |
+
|
77 |
+
# default Qwen2.5 code from this point ...
|
78 |
+
text = tokenizer.apply_chat_template(
|
79 |
+
messages,
|
80 |
+
tokenize=False,
|
81 |
+
add_generation_prompt=True
|
82 |
+
)
|
83 |
+
|
84 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
85 |
+
|
86 |
+
generated_ids = model.generate(
|
87 |
+
**model_inputs,
|
88 |
+
max_new_tokens=512
|
89 |
+
)
|
90 |
+
generated_ids = [
|
91 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
92 |
+
]
|
93 |
+
|
94 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
95 |
+
|
96 |
+
print(response)
|
97 |
+
|
98 |
+
# sample answer obtained to my query, to show expected format
|
99 |
+
# (note that the answer, 53, is correct here)
|
100 |
+
"""
|
101 |
+
"<reasoning>\nTo find the smallest prime number greater than 50, we can start checking from 51 onwards for primality. A prime number is a number that has no divisors other than 1 and itself. We check each number to see if it's divisible by any number other than 1 and itself.\n</reasoning>\n<answer>\n53\n</answer>"
|
102 |
+
"""
|
103 |
+
```
|
104 |
+
|
105 |
+
## Training Details
|
106 |
+
|
107 |
+
### Training Data
|
108 |
+
|
109 |
+
<!-- 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. -->
|
110 |
+
|
111 |
Trained on GSM8K mathematics dataset.
|