katuni4ka commited on
Commit
9dac3d1
1 Parent(s): a4d3157

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +52 -11
README.md CHANGED
@@ -3,7 +3,7 @@ license: apache-2.0
3
  license_link: https://choosealicense.com/licenses/apache-2.0/
4
  ---
5
  # whisper-base-int8-ov
6
- * Model creator: [Openai](https://huggingface.co/openai)
7
  * Original model: [whisper-base](https://huggingface.co/openai/whisper-base)
8
 
9
  ## Description
@@ -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 AutoTokenizer
41
- from optimum.intel.openvino import OVModelForCausalLM
42
 
43
- model_id = "OpenVINO/whisper-base-int8-ov"
44
- tokenizer = AutoTokenizer.from_pretrained(model_id)
45
- model = OVModelForCausalLM.from_pretrained(model_id)
46
 
47
- inputs = tokenizer("What is OpenVINO?", return_tensors="pt")
 
48
 
49
- outputs = model.generate(**inputs, max_length=200)
50
- text = tokenizer.batch_decode(outputs)[0]
 
 
 
 
 
 
51
  print(text)
52
  ```
53
 
54
- 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).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  ## Limitations
57
 
 
3
  license_link: https://choosealicense.com/licenses/apache-2.0/
4
  ---
5
  # whisper-base-int8-ov
6
+ * Model creator: [OpenAI](https://huggingface.co/openai)
7
  * Original model: [whisper-base](https://huggingface.co/openai/whisper-base)
8
 
9
  ## Description
 
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-v2-fp16-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-v2-fp16-ov"
75
+ model_path = "distil-large-v2-fp16-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