File size: 4,564 Bytes
665496b
 
59cbd97
 
 
 
 
 
 
 
 
665496b
 
59cbd97
665496b
59cbd97
665496b
59cbd97
665496b
 
c4c4d46
 
 
 
 
49d4c43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
665496b
0e807ef
19e4bd0
0e807ef
19e4bd0
 
 
 
0e807ef
19e4bd0
 
 
c4c4d46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19e4bd0
0e807ef
19e4bd0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0e807ef
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
---
library_name: transformers
license: mit
datasets:
- HuggingFaceH4/Bespoke-Stratos-17k
- AI-MO/NuminaMath-TIR
language:
- en
- ja
base_model:
- microsoft/phi-4
---

![image/png](https://cdn-uploads.huggingface.co/production/uploads/657e900beaad53ff67ba84db/laV1mnj8n5hX8EmeumjRk.png)

# AXCXEPT/phi-4-open-R1-Distill-EZOv1

<!-- Provide a quick summary of what the model is/does. -->

## Model Details
This model is a Reasoner version of the phi-4 model by employing open-r1, which mimics the Distill methodology of Deepseek-R1. In particular, since it is specialized for Japanese, answers will be given in Japanese in principle.
It can be made more flexible by interweaving English.

Deepseek-R1のDistill手法を模倣した、open-r1を採用して、phi-4モデルを Reasonerにしたモデルです。特に日本語に特化させているため、原則日本語で回答します。
英語を織り交ぜることでより柔軟にすることが可能です。

## Example Output
```
<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>
```

--------------------------------------
## HOW TO USE
-------------------
### Setup
```
pip install --upgrade transformers accelerate datasets trl
```
-------------------
### Predict(using AutoModelForCausalLM)
```python

from transformers import AutoModelForCausalLM, AutoTokenizer



model_name = "AXCXEPT/phi-4-open-R1-Distill-EZOv1"

model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype="auto",
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)

prompt = f"""
ある父と子の年齢に関する問題があります。条件は次の通りです:

父の現在の年齢は息子の現在の年齢の3倍です。
6年前、父の年齢は息子の年齢の5倍でした。
父と息子の年齢を求めてください。
"""
messages = [
    {"role": "system", "content": "You are an excellent AI."},
    {"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)

generated_ids = model.generate(
    **model_inputs,
    max_new_tokens=2048
)
generated_ids = [
    output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]

response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]

print(response)
```
-------------------
### Predict(using vllm)
#### Setup
```
pip install vllm 
vllm serve AXCXEPT/phi-4-open-R1-Distill-EZOv1
```
#### Predict
```
from 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)
```


### Special Thanks
Phi-4 develop team, open-r1 team developer, deepseek team, thanks for your special technology and knowledge.