Instructions to use OpenVINO/Phi-3-medium-4k-instruct-fp16-ov with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenVINO/Phi-3-medium-4k-instruct-fp16-ov with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OpenVINO/Phi-3-medium-4k-instruct-fp16-ov", 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("OpenVINO/Phi-3-medium-4k-instruct-fp16-ov", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("OpenVINO/Phi-3-medium-4k-instruct-fp16-ov", trust_remote_code=True, device_map="auto") 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 Settings
- vLLM
How to use OpenVINO/Phi-3-medium-4k-instruct-fp16-ov with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenVINO/Phi-3-medium-4k-instruct-fp16-ov" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenVINO/Phi-3-medium-4k-instruct-fp16-ov", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/OpenVINO/Phi-3-medium-4k-instruct-fp16-ov
- SGLang
How to use OpenVINO/Phi-3-medium-4k-instruct-fp16-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-3-medium-4k-instruct-fp16-ov" \ --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": "OpenVINO/Phi-3-medium-4k-instruct-fp16-ov", "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 "OpenVINO/Phi-3-medium-4k-instruct-fp16-ov" \ --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": "OpenVINO/Phi-3-medium-4k-instruct-fp16-ov", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use OpenVINO/Phi-3-medium-4k-instruct-fp16-ov with Docker Model Runner:
docker model run hf.co/OpenVINO/Phi-3-medium-4k-instruct-fp16-ov
| <net name="detokenizer" version="11"> | |
| <layers> | |
| <layer id="0" name="Parameter_37" type="Parameter" version="opset1"> | |
| <data shape="?,?" element_type="i64" /> | |
| <output> | |
| <port id="0" precision="I64" names="Parameter_37"> | |
| <dim>-1</dim> | |
| <dim>-1</dim> | |
| </port> | |
| </output> | |
| </layer> | |
| <layer id="1" name="Constant_2" type="Const" version="opset1"> | |
| <data element_type="u8" shape="499991" offset="0" size="499991" /> | |
| <output> | |
| <port id="0" precision="U8"> | |
| <dim>499991</dim> | |
| </port> | |
| </output> | |
| </layer> | |
| <layer id="2" name="Convert_47" type="Convert" version="opset1"> | |
| <data destination_type="i32" /> | |
| <input> | |
| <port id="0" precision="I64"> | |
| <dim>-1</dim> | |
| <dim>-1</dim> | |
| </port> | |
| </input> | |
| <output> | |
| <port id="1" precision="I32"> | |
| <dim>-1</dim> | |
| <dim>-1</dim> | |
| </port> | |
| </output> | |
| </layer> | |
| <layer id="3" name="SentencepieceDetokenizer_38" type="SentencepieceDetokenizer" version="extension"> | |
| <input> | |
| <port id="0" precision="U8"> | |
| <dim>499991</dim> | |
| </port> | |
| <port id="1" precision="I32"> | |
| <dim>-1</dim> | |
| <dim>-1</dim> | |
| </port> | |
| </input> | |
| <output> | |
| <port id="2" precision="I32"> | |
| <dim>-1</dim> | |
| </port> | |
| <port id="3" precision="I32"> | |
| <dim>-1</dim> | |
| </port> | |
| <port id="4" precision="U8"> | |
| <dim>-1</dim> | |
| </port> | |
| </output> | |
| </layer> | |
| <layer id="4" name="StringTensorPack_39" type="StringTensorPack" version="extension"> | |
| <data mode="begins_ends" /> | |
| <input> | |
| <port id="0" precision="I32"> | |
| <dim>-1</dim> | |
| </port> | |
| <port id="1" precision="I32"> | |
| <dim>-1</dim> | |
| </port> | |
| <port id="2" precision="U8"> | |
| <dim>-1</dim> | |
| </port> | |
| </input> | |
| <output> | |
| <port id="3" precision="STRING" names="string_output"> | |
| <dim>-1</dim> | |
| </port> | |
| </output> | |
| </layer> | |
| <layer id="5" name="Result_40" type="Result" version="opset1"> | |
| <input> | |
| <port id="0" precision="STRING"> | |
| <dim>-1</dim> | |
| </port> | |
| </input> | |
| </layer> | |
| </layers> | |
| <edges> | |
| <edge from-layer="0" from-port="0" to-layer="2" to-port="0" /> | |
| <edge from-layer="1" from-port="0" to-layer="3" to-port="0" /> | |
| <edge from-layer="2" from-port="1" to-layer="3" to-port="1" /> | |
| <edge from-layer="3" from-port="2" to-layer="4" to-port="0" /> | |
| <edge from-layer="3" from-port="3" to-layer="4" to-port="1" /> | |
| <edge from-layer="3" from-port="4" to-layer="4" to-port="2" /> | |
| <edge from-layer="4" from-port="3" to-layer="5" to-port="0" /> | |
| </edges> | |
| <rt_info> | |
| <bos_token_id value="1" /> | |
| <chat_template value="{% for message in messages %}{% if (message['role'] == 'user') %}{{'<|user|>' + ' ' + message['content'] + '<|end|>' + ' ' + '<|assistant|>' + ' '}}{% elif (message['role'] == 'assistant') %}{{message['content'] + '<|end|>' + ' '}}{% endif %}{% endfor %}" /> | |
| <eos_token_id value="32000" /> | |
| <original_tokenizer_class value="<class 'transformers.models.llama.tokenization_llama_fast.LlamaTokenizerFast'>" /> | |
| <pad_token_id value="32000" /> | |
| </rt_info> | |
| </net> | |