Instructions to use steven0226/qwen2.5-3b-grpo-gsm8k-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use steven0226/qwen2.5-3b-grpo-gsm8k-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/qwen2.5-3b-instruct-unsloth-bnb-4bit") model = PeftModel.from_pretrained(base_model, "steven0226/qwen2.5-3b-grpo-gsm8k-lora") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Studio
How to use steven0226/qwen2.5-3b-grpo-gsm8k-lora with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for steven0226/qwen2.5-3b-grpo-gsm8k-lora to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for steven0226/qwen2.5-3b-grpo-gsm8k-lora to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for steven0226/qwen2.5-3b-grpo-gsm8k-lora to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="steven0226/qwen2.5-3b-grpo-gsm8k-lora", max_seq_length=2048, )
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,210 +1,193 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
library_name: peft
|
| 4 |
pipeline_tag: text-generation
|
| 5 |
tags:
|
| 6 |
-
- base_model:adapter:unsloth/qwen2.5-3b-instruct-unsloth-bnb-4bit
|
| 7 |
- grpo
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
- trl
|
| 11 |
- unsloth
|
|
|
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
## Model Details
|
| 21 |
-
|
| 22 |
-
### Model Description
|
| 23 |
-
|
| 24 |
-
<!-- Provide a longer summary of what this model is. -->
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
- **Developed by:** [More Information Needed]
|
| 29 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 30 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 31 |
-
- **Model type:** [More Information Needed]
|
| 32 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 33 |
-
- **License:** [More Information Needed]
|
| 34 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 35 |
-
|
| 36 |
-
### Model Sources [optional]
|
| 37 |
-
|
| 38 |
-
<!-- Provide the basic links for the model. -->
|
| 39 |
-
|
| 40 |
-
- **Repository:** [More Information Needed]
|
| 41 |
-
- **Paper [optional]:** [More Information Needed]
|
| 42 |
-
- **Demo [optional]:** [More Information Needed]
|
| 43 |
-
|
| 44 |
-
## Uses
|
| 45 |
-
|
| 46 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 47 |
-
|
| 48 |
-
### Direct Use
|
| 49 |
-
|
| 50 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 51 |
-
|
| 52 |
-
[More Information Needed]
|
| 53 |
-
|
| 54 |
-
### Downstream Use [optional]
|
| 55 |
-
|
| 56 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 57 |
-
|
| 58 |
-
[More Information Needed]
|
| 59 |
-
|
| 60 |
-
### Out-of-Scope Use
|
| 61 |
-
|
| 62 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 63 |
-
|
| 64 |
-
[More Information Needed]
|
| 65 |
-
|
| 66 |
-
## Bias, Risks, and Limitations
|
| 67 |
-
|
| 68 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 69 |
-
|
| 70 |
-
[More Information Needed]
|
| 71 |
-
|
| 72 |
-
### Recommendations
|
| 73 |
-
|
| 74 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 75 |
-
|
| 76 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 77 |
-
|
| 78 |
-
## How to Get Started with the Model
|
| 79 |
-
|
| 80 |
-
Use the code below to get started with the model.
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
-
|
| 84 |
-
## Training Details
|
| 85 |
-
|
| 86 |
-
### Training Data
|
| 87 |
-
|
| 88 |
-
<!-- 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. -->
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
### Training Procedure
|
| 93 |
-
|
| 94 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 95 |
-
|
| 96 |
-
#### Preprocessing [optional]
|
| 97 |
-
|
| 98 |
-
[More Information Needed]
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
#### Training Hyperparameters
|
| 102 |
-
|
| 103 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 104 |
-
|
| 105 |
-
#### Speeds, Sizes, Times [optional]
|
| 106 |
|
| 107 |
-
|
|
|
|
|
|
|
| 108 |
|
| 109 |
-
|
| 110 |
|
| 111 |
-
|
|
|
|
|
|
|
| 112 |
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
-
|
|
|
|
|
|
|
| 116 |
|
| 117 |
-
##
|
| 118 |
|
| 119 |
-
|
| 120 |
|
| 121 |
-
[
|
| 122 |
|
| 123 |
-
##
|
| 124 |
|
| 125 |
-
|
| 126 |
|
| 127 |
-
|
| 128 |
|
| 129 |
-
|
|
|
|
|
|
|
| 130 |
|
| 131 |
-
|
|
|
|
| 132 |
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
| 136 |
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
-
|
| 140 |
|
|
|
|
|
|
|
|
|
|
| 141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
-
|
|
|
|
|
|
|
| 144 |
|
| 145 |
-
|
| 146 |
|
| 147 |
-
|
| 148 |
|
| 149 |
-
|
| 150 |
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
-
|
| 154 |
|
| 155 |
-
|
| 156 |
-
- **Hours used:** [More Information Needed]
|
| 157 |
-
- **Cloud Provider:** [More Information Needed]
|
| 158 |
-
- **Compute Region:** [More Information Needed]
|
| 159 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 160 |
|
| 161 |
-
|
|
|
|
|
|
|
| 162 |
|
| 163 |
-
|
| 164 |
|
| 165 |
-
[
|
|
|
|
|
|
|
| 166 |
|
| 167 |
-
|
|
|
|
|
|
|
| 168 |
|
| 169 |
-
[
|
|
|
|
|
|
|
| 170 |
|
| 171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
-
|
|
|
|
|
|
|
| 174 |
|
| 175 |
-
|
| 176 |
|
| 177 |
-
|
| 178 |
|
| 179 |
-
|
| 180 |
|
| 181 |
-
|
| 182 |
|
| 183 |
-
|
| 184 |
|
| 185 |
-
|
| 186 |
|
| 187 |
-
|
| 188 |
|
| 189 |
-
|
| 190 |
|
| 191 |
-
|
| 192 |
|
| 193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
-
[More Information Needed]
|
| 196 |
|
| 197 |
-
##
|
| 198 |
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
-
|
|
|
|
|
|
|
| 202 |
|
| 203 |
-
|
| 204 |
|
| 205 |
-
|
|
|
|
|
|
|
| 206 |
|
| 207 |
-
|
| 208 |
-
### Framework versions
|
| 209 |
|
| 210 |
-
-
|
|
|
|
| 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: peft
|
| 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 — LoRA adapter(rank 32)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
以 **GRPO**(Group Relative Policy Optimization)+ **可驗證獎勵**(RLVR)在 GSM8K
|
| 22 |
+
數學題上訓練 `Qwen/Qwen2.5-3B-Instruct` 的推理能力。完整 merged 模型:[steven0226/qwen2.5-3b-grpo-gsm8k](https://huggingface.co/steven0226/qwen2.5-3b-grpo-gsm8k)。
|
| 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 |
+

|
| 45 |
|
| 46 |
+

|
| 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 altogether in April and May, we need to follow these steps:
|
| 57 |
|
| 58 |
+
1. Determine the number of clips sold in May.
|
| 59 |
+
2. Sum the clips sold in April and May.
|
| 60 |
|
| 61 |
+
First, we know that Natalia sold 48 clips in April. According to the problem, she sold half as many clips in May as she did in April. Thus, the number of clips sold in May would be:
|
| 62 |
+
\[
|
| 63 |
+
\text{Clips sold in May} = \frac{48}{2} = 24
|
| 64 |
+
\]
|
| 65 |
|
| 66 |
+
Next, to find the total number of clips sold in April and May, we add the clips sold in each month:
|
| 67 |
+
\[
|
| 68 |
+
\text{Total clips sold} = \text{Clips sold in April} + \text{Clips sold in May} = 48 + 24
|
| 69 |
+
\]
|
| 70 |
|
| 71 |
+
Performing the addition:
|
| 72 |
+
\[
|
| 73 |
+
48 + 24 = 72
|
| 74 |
+
\]
|
| 75 |
|
| 76 |
+
Therefore, Natalia sold a total of 72 clips in April and May.
|
| 77 |
|
| 78 |
+
</reasoning>
|
| 79 |
+
<answer>
|
| 80 |
+
72 clips
|
| 81 |
|
| 82 |
+
Natalia sold a total of 72 clips in April and May. </answer>
|
| 83 |
+
```
|
| 84 |
+
</details>
|
| 85 |
+
<details><summary>訓練後(GRPO)</summary>
|
| 86 |
|
| 87 |
+
```
|
| 88 |
+
<reasoning>
|
| 89 |
+
To determine the total number of clips Natalia sold in April and May, we first need to find out how many 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 is:
|
| 90 |
|
| 91 |
+
\[ \text{Clips sold in May} = \frac{48}{2} = 24 \]
|
| 92 |
|
| 93 |
+
Next, we need to find the total number of clips sold in both April and May by adding the clips sold in April to the clips sold in May:
|
| 94 |
|
| 95 |
+
\[ \text{Total clips sold} = \text{Clips sold in April} + \text{Clips sold in May} = 48 + 24 = 72 \]
|
| 96 |
|
| 97 |
+
Therefore, the total number of clips Natalia sold in April and May is 72.
|
| 98 |
+
</reasoning>
|
| 99 |
+
<answer>
|
| 100 |
+
72
|
| 101 |
+
</answer>
|
| 102 |
+
```
|
| 103 |
+
</details>
|
| 104 |
|
| 105 |
+
**題目**:Weng earns $12 an hour for babysitting. Yesterday, she just did 50 minutes of babysitting. How much did she earn?
|
| 106 |
|
| 107 |
+
<details><summary>訓練前(base)</summary>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
+
```
|
| 110 |
+
<reasoning>
|
| 111 |
+
To determine how much Weng earned, we first need to convert her babysitting time into hours since her hourly rate is given in dollars per hour. Since there are 60 minutes in an hour, 50 minutes can be converted to hours by dividing 50 by 60.
|
| 112 |
|
| 113 |
+
Next, we multiply the number of hours she worked by her hourly wage of $12 to find out how much she earned.
|
| 114 |
|
| 115 |
+
\[
|
| 116 |
+
\text{Hours worked} = \frac{50}{60} = \frac{5}{6} \text{ hours}
|
| 117 |
+
\]
|
| 118 |
|
| 119 |
+
\[
|
| 120 |
+
\text{Earnings} = \text{Hours worked} \times \text{Hourly wage} = \frac{5}{6} \times 12
|
| 121 |
+
\]
|
| 122 |
|
| 123 |
+
\[
|
| 124 |
+
\text{Earnings} = \frac{5 \times 12}{6} = \frac{60}{6} = 10
|
| 125 |
+
\]
|
| 126 |
|
| 127 |
+
Therefore, Weng earned $10.
|
| 128 |
+
</reasoning>
|
| 129 |
+
<answer>
|
| 130 |
+
Weng earned $10 for babysitting 50 minutes.
|
| 131 |
+
</answer>
|
| 132 |
+
```
|
| 133 |
+
</details>
|
| 134 |
+
<details><summary>訓練後(GRPO)</summary>
|
| 135 |
|
| 136 |
+
```
|
| 137 |
+
<reasoning>
|
| 138 |
+
To determine how much Weng earned, we need to calculate the earnings based on the hourly rate and the number of hours worked. First, we need to convert the time worked from minutes to hours. We know that 1 hour is equal to 60 minutes. Weng worked for 50 minutes, which is less than 1 hour. We can find out how many hours 50 minutes is equivalent to by using the conversion factor:
|
| 139 |
|
| 140 |
+
\[ \text{Hours} = \frac{\text{Minutes}}{60} \]
|
| 141 |
|
| 142 |
+
Substituting 50 for minutes:
|
| 143 |
|
| 144 |
+
\[ \text{Hours} = \frac{50}{60} = \frac{5}{6} \text{ hours} \]
|
| 145 |
|
| 146 |
+
Next, we calculate the earnings by multiplying the hourly rate by the number of hours worked:
|
| 147 |
|
| 148 |
+
\[ \text{Earnings} = \text{Hourly Rate} \times \text{Hours Worked} \]
|
| 149 |
|
| 150 |
+
Substituting $12 for the hourly rate and \(\frac{5}{6}\) for the hours worked:
|
| 151 |
|
| 152 |
+
\[ \text{Earnings} = 12 \times \frac{5}{6} \]
|
| 153 |
|
| 154 |
+
To simplify the multiplication:
|
| 155 |
|
| 156 |
+
\[ \text{Earnings} = 12 \times \frac{5}{6} = 12 \times \frac{5}{6} = 2 \times 5 = 10 \]
|
| 157 |
|
| 158 |
+
Therefore, Weng earned $10.
|
| 159 |
+
</reasoning>
|
| 160 |
+
<answer>
|
| 161 |
+
10
|
| 162 |
+
</answer>
|
| 163 |
+
```
|
| 164 |
+
</details>
|
| 165 |
|
|
|
|
| 166 |
|
| 167 |
+
## 超參數
|
| 168 |
|
| 169 |
+
| 項目 | 值 |
|
| 170 |
+
|---|---|
|
| 171 |
+
| base model | Qwen/Qwen2.5-3B-Instruct |
|
| 172 |
+
| 演算法 | GRPO(TRL + Unsloth,vLLM rollout) |
|
| 173 |
+
| LoRA rank / alpha | 32 / 32(QKVO + MLP 全模組) |
|
| 174 |
+
| learning rate | 5e-06(cosine,warmup 0.1,adamw_8bit) |
|
| 175 |
+
| num_generations | 8 |
|
| 176 |
+
| max prompt / completion length | 256 / 768 |
|
| 177 |
+
| steps | 1000 |
|
| 178 |
+
| 量化 | 4-bit QLoRA(訓練時) |
|
| 179 |
+
| seed | 3407 |
|
| 180 |
|
| 181 |
+
超參以 Unsloth 官方 GRPO 範例為基準;偏差:LoRA r=32(官方 64)、
|
| 182 |
+
completion 上限 768(官方 200,為觀察長度成長而加大)、
|
| 183 |
+
strict_format regex 修正了官方版缺 re.DOTALL 導致多行推理永不匹配的問題。
|
| 184 |
|
| 185 |
+
## 資料與污染聲明
|
| 186 |
|
| 187 |
+
只使用 `openai/gsm8k`(config `main`)的 **train split(7,473 題)**;
|
| 188 |
+
評測用的另一個 split 在整個訓練管線中**零接觸**(notebook 內有 assert 與
|
| 189 |
+
程式級保證),評測結果見 GitHub repo 的 `results/eval_report.md`。
|
| 190 |
|
| 191 |
+
## License
|
|
|
|
| 192 |
|
| 193 |
+
Apache-2.0
|