Instructions to use Intel/phi-2-ov-quantized with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Intel/phi-2-ov-quantized with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Intel/phi-2-ov-quantized")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Intel/phi-2-ov-quantized") model = AutoModelForCausalLM.from_pretrained("Intel/phi-2-ov-quantized") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Intel/phi-2-ov-quantized with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Intel/phi-2-ov-quantized" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Intel/phi-2-ov-quantized", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Intel/phi-2-ov-quantized
- SGLang
How to use Intel/phi-2-ov-quantized 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 "Intel/phi-2-ov-quantized" \ --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": "Intel/phi-2-ov-quantized", "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 "Intel/phi-2-ov-quantized" \ --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": "Intel/phi-2-ov-quantized", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Intel/phi-2-ov-quantized with Docker Model Runner:
docker model run hf.co/Intel/phi-2-ov-quantized
Upload config.json
Browse filesupdating config.json file to remove auto_map
- config.json +1 -6
config.json
CHANGED
|
@@ -4,10 +4,6 @@
|
|
| 4 |
"PhiForCausalLM"
|
| 5 |
],
|
| 6 |
"attention_dropout": 0.0,
|
| 7 |
-
"auto_map": {
|
| 8 |
-
"AutoConfig": "microsoft/phi-2--configuration_phi.PhiConfig",
|
| 9 |
-
"AutoModelForCausalLM": "microsoft/phi-2--modeling_phi.PhiForCausalLM"
|
| 10 |
-
},
|
| 11 |
"bos_token_id": 50256,
|
| 12 |
"embd_pdrop": 0.0,
|
| 13 |
"eos_token_id": 50256,
|
|
@@ -15,7 +11,6 @@
|
|
| 15 |
"hidden_size": 2560,
|
| 16 |
"initializer_range": 0.02,
|
| 17 |
"intermediate_size": 10240,
|
| 18 |
-
"is_decoder": true,
|
| 19 |
"layer_norm_eps": 1e-05,
|
| 20 |
"max_position_embeddings": 2048,
|
| 21 |
"model_type": "phi",
|
|
@@ -29,7 +24,7 @@
|
|
| 29 |
"rope_theta": 10000.0,
|
| 30 |
"tie_word_embeddings": false,
|
| 31 |
"torch_dtype": "float16",
|
| 32 |
-
"transformers_version": "4.
|
| 33 |
"use_cache": true,
|
| 34 |
"vocab_size": 51200
|
| 35 |
}
|
|
|
|
| 4 |
"PhiForCausalLM"
|
| 5 |
],
|
| 6 |
"attention_dropout": 0.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
"bos_token_id": 50256,
|
| 8 |
"embd_pdrop": 0.0,
|
| 9 |
"eos_token_id": 50256,
|
|
|
|
| 11 |
"hidden_size": 2560,
|
| 12 |
"initializer_range": 0.02,
|
| 13 |
"intermediate_size": 10240,
|
|
|
|
| 14 |
"layer_norm_eps": 1e-05,
|
| 15 |
"max_position_embeddings": 2048,
|
| 16 |
"model_type": "phi",
|
|
|
|
| 24 |
"rope_theta": 10000.0,
|
| 25 |
"tie_word_embeddings": false,
|
| 26 |
"torch_dtype": "float16",
|
| 27 |
+
"transformers_version": "4.37.0",
|
| 28 |
"use_cache": true,
|
| 29 |
"vocab_size": 51200
|
| 30 |
}
|