steven0226 commited on
Commit
eafe399
·
verified ·
1 Parent(s): 530490b

Unsloth Model Card

Browse files
Files changed (1) hide show
  1. README.md +12 -146
README.md CHANGED
@@ -1,155 +1,21 @@
1
  ---
 
 
 
 
 
 
2
  license: apache-2.0
3
- base_model: Qwen/Qwen2.5-3B-Instruct
4
- datasets:
5
- - openai/gsm8k
6
  language:
7
  - en
8
- library_name: transformers
9
- pipeline_tag: text-generation
10
- tags:
11
- - grpo
12
- - rlvr
13
- - reasoning
14
- - unsloth
15
- - trl
16
- - qwen2.5
17
  ---
18
 
19
- # Qwen2.5-3B GRPO(RLVR)on GSM8K — merged 16-bit 完整模型
20
-
21
- 以 **GRPO**(Group Relative Policy Optimization)+ **可驗證獎勵**(RLVR)在 GSM8K
22
- 數學題上訓練 `Qwen/Qwen2.5-3B-Instruct` 的推理能力。LoRA adapter 版本:[steven0226/qwen2.5-3b-grpo-gsm8k-lora](https://huggingface.co/steven0226/qwen2.5-3b-grpo-gsm8k-lora)。
23
- 訓練程式與獎勵函數:[GitHub — grpo-rlvr-reasoning](https://github.com/kuotunyu/grpo-rlvr-reasoning)。
24
-
25
- ## 方法(白話)
26
-
27
- GRPO 對同一題一次抽 8 個回答,**組內互相比較**算出每個回答的
28
- 相對優勢(advantage),取代 PPO 的 value model;獎勵不是另一個神經網路
29
- (reward model),而是**可程式驗證的規則**:
30
-
31
- | 獎勵函數 | 條件 | 分數 |
32
- |---|---|---|
33
- | correctness_reward | `<answer>` 內數字 == 標準答案 | 2.0 |
34
- | strict_format_reward | 完整 `<reasoning>...</reasoning><answer>...</answer>` 結構 | 0.5 |
35
- | soft_format_reward | 兩組 tag 依序出現(部分符合) | 0.5 |
36
- | number_only_reward | `<answer>` 是純數字 | 0.5 |
37
-
38
- 答案對錯是可驗證的 —— 不會被 reward hacking、也省掉訓 reward model 的成本。
39
- 這就是 DeepSeek-R1 帶起的 RLVR 路線;本專案復刻其招牌現象:
40
- **completion 長度隨訓練成長、reward 同步爬升**(模型自己學會寫更長的推理)。
41
-
42
- ## 訓練曲線
43
-
44
- ![reward curve](figs/reward_curve.png)
45
-
46
- ![completion length curve](figs/completion_length_curve.png)
47
-
48
- ## 訓練前後對照
49
-
50
- **題目**:Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether in April and May?
51
-
52
- <details><summary>訓練前(base)</summary>
53
-
54
- ```
55
- <reasoning>
56
- To find out how many clips Natalia sold in total in April and May, we first need to determine the number of clips she sold in May. According to the problem, Natalia sold half as many clips in May as she did in April. Since she sold 48 clips in April, the number of clips sold in May would be half of 48. We can then add the number of clips sold in April and May to get the total.
57
-
58
- Let's perform the calculation:
59
- - Number of clips sold in April: 48
60
- - Number of clips sold in May: \(\frac{1}{2} \times 48 = 24\)
61
-
62
- Total clips sold in April and May: \(48 + 24 = 72\)
63
- </reasoning>
64
- <answer>
65
- Natalia sold a total of 72 clips in April and May.
66
- </answer>
67
- ```
68
- </details>
69
- <details><summary>訓練後(GRPO)</summary>
70
-
71
- ```
72
- <reasoning>
73
- To find out how many clips Natalia sold altogether in April and May, we need to follow these steps:
74
-
75
- 1. Determine how many clips Natalia sold in May.
76
- 2. Add the number of clips sold in April to the number of clips sold in May.
77
-
78
- First, we know that Natalia sold 48 clips in April. In May, she sold half as many clips as she did in April. Therefore, the number of clips sold in May is:
79
- \[ \text{Clips sold in May} = \frac{48}{2} = 24 \]
80
-
81
- Next, we add the clips sold in April to the clips sold in May:
82
- \[ \text{Total clips sold} = \text{Clips sold in April} + \text{Clips sold in May} = 48 + 24 = 72 \]
83
-
84
- So, the total number of clips Natalia sold in April and May is 72.
85
- </reasoning>
86
- <answer>
87
- 72
88
- </answer>
89
- ```
90
- </details>
91
-
92
- **題目**:Weng earns $12 an hour for babysitting. Yesterday, she just did 50 minutes of babysitting. How much did she earn?
93
-
94
- <details><summary>訓練前(base)</summary>
95
-
96
- ```
97
- <reasoning>
98
- Weng earns $12 per hour for babysitting. Since she babysat for 50 minutes, we first need to convert this time into hours because her pay rate is given per hour. There are 60 minutes in an hour, so 50 minutes is equivalent to 50/60 hours. We can simplify 50/60 to 5/6. Now, we need to calculate 12 * (5/6) to find out how much she earned.
99
- </reasoning>
100
- <answer>
101
- 12 * (5/6) = 10
102
- </answer>
103
- ```
104
- </details>
105
- <details><summary>訓練後(GRPO)</summary>
106
-
107
- ```
108
- <reasoning>
109
- To determine how much Weng earned for babysitting for 50 minutes at a rate of $12 per hour, we first need to convert the time into hours. There are 60 minutes in an hour.
110
-
111
- The conversion is:
112
- \[ \text{Time in hours} = \frac{\text{Time in minutes}}{60} = \frac{50}{60} = \frac{5}{6} \text{ hours} \]
113
-
114
- Next, we calculate the earnings by multiplying the hourly rate by the time in hours:
115
- \[ \text{Earnings} = \text{Hourly rate} \times \text{Time in hours} = 12 \times \frac{5}{6} \]
116
-
117
- To simplify the multiplication:
118
- \[ 12 \times \frac{5}{6} = 12 \times \frac{5}{6} = 2 \times 5 = 10 \]
119
-
120
- Therefore, Weng earned $10 for the babysitting.
121
- </reasoning>
122
- <answer>
123
- 10
124
- </answer>
125
- ```
126
- </details>
127
-
128
-
129
- ## 超參數
130
-
131
- | 項目 | 值 |
132
- |---|---|
133
- | base model | Qwen/Qwen2.5-3B-Instruct |
134
- | 演算法 | GRPO(TRL + Unsloth,vLLM rollout) |
135
- | LoRA rank / alpha | 32 / 32(QKVO + MLP 全模組) |
136
- | learning rate | 5e-06(cosine,warmup 0.1,adamw_8bit) |
137
- | num_generations | 8 |
138
- | max prompt / completion length | 256 / 768 |
139
- | steps | 500 |
140
- | 量化 | 4-bit QLoRA(訓練時) |
141
- | seed | 3407 |
142
-
143
- 超參以 Unsloth 官方 GRPO 範例為基準;偏差:LoRA r=32(官方 64)、
144
- completion 上限 768(官方 200,為觀察長度成長而加大)、
145
- strict_format regex 修正了官方版缺 re.DOTALL 導致多行推理永不匹配的問題。
146
-
147
- ## 資料與污染聲明
148
 
149
- 只使用 `openai/gsm8k`(config `main`)的 **train split(7,473 題)**;
150
- 評測用的另一個 split 在整個訓練管線中**零接觸**(notebook 內有 assert 與
151
- 程式級保證),評測結果見 GitHub repo `results/eval_report.md`。
152
 
153
- ## License
154
 
155
- Apache-2.0
 
1
  ---
2
+ base_model: unsloth/qwen2.5-3b-instruct-unsloth-bnb-4bit
3
+ tags:
4
+ - text-generation-inference
5
+ - transformers
6
+ - unsloth
7
+ - qwen2
8
  license: apache-2.0
 
 
 
9
  language:
10
  - en
 
 
 
 
 
 
 
 
 
11
  ---
12
 
13
+ # Uploaded finetuned model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
+ - **Developed by:** steven0226
16
+ - **License:** apache-2.0
17
+ - **Finetuned from model :** unsloth/qwen2.5-3b-instruct-unsloth-bnb-4bit
18
 
19
+ This qwen2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
20
 
21
+ [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)