srang992 commited on
Commit
bd9a82b
·
verified ·
1 Parent(s): 7719c2e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +87 -3
README.md CHANGED
@@ -1,3 +1,87 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: gpl-3.0
3
+ pipeline_tag: text-generation
4
+ language:
5
+ - en
6
+ library_name: transformers
7
+ ---
8
+ # Llama-3.2-3B-Instruct-ov-INT4
9
+ * Model creator: [Meta Llama](https://huggingface.co/meta-llama)
10
+ * Original model: [Llama-3.2-3B-Instruct](https://huggingface.co/meta-llama/Llama-3.2-3B-Instruct)
11
+
12
+ ## Description
13
+ This is [Llama-3.2-3B-Instruct](https://huggingface.co/meta-llama/Llama-3.2-3B-Instruct) 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
+
15
+ ## Quantization Parameters
16
+
17
+ Weight compression was performed using `nncf.compress_weights` with the following parameters:
18
+
19
+ * mode: **int4_sym**
20
+ * ratio: **1**
21
+
22
+ For more information on quantization, check the [OpenVINO model optimization guide](https://docs.openvino.ai/2024/openvino-workflow/model-optimization-guide/weight-compression.html).
23
+
24
+
25
+ ## Compatibility
26
+
27
+ The provided OpenVINO™ IR model is compatible with:
28
+
29
+ * OpenVINO version 2024.4.0 and higher
30
+ * Optimum Intel 1.19.0 and higher
31
+
32
+ ## Running Model Inference with [Optimum Intel](https://huggingface.co/docs/optimum/intel/index)
33
+
34
+
35
+ 1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
36
+
37
+ ```
38
+ pip install optimum[openvino]
39
+ ```
40
+
41
+ 2. Run model inference:
42
+
43
+ ```
44
+ from transformers import AutoTokenizer
45
+ from optimum.intel.openvino import OVModelForCausalLM
46
+
47
+ model_id = "srang992/Llama-3.2-3B-Instruct-ov-INT4"
48
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
49
+ model = OVModelForCausalLM.from_pretrained(model_id)
50
+
51
+ inputs = tokenizer("What is OpenVINO?", return_tensors="pt")
52
+
53
+ outputs = model.generate(**inputs, max_length=200)
54
+ text = tokenizer.batch_decode(outputs)[0]
55
+ print(text)
56
+ ```
57
+
58
+ For more examples and possible optimizations, refer to the [OpenVINO Large Language Model Inference Guide](https://docs.openvino.ai/2024/learn-openvino/llm_inference_guide.html).
59
+
60
+ ## Running Model Inference with [OpenVINO GenAI](https://github.com/openvinotoolkit/openvino.genai)
61
+
62
+ 1. Install packages required for using OpenVINO GenAI.
63
+ ```
64
+ pip install openvino-genai huggingface_hub
65
+ ```
66
+
67
+ 2. Download model from HuggingFace Hub
68
+
69
+ ```
70
+ import huggingface_hub as hf_hub
71
+
72
+ model_id = "srang992/Llama-3.2-3B-Instruct-ov-INT4"
73
+ model_path = "Llama-3.2-3B-Instruct-ov-INT4"
74
+
75
+ hf_hub.snapshot_download(model_id, local_dir=model_path)
76
+
77
+ ```
78
+
79
+ 3. Run model inference:
80
+
81
+ ```
82
+ import openvino_genai as ov_genai
83
+
84
+ device = "CPU"
85
+ pipe = ov_genai.LLMPipeline(model_path, device)
86
+ print(pipe.generate("What is OpenVINO?", max_length=200))
87
+ ```