Text Generation
Transformers
PyTorch
ExecuTorch
multilingual
phi3
torchao
phi
phi4
nlp
code
math
chat
conversational
custom_code
text-generation-inference
Instructions to use pytorch/Phi-4-mini-instruct-INT8-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-INT8-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-INT8-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-INT8-INT4", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("pytorch/Phi-4-mini-instruct-INT8-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-INT8-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-INT8-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-INT8-INT4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/pytorch/Phi-4-mini-instruct-INT8-INT4
- SGLang
How to use pytorch/Phi-4-mini-instruct-INT8-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-INT8-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-INT8-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-INT8-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-INT8-INT4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use pytorch/Phi-4-mini-instruct-INT8-INT4 with Docker Model Runner:
docker model run hf.co/pytorch/Phi-4-mini-instruct-INT8-INT4
Commit History
-
Update README.md
Verified signatureca214ad
-
Update README.md
Verified signature3eaf791 -
Update README.md
Verified signaturea900e40 -
Update README.md
Verified signatureaff3b08 -
Update README.md
Verified signature0a8bc88 -
Update README.md
Verified signature3d69139
-
Upload 3 files
Verified signatureefabc4c -
Delete 26b5ee14345ab0d7547c3877f138b8703256022a
Verified signature9d60992 -
Upload 26b5ee14345ab0d7547c3877f138b8703256022a
Verified signature35cb97b -
Delete config.json
Verified signature1028a93 -
Delete pytorch_model.bin.index.json
Verified signature32fb0bf -
Delete pytorch_model_converted.bin
Verified signature45cf0b8 -
Delete pytorch_model.bin
Verified signatured9c331c -
Delete phi4-mini-INT8-INT4.pte
Verified signaturecf48e9f -
Delete pytorch_model-00002-of-00002.bin
Verified signature37e5549 -
Delete pytorch_model-00001-of-00002.bin
Verified signature55d0319 -
Update README.md
Verified signatureb41df82
-
Update README.md
Verified signature692e809 -
Rename phi4-mini-8da4w.pte to phi4-mini-INT8-INT4.pte
Verified signature969e5bc -
Update README.md
Verified signature04b9620
-
Update README.md
Verified signaturec6f0171
-
Upload Phi3ForCausalLM
Verified signaturea2c6d39 -
Update README.md
Verified signaturef950c8a -
Update README.md
Verified signature0178249 -
Update README.md
Verified signature4acd484
-
Update README.md
Verified signaturec998a80
-
Update README.md
Verified signaturea019a61 -
Rename phi4-mini-8da4w-converted.bin to pytorch_model_converted.bin
Verified signature2a7fea4
-
Update README.md
Verified signature1afa5a7
-
Update README.md
Verified signature48419ea
-
Update README.md
Verified signature9c26e80 -
Update README.md
Verified signature075c375
-
Update README.md
Verified signaturefd2c662 -
Update README.md
Verified signaturee8345c2 -
Update README.md
Verified signatureb66d138 -
Update README.md
Verified signature2821130
-
Update README.md
Verified signatureb9abd8d
-
Update README.md
Verified signaturefb71c2a -
Update README.md
Verified signature55e2bb7 -
Update README.md
Verified signature5a39c0e -
Update README.md
Verified signature75a64a1 -
Update README.md
Verified signature31b7eb3 -
Update README.md
Verified signature3b07e48 -
Update README.md
Verified signature7852389 -
Update README.md
Verified signature3716f73 -
Update README.md
Verified signature59a0be3 -
Update README.md
Verified signaturee468e62
-
Update README.md
Verified signatureaa8ef96 -
Update README.md
Verified signatureab71d7e -
Update README.md
Verified signature164eb9a