math RL for LLM
Collection
算術推論能力を検証するためのモデル
•
2 items
•
Updated
max_new_tokens=256で、openai/gsm8kを使って事後学習したモデルです。import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "ryota39/Qwen3-8B-math-RL-en"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
device_map="auto",
)
prompt = "A Christmas tree has 8 shelves for decorations, and each shelf can hold 45 ornaments. Currently, two-thirds of the total capacity is decorated. How many ornaments are on the tree in total? Write your answer in the format \\boxed{answer}."
messages = [{"role": "user", "content": prompt}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
# 出力例
# <think>
# Okay, let's see. The Christmas tree has 8 shelves, each holding 45 ornaments. So the total capacity is 8 times 45. Let me calculate that: 8*45 is 360. So the total capacity is 360 ornaments. Now, two-thirds of that is decorated. So two-thirds of 360 is (2/3)*360. Let me compute that: 360 divided by 3 is 120, times 2 is 240. So there are 240 ornaments on the tree. The answer is \boxed{240}.
#
# **Final Answer**
# \boxed{240}
# </think>
#
# To determine how many ornaments are currently on the tree, we start by calculating the total capacity of the tree:
#
# - There are 8 shelves, and each shelf holds 45 ornaments.
# - Total capacity = $ 8 \times 45 = 360 $ ornaments.
#
# Next, we are told that two-thirds of this total capacity is currently decorated:
#
# - Two-thirds of 360 = $ \frac{2}{3} \times 360 = 240 $