初始化项目,由ModelHub XC社区提供模型
Model: AXCXEPT/phi-4-open-R1-Distill-EZOv1 Source: Original Platform
This commit is contained in:
153
README.md
Normal file
153
README.md
Normal file
@@ -0,0 +1,153 @@
|
||||
---
|
||||
library_name: transformers
|
||||
license: mit
|
||||
datasets:
|
||||
- HuggingFaceH4/Bespoke-Stratos-17k
|
||||
- AI-MO/NuminaMath-TIR
|
||||
language:
|
||||
- en
|
||||
- ja
|
||||
base_model:
|
||||
- microsoft/phi-4
|
||||
---
|
||||
|
||||

|
||||
|
||||
# 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.
|
||||
Reference in New Issue
Block a user