Views
No views yet

<thinking>
まず、問題文を整理します。父親の現在の年齢は息子の3倍であり、6年前の父親の年齢は息子の5倍でした。これを数式で表現すると:
1. 現在の年齢関係:父親の年齢 = 3 × 息子の年齢 → F = 3S
2. 6年前の年齢関係:父親の年齢 - 6 = 5 × (息子の年齢 - 6) → F - 6 = 5(S - 6)
これらの2つの方程式を同時に解きます。まず第1式からF = 3Sを代入すると:
3S - 6 = 5(S - 6)
3S - 6 = 5S - 30
30 - 6 = 5S - 3S
24 = 2S
S = 12
息子の年齢が12歳であることが分かります。これを第1式に代入すると:
F = 3 × 12 = 36
父親の年齢は36歳です。最後に条件を確認します:
- 現在の年齢関係:36 = 3×12 → 成立
- 6年前の年齢関係:36-6=30 vs 12-6=6 → 30=5×6 → 成立
両方の条件が満たされているため、解は正しいと言えます。
</thinking>
<answer>
父親の年齢は36歳、息子の年齢は12歳です。
根拠:
1. 現在の年齢関係:36 = 3×12(成立)
2. 6年前の年齢関係:30 = 5×6(成立)
3. 両方の条件を満たす唯一の解
</answer>pip install --upgrade transformers accelerate datasets trl1
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4
5
6model_name = "AXCXEPT/phi-4-open-R1-Distill-EZOv1"
7
8model = AutoModelForCausalLM.from_pretrained(
9 model_name,
10 torch_dtype="auto",
11 device_map="auto"
12)
13tokenizer = AutoTokenizer.from_pretrained(model_name)
14
15prompt = f"""
16ある父と子の年齢に関する問題があります。条件は次の通りです:
17
18父の現在の年齢は息子の現在の年齢の3倍です。
196年前、父の年齢は息子の年齢の5倍でした。
20父と息子の年齢を求めてください。
21"""
22messages = [
23 {"role": "system", "content": "You are an excellent AI."},
24 {"role": "user", "content": prompt}
25]
26text = tokenizer.apply_chat_template(
27 messages,
28 tokenize=False,
29 add_generation_prompt=True
30)
31model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
32
33generated_ids = model.generate(
34 **model_inputs,
35 max_new_tokens=2048
36)
37generated_ids = [
38 output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
39]
40
41response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
42
43print(response)pip install vllm
vllm serve AXCXEPT/phi-4-open-R1-Distill-EZOv1from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="token-abc123",
)
prompt = f"""
There is a question concerning the age of a father and his child. The conditions are as follows
The father's current age is 3 times the son's current age.
Six years ago, the father's age was five times the son's age.
Find the ages of the father and the son.
"""
completion = client.chat.completions.create(
model="AXCXEPT/EZO-phi-4-openr1-v1_917",
messages=[
{"role": "system", "content": "You are an excellent AI. Please answer carefully and thoughtfully, in the same language as the instructions."}
{"role": "user", "content": prompt}
]
)
print(completion.choices[0].message.content)