Update README.md
Browse files
README.md
CHANGED
@@ -30,7 +30,7 @@ The provided OpenVINO™ IR model is compatible with:
|
|
30 |
* OpenVINO version 2024.1.0 and higher
|
31 |
* Optimum Intel 1.16.0 and higher
|
32 |
|
33 |
-
## Running Model Inference
|
34 |
|
35 |
1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
|
36 |
|
@@ -48,7 +48,7 @@ The provided OpenVINO™ IR model is compatible with:
|
|
48 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
49 |
model = OVModelForCausalLM.from_pretrained(model_id)
|
50 |
|
51 |
-
inputs = tokenizer("
|
52 |
|
53 |
outputs = model.generate(**inputs, max_length=200)
|
54 |
text = tokenizer.batch_decode(outputs)[0]
|
@@ -57,6 +57,38 @@ The provided OpenVINO™ IR model is compatible with:
|
|
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 |
## Limitations
|
61 |
|
62 |
Check the original model card for [limitations](https://huggingface.co/Salesforce/codegen2-3_7B_P#intended-use-and-limitations).
|
|
|
30 |
* OpenVINO version 2024.1.0 and higher
|
31 |
* Optimum Intel 1.16.0 and higher
|
32 |
|
33 |
+
## Running Model Inference with [Optimum Intel](https://huggingface.co/docs/optimum/intel/index)
|
34 |
|
35 |
1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
|
36 |
|
|
|
48 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
49 |
model = OVModelForCausalLM.from_pretrained(model_id)
|
50 |
|
51 |
+
inputs = tokenizer("def print_hello_world():", return_tensors="pt")
|
52 |
|
53 |
outputs = model.generate(**inputs, max_length=200)
|
54 |
text = tokenizer.batch_decode(outputs)[0]
|
|
|
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 = "OpenVINO/codegen2-3_7B_P-int4-ov"
|
73 |
+
model_path = "codegen2-3_7B_P-int4-ov"
|
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("def print_hello_world():"))
|
87 |
+
```
|
88 |
+
|
89 |
+
More GenAI usage examples can be found in OpenVINO GenAI library [docs](https://github.com/openvinotoolkit/openvino.genai/blob/master/src/README.md) and [samples](https://github.com/openvinotoolkit/openvino.genai?tab=readme-ov-file#openvino-genai-samples)
|
90 |
+
|
91 |
+
|
92 |
## Limitations
|
93 |
|
94 |
Check the original model card for [limitations](https://huggingface.co/Salesforce/codegen2-3_7B_P#intended-use-and-limitations).
|