Views
No views yet
meta-llama/Llama-3.2-1B:<think> reasoning tags for step-by-step problem solving/project/rcc/youzhi/Llama-3.2-1B-reasoning/final_modelmeta-llama/Llama-3.2-1B1user: {question}
2assistant: <think>{reasoning}</think>{answer}/project/rcc/youzhi/Llama-3.2-1B-reasoning/final_model)1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model_name = "PursuitOfDataScience/Llama-3.2-1B-GRPO"
5model = AutoModelForCausalLM.from_pretrained(
6 model_name,
7 torch_dtype=torch.bfloat16,
8 device_map="auto"
9)
10tokenizer = AutoTokenizer.from_pretrained(model_name)
11
12# Format the prompt
13question = "Janet'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?"
14
15prompt = f"""user: Solve this math problem step by step. Show your reasoning inside <think></think> tags, then give the final answer after ####.
16
17Question: {question}
18assistant:"""
19
20# Generate
21inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
22outputs = model.generate(
23 **inputs,
24 max_new_tokens=512,
25 temperature=0.7,
26 top_p=0.9,
27 do_sample=True,
28 pad_token_id=tokenizer.pad_token_id
29)
30
31response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
32print(response)1<think>
2[Step-by-step reasoning here]
3</think>
4#### [final answer]1@misc{llama32-1b-grpo,
2 author = {PursuitOfDataScience},
3 title = {Llama-3.2-1B-GRPO: Chain-of-Thought Reasoning with GRPO},
4 year = {2026},
5 publisher = {HuggingFace},
6 url = {https://huggingface.co/PursuitOfDataScience/Llama-3.2-1B-GRPO}
7}