Text Generation
Transformers
Safetensors
English
phi3
phi
nlp
math
code
chat
conversational
reasoning
Eval Results
text-generation-inference
Instructions to use microsoft/Phi-4-reasoning-plus with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/Phi-4-reasoning-plus with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="microsoft/Phi-4-reasoning-plus") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-4-reasoning-plus") model = AutoModelForMultimodalLM.from_pretrained("microsoft/Phi-4-reasoning-plus") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use microsoft/Phi-4-reasoning-plus with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "microsoft/Phi-4-reasoning-plus" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/Phi-4-reasoning-plus", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/microsoft/Phi-4-reasoning-plus
- SGLang
How to use microsoft/Phi-4-reasoning-plus with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "microsoft/Phi-4-reasoning-plus" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/Phi-4-reasoning-plus", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "microsoft/Phi-4-reasoning-plus" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/Phi-4-reasoning-plus", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use microsoft/Phi-4-reasoning-plus with Docker Model Runner:
docker model run hf.co/microsoft/Phi-4-reasoning-plus
fix(tokenizer_config): Sets fim and think tokens to non-special, and removes unk_token.
Browse files- tokenizer_config.json +6 -15
tokenizer_config.json
CHANGED
|
@@ -1,14 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"add_prefix_space": false,
|
| 3 |
"added_tokens_decoder": {
|
| 4 |
-
"5809": {
|
| 5 |
-
"content": "�",
|
| 6 |
-
"lstrip": false,
|
| 7 |
-
"normalized": false,
|
| 8 |
-
"rstrip": false,
|
| 9 |
-
"single_word": false,
|
| 10 |
-
"special": true
|
| 11 |
-
},
|
| 12 |
"100256": {
|
| 13 |
"content": "<|dummy_0|>",
|
| 14 |
"lstrip": true,
|
|
@@ -31,7 +23,7 @@
|
|
| 31 |
"normalized": false,
|
| 32 |
"rstrip": true,
|
| 33 |
"single_word": false,
|
| 34 |
-
"special":
|
| 35 |
},
|
| 36 |
"100259": {
|
| 37 |
"content": "<|fim_middle|>",
|
|
@@ -39,7 +31,7 @@
|
|
| 39 |
"normalized": false,
|
| 40 |
"rstrip": true,
|
| 41 |
"single_word": false,
|
| 42 |
-
"special":
|
| 43 |
},
|
| 44 |
"100260": {
|
| 45 |
"content": "<|fim_suffix|>",
|
|
@@ -47,7 +39,7 @@
|
|
| 47 |
"normalized": false,
|
| 48 |
"rstrip": true,
|
| 49 |
"single_word": false,
|
| 50 |
-
"special":
|
| 51 |
},
|
| 52 |
"100261": {
|
| 53 |
"content": "<|dummy_1|>",
|
|
@@ -767,7 +759,7 @@
|
|
| 767 |
"normalized": false,
|
| 768 |
"rstrip": true,
|
| 769 |
"single_word": false,
|
| 770 |
-
"special":
|
| 771 |
},
|
| 772 |
"100351": {
|
| 773 |
"content": "</think>",
|
|
@@ -775,7 +767,7 @@
|
|
| 775 |
"normalized": false,
|
| 776 |
"rstrip": true,
|
| 777 |
"single_word": false,
|
| 778 |
-
"special":
|
| 779 |
}
|
| 780 |
},
|
| 781 |
"bos_token": "<|endoftext|>",
|
|
@@ -786,6 +778,5 @@
|
|
| 786 |
"model_max_length": 32768,
|
| 787 |
"pad_token": "<|dummy_85|>",
|
| 788 |
"padding_side": "left",
|
| 789 |
-
"tokenizer_class": "GPT2Tokenizer"
|
| 790 |
-
"unk_token": "�"
|
| 791 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"add_prefix_space": false,
|
| 3 |
"added_tokens_decoder": {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
"100256": {
|
| 5 |
"content": "<|dummy_0|>",
|
| 6 |
"lstrip": true,
|
|
|
|
| 23 |
"normalized": false,
|
| 24 |
"rstrip": true,
|
| 25 |
"single_word": false,
|
| 26 |
+
"special": false
|
| 27 |
},
|
| 28 |
"100259": {
|
| 29 |
"content": "<|fim_middle|>",
|
|
|
|
| 31 |
"normalized": false,
|
| 32 |
"rstrip": true,
|
| 33 |
"single_word": false,
|
| 34 |
+
"special": false
|
| 35 |
},
|
| 36 |
"100260": {
|
| 37 |
"content": "<|fim_suffix|>",
|
|
|
|
| 39 |
"normalized": false,
|
| 40 |
"rstrip": true,
|
| 41 |
"single_word": false,
|
| 42 |
+
"special": false
|
| 43 |
},
|
| 44 |
"100261": {
|
| 45 |
"content": "<|dummy_1|>",
|
|
|
|
| 759 |
"normalized": false,
|
| 760 |
"rstrip": true,
|
| 761 |
"single_word": false,
|
| 762 |
+
"special": false
|
| 763 |
},
|
| 764 |
"100351": {
|
| 765 |
"content": "</think>",
|
|
|
|
| 767 |
"normalized": false,
|
| 768 |
"rstrip": true,
|
| 769 |
"single_word": false,
|
| 770 |
+
"special": false
|
| 771 |
}
|
| 772 |
},
|
| 773 |
"bos_token": "<|endoftext|>",
|
|
|
|
| 778 |
"model_max_length": 32768,
|
| 779 |
"pad_token": "<|dummy_85|>",
|
| 780 |
"padding_side": "left",
|
| 781 |
+
"tokenizer_class": "GPT2Tokenizer"
|
|
|
|
| 782 |
}
|