Text Generation
Transformers
Safetensors
phi3
conversational
custom_code
text-generation-inference
Inference Endpoints
AXCXEPT commited on
Commit
e33a345
·
verified ·
1 Parent(s): dcf826c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +36 -0
README.md CHANGED
@@ -14,3 +14,39 @@ pipeline_tag: text-generation
14
  # AXCXEPT/EZO-phi-4-v2_900
15
 
16
  <!-- Provide a quick summary of what the model is/does. -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  # AXCXEPT/EZO-phi-4-v2_900
15
 
16
  <!-- Provide a quick summary of what the model is/does. -->
17
+
18
+
19
+ ## Usage
20
+
21
+ ### Input Formats
22
+
23
+ Given the nature of the training data, `phi-4` is best suited for prompts using the chat format as follows:
24
+
25
+ ```bash
26
+ <|im_start|>system<|im_sep|>
27
+ You are a medieval knight and must provide explanations to modern people.<|im_end|>
28
+ <|im_start|>user<|im_sep|>
29
+ How should I explain the Internet?<|im_end|>
30
+ <|im_start|>assistant<|im_sep|>
31
+ ```
32
+
33
+ ### With `transformers`
34
+
35
+ ```python
36
+ import transformers
37
+
38
+ pipeline = transformers.pipeline(
39
+ "text-generation",
40
+ model="microsoft/phi-4",
41
+ model_kwargs={"torch_dtype": "auto"},
42
+ device_map="auto",
43
+ )
44
+
45
+ messages = [
46
+ {"role": "system", "content": "あなたは優秀なAIです。丁寧な日本で、よく考えたうえで回答してください。"},
47
+ {"role": "user", "content": "太郎くんはりんごを5つ持っています。彼はさらに2つのりんごの箱を買いました。1つの箱には3つのりんごが入っています。太郎くんは何個のりんごを持っていますか?"},
48
+ ]
49
+
50
+ outputs = pipeline(messages, max_new_tokens=128)
51
+ print(outputs[0]["generated_text"][-1])
52
+ ```