|
78 | 78 | "source": [
|
79 | 79 | "from optimum.intel import OVModelForQuestionAnswering\n",
|
80 | 80 | "\n",
|
| 81 | + "\n", |
81 | 82 | "# Load PyTorch model from the Hub and export to OpenVINO in the background\n",
|
82 | 83 | "model = OVModelForQuestionAnswering.from_pretrained(\"distilbert-base-uncased-distilled-squad\", export=True)\n",
|
83 | 84 | "\n",
|
|
122 | 123 | "source": [
|
123 | 124 | "from transformers import AutoTokenizer\n",
|
124 | 125 | "\n",
|
| 126 | + "\n", |
125 | 127 | "tokenizer = AutoTokenizer.from_pretrained(\"distilbert-base-uncased-distilled-squad\")\n",
|
126 | 128 | "tokenizer.save_pretrained(\"distilbert-base-uncased-distilled-squad-ov-fp32\")"
|
127 | 129 | ]
|
|
182 | 184 | }
|
183 | 185 | ],
|
184 | 186 | "source": [
|
185 |
| - "from optimum.intel import OVModelForQuestionAnswering\n", |
186 | 187 | "from transformers import AutoTokenizer, pipeline\n",
|
187 | 188 | "\n",
|
| 189 | + "from optimum.intel import OVModelForQuestionAnswering\n", |
| 190 | + "\n", |
| 191 | + "\n", |
188 | 192 | "model = OVModelForQuestionAnswering.from_pretrained(\"distilbert-base-uncased-distilled-squad-ov-fp32\")\n",
|
189 | 193 | "tokenizer = AutoTokenizer.from_pretrained(\"distilbert-base-uncased-distilled-squad\")\n",
|
190 | 194 | "ov_pipe = pipeline(\"question-answering\", model=model, tokenizer=tokenizer)\n",
|
|
240 | 244 | ],
|
241 | 245 | "source": [
|
242 | 246 | "import torch\n",
|
243 |
| - "from optimum.intel import OVModelForQuestionAnswering\n", |
244 | 247 | "from transformers import AutoTokenizer, pipeline\n",
|
245 | 248 | "\n",
|
| 249 | + "from optimum.intel import OVModelForQuestionAnswering\n", |
| 250 | + "\n", |
| 251 | + "\n", |
246 | 252 | "model = OVModelForQuestionAnswering.from_pretrained(\"distilbert-base-uncased-distilled-squad-ov-fp32\")\n",
|
247 | 253 | "tokenizer = AutoTokenizer.from_pretrained(\"distilbert-base-uncased-distilled-squad-ov-fp32\")\n",
|
248 | 254 | "\n",
|
|
324 | 330 | }
|
325 | 331 | ],
|
326 | 332 | "source": [
|
327 |
| - "from optimum.intel import OVModelForQuestionAnswering\n", |
328 | 333 | "from transformers import AutoTokenizer, pipeline\n",
|
329 | 334 | "\n",
|
| 335 | + "from optimum.intel import OVModelForQuestionAnswering\n", |
| 336 | + "\n", |
| 337 | + "\n", |
330 | 338 | "model = OVModelForQuestionAnswering.from_pretrained(\n",
|
331 | 339 | " \"helenai/distilbert-base-uncased-distilled-squad-ov-fp32\", compile=False\n",
|
332 | 340 | ")\n",
|
|
411 | 419 | "source": [
|
412 | 420 | "from openvino.runtime import Core\n",
|
413 | 421 | "\n",
|
| 422 | + "\n", |
414 | 423 | "for device in Core().available_devices:\n",
|
415 | 424 | " print(device, Core().get_property(device, \"FULL_DEVICE_NAME\"))"
|
416 | 425 | ]
|
|
528 | 537 | }
|
529 | 538 | ],
|
530 | 539 | "source": [
|
| 540 | + "from datasets import load_dataset\n", |
531 | 541 | "from IPython.display import Audio\n",
|
532 |
| - "from optimum.intel import OVModelForAudioClassification\n", |
533 | 542 | "from transformers import AutoFeatureExtractor, pipeline\n",
|
534 |
| - "from datasets import load_dataset\n", |
| 543 | + "\n", |
| 544 | + "from optimum.intel import OVModelForAudioClassification\n", |
| 545 | + "\n", |
535 | 546 | "\n",
|
536 | 547 | "model_id = \"helenai/MIT-ast-finetuned-speech-commands-v2-ov\"\n",
|
537 | 548 | "model = OVModelForAudioClassification.from_pretrained(model_id)\n",
|
|
638 | 649 | }
|
639 | 650 | ],
|
640 | 651 | "source": [
|
641 |
| - "from optimum.intel import OVModelForCausalLM\n", |
642 | 652 | "from transformers import AutoTokenizer, pipeline\n",
|
643 | 653 | "\n",
|
| 654 | + "from optimum.intel import OVModelForCausalLM\n", |
| 655 | + "\n", |
| 656 | + "\n", |
644 | 657 | "model_id = \"helenai/gpt2-ov\"\n",
|
645 | 658 | "tokenizer = AutoTokenizer.from_pretrained(model_id)\n",
|
646 | 659 | "model = OVModelForCausalLM.from_pretrained(model_id)\n",
|
|
704 | 717 | ],
|
705 | 718 | "source": [
|
706 | 719 | "from IPython.display import Image\n",
|
707 |
| - "from optimum.intel import OVModelForImageClassification\n", |
708 | 720 | "from transformers import AutoImageProcessor, pipeline\n",
|
709 | 721 | "\n",
|
| 722 | + "from optimum.intel import OVModelForImageClassification\n", |
| 723 | + "\n", |
| 724 | + "\n", |
710 | 725 | "model_id = \"helenai/microsoft-swin-tiny-patch4-window7-224-ov\"\n",
|
711 | 726 | "model = OVModelForImageClassification.from_pretrained(model_id, compile=False)\n",
|
712 | 727 | "image_processor = AutoImageProcessor.from_pretrained(model_id)\n",
|
|
766 | 781 | }
|
767 | 782 | ],
|
768 | 783 | "source": [
|
769 |
| - "from optimum.intel import OVModelForMaskedLM\n", |
770 | 784 | "from transformers import AutoTokenizer, pipeline\n",
|
771 | 785 | "\n",
|
| 786 | + "from optimum.intel import OVModelForMaskedLM\n", |
| 787 | + "\n", |
| 788 | + "\n", |
772 | 789 | "model_id = \"helenai/bert-base-uncased-ov\"\n",
|
773 | 790 | "model = OVModelForMaskedLM.from_pretrained(model_id)\n",
|
774 | 791 | "tokenizer = AutoTokenizer.from_pretrained(model_id)\n",
|
|
835 | 852 | }
|
836 | 853 | ],
|
837 | 854 | "source": [
|
838 |
| - "from optimum.intel import OVModelForQuestionAnswering\n", |
839 | 855 | "from transformers import AutoTokenizer, pipeline\n",
|
840 | 856 | "\n",
|
| 857 | + "from optimum.intel import OVModelForQuestionAnswering\n", |
| 858 | + "\n", |
| 859 | + "\n", |
841 | 860 | "# Load the model and tokenizer saved in Part 1 of this notebook. Or use the line below to load them from the hub\n",
|
842 | 861 | "# model_id = \"helenai/distilbert-base-uncased-distilled-squad-ov-fp32\"\n",
|
843 | 862 | "model_id = \"distilbert-base-uncased-distilled-squad-ov-fp32\"\n",
|
|
890 | 909 | }
|
891 | 910 | ],
|
892 | 911 | "source": [
|
893 |
| - "from optimum.intel import OVModelForSeq2SeqLM\n", |
894 | 912 | "from transformers import AutoTokenizer, pipeline\n",
|
895 | 913 | "\n",
|
| 914 | + "from optimum.intel import OVModelForSeq2SeqLM\n", |
| 915 | + "\n", |
| 916 | + "\n", |
896 | 917 | "model_id = \"helenai/t5-small-ov\"\n",
|
897 | 918 | "model = OVModelForSeq2SeqLM.from_pretrained(model_id, compile=False, trust_remote_code=True)\n",
|
898 | 919 | "tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)\n",
|
|
998 | 1019 | }
|
999 | 1020 | ],
|
1000 | 1021 | "source": [
|
1001 |
| - "from optimum.intel import OVModelForSequenceClassification\n", |
1002 | 1022 | "from transformers import AutoTokenizer, pipeline\n",
|
1003 | 1023 | "\n",
|
| 1024 | + "from optimum.intel import OVModelForSequenceClassification\n", |
| 1025 | + "\n", |
| 1026 | + "\n", |
1004 | 1027 | "model_id = \"helenai/papluca-xlm-roberta-base-language-detection-ov\"\n",
|
1005 | 1028 | "model = OVModelForSequenceClassification.from_pretrained(model_id)\n",
|
1006 | 1029 | "tokenizer = AutoTokenizer.from_pretrained(model_id)\n",
|
|
1047 | 1070 | }
|
1048 | 1071 | ],
|
1049 | 1072 | "source": [
|
1050 |
| - "from optimum.intel import OVModelForTokenClassification\n", |
1051 | 1073 | "from transformers import AutoTokenizer, pipeline\n",
|
1052 | 1074 | "\n",
|
| 1075 | + "from optimum.intel import OVModelForTokenClassification\n", |
| 1076 | + "\n", |
| 1077 | + "\n", |
1053 | 1078 | "model_id = \"helenai/dslim-bert-base-NER-ov-fp32\"\n",
|
1054 | 1079 | "tokenizer = AutoTokenizer.from_pretrained(model_id)\n",
|
1055 | 1080 | "model = OVModelForTokenClassification.from_pretrained(model_id)\n",
|
|
0 commit comments