Update README.md
Browse files
README.md
CHANGED
@@ -26,7 +26,7 @@ The provided OpenVINO™ IR model is compatible with:
|
|
26 |
* OpenVINO version 2024.4.0 and higher
|
27 |
* Optimum Intel 1.20.0 and higher
|
28 |
|
29 |
-
## Running Model Inference
|
30 |
|
31 |
1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
|
32 |
|
@@ -37,21 +37,62 @@ pip install optimum[openvino]
|
|
37 |
2. Run model inference:
|
38 |
|
39 |
```
|
40 |
-
from transformers import
|
41 |
-
from optimum.intel.openvino import
|
42 |
|
43 |
model_id = "OpenVINO/distil-large-v3-int8-ov"
|
44 |
-
tokenizer =
|
45 |
-
model =
|
46 |
|
47 |
-
|
|
|
48 |
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
print(text)
|
52 |
```
|
53 |
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
## Limitations
|
57 |
|
|
|
26 |
* OpenVINO version 2024.4.0 and higher
|
27 |
* Optimum Intel 1.20.0 and higher
|
28 |
|
29 |
+
## Running Model Inference with [Optimum Intel](https://huggingface.co/docs/optimum/intel/index)
|
30 |
|
31 |
1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
|
32 |
|
|
|
37 |
2. Run model inference:
|
38 |
|
39 |
```
|
40 |
+
from transformers import AutoProcessor
|
41 |
+
from optimum.intel.openvino import OVModelForSpeechSeq2Seq
|
42 |
|
43 |
model_id = "OpenVINO/distil-large-v3-int8-ov"
|
44 |
+
tokenizer = AutoProcessor.from_pretrained(model_id)
|
45 |
+
model = OVModelForSpeechSeq2Seq.from_pretrained(model_id)
|
46 |
|
47 |
+
dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True)
|
48 |
+
sample = dataset[0]
|
49 |
|
50 |
+
input_features = processor(
|
51 |
+
sample["audio"]["array"],
|
52 |
+
sampling_rate=sample["audio"]["sampling_rate"],
|
53 |
+
return_tensors="pt",
|
54 |
+
).input_features
|
55 |
+
|
56 |
+
outputs = model.generate(input_features)
|
57 |
+
text = processor.batch_decode(outputs)[0]
|
58 |
print(text)
|
59 |
```
|
60 |
|
61 |
+
## Running Model Inference with [OpenVINO GenAI](https://github.com/openvinotoolkit/openvino.genai)
|
62 |
+
|
63 |
+
1. Install packages required for using OpenVINO GenAI.
|
64 |
+
```
|
65 |
+
pip install huggingface_hub
|
66 |
+
pip install -U --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly openvino openvino-tokenizers openvino-genai
|
67 |
+
```
|
68 |
+
|
69 |
+
2. Download model from HuggingFace Hub
|
70 |
+
|
71 |
+
```
|
72 |
+
import huggingface_hub as hf_hub
|
73 |
+
|
74 |
+
model_id = "OpenVINO/distil-large-v3-int8-ov"
|
75 |
+
model_path = "distil-large-v3-int8-ov"
|
76 |
+
|
77 |
+
hf_hub.snapshot_download(model_id, local_dir=model_path)
|
78 |
+
|
79 |
+
```
|
80 |
+
|
81 |
+
3. Run model inference:
|
82 |
+
|
83 |
+
```
|
84 |
+
import openvino_genai as ov_genai
|
85 |
+
import datasets
|
86 |
+
|
87 |
+
device = "CPU"
|
88 |
+
pipe = ov_genai.WhisperPipeline(model_path, device)
|
89 |
+
|
90 |
+
dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True)
|
91 |
+
sample = dataset[0]["audio]["array"]
|
92 |
+
print(pipe.generate(sample))
|
93 |
+
```
|
94 |
+
|
95 |
+
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)
|
96 |
|
97 |
## Limitations
|
98 |
|