Text Generation
Transformers
Safetensors
English
phi3
nlp
code
conversational
custom_code
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)# 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) 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- 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
fix(tokenizer): Also updates tokenizer.json to prevent any mismatch.
Browse files- tokenizer.json +12 -12
tokenizer.json
CHANGED
|
@@ -26,9 +26,9 @@
|
|
| 26 |
"content": "</s>",
|
| 27 |
"single_word": false,
|
| 28 |
"lstrip": false,
|
| 29 |
-
"rstrip":
|
| 30 |
"normalized": false,
|
| 31 |
-
"special":
|
| 32 |
},
|
| 33 |
{
|
| 34 |
"id": 32000,
|
|
@@ -44,7 +44,7 @@
|
|
| 44 |
"content": "<|assistant|>",
|
| 45 |
"single_word": false,
|
| 46 |
"lstrip": false,
|
| 47 |
-
"rstrip":
|
| 48 |
"normalized": false,
|
| 49 |
"special": true
|
| 50 |
},
|
|
@@ -53,7 +53,7 @@
|
|
| 53 |
"content": "<|placeholder1|>",
|
| 54 |
"single_word": false,
|
| 55 |
"lstrip": false,
|
| 56 |
-
"rstrip":
|
| 57 |
"normalized": false,
|
| 58 |
"special": true
|
| 59 |
},
|
|
@@ -62,7 +62,7 @@
|
|
| 62 |
"content": "<|placeholder2|>",
|
| 63 |
"single_word": false,
|
| 64 |
"lstrip": false,
|
| 65 |
-
"rstrip":
|
| 66 |
"normalized": false,
|
| 67 |
"special": true
|
| 68 |
},
|
|
@@ -71,7 +71,7 @@
|
|
| 71 |
"content": "<|placeholder3|>",
|
| 72 |
"single_word": false,
|
| 73 |
"lstrip": false,
|
| 74 |
-
"rstrip":
|
| 75 |
"normalized": false,
|
| 76 |
"special": true
|
| 77 |
},
|
|
@@ -80,7 +80,7 @@
|
|
| 80 |
"content": "<|placeholder4|>",
|
| 81 |
"single_word": false,
|
| 82 |
"lstrip": false,
|
| 83 |
-
"rstrip":
|
| 84 |
"normalized": false,
|
| 85 |
"special": true
|
| 86 |
},
|
|
@@ -89,7 +89,7 @@
|
|
| 89 |
"content": "<|system|>",
|
| 90 |
"single_word": false,
|
| 91 |
"lstrip": false,
|
| 92 |
-
"rstrip":
|
| 93 |
"normalized": false,
|
| 94 |
"special": true
|
| 95 |
},
|
|
@@ -98,7 +98,7 @@
|
|
| 98 |
"content": "<|end|>",
|
| 99 |
"single_word": false,
|
| 100 |
"lstrip": false,
|
| 101 |
-
"rstrip":
|
| 102 |
"normalized": false,
|
| 103 |
"special": true
|
| 104 |
},
|
|
@@ -107,7 +107,7 @@
|
|
| 107 |
"content": "<|placeholder5|>",
|
| 108 |
"single_word": false,
|
| 109 |
"lstrip": false,
|
| 110 |
-
"rstrip":
|
| 111 |
"normalized": false,
|
| 112 |
"special": true
|
| 113 |
},
|
|
@@ -116,7 +116,7 @@
|
|
| 116 |
"content": "<|placeholder6|>",
|
| 117 |
"single_word": false,
|
| 118 |
"lstrip": false,
|
| 119 |
-
"rstrip":
|
| 120 |
"normalized": false,
|
| 121 |
"special": true
|
| 122 |
},
|
|
@@ -125,7 +125,7 @@
|
|
| 125 |
"content": "<|user|>",
|
| 126 |
"single_word": false,
|
| 127 |
"lstrip": false,
|
| 128 |
-
"rstrip":
|
| 129 |
"normalized": false,
|
| 130 |
"special": true
|
| 131 |
}
|
|
|
|
| 26 |
"content": "</s>",
|
| 27 |
"single_word": false,
|
| 28 |
"lstrip": false,
|
| 29 |
+
"rstrip": true,
|
| 30 |
"normalized": false,
|
| 31 |
+
"special": false
|
| 32 |
},
|
| 33 |
{
|
| 34 |
"id": 32000,
|
|
|
|
| 44 |
"content": "<|assistant|>",
|
| 45 |
"single_word": false,
|
| 46 |
"lstrip": false,
|
| 47 |
+
"rstrip": true,
|
| 48 |
"normalized": false,
|
| 49 |
"special": true
|
| 50 |
},
|
|
|
|
| 53 |
"content": "<|placeholder1|>",
|
| 54 |
"single_word": false,
|
| 55 |
"lstrip": false,
|
| 56 |
+
"rstrip": true,
|
| 57 |
"normalized": false,
|
| 58 |
"special": true
|
| 59 |
},
|
|
|
|
| 62 |
"content": "<|placeholder2|>",
|
| 63 |
"single_word": false,
|
| 64 |
"lstrip": false,
|
| 65 |
+
"rstrip": true,
|
| 66 |
"normalized": false,
|
| 67 |
"special": true
|
| 68 |
},
|
|
|
|
| 71 |
"content": "<|placeholder3|>",
|
| 72 |
"single_word": false,
|
| 73 |
"lstrip": false,
|
| 74 |
+
"rstrip": true,
|
| 75 |
"normalized": false,
|
| 76 |
"special": true
|
| 77 |
},
|
|
|
|
| 80 |
"content": "<|placeholder4|>",
|
| 81 |
"single_word": false,
|
| 82 |
"lstrip": false,
|
| 83 |
+
"rstrip": true,
|
| 84 |
"normalized": false,
|
| 85 |
"special": true
|
| 86 |
},
|
|
|
|
| 89 |
"content": "<|system|>",
|
| 90 |
"single_word": false,
|
| 91 |
"lstrip": false,
|
| 92 |
+
"rstrip": true,
|
| 93 |
"normalized": false,
|
| 94 |
"special": true
|
| 95 |
},
|
|
|
|
| 98 |
"content": "<|end|>",
|
| 99 |
"single_word": false,
|
| 100 |
"lstrip": false,
|
| 101 |
+
"rstrip": true,
|
| 102 |
"normalized": false,
|
| 103 |
"special": true
|
| 104 |
},
|
|
|
|
| 107 |
"content": "<|placeholder5|>",
|
| 108 |
"single_word": false,
|
| 109 |
"lstrip": false,
|
| 110 |
+
"rstrip": true,
|
| 111 |
"normalized": false,
|
| 112 |
"special": true
|
| 113 |
},
|
|
|
|
| 116 |
"content": "<|placeholder6|>",
|
| 117 |
"single_word": false,
|
| 118 |
"lstrip": false,
|
| 119 |
+
"rstrip": true,
|
| 120 |
"normalized": false,
|
| 121 |
"special": true
|
| 122 |
},
|
|
|
|
| 125 |
"content": "<|user|>",
|
| 126 |
"single_word": false,
|
| 127 |
"lstrip": false,
|
| 128 |
+
"rstrip": true,
|
| 129 |
"normalized": false,
|
| 130 |
"special": true
|
| 131 |
}
|