katuni4ka commited on
Commit
dabc77a
·
verified ·
1 Parent(s): adbb50b

Update README.md

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