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, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-4-reasoning-plus") model = AutoModelForCausalLM.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
- 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
Running with VLLM is not printing '<think>' tokens.
I'm trying the Phi-4-reasoning-plus model using vllm's v0.8.5 docker container and using the --enable-reasoning --reasoning-parser deepseek_r1 flags but it's not printing <think>or </think>. Am I doing something wrong? Ollama runs it just fine so I'm wondering what I'm missing.
Excellent model by the way!
Thanks,
Same for me using SGL. The model just starts thinking and never terminates with </think>, so it gets stuck repeating the same few reasoning sentences over and over. I'm using the standard prompt shown in the model card.
I could not get the part working either
Well, here's where I come back and let folks know the problem was between the keyboard and the chair (PBKAC).
The multi line docker string I was sending had an inadvertent ' ' after a line continuation, which in docker causes the rest of the options to not pass to vllm.
If you spawn your container like this i'll work
docker run --runtime nvidia --gpus '"device=0,1"' \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HUGGING_FACE_HUB_TOKEN=hf_redactedY" \
--net=host \
--ipc=host \
vllm/vllm-openai:v0.8.5 \
--model microsoft/Phi-4-reasoning-plus \
--served-model-name Phi-4-reasoning-plus \
--generation-config vllm \
--enable-reasoning \
--reasoning-parser deepseek_r1
However, that said, I have seen vllm just stop printing tokens mid answer. Ollama is fine though. I'll also say that running through vllm seems to have less precision than running via Ollama. Same prompts, same temps, and topk/p but less precise answers. Almost like the context cache is not as effective with vllm as opposed to Ollama. I'm not sure why, but I've switched over to Ollama because of these two issues with vllm.
I don't think this is a VLLM issue, on KoboldCpp I haven't gotten the model to reason correctly either despite us having no issues with any other reasoning models.
Exact same behavior where is not sent or if forced the is never sent. Result is either no reasoning at all or infinite reasoning.
Same problem with llama.cpp directly
Has that issue been resolved yet?
Same problem with llama.cpp. Using Bartowski GGUF,llama.cpp chat ui with system message from chat template shown on this page. It does "think", but never emits tags.
I am using LM Studio, and had the came problem. I managed to fix it by simply re-wording and reducing the length of my prompt. Also try different "context overflow" settings