OpenVINO models
Collection
A collection of quantized LLMs in OpenVINO format • 5 items • Updated
How to use jojo1899/Mistral-7B-Instruct-v0.2-ov-int4 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="jojo1899/Mistral-7B-Instruct-v0.2-ov-int4")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("jojo1899/Mistral-7B-Instruct-v0.2-ov-int4")
model = AutoModelForCausalLM.from_pretrained("jojo1899/Mistral-7B-Instruct-v0.2-ov-int4")
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]:]))How to use jojo1899/Mistral-7B-Instruct-v0.2-ov-int4 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "jojo1899/Mistral-7B-Instruct-v0.2-ov-int4"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "jojo1899/Mistral-7B-Instruct-v0.2-ov-int4",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/jojo1899/Mistral-7B-Instruct-v0.2-ov-int4
How to use jojo1899/Mistral-7B-Instruct-v0.2-ov-int4 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "jojo1899/Mistral-7B-Instruct-v0.2-ov-int4" \
--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": "jojo1899/Mistral-7B-Instruct-v0.2-ov-int4",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "jojo1899/Mistral-7B-Instruct-v0.2-ov-int4" \
--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": "jojo1899/Mistral-7B-Instruct-v0.2-ov-int4",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use jojo1899/Mistral-7B-Instruct-v0.2-ov-int4 with Docker Model Runner:
docker model run hf.co/jojo1899/Mistral-7B-Instruct-v0.2-ov-int4
This is an INT4 quantized version of the mistralai/Mistral-7B-Instruct-v0.2 model. The Python packages used in creating this model are as follows:
openvino==2024.5.0rc1
optimum==1.23.3
optimum-intel==1.20.1
nncf==2.13.0
torch==2.5.1
transformers==4.46.2
This quantized model is created using the following command:
optimum-cli export openvino --model "mistralai/Mistral-7B-Instruct-v0.2" --weight-format int4 --group-size 128 --sym --ratio 1 --all-layers ./Mistral-7B-Instruct-v0.2-ov-int4
For more details, run the following command from your Python environment: optimum-cli export openvino --help
INFO:nncf:Statistics of the bitwidth distribution:
| Num bits (N) | % all parameters (layers) | % ratio-defining parameters (layers) |
|---|---|---|
| 4 | 100% (226 / 226) | 100% (226 / 226) |