katuni4ka commited on
Commit
f321f97
1 Parent(s): a16ba12

Update README.md

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