Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
license_link: https://huggingface.co/Qwen/Qwen3-4B/blob/main/LICENSE
|
4 |
+
base_model:
|
5 |
+
- Qwen/Qwen3-4B
|
6 |
+
base_model_relation: quantized
|
7 |
+
|
8 |
+
---
|
9 |
+
# Qwen3-4B-int8-ov
|
10 |
+
* Model creator: [Qwen](https://huggingface.co/Qwen)
|
11 |
+
* Original model: [Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B)
|
12 |
+
|
13 |
+
## Description
|
14 |
+
This is [Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B) model converted to the [OpenVINO™ IR](https://docs.openvino.ai/2025/documentation/openvino-ir-format.html) (Intermediate Representation) format with weights compressed to INT8 by [NNCF](https://github.com/openvinotoolkit/nncf).
|
15 |
+
|
16 |
+
## Quantization Parameters
|
17 |
+
|
18 |
+
Weight compression was performed using `nncf.compress_weights` with the following parameters:
|
19 |
+
|
20 |
+
* mode: **INT8_ASYM**
|
21 |
+
|
22 |
+
For more information on quantization, check the [OpenVINO model optimization guide](https://docs.openvino.ai/2025/openvino-workflow/model-optimization-guide/weight-compression.html).
|
23 |
+
|
24 |
+
## Compatibility
|
25 |
+
|
26 |
+
The provided OpenVINO™ IR model is compatible with:
|
27 |
+
|
28 |
+
* OpenVINO version 2025.1.0 and higher
|
29 |
+
* Optimum Intel 1.24.0 and higher
|
30 |
+
|
31 |
+
## Running Model Inference with [Optimum Intel](https://huggingface.co/docs/optimum/intel/index)
|
32 |
+
|
33 |
+
1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
|
34 |
+
|
35 |
+
```
|
36 |
+
pip install optimum[openvino]
|
37 |
+
```
|
38 |
+
|
39 |
+
2. Run model inference:
|
40 |
+
|
41 |
+
```
|
42 |
+
from transformers import AutoTokenizer
|
43 |
+
from optimum.intel.openvino import OVModelForCausalLM
|
44 |
+
|
45 |
+
model_id = "OpenVINO/qwen3-4b-int8-ov"
|
46 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
47 |
+
model = OVModelForCausalLM.from_pretrained(model_id)
|
48 |
+
|
49 |
+
inputs = tokenizer("What is OpenVINO?", return_tensors="pt")
|
50 |
+
|
51 |
+
outputs = model.generate(**inputs, max_length=200)
|
52 |
+
text = tokenizer.batch_decode(outputs)[0]
|
53 |
+
print(text)
|
54 |
+
```
|
55 |
+
|
56 |
+
For more examples and possible optimizations, refer to the [Inference with Optimum Intel](https://docs.openvino.ai/2025/openvino-workflow-generative/inference-with-optimum-intel.html).
|
57 |
+
|
58 |
+
## Running Model Inference with [OpenVINO GenAI](https://github.com/openvinotoolkit/openvino.genai)
|
59 |
+
|
60 |
+
|
61 |
+
1. Install packages required for using OpenVINO GenAI.
|
62 |
+
```
|
63 |
+
pip install openvino-genai huggingface_hub
|
64 |
+
```
|
65 |
+
|
66 |
+
2. Download model from HuggingFace Hub
|
67 |
+
|
68 |
+
```
|
69 |
+
import huggingface_hub as hf_hub
|
70 |
+
|
71 |
+
model_id = "OpenVINO/qwen3-4b-int8-ov"
|
72 |
+
model_path = "qwen3-4b-int8-ov"
|
73 |
+
|
74 |
+
hf_hub.snapshot_download(model_id, local_dir=model_path)
|
75 |
+
|
76 |
+
```
|
77 |
+
|
78 |
+
3. Run model inference:
|
79 |
+
|
80 |
+
```
|
81 |
+
import openvino_genai as ov_genai
|
82 |
+
|
83 |
+
device = "CPU"
|
84 |
+
pipe = ov_genai.LLMPipeline(model_path, device)
|
85 |
+
pipe.get_tokenizer().set_chat_template(pipe.get_tokenizer().chat_template)
|
86 |
+
print(pipe.generate("What is OpenVINO?", max_length=200))
|
87 |
+
```
|
88 |
+
|
89 |
+
More GenAI usage examples can be found in OpenVINO GenAI library [docs](https://docs.openvino.ai/2025/openvino-workflow-generative/inference-with-genai.html) and [samples](https://github.com/openvinotoolkit/openvino.genai?tab=readme-ov-file#openvino-genai-samples)
|
90 |
+
|
91 |
+
You can find more detaild usage examples in OpenVINO Notebooks:
|
92 |
+
|
93 |
+
- [LLM](https://openvinotoolkit.github.io/openvino_notebooks/?search=LLM)
|
94 |
+
- [RAG text generation](https://openvinotoolkit.github.io/openvino_notebooks/?search=RAG+system&tasks=Text+Generation)
|
95 |
+
|
96 |
+
## Limitations
|
97 |
+
|
98 |
+
Check the original [model card](https://huggingface.co/Qwen/Qwen3-4B) for limitations.
|
99 |
+
|
100 |
+
## Legal information
|
101 |
+
|
102 |
+
The original model is distributed under [Apache License Version 2.0](https://huggingface.co/Qwen/Qwen3-4B/blob/main/LICENSE) license. More details can be found in [Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B).
|
103 |
+
|
104 |
+
## Disclaimer
|
105 |
+
|
106 |
+
Intel is committed to respecting human rights and avoiding causing or contributing to adverse impacts on human rights. See [Intel’s Global Human Rights Principles](https://www.intel.com/content/dam/www/central-libraries/us/en/documents/policy-human-rights.pdf). Intel’s products and software are intended only to be used in applications that do not cause or contribute to adverse impacts on human rights.
|