Update README.md
Browse files
README.md
CHANGED
@@ -18,8 +18,11 @@ base_model:
|
|
18 |
<!-- Provide a quick summary of what the model is/does. -->
|
19 |
|
20 |
## Model Details
|
21 |
-
This model is a Reasoner version of the phi-4 model by employing open-r1, which mimics the Distill methodology of Deepseek-R1.
|
22 |
-
|
|
|
|
|
|
|
23 |
|
24 |
## Example Output
|
25 |
```
|
@@ -69,6 +72,48 @@ pip install --upgrade transformers accelerate datasets trl
|
|
69 |
### Predict(using AutoModelForCausalLM)
|
70 |
```python
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
```
|
73 |
-------------------
|
74 |
### Predict(using vllm)
|
|
|
18 |
<!-- Provide a quick summary of what the model is/does. -->
|
19 |
|
20 |
## Model Details
|
21 |
+
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.
|
22 |
+
It can be made more flexible by interweaving English.
|
23 |
+
|
24 |
+
Deepseek-R1のDistill手法を模倣した、open-r1を採用して、phi-4モデルを Reasonerにしたモデルです。特に日本語に特化させているため、原則日本語で回答します。
|
25 |
+
英語を織り交ぜることでより柔軟にすることが可能です。
|
26 |
|
27 |
## Example Output
|
28 |
```
|
|
|
72 |
### Predict(using AutoModelForCausalLM)
|
73 |
```python
|
74 |
|
75 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
76 |
+
|
77 |
+
|
78 |
+
|
79 |
+
model_name = "AXCXEPT/phi-4-open-R1-Distill-EZOv1"
|
80 |
+
|
81 |
+
model = AutoModelForCausalLM.from_pretrained(
|
82 |
+
model_name,
|
83 |
+
torch_dtype="auto",
|
84 |
+
device_map="auto"
|
85 |
+
)
|
86 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
87 |
+
|
88 |
+
prompt = f"""
|
89 |
+
ある父と子の年齢に関する問題があります。条件は次の通りです:
|
90 |
+
|
91 |
+
父の現在の年齢は息子の現在の年齢の3倍です。
|
92 |
+
6年前、父の年齢は息子の年齢の5倍でした。
|
93 |
+
父と息子の年齢を求めてください。
|
94 |
+
"""
|
95 |
+
messages = [
|
96 |
+
{"role": "system", "content": "You are an excellent AI."},
|
97 |
+
{"role": "user", "content": prompt}
|
98 |
+
]
|
99 |
+
text = tokenizer.apply_chat_template(
|
100 |
+
messages,
|
101 |
+
tokenize=False,
|
102 |
+
add_generation_prompt=True
|
103 |
+
)
|
104 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
105 |
+
|
106 |
+
generated_ids = model.generate(
|
107 |
+
**model_inputs,
|
108 |
+
max_new_tokens=2048
|
109 |
+
)
|
110 |
+
generated_ids = [
|
111 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
112 |
+
]
|
113 |
+
|
114 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
115 |
+
|
116 |
+
print(response)
|
117 |
```
|
118 |
-------------------
|
119 |
### Predict(using vllm)
|