katuni4ka commited on
Commit
67e6775
1 Parent(s): 9d673a0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +51 -10
README.md CHANGED
@@ -3,7 +3,7 @@ license: apache-2.0
3
  license_link: https://choosealicense.com/licenses/apache-2.0/
4
  ---
5
  # whisper-tiny-fp16-ov
6
- * Model creator: [Openai](https://huggingface.co/openai)
7
  * Original model: [whisper-tiny](https://huggingface.co/openai/whisper-tiny)
8
 
9
  ## Description
@@ -15,7 +15,7 @@ The provided OpenVINO™ IR model is compatible with:
15
  * OpenVINO version 2024.4.0 and higher
16
  * Optimum Intel 1.20.0 and higher
17
 
18
- ## Running Model Inference
19
 
20
  1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
21
 
@@ -26,21 +26,62 @@ pip install optimum[openvino]
26
  2. Run model inference:
27
 
28
  ```
29
- from transformers import AutoTokenizer
30
- from optimum.intel.openvino import OVModelForCausalLM
31
 
32
  model_id = "OpenVINO/whisper-tiny-fp16-ov"
33
- tokenizer = AutoTokenizer.from_pretrained(model_id)
34
- model = OVModelForCausalLM.from_pretrained(model_id)
35
 
36
- inputs = tokenizer("What is OpenVINO?", return_tensors="pt")
 
37
 
38
- outputs = model.generate(**inputs, max_length=200)
39
- text = tokenizer.batch_decode(outputs)[0]
 
 
 
 
 
 
40
  print(text)
41
  ```
42
 
43
- 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).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  ## Limitations
46
 
 
3
  license_link: https://choosealicense.com/licenses/apache-2.0/
4
  ---
5
  # whisper-tiny-fp16-ov
6
+ * Model creator: [OpenAI](https://huggingface.co/openai)
7
  * Original model: [whisper-tiny](https://huggingface.co/openai/whisper-tiny)
8
 
9
  ## Description
 
15
  * OpenVINO version 2024.4.0 and higher
16
  * Optimum Intel 1.20.0 and higher
17
 
18
+ ## Running Model Inference with [Optimum Intel](https://huggingface.co/docs/optimum/intel/index)
19
 
20
  1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
21
 
 
26
  2. Run model inference:
27
 
28
  ```
29
+ from transformers import AutoProcessor
30
+ from optimum.intel.openvino import OVModelForSpeechSeq2Seq
31
 
32
  model_id = "OpenVINO/whisper-tiny-fp16-ov"
33
+ tokenizer = AutoProcessor.from_pretrained(model_id)
34
+ model = OVModelForSpeechSeq2Seq.from_pretrained(model_id)
35
 
36
+ dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True)
37
+ sample = dataset[0]
38
 
39
+ input_features = processor(
40
+ sample["audio"]["array"],
41
+ sampling_rate=sample["audio"]["sampling_rate"],
42
+ return_tensors="pt",
43
+ ).input_features
44
+
45
+ outputs = model.generate(input_features)
46
+ text = processor.batch_decode(outputs)[0]
47
  print(text)
48
  ```
49
 
50
+ ## Running Model Inference with [OpenVINO GenAI](https://github.com/openvinotoolkit/openvino.genai)
51
+
52
+ 1. Install packages required for using OpenVINO GenAI.
53
+ ```
54
+ pip install huggingface_hub
55
+ pip install -U --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly openvino openvino-tokenizers openvino-genai
56
+ ```
57
+
58
+ 2. Download model from HuggingFace Hub
59
+
60
+ ```
61
+ import huggingface_hub as hf_hub
62
+
63
+ model_id = "OpenVINO/whisper-tiny-fp16-ov"
64
+ model_path = "whisper-tiny-fp16-ov"
65
+
66
+ hf_hub.snapshot_download(model_id, local_dir=model_path)
67
+
68
+ ```
69
+
70
+ 3. Run model inference:
71
+
72
+ ```
73
+ import openvino_genai as ov_genai
74
+ import datasets
75
+
76
+ device = "CPU"
77
+ pipe = ov_genai.WhisperPipeline(model_path, device)
78
+
79
+ dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True)
80
+ sample = dataset[0]["audio]["array"]
81
+ print(pipe.generate(sample))
82
+ ```
83
+
84
+ 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)
85
 
86
  ## Limitations
87