Text Generation
Transformers
Safetensors
English
French
phi3
nlp
code
conversational
custom_code
Eval Results
text-generation-inference
Instructions to use microsoft/Phi-3-mini-4k-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/Phi-3-mini-4k-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True) 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use microsoft/Phi-3-mini-4k-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-4k-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-4k-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/microsoft/Phi-3-mini-4k-instruct
- SGLang
How to use microsoft/Phi-3-mini-4k-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-4k-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-4k-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-4k-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-4k-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use microsoft/Phi-3-mini-4k-instruct with Docker Model Runner:
docker model run hf.co/microsoft/Phi-3-mini-4k-instruct
Add GSM8K eval result (85.7, 8-shot CoT)
#116 opened about 2 months ago
by
julien-c
Install & run this model easily using llmpm
#115 opened 2 months ago
by
sarthak-saxena
KeyError: 'type' when using pipeline with Phi-3-mini-4k-instruct on Kaggle/Colab
1
#114 opened 3 months ago
by
tusherbhomik
[RFC] The End of Dead Internet: A Proposal for Bilateral Optimization
#113 opened 3 months ago
by
lomax3
[RFC] The End of Dead Internet: A Proposal for Bilateral Optimization
#112 opened 3 months ago
by
lomax3
Compact model deployment for embedded systems
#111 opened 4 months ago
by
Cagnicolas
Request: DOI
#110 opened 5 months ago
by
zaryab199
Phi-3 Mini and the cognitive structure of instruction
#106 opened 7 months ago
by
elly99
Request: DOI
➕🚀 3
#105 opened 7 months ago
by
Karan-87
Add link to Neuron-optimized version
#104 opened 9 months ago
by
badaoui
Inquiry About Phi-3 Pre-Training Dataset Composition
1
#103 opened 11 months ago
by
Zieksy
Update modeling_phi3.py
#102 opened about 1 year ago
by
TarunSinghal
Update modeling_phi3.py for compatibility with transformers 4.49
👍 2
1
#100 opened about 1 year ago
by
sylwia-kuros
Config class problems
#99 opened over 1 year ago
by
VityaVitalich
Request: DOI
#98 opened over 1 year ago
by
Hlias11
Phi-3 is not generating from input embeddings [BUG]RuntimeError: shape '[-1, 0]' is invalid for input of size 5
1
#97 opened over 1 year ago
by
Ryz3n758
Thanks for Phi 3 mini and your inclusion of MedQA benchmark in your testing!
👍 1
#95 opened over 1 year ago
by
Hugman2345
KV cahing problem during the inference loop
#94 opened almost 2 years ago
by
mohamedlotfy50
Issue with Phi-3 Mini 4K Instruct Response Format
➕ 2
1
#93 opened almost 2 years ago
by
adameda
Is it required to add a BOS token?
1
#92 opened almost 2 years ago
by
iarbel
Thanks for sharing this model, I use it in my open source app for synthetic data :)
❤️ 2
1
#91 opened almost 2 years ago
by
lhoestq
phi3 4K vs phi3 4K. dupplcated name on the leaderboard
#89 opened almost 2 years ago
by
bedio
Please add more AutoModel Mapping
#88 opened almost 2 years ago
by
qcqced
phi3 4K vs 128K
👍 4
3
#87 opened almost 2 years ago
by
Emilio
CUDA error when using the code example with pipeline provided on the model page
2
#86 opened almost 2 years ago
by
saurabhkumar
Issues with llamacpp/LM studio and ollama
9
#85 opened almost 2 years ago
by
rombodawg
Model doesn't seem to tokenize new lines in chat template?
👍 1
6
#84 opened almost 2 years ago
by
bartowski
Underreported HumanEval Scores?
2
#83 opened almost 2 years ago
by
VaibhavSahai
Uploaded GGUF and exl2 as Phi 3.1
❤️ 7
5
#80 opened almost 2 years ago
by
bartowski
Thanks for the updated version!
❤️ 4
#78 opened almost 2 years ago
by
Nafnlaus
The model stops after generating one new token
🚀 1
2
#76 opened almost 2 years ago
by
rajiv-data-chef
Create the tokenizer.json properly (with TemplateProcessing included).
#75 opened almost 2 years ago
by
Narsil
Jetson nano
#74 opened almost 2 years ago
by
idotr7
fixed generation_args in Sample inference code
1
#73 opened almost 2 years ago
by
dkleine
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
2
#72 opened almost 2 years ago
by
Kenkentron
tflite convertion
1
#71 opened almost 2 years ago
by
henrywang0314
fine-tuning with structured data set
👀 1
4
#68 opened almost 2 years ago
by
don412
fp16 normal weights
#62 opened about 2 years ago
by
gioaca
Recent change on the rstrip property on special tokens
👍 3
1
#59 opened about 2 years ago
by
xxhansh
Help with merging LoRA layers back onto Phi3
2
#55 opened about 2 years ago
by
SHIMURA0321