srang992 commited on
Commit
688b191
·
verified ·
1 Parent(s): 74a3c56

Update README.md

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