steven0226/qwen2.5-3b-grpo-gsm8k
Qwen2.5-3B GRPO(RLVR)on GSM8K — merged 16-bit 完整模型
以 GRPO(Group Relative Policy Optimization)+ 可驗證獎勵(RLVR)在 GSM8K 數學題上訓練 Qwen/Qwen2.5-3B-Instruct 的推理能力。LoRA adapter 版本:steven0226/qwen2.5-3b-grpo-gsm8k-lora。 訓練程式與獎勵函數:GitHub — grpo-rlvr-reasoning。
方法(白話)
GRPO 對同一題一次抽 8 個回答,組內互相比較算出每個回答的 相對優勢(advantage),取代 PPO 的 value model;獎勵不是另一個神經網路 (reward model),而是可程式驗證的規則:
答案對錯可由規則驗證,省掉訓 reward model 的成本;但規則仍可能有可鑽漏洞, 所以本專案保留逐題輸出並稽核抽取、格式與長度。本次 1000-step run 的 reward 由約 1.4 上升並穩定於 3.1–3.3,strict format 由 19.5% 升到 90.0%;completion 長度沒有淨成長。從 500 步延長到 1000 步仍得到相同趨勢,提高了此負結果在本次 設定內的可信度,但不外推到其他模型、資料集或更長訓練。在已檢查的 200 題逐題 輸出中未發現明顯無效格式或簡單 verifier exploit;這不是「reward hacking 不可能」的保證。
完整分析見 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?
<details><summary>訓練前(base)</summary>
<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></details> <details><summary>訓練後(GRPO)</summary>
<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></details>
題目:Weng earns $12 an hour for babysitting. Yesterday, she just did 50 minutes of babysitting. How much did she earn?
<details><summary>訓練前(base)</summary>
<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></details> <details><summary>訓練後(GRPO)</summary>
<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></details>
超參數
超參以 Unsloth 官方 GRPO 範例為基準;偏差:LoRA r=32(官方 64)、 completion 上限 768(官方 200,為推理長度留觀察空間而加大,實測並未觀察到淨成長)、 strict_format regex 修正了官方版缺 re.DOTALL 導致多行推理永不匹配的問題。
資料與污染聲明
只使用 openai/gsm8k(config main)的 train split(7,473 題); 訓練程式只載入 openai/gsm8k(config main) 的 train split(7,473 題); test split 只由獨立的 eval/run_eval.py 載入。已提交評測固定使用 test 前 200 題, 逐題資料來源、MIT notice、revision、SHA-256 與可重現性限制見 GitHub results provenance。
Improved using Qwen. 本模型由 Qwen/Qwen2.5-3B-Instruct 經 GRPO/QLoRA 微調而成。授權與資料來源
- 模型 artifact: 受 Qwen Research License 約束, 僅授權非商業研究與評估;商業使用需另向 Qwen/Alibaba Cloud 取得授權。 下載或散布本模型不會取得 GitHub 原始碼的 Apache-2.0 授權。
- GSM8K: 訓練資料來自 OpenAI 的 GSM8K,原始資料以 MIT License 發布。 請引用 Cobbe et al., Training Verifiers to Solve Math Word Problems, arXiv:2110.14168 (2021)。
- 原始碼: 訓練、評測與分析程式的個別授權與第三方聲明請見 GitHub repo 的
LICENSE、LICENSES/與THIRD_PARTY_NOTICES.md。
Redistribution notice: Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) Alibaba Cloud. All Rights Reserved.
