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, )
Qwen2.5-3B GRPO(RLVR)on GSM8K — LoRA adapter(rank 32)
以 GRPO(Group Relative Policy Optimization)+ 可驗證獎勵(RLVR)在 GSM8K
數學題上訓練 Qwen/Qwen2.5-3B-Instruct 的推理能力。完整 merged 模型:steven0226/qwen2.5-3b-grpo-gsm8k。
訓練程式與獎勵函數:GitHub — grpo-rlvr-reasoning。
方法(白話)
GRPO 對同一題一次抽 8 個回答,組內互相比較算出每個回答的 相對優勢(advantage),取代 PPO 的 value model;獎勵不是另一個神經網路 (reward model),而是可程式驗證的規則:
| 獎勵函數 | 條件 | 分數 |
|---|---|---|
| correctness_reward | <answer> 內數字 == 標準答案 |
2.0 |
| strict_format_reward | 完整 <reasoning>...</reasoning><answer>...</answer> 結構 |
0.5 |
| soft_format_reward | 兩組 tag 依序出現(部分符合) | 0.5 |
| number_only_reward | <answer> 是純數字 |
0.5 |
答案對錯是可驗證的 —— 不會被 reward hacking、也省掉訓 reward model 的成本。
這就是 DeepSeek-R1 帶起的 RLVR 路線。訓練結果:reward 乾淨爬升(從 1.4 穩定到
3.13.3,滿分 3.5),strict format 遵循率從 19.5% 衝到 90%。但 completion 長度
並沒有隨訓練淨成長 —— 這點特別驗證過:500 步觀察到後又延長訓練到 1000 步重現
幾乎一樣的結果,排除了「訓不夠久」的可能。更細緻的分析發現模型學到的是「難題多想、
易題少想」的效率提升(每個難度區間的輸出都比訓練前短,但難題仍分配更多 token),
而不是無腦的長度成長。完整分析見
GitHub README。
訓練曲線
訓練前後對照
題目: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?
訓練前(base)
<reasoning>
To find out how many clips Natalia sold altogether in April and May, we need to follow these steps:
1. Determine the number of clips sold in May.
2. Sum the clips sold in April and May.
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:
\[
\text{Clips sold in May} = \frac{48}{2} = 24
\]
Next, to find the total number of clips sold in April and May, we add the clips sold in each month:
\[
\text{Total clips sold} = \text{Clips sold in April} + \text{Clips sold in May} = 48 + 24
\]
Performing the addition:
\[
48 + 24 = 72
\]
Therefore, Natalia sold a total of 72 clips in April and May.
</reasoning>
<answer>
72 clips
Natalia sold a total of 72 clips in April and May. </answer>
訓練後(GRPO)
<reasoning>
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:
\[ \text{Clips sold in May} = \frac{48}{2} = 24 \]
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:
\[ \text{Total clips sold} = \text{Clips sold in April} + \text{Clips sold in May} = 48 + 24 = 72 \]
Therefore, the total number of clips Natalia sold in April and May is 72.
</reasoning>
<answer>
72
</answer>
題目:Weng earns $12 an hour for babysitting. Yesterday, she just did 50 minutes of babysitting. How much did she earn?
訓練前(base)
<reasoning>
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.
Next, we multiply the number of hours she worked by her hourly wage of $12 to find out how much she earned.
\[
\text{Hours worked} = \frac{50}{60} = \frac{5}{6} \text{ hours}
\]
\[
\text{Earnings} = \text{Hours worked} \times \text{Hourly wage} = \frac{5}{6} \times 12
\]
\[
\text{Earnings} = \frac{5 \times 12}{6} = \frac{60}{6} = 10
\]
Therefore, Weng earned $10.
</reasoning>
<answer>
Weng earned $10 for babysitting 50 minutes.
</answer>
訓練後(GRPO)
<reasoning>
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:
\[ \text{Hours} = \frac{\text{Minutes}}{60} \]
Substituting 50 for minutes:
\[ \text{Hours} = \frac{50}{60} = \frac{5}{6} \text{ hours} \]
Next, we calculate the earnings by multiplying the hourly rate by the number of hours worked:
\[ \text{Earnings} = \text{Hourly Rate} \times \text{Hours Worked} \]
Substituting $12 for the hourly rate and \(\frac{5}{6}\) for the hours worked:
\[ \text{Earnings} = 12 \times \frac{5}{6} \]
To simplify the multiplication:
\[ \text{Earnings} = 12 \times \frac{5}{6} = 12 \times \frac{5}{6} = 2 \times 5 = 10 \]
Therefore, Weng earned $10.
</reasoning>
<answer>
10
</answer>
超參數
| 項目 | 值 |
|---|---|
| base model | Qwen/Qwen2.5-3B-Instruct |
| 演算法 | GRPO(TRL + Unsloth,vLLM rollout) |
| LoRA rank / alpha | 32 / 32(QKVO + MLP 全模組) |
| learning rate | 5e-06(cosine,warmup 0.1,adamw_8bit) |
| num_generations | 8 |
| max prompt / completion length | 256 / 768 |
| steps | 1000 |
| 量化 | 4-bit QLoRA(訓練時) |
| seed | 3407 |
超參以 Unsloth 官方 GRPO 範例為基準;偏差:LoRA r=32(官方 64)、 completion 上限 768(官方 200,為推理長度留觀察空間而加大,實測並未觀察到淨成長)、 strict_format regex 修正了官方版缺 re.DOTALL 導致多行推理永不匹配的問題。
資料與污染聲明
只使用 openai/gsm8k(config main)的 train split(7,473 題);
評測用的另一個 split 在整個訓練管線中零接觸(notebook 內有 assert 與
程式級保證),評測結果見 GitHub repo 的 results/eval_report.md。
License
Apache-2.0
- Downloads last month
- 85

