Skip to content

Commit

Permalink
Optimum-Intel Notebook (#484)
Browse files Browse the repository at this point in the history
* Corrections to quantization description

* fix json structure

* Update setfit-optimum-intel.ipynb

* Update setfit-optimum-intel.ipynb
  • Loading branch information
danielkorat committed Feb 2, 2024
1 parent 2af9042 commit 1e3ce93
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions notebooks/setfit-optimum-intel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"source": [
"* Linux OS\n",
"* Python 3.9+\n",
"* An Intel Xeon Processor which supports [bfloat16](https://www.intel.com/content/www/us/en/developer/articles/technical/pytorch-on-xeon-processors-with-bfloat16.html))\n",
"* An Intel Xeon Processor which supports [bfloat16](https://www.intel.com/content/www/us/en/developer/articles/technical/pytorch-on-xeon-processors-with-bfloat16.html)\n",
"\n",
"Since Google Colab doesn't meet the hardware requirement, it's incompatible with this notebook and will not see speedups from our optimizations.\n",
"\n",
Expand Down Expand Up @@ -508,7 +508,7 @@
"source": [
"from setfit import SetFitModel\n",
"\n",
"small_model = SetFitModel.from_pretrained(\"moshew/bge-small-en-v1.5_setfit-sst2-english\")\n",
"small_model = SetFitModel.from_pretrained(\"dkorat/bge-small-en-v1.5_setfit-sst2-english\")\n",
"pb = PerformanceBenchmark(small_model, test_dataset, \"bge-small (PyTorch)\", batch_sizes=BATCH_SIZES)\n",
"perf_metrics = pb.run_benchmark()"
]
Expand Down Expand Up @@ -610,7 +610,7 @@
" )\n",
" tokenizer.save_pretrained(output_path)\n",
" \n",
"model_name = \"moshew/bge-small-en-v1.5_setfit-sst2-english\"\n",
"model_name = \"dkorat/bge-small-en-v1.5_setfit-sst2-english\"\n",
"calibration_set = load_qasper_calibration_set(sample_size=100)\n",
"optimum_model_path = f\"/tmp/{model_name}_opt\""
]
Expand Down Expand Up @@ -747,8 +747,8 @@
"2024-02-01 10:03:34 [INFO] [Strategy] Found the model meets accuracy requirements, ending the tuning process.\n",
"2024-02-01 10:03:34 [INFO] Specified timeout or max trials is reached! Found a quantized model which meet accuracy goal. Exit.\n",
"2024-02-01 10:03:34 [INFO] Save deploy yaml to /home/sdp/dkorat/setfit/notebooks/nc_workspace/2024-02-01_10-03-17/deploy.yaml\n",
"Model weights saved to /tmp/moshew/bge-small-en-v1.5_setfit-sst2-english_opt/pytorch_model.bin\n",
"Configuration saved in /tmp/moshew/bge-small-en-v1.5_setfit-sst2-english_opt/inc_config.json\n"
"Model weights saved to /tmp/dkorat/bge-small-en-v1.5_setfit-sst2-english_opt/pytorch_model.bin\n",
"Configuration saved in /tmp/dkorat/bge-small-en-v1.5_setfit-sst2-english_opt/inc_config.json\n"
]
}
],
Expand Down Expand Up @@ -836,7 +836,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"loading configuration file /tmp/moshew/bge-small-en-v1.5_setfit-sst2-english_opt/inc_config.json\n",
"loading configuration file /tmp/dkorat/bge-small-en-v1.5_setfit-sst2-english_opt/inc_config.json\n",
"INCConfig {\n",
" \"distillation\": {},\n",
" \"neural_compressor_version\": \"2.4.1\",\n",
Expand All @@ -852,7 +852,7 @@
"}\n",
"\n",
"intel_extension_for_pytorch version is 2.1.100+cpu\n",
"2024-02-01 10:03:35,206 - sentence_transformers.SentenceTransformer - INFO - Load pretrained SentenceTransformer: moshew/bge-small-en-v1.5_setfit-sst2-english\n",
"2024-02-01 10:03:35,206 - sentence_transformers.SentenceTransformer - INFO - Load pretrained SentenceTransformer: dkorat/bge-small-en-v1.5_setfit-sst2-english\n",
"2024-02-01 10:03:36,508 - sentence_transformers.SentenceTransformer - INFO - Use pytorch device_name: cpu\n"
]
},
Expand All @@ -870,7 +870,7 @@
"source": [
"tokenizer = AutoTokenizer.from_pretrained(optimum_model_path, model_max_length=512)\n",
"optimum_model = optimum.intel.INCModel.from_pretrained(optimum_model_path)\n",
"model = SetFitModel.from_pretrained(\"moshew/bge-small-en-v1.5_setfit-sst2-english\")\n",
"model = SetFitModel.from_pretrained(\"dkorat/bge-small-en-v1.5_setfit-sst2-english\")\n",
"optimum_setfit_model = OptimumSetFitModel(optimum_model, tokenizer, model.model_head)\n",
"\n",
"# Reload test dataset\n",
Expand Down

0 comments on commit 1e3ce93

Please sign in to comment.