Text Generation
Transformers
PyTorch
multilingual
phi3
torchao
phi
phi4
nlp
code
math
chat
conversational
custom_code
text-generation-inference
Instructions to use pytorch/Phi-4-mini-instruct-INT4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pytorch/Phi-4-mini-instruct-INT4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="pytorch/Phi-4-mini-instruct-INT4", 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("pytorch/Phi-4-mini-instruct-INT4", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("pytorch/Phi-4-mini-instruct-INT4", 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use pytorch/Phi-4-mini-instruct-INT4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "pytorch/Phi-4-mini-instruct-INT4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pytorch/Phi-4-mini-instruct-INT4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/pytorch/Phi-4-mini-instruct-INT4
- SGLang
How to use pytorch/Phi-4-mini-instruct-INT4 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 "pytorch/Phi-4-mini-instruct-INT4" \ --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": "pytorch/Phi-4-mini-instruct-INT4", "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 "pytorch/Phi-4-mini-instruct-INT4" \ --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": "pytorch/Phi-4-mini-instruct-INT4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use pytorch/Phi-4-mini-instruct-INT4 with Docker Model Runner:
docker model run hf.co/pytorch/Phi-4-mini-instruct-INT4
Commit History
-
Update model card: Add TorchAO paper, code, documentation links and correct license
Verified signatureThis PR updates the model card for `pytorch/Phi-4-mini-instruct-int4wo-hqq` by: * Correcting the license to `BSD-3-Clause` as per the official TorchAO repository. * Adding a section for the [TorchAO: PyTorch-Native Training-to-Serving Model Optimization](https://huggingface.co/papers/2507.16099) paper, including its abstract and link. * Adding direct links to the official TorchAO GitHub repository and documentation. These changes provide more comprehensive information about the model and the framework it utilizes.ab2360d
-
Update README.md
Verified signature1f33f1e -
Update README.md
Verified signature819a3a6 -
Update README.md
Verified signature00b147a -
Update README.md
Verified signatureba0fa2f -
Update README.md
Verified signaturee332c15 -
Update README.md
Verified signature6cedb9c
-
Update README.md
Verified signature006f2f9
-
Update README.md
Verified signature5b90bcb
-
Update README.md
Verified signaturec606613 -
Update README.md
Verified signature37c4bff -
Update README.md
Verified signaturea2288d0
-
Update README.md
Verified signature4a40309 -
Update README.md
Verified signatured0f0e1e -
Update README.md
Verified signature4ba6889 -
Update README.md
Verified signature37987cd -
Update README.md
Verified signatured906e2b -
Update README.md
Verified signature864b9be -
Update README.md
Verified signature40b794c -
Update README.md
Verified signature8dc4e9b -
Update README.md
Verified signatureb20cbe9
-
Update README.md
Verified signaturee3fc1c2 -
Update README.md
Verified signature3be2c47
-
Update README.md
Verified signatureb108c3f -
Update README.md
Verified signature38d28bc -
Update README.md
Verified signature54fedb9
-
Update README.md
Verified signature973d591 -
Update README.md
Verified signaturedef09db -
Update README.md
Verified signature63d511c -
Update README.md
Verified signature8e3e54a -
Update README.md
Verified signature47aed6e -
Update README.md
Verified signature95dc31b -
Update README.md
Verified signatureb6de200 -
Update README.md
Verified signatureb548de8 -
Update README.md
Verified signatureea000a3 -
Update README.md
Verified signaturec008424 -
Update README.md
Verified signatured6542af -
Update README.md
Verified signatureea29a3b -
Update README.md
Verified signaturee3d011c -
Update README.md
Verified signature1170503 -
Update README.md
Verified signaturea6100fd -
Update README.md
Verified signaturefe70e1e -
Update README.md
Verified signature7ecf1b2 -
Update README.md
Verified signature070762d -
Update README.md
Verified signature04e792e
-
Update README.md
Verified signature9579235 -
Update README.md
Verified signature169e4da -
Update README.md
Verified signature059d669 -
Update README.md
Verified signature2ab02aa -
Update README.md
Verified signature9af0683