katuni4ka commited on
Commit
d77e0c7
1 Parent(s): bfdd39b

Update README.md

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