Views
No views yet
1from modelscope import pipeline
2from modelscope.msdatasets import MsDataset
3ds = MsDataset.load('modelscope/gsm8k', subset_name='main', split='test',trust_remote_code=True)
4sample = ds[0]
5question = sample['question']
6true_answer = sample['answer']
7print(question,true_answer)
8
9generator = pipeline(
10 task="text-generation",
11 model="yuanmodel/Qwen3-0.6B-GRPO-GSM8K-Think",
12 device="cuda",trust_remote_code=True
13)
14
15output = generator([{"role": "user", "content": question}], max_new_tokens=512)
16print("Raw output:", output)
17print("answer", output["message"]["content"])1Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market? Janet sells 16 - 3 - 4 = <<16-3-4=9>>9 duck eggs a day.
2She makes 9 * 2 = $<<9*2=18>>18 every day at the farmer's market.
3#### 18
4
5
6Raw output: {'message': {'role': 'assistant', 'content': "<think>\nOkay, let me try to figure out how much Janet makes every day at the farmers' market. Hmm, so first, I need to break down her daily activities and calculate each part. Let me start by listing out what she does each day.\n\nJanet's ducks lay 16 eggs per day. So, if she does that every day, the total eggs laid would be 16 eggs. Then, she eats three eggs for breakfast. So, that's 3 eggs. Then, she bakes muffins for her friends every day with four eggs per muffin. So, 4 eggs per muffin times the number of days she bakes. Since it's a daily activity, that's 4 times 1, so 4 eggs total for muffins. \n\nAfter that, the remainder of the eggs is sold at the farmers' market for $2 per egg. So, the eggs remaining after breakfast and muffins would be 16 eggs minus 3 eggs (breakfast) minus 4 eggs (muffins) equals 9 eggs. Then, 9 eggs multiplied by $2 per egg gives the total amount for the market.\n\nLet me check the math step by step to make sure I didn't make a mistake. 16 eggs total. Subtract 3 for breakfast: 16 - 3 = 13 eggs left. Then 13 - 4 = 9 eggs. Multiply 9 by 2: 18 dollars. So, $18 should be the amount she makes at the market. That seems right.\n\nWait, just to confirm, 16 - 3 is 13, 13 - 4 is 9, 9*2 is 18. Yep, that adds up. I don't think I missed anything here. So the answer should be $18.\n</think>\n\nJanet's ducks lay 16 eggs per day. She eats 3 eggs for breakfast, and bakes 4 eggs for muffins daily. The remainder is sold at the farmers' market for $2 per egg.\n\n1. Total eggs: $16$\n2. Eggs eaten: $16 - 3 = 13$\n3. Eggs remaining: $13 - 4 = 9$\n4. Revenue from market: $9 \\times 2 = 18$\n\n**Answer:** Janet makes $\\boxed{18}$ dollars every day at the farmers' market."}}
7answer <think>
8Okay, let me try to figure out how much Janet makes every day at the farmers' market. Hmm, so first, I need to break down her daily activities and calculate each part. Let me start by listing out what she does each day.
9
10Janet's ducks lay 16 eggs per day. So, if she does that every day, the total eggs laid would be 16 eggs. Then, she eats three eggs for breakfast. So, that's 3 eggs. Then, she bakes muffins for her friends every day with four eggs per muffin. So, 4 eggs per muffin times the number of days she bakes. Since it's a daily activity, that's 4 times 1, so 4 eggs total for muffins.
11
12After that, the remainder of the eggs is sold at the farmers' market for $2 per egg. So, the eggs remaining after breakfast and muffins would be 16 eggs minus 3 eggs (breakfast) minus 4 eggs (muffins) equals 9 eggs. Then, 9 eggs multiplied by $2 per egg gives the total amount for the market.
13
14Let me check the math step by step to make sure I didn't make a mistake. 16 eggs total. Subtract 3 for breakfast: 16 - 3 = 13 eggs left. Then 13 - 4 = 9 eggs. Multiply 9 by 2: 18 dollars. So, $18 should be the amount she makes at the market. That seems right.
15
16Wait, just to confirm, 16 - 3 is 13, 13 - 4 is 9, 9*2 is 18. Yep, that adds up. I don't think I missed anything here. So the answer should be $18.
17</think>
18
19Janet's ducks lay 16 eggs per day. She eats 3 eggs for breakfast, and bakes 4 eggs for muffins daily. The remainder is sold at the farmers' market for $2 per egg.
20
211. Total eggs: $16$
222. Eggs eaten: $16 - 3 = 13$
233. Eggs remaining: $13 - 4 = 9$
244. Revenue from market: $9 \times 2 = 18$
25
26**Answer:** Janet makes $\boxed{18}$ dollars every day at the farmers' market.1from modelscope import pipeline
2from modelscope.msdatasets import MsDataset
3
4SYSTEM_PROMPT = """
5Please solve the math problem step by step. Use <think> tags to show your reasoning process, then provide the final numerical answer.
6
7IMPORTANT: Your final answer must be a pure number only, following these rules:
8- No currency symbols: use 42, not $42 or 42 dollars
9- No thousand separators: use 16000, not 16,000 or 16 000
10- No decimal if integer: use 42, not 42.0 or 42.00
11- No units or text: use 144, not 144 gallons or 144 total
12
13Examples:
14- Good: 42, 16000, 144, 999000
15- Bad: $42, 16,000, 42.0, 144 gallons
16
17Format:
18<think>
19Your step-by-step reasoning here...
20</think>
21Final answer: [pure number only]
22"""
23
24
25ds = MsDataset.load('modelscope/gsm8k', subset_name='main', split='test', trust_remote_code=True)
26sample = ds[0]
27question = sample['question']
28true_answer = sample['answer']
29print("Question:", question)
30print("True answer:", true_answer)
31
32messages = [
33 {"role": "system", "content": SYSTEM_PROMPT},
34 {"role": "user", "content": question}
35]
36
37generator = pipeline(
38 task="text-generation",
39 model="yuanmodel/Qwen3-0.6B-GRPO-GSM8K-Think",
40 device="cuda",
41 trust_remote_code=True
42)
43
44output = generator(messages, max_new_tokens=512)
45print("Raw output:", output)
46print("Model answer:", output["message"]["content"])1Raw output: {'message': {'role': 'assistant', 'content': "<think>\nOkay, let's see. Janet's ducks lay 16 eggs per day. She eats three eggs for breakfast and four eggs for baking muffins each day. Then she sells the rest at $2 per egg. So, I need to calculate how many eggs she has left each day, multiply that by $2, and that should give the total amount she makes.\n\nFirst, let's find out the total eggs per day. She lays 16 eggs, eats 3 + 4 = 7 eggs. So total eggs left = 16 - 7 = 9 eggs per day. Then multiply by $2: 9 * 2 = $18. So, the answer should be $18.\n</think>\n\nFinal answer: 18"}}
2Model answer: <think>
3Okay, let's see. Janet's ducks lay 16 eggs per day. She eats three eggs for breakfast and four eggs for baking muffins each day. Then she sells the rest at $2 per egg. So, I need to calculate how many eggs she has left each day, multiply that by $2, and that should give the total amount she makes.
4
5First, let's find out the total eggs per day. She lays 16 eggs, eats 3 + 4 = 7 eggs. So total eggs left = 16 - 7 = 9 eggs per day. Then multiply by $2: 9 * 2 = $18. So, the answer should be $18.
6</think>
7
8Final answer: 18
9| Model | GSM8K-Val | GSM8K-Test | Improvement |
|---|---|---|---|
| Qwen/Qwen3-0.6B (official) | - | 59.59% | - |
| Qwen/Qwen3-0.6B (local reproduction) | 53.25% | 56.33% | - |
| Qwen/Qwen3-0.6B GRPO-checkpoint-160 | - | 59.67% | +5.92% |
| Qwen/Qwen3-0.6B GRPO-checkpoint-180 | 62.8% | 60.65% | +7.66% |
1@article{zhihong2024deepseekmath,
2 title = {{DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models}},
3 author = {Zhihong Shao and Peiyi Wang and Qihao Zhu and Runxin Xu and Junxiao Song and Mingchuan Zhang and Y. K. Li and Y. Wu and Daya Guo},
4 year = 2024,
5 eprint = {arXiv:2402.03300},
6}
71@misc{vonwerra2022trl,
2 title = {{TRL: Transformer Reinforcement Learning}},
3 author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
4 year = 2020,
5 journal = {GitHub repository},
6 publisher = {GitHub},
7 howpublished = {\url{https://github.com/huggingface/trl}}
8}