Instructions to use OpenVINO/phi-2-int4-ov with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenVINO/phi-2-int4-ov with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OpenVINO/phi-2-int4-ov", device_map="auto")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("OpenVINO/phi-2-int4-ov") model = AutoModelForCausalLM.from_pretrained("OpenVINO/phi-2-int4-ov", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use OpenVINO/phi-2-int4-ov with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenVINO/phi-2-int4-ov" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenVINO/phi-2-int4-ov", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/OpenVINO/phi-2-int4-ov
- SGLang
How to use OpenVINO/phi-2-int4-ov 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 "OpenVINO/phi-2-int4-ov" \ --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": "OpenVINO/phi-2-int4-ov", "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 "OpenVINO/phi-2-int4-ov" \ --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": "OpenVINO/phi-2-int4-ov", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use OpenVINO/phi-2-int4-ov with Docker Model Runner:
docker model run hf.co/OpenVINO/phi-2-int4-ov
Update README.md
Browse files
README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
| 2 |
license: mit
|
| 3 |
license_link: https://choosealicense.com/licenses/mit/
|
| 4 |
---
|
| 5 |
-
# -int4-ov
|
| 6 |
* Model creator: [Microsoft](https://huggingface.co/microsoft)
|
| 7 |
-
|
| 8 |
|
| 9 |
## Description
|
| 10 |
This is [phi-2](https://huggingface.co/microsoft/phi-2) model converted to the [OpenVINO™ IR](https://docs.openvino.ai/2024/documentation/openvino-ir-format.html) (Intermediate Representation) format with weights compressed to INT4 by [NNCF](https://github.com/openvinotoolkit/nncf).
|
|
@@ -14,7 +14,7 @@ This is [phi-2](https://huggingface.co/microsoft/phi-2) model converted to the [
|
|
| 14 |
Weight compression was performed using `nncf.compress_weights` with the following parameters:
|
| 15 |
|
| 16 |
* mode: **int4_sym**
|
| 17 |
-
* ratio: **1**
|
| 18 |
* group_size: **128**
|
| 19 |
|
| 20 |
For more information on quantization, check the [OpenVINO model optimization guide](https://docs.openvino.ai/2024/openvino-workflow/model-optimization-guide/weight-compression.html).
|
|
|
|
| 2 |
license: mit
|
| 3 |
license_link: https://choosealicense.com/licenses/mit/
|
| 4 |
---
|
| 5 |
+
# phi-2-int4-ov
|
| 6 |
* Model creator: [Microsoft](https://huggingface.co/microsoft)
|
| 7 |
+
* Original model: [phi-2](https://huggingface.co/microsoft/phi-2)
|
| 8 |
|
| 9 |
## Description
|
| 10 |
This is [phi-2](https://huggingface.co/microsoft/phi-2) model converted to the [OpenVINO™ IR](https://docs.openvino.ai/2024/documentation/openvino-ir-format.html) (Intermediate Representation) format with weights compressed to INT4 by [NNCF](https://github.com/openvinotoolkit/nncf).
|
|
|
|
| 14 |
Weight compression was performed using `nncf.compress_weights` with the following parameters:
|
| 15 |
|
| 16 |
* mode: **int4_sym**
|
| 17 |
+
* ratio: **1.0**
|
| 18 |
* group_size: **128**
|
| 19 |
|
| 20 |
For more information on quantization, check the [OpenVINO model optimization guide](https://docs.openvino.ai/2024/openvino-workflow/model-optimization-guide/weight-compression.html).
|