Instructions to use microsoft/phi-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/phi-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="microsoft/phi-2")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-2") model = AutoModelForCausalLM.from_pretrained("microsoft/phi-2") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use microsoft/phi-2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "microsoft/phi-2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/phi-2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/microsoft/phi-2
- SGLang
How to use microsoft/phi-2 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-2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/phi-2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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-2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/phi-2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use microsoft/phi-2 with Docker Model Runner:
docker model run hf.co/microsoft/phi-2
Delete added_tokens.json
Browse files- added_tokens.json +0 -40
added_tokens.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"\t\t": 50294,
|
| 3 |
-
"\t\t\t": 50293,
|
| 4 |
-
"\t\t\t\t": 50292,
|
| 5 |
-
"\t\t\t\t\t": 50291,
|
| 6 |
-
"\t\t\t\t\t\t": 50290,
|
| 7 |
-
"\t\t\t\t\t\t\t": 50289,
|
| 8 |
-
"\t\t\t\t\t\t\t\t": 50288,
|
| 9 |
-
"\t\t\t\t\t\t\t\t\t": 50287,
|
| 10 |
-
" ": 50286,
|
| 11 |
-
" ": 50285,
|
| 12 |
-
" ": 50284,
|
| 13 |
-
" ": 50283,
|
| 14 |
-
" ": 50282,
|
| 15 |
-
" ": 50281,
|
| 16 |
-
" ": 50280,
|
| 17 |
-
" ": 50279,
|
| 18 |
-
" ": 50278,
|
| 19 |
-
" ": 50277,
|
| 20 |
-
" ": 50276,
|
| 21 |
-
" ": 50275,
|
| 22 |
-
" ": 50274,
|
| 23 |
-
" ": 50273,
|
| 24 |
-
" ": 50272,
|
| 25 |
-
" ": 50271,
|
| 26 |
-
" ": 50270,
|
| 27 |
-
" ": 50269,
|
| 28 |
-
" ": 50268,
|
| 29 |
-
" ": 50267,
|
| 30 |
-
" ": 50266,
|
| 31 |
-
" ": 50265,
|
| 32 |
-
" ": 50264,
|
| 33 |
-
" ": 50263,
|
| 34 |
-
" ": 50262,
|
| 35 |
-
" ": 50261,
|
| 36 |
-
" ": 50260,
|
| 37 |
-
" ": 50259,
|
| 38 |
-
" ": 50258,
|
| 39 |
-
" ": 50257
|
| 40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|