Text Generation
Transformers
Safetensors
English
phi3
nlp
code
conversational
custom_code
Eval Results
text-generation-inference
Instructions to use microsoft/Phi-3-mini-128k-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/Phi-3-mini-128k-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="microsoft/Phi-3-mini-128k-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-3-mini-128k-instruct", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-3-mini-128k-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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use microsoft/Phi-3-mini-128k-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "microsoft/Phi-3-mini-128k-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-3-mini-128k-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/microsoft/Phi-3-mini-128k-instruct
- SGLang
How to use microsoft/Phi-3-mini-128k-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-3-mini-128k-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-3-mini-128k-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-3-mini-128k-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-3-mini-128k-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use microsoft/Phi-3-mini-128k-instruct with Docker Model Runner:
docker model run hf.co/microsoft/Phi-3-mini-128k-instruct
Commit History
-
Update README.md (#104)
Verified signature- Update README.md (5ce8d63b8679046e678f2f38c5e8db961c52ec51) Co-authored-by: Blake S <bsnelling@users.noreply.huggingface.co>f3c06ae -
Upload data_summary_card.md (#103)
Verified signature- Upload data_summary_card.md (76b1c5a5c7c428236bf710260b6bd79987faf208) Co-authored-by: Blake S <bsnelling@users.noreply.huggingface.co>17fb6f6
-
Update readme
Verified signature072cb75
-
Update README.md
Verified signaturea90b62a
-
Minor updates for README
Verified signatured548c23 -
Update model (#84)
Verified signature- Update model (b1b6d1319a4a315ba5d10ea7fbb3c084d2f7fc2d) - added "attention_bias": false to config.json (4293b7fb001eb944dd11bab41111cc36e8f0ca19) Co-authored-by: Amit Garg <gargamit@users.noreply.huggingface.co>10d25df
-
Add the classifiers to the auto_map (#76)
Verified signature- Add the classifiers to the auto_map (a53528a5e4554ddc4c53d4d34db9fbcfcc1f4aea) Co-authored-by: Mohammadreza Mohseni <mrm196@users.noreply.huggingface.co>bb5bf1e
-
Add attention_bias to make TGI work (#68)
Verified signature- Add attention_bias to make TGI work (0392c47a6c5f331d660034da046f02eff26c6372) - Update config.json (c64f7f0274c7516d706e61804045df681b86b68d) Co-authored-by: Philipp Schmid <philschmid@users.noreply.huggingface.co>5be6479 -
Add link to Phi-3 vision ONNX models
Verified signature6417fb9
-
Update sample_finetune.py (#70)
Verified signature- Update sample_finetune.py (bd1e66a6743baac0bfd87a6c51c5a56a97776630) Co-authored-by: Adam McGuinness <amcguinness@users.noreply.huggingface.co>3c014d5
-
Update sample_finetune.py (#69)
Verified signature- Update sample_finetune.py (a9fe59ff7e4587cd385fb5c04166d3e03f29d501) Co-authored-by: David Majercak <damajercakms@users.noreply.huggingface.co>bbd531d
-
Update README
Verified signature30e8c65
-
fix(tokenizer): Also updates tokenizer.json to prevent any mismatch.
Verified signature8a362e7 -
fix(tokenizer_config): Adjusts `rstrip` of special tokens. (#54)
Verified signature- fix(tokenizer_config): Adjusts `rstrip` of special tokens. (03fad24bbbfa402cd130aaef30e4013aaf61633c)82eebd7
-
Update README.md
Verified signature39d6675 -
fix(root): Replaces system by user to improve generation experience.
fc313b0
-
Update README.md
Verified signature810c2e6 -
Update sample_finetune.py (#42)
Verified signature- Update sample_finetune.py (91d1d9bcfc9841d30eaa70889abfe6cf0492dc8c) Co-authored-by: Wen Wen <wwwaj@users.noreply.huggingface.co>0693e0b -
chore(readme): Adds a proper chat example to widget.
Verified signature49f911d
-
fix(readme): Adds information about placeholder tokens.
f10fb29 -
fix(tokenizer_config): Ensures model_max_length corresponds to actual maximum number.
Verified signature48788d7
-
chore(root): Initial files upload.
7de6f02 -
initial commit
Verified signaturef310673