Text Generation
Transformers
Safetensors
phi3
nlp
code
conversational
custom_code
Eval Results
text-generation-inference
Instructions to use microsoft/Phi-4-mini-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/Phi-4-mini-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="microsoft/Phi-4-mini-instruct", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-4-mini-instruct", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-4-mini-instruct", trust_remote_code=True, device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use microsoft/Phi-4-mini-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "microsoft/Phi-4-mini-instruct" # 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-mini-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/microsoft/Phi-4-mini-instruct
- SGLang
How to use microsoft/Phi-4-mini-instruct 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-mini-instruct" \ --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-mini-instruct", "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-mini-instruct" \ --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-mini-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use microsoft/Phi-4-mini-instruct with Docker Model Runner:
docker model run hf.co/microsoft/Phi-4-mini-instruct
Commit History
-
Update EvalEval source links to flat datastore
Verified signatureUpdates existing EvalEval Community Evals YAML entries to link to flat datastore aggregate objects pinned to an immutable EEE datastore commit, and normalizes source.name to EvalEval. No score, dataset, task, or date changes are intended. This updates existing open PR refs only. Contributor: evaleval93fdb79
-
Add EvalEval community eval results
Verified signatureAdds EvalEval Community Evals YAML entries with source backlinks to EEE aggregate records. Contributor: evaleval5e18559
-
Add EvalEval community eval results
Verified signatureAdds EvalEval Community Evals YAML entries with source backlinks to EEE aggregate records. Contributor: evaleval1740258 -
Add EvalEval community eval results
Verified signatureAdds EvalEval Community Evals YAML entries with source backlinks to EEE aggregate records. Contributor: evaleval452a8d0
-
Update README.md (#43)
Verified signature- Update README.md (477fce535165188fd941f5e68ff511bb6a549681) Co-authored-by: Blake S <bsnelling@users.noreply.huggingface.co>cfbefac -
Upload data_summary_card.md (#42)
Verified signature- Upload data_summary_card.md (09ccd78d4b1b364c58403bf1223c10254f820514) Co-authored-by: Blake S <bsnelling@users.noreply.huggingface.co>7c44507
-
Update urls
Verified signature5a14955
-
Add metadata and links to model card (#16)
Verified signature- Add metadata and links to model card (57d6888337c9e6e7bbcffa3237fb5b33c6c7227a) Co-authored-by: Niels Rogge <nielsr@users.noreply.huggingface.co>c0fb9e7 -
Update sample_finetune.py (#17)
Verified signature- Update sample_finetune.py (6c4e0743182186aa1eee5b6b59a7dfe4e20ba8e0) Co-authored-by: Pavan Kumar Balijepalli <pavankumarbalijepalli@users.noreply.huggingface.co>fad2462
-
Update readme
Verified signatured02e859 -
Update readme
Verified signature5889daf
-
Update readme
Verified signatureb93bc76
-
Update README.md (#10)
Verified signature- Update README.md (a84cca47e89c93eca1ef396811aa637e29ec8106) Co-authored-by: Young Jin Kim <ykim362@users.noreply.huggingface.co>2ebeb38
-
Update README.md (#9)
Verified signature- Update README.md (019abf5afbe30be6cca3212b91f71831a709426b) Co-authored-by: Young Jin Kim <ykim362@users.noreply.huggingface.co>0fd084b -
Fix "Norway problem" in YAML (#7)
Verified signature- Fix "Norway problem" in YAML (2b18b5b9361a36613005793b32f999d206be787b) Co-authored-by: Xuan-Son Nguyen <ngxson@users.noreply.huggingface.co>f7a0a61 -
Add language tag (#5)
Verified signature- Add language tag (1a54ef5b71aaae23f6adf72306c6e273979788dd) Co-authored-by: Loïck BOURDOIS <lbourdois@users.noreply.huggingface.co>f984c15
-
Update readme
Verified signature4b00ec8
-
Update readme
Verified signature12cce9e -
update readme
Verified signature4665bce -
update blog url
Verified signature4fcd2e8 -
Update README
Verified signature66561c5
-
update readme
Verified signaturea58b82a
-
Update readme
Verified signaturef8b7731
-
Added model files
618e63e -
initial commit
Verified signaturefde0620