AnjaJuana commited on
Commit
91db1e9
·
1 Parent(s): 4c6440f

Auto-update from GitHub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .ipynb_checkpoints/app-checkpoint.py +0 -4
  2. .ipynb_checkpoints/code_blog_post-checkpoint.ipynb +17 -114
  3. app.py +0 -4
  4. blog_post/.DS_Store +0 -0
  5. blog_post/article.md +284 -45
  6. blog_post/img/gradio_pred_trip.png +0 -0
  7. code_blog_post.ipynb +17 -114
  8. space/.ipynb_checkpoints/app-checkpoint.py +3 -4
  9. space/app.py +3 -4
  10. space/main_model.ipynb +7 -0
  11. space/space/.DS_Store +0 -0
  12. space/space/.ipynb_checkpoints/app-checkpoint.py +4 -5
  13. space/space/app.py +4 -5
  14. space/space/code_blog_post.ipynb +1 -1
  15. space/space/main_model.ipynb +6 -6
  16. space/space/space/.ipynb_checkpoints/code_blog_post-checkpoint.ipynb +229 -8
  17. space/space/space/.ipynb_checkpoints/main_model-checkpoint.ipynb +418 -22
  18. space/space/space/space/requirements.txt +0 -3
  19. space/space/space/space/space/space/.ipynb_checkpoints/code_blog_post-checkpoint.ipynb +398 -0
  20. space/space/space/space/space/space/.ipynb_checkpoints/packing_list_api-checkpoint.ipynb +541 -89
  21. space/space/space/space/space/space/README.md +6 -6
  22. space/space/space/space/space/space/blog_post/article.md +129 -5
  23. space/space/space/space/space/space/code_blog_post.ipynb +619 -0
  24. space/space/space/space/space/space/packing_list_api.ipynb +22 -34
  25. space/space/space/space/space/space/requirements.txt +7 -2
  26. space/space/space/space/space/space/space/space/packing_templates_self_supported_offgrid_expanded_dutch_original.json +696 -0
  27. space/space/space/space/space/space/space/space/space/.ipynb_checkpoints/app-checkpoint.py +25 -11
  28. space/space/space/space/space/space/space/space/space/.ipynb_checkpoints/labels-checkpoint.txt +93 -0
  29. space/space/space/space/space/space/space/space/space/.ipynb_checkpoints/main_model-checkpoint.ipynb +0 -0
  30. space/space/space/space/space/space/space/space/space/app.py +25 -11
  31. space/space/space/space/space/space/space/space/space/blog_post/article.md +44 -0
  32. space/space/space/space/space/space/space/space/space/main_model.ipynb +601 -204
  33. space/space/space/space/space/space/space/space/space/packing_templates_self_supported_offgrid_expanded.json +525 -526
  34. space/space/space/space/space/space/space/space/space/space/space/space/.ipynb_checkpoints/app-checkpoint.py +37 -11
  35. space/space/space/space/space/space/space/space/space/space/space/space/.ipynb_checkpoints/main_model-checkpoint.ipynb +0 -0
  36. space/space/space/space/space/space/space/space/space/space/space/space/app.py +37 -11
  37. space/space/space/space/space/space/space/space/space/space/space/space/main_model.ipynb +1115 -0
  38. space/space/space/space/space/space/space/space/space/space/space/space/results/.DS_Store +0 -0
  39. space/space/space/space/space/space/space/space/space/space/space/space/results/MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli_results.pkl +3 -0
  40. space/space/space/space/space/space/space/space/space/space/space/space/results/MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli_results.pkl +3 -0
  41. space/space/space/space/space/space/space/space/space/space/space/space/results/MoritzLaurer-deberta-v3-large-zeroshot-v2.0_results.pkl +3 -0
  42. space/space/space/space/space/space/space/space/space/space/space/space/results/MoritzLaurer-mDeBERTa-v3-base-mnli-xnli_results.pkl +3 -0
  43. space/space/space/space/space/space/space/space/space/space/space/space/results/before/MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli_results.pkl +3 -0
  44. space/space/space/space/space/space/space/space/space/space/space/space/results/before/MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli_results.pkl +3 -0
  45. space/space/space/space/space/space/space/space/space/space/space/space/results/before/MoritzLaurer-deberta-v3-large-zeroshot-v2.0_results.pkl +3 -0
  46. space/space/space/space/space/space/space/space/space/space/space/space/results/before/MoritzLaurer-mDeBERTa-v3-base-mnli-xnli_results.pkl +3 -0
  47. space/space/space/space/space/space/space/space/space/space/space/space/results/before/cross-encoder-nli-deberta-v3-base_results.pkl +3 -0
  48. space/space/space/space/space/space/space/space/space/space/space/space/results/before/cross-encoder-nli-deberta-v3-large_results.pkl +3 -0
  49. space/space/space/space/space/space/space/space/space/space/space/space/results/before/facebook-bart-large-mnli_results.pkl +3 -0
  50. space/space/space/space/space/space/space/space/space/space/space/space/results/before/joeddav-bart-large-mnli-yahoo-answers_results.pkl +3 -0
.ipynb_checkpoints/app-checkpoint.py CHANGED
@@ -12,10 +12,6 @@ with open("packing_label_structure.json", "r") as file:
12
  candidate_labels = json.load(file)
13
  keys_list = list(candidate_labels.keys())
14
 
15
- # Load test data (in list of dictionaries)
16
- with open("test_data.json", "r") as file:
17
- packing_data = json.load(file)
18
-
19
  # Load packing item data
20
  with open("packing_templates_self_supported_offgrid_expanded.json", "r") as file:
21
  packing_items = json.load(file)
 
12
  candidate_labels = json.load(file)
13
  keys_list = list(candidate_labels.keys())
14
 
 
 
 
 
15
  # Load packing item data
16
  with open("packing_templates_self_supported_offgrid_expanded.json", "r") as file:
17
  packing_items = json.load(file)
.ipynb_checkpoints/code_blog_post-checkpoint.ipynb CHANGED
@@ -10,7 +10,7 @@
10
  },
11
  {
12
  "cell_type": "code",
13
- "execution_count": 14,
14
  "id": "1eaa3a9f-0b39-4d77-91d6-f935d226ac98",
15
  "metadata": {},
16
  "outputs": [],
@@ -41,7 +41,7 @@
41
  },
42
  {
43
  "cell_type": "code",
44
- "execution_count": 19,
45
  "id": "bb1bc7ed-227e-4c0b-b769-ead4daf01c57",
46
  "metadata": {},
47
  "outputs": [
@@ -155,26 +155,7 @@
155
  },
156
  {
157
  "cell_type": "code",
158
- "execution_count": 20,
159
- "id": "e114d7ab-9bd3-4214-a630-7f9166c3b8a5",
160
- "metadata": {},
161
- "outputs": [
162
- {
163
- "name": "stdout",
164
- "output_type": "stream",
165
- "text": [
166
- "activity_type\n"
167
- ]
168
- }
169
- ],
170
- "source": [
171
- "# First classify using first dimension of classes ()\n",
172
- "print(keys_list[0])"
173
- ]
174
- },
175
- {
176
- "cell_type": "code",
177
- "execution_count": 40,
178
  "id": "4b3a1bcb-3450-4128-b941-952f145baf99",
179
  "metadata": {},
180
  "outputs": [
@@ -210,6 +191,7 @@
210
  }
211
  ],
212
  "source": [
 
213
  "model_name = \"facebook/bart-large-mnli\"\n",
214
  "trip_descr = \"I am planning a trip to Greece with my boyfriend, where we will visit two islands. We have booked an apartment on each island for a few days and plan to spend most of our time relaxing. Our main goals are to enjoy the beach, try delicious local food, and possibly go on a hike—if it’s not too hot. We will be relying solely on public transport. We’re in our late 20s and traveling from the Netherlands.\"\n",
215
  "classifier = pipeline(\"zero-shot-classification\", model = model_name)\n",
@@ -224,7 +206,7 @@
224
  },
225
  {
226
  "cell_type": "code",
227
- "execution_count": 25,
228
  "id": "04208f9e-59bb-408b-92c6-941d064bf43d",
229
  "metadata": {},
230
  "outputs": [
@@ -244,7 +226,7 @@
244
  },
245
  {
246
  "cell_type": "code",
247
- "execution_count": 30,
248
  "id": "9f5f1c45-b411-4de1-a0a6-a7ecde5d8eae",
249
  "metadata": {},
250
  "outputs": [
@@ -283,12 +265,13 @@
283
  " \"Label\": result[\"labels\"],\n",
284
  " \"Score\": result[\"scores\"]\n",
285
  "})\n",
286
- "print(df)"
 
287
  ]
288
  },
289
  {
290
  "cell_type": "code",
291
- "execution_count": 31,
292
  "id": "7c5c50c4-7d58-4f5a-8f22-e4c06298a2f7",
293
  "metadata": {},
294
  "outputs": [
@@ -300,13 +283,11 @@
300
  ]
301
  }
302
  ],
303
- "source": [
304
- "print(classes)"
305
- ]
306
  },
307
  {
308
  "cell_type": "code",
309
- "execution_count": 45,
310
  "id": "3a7287c2-78f0-4a53-af72-1bc0f62da36f",
311
  "metadata": {},
312
  "outputs": [],
@@ -342,7 +323,7 @@
342
  },
343
  {
344
  "cell_type": "code",
345
- "execution_count": 35,
346
  "id": "43481d4c-039a-4a37-bd6d-dfe638bf9732",
347
  "metadata": {},
348
  "outputs": [
@@ -357,7 +338,7 @@
357
  "name": "stdout",
358
  "output_type": "stream",
359
  "text": [
360
- "Processing 8/9... superclass pred_class\n",
361
  "0 activity_type beach vacation\n",
362
  "1 activities [going to the beach, relaxing, hiking]\n",
363
  "2 climate_or_season warm destination / summer\n",
@@ -385,7 +366,7 @@
385
  },
386
  {
387
  "cell_type": "code",
388
- "execution_count": 37,
389
  "id": "35e14ac8-4445-4586-a115-081cf1ef2686",
390
  "metadata": {},
391
  "outputs": [],
@@ -401,10 +382,6 @@
401
  " candidate_labels = json.load(file)\n",
402
  "keys_list = list(candidate_labels.keys())\n",
403
  "\n",
404
- "# Load test data (in list of dictionaries)\n",
405
- "with open(\"test_data.json\", \"r\") as file:\n",
406
- " packing_data = json.load(file)\n",
407
- "\n",
408
  "# Load packing item data\n",
409
  "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
410
  " packing_items = json.load(file)"
@@ -412,7 +389,7 @@
412
  },
413
  {
414
  "cell_type": "code",
415
- "execution_count": 39,
416
  "id": "8eefd4cc-c375-4cc0-956b-472b36bafdb7",
417
  "metadata": {},
418
  "outputs": [
@@ -420,9 +397,7 @@
420
  "name": "stdout",
421
  "output_type": "stream",
422
  "text": [
423
- "Running on local URL: http://127.0.0.1:7861\n",
424
- "\n",
425
- "Thanks for being a Gradio user! If you have questions or feedback, please join our Discord server and chat with us: https://discord.gg/feTf9x3ZSB\n",
426
  "\n",
427
  "To create a public link, set `share=True` in `launch()`.\n"
428
  ]
@@ -430,7 +405,7 @@
430
  {
431
  "data": {
432
  "text/html": [
433
- "<div><iframe src=\"http://127.0.0.1:7861/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
434
  ],
435
  "text/plain": [
436
  "<IPython.core.display.HTML object>"
@@ -438,78 +413,6 @@
438
  },
439
  "metadata": {},
440
  "output_type": "display_data"
441
- },
442
- {
443
- "name": "stderr",
444
- "output_type": "stream",
445
- "text": [
446
- "Traceback (most recent call last):\n",
447
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/utils/_http.py\", line 406, in hf_raise_for_status\n",
448
- " response.raise_for_status()\n",
449
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/requests/models.py\", line 1024, in raise_for_status\n",
450
- " raise HTTPError(http_error_msg, response=self)\n",
451
- "requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli/resolve/main/config.json\n",
452
- "\n",
453
- "The above exception was the direct cause of the following exception:\n",
454
- "\n",
455
- "Traceback (most recent call last):\n",
456
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/utils/hub.py\", line 403, in cached_file\n",
457
- " resolved_file = hf_hub_download(\n",
458
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py\", line 114, in _inner_fn\n",
459
- " return fn(*args, **kwargs)\n",
460
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 860, in hf_hub_download\n",
461
- " return _hf_hub_download_to_cache_dir(\n",
462
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 967, in _hf_hub_download_to_cache_dir\n",
463
- " _raise_on_head_call_error(head_call_error, force_download, local_files_only)\n",
464
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 1482, in _raise_on_head_call_error\n",
465
- " raise head_call_error\n",
466
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 1374, in _get_metadata_or_catch_error\n",
467
- " metadata = get_hf_file_metadata(\n",
468
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py\", line 114, in _inner_fn\n",
469
- " return fn(*args, **kwargs)\n",
470
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 1294, in get_hf_file_metadata\n",
471
- " r = _request_wrapper(\n",
472
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 278, in _request_wrapper\n",
473
- " response = _request_wrapper(\n",
474
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 302, in _request_wrapper\n",
475
- " hf_raise_for_status(response)\n",
476
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/utils/_http.py\", line 454, in hf_raise_for_status\n",
477
- " raise _format(RepositoryNotFoundError, message, response) from e\n",
478
- "huggingface_hub.errors.RepositoryNotFoundError: 401 Client Error. (Request ID: Root=1-68fa0a8b-0d531523246f6614068c359e;d99d5b5d-694d-4d4b-b774-bb70066228d2)\n",
479
- "\n",
480
- "Repository Not Found for url: https://huggingface.co/MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli/resolve/main/config.json.\n",
481
- "Please make sure you specified the correct `repo_id` and `repo_type`.\n",
482
- "If you are trying to access a private or gated repo, make sure you are authenticated.\n",
483
- "Invalid username or password.\n",
484
- "\n",
485
- "The above exception was the direct cause of the following exception:\n",
486
- "\n",
487
- "Traceback (most recent call last):\n",
488
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/queueing.py\", line 536, in process_events\n",
489
- " response = await route_utils.call_process_api(\n",
490
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/route_utils.py\", line 322, in call_process_api\n",
491
- " output = await app.get_blocks().process_api(\n",
492
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/blocks.py\", line 1935, in process_api\n",
493
- " result = await self.call_function(\n",
494
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/blocks.py\", line 1520, in call_function\n",
495
- " prediction = await anyio.to_thread.run_sync( # type: ignore\n",
496
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/anyio/to_thread.py\", line 56, in run_sync\n",
497
- " return await get_async_backend().run_sync_in_worker_thread(\n",
498
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/anyio/_backends/_asyncio.py\", line 2134, in run_sync_in_worker_thread\n",
499
- " return await future\n",
500
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/anyio/_backends/_asyncio.py\", line 851, in run\n",
501
- " result = context.run(func, *args)\n",
502
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/utils.py\", line 826, in wrapper\n",
503
- " response = f(*args, **kwargs)\n",
504
- " File \"/var/folders/r5/y63bxy5d4_zfxf6cgwtwysbc0000gn/T/ipykernel_22464/1188444081.py\", line 3, in classify\n",
505
- " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
506
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/pipelines/__init__.py\", line 798, in pipeline\n",
507
- " resolved_config_file = cached_file(\n",
508
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/utils/hub.py\", line 426, in cached_file\n",
509
- " raise EnvironmentError(\n",
510
- "OSError: MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'\n",
511
- "If this is a private repository, make sure to pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`\n"
512
- ]
513
  }
514
  ],
515
  "source": [
 
10
  },
11
  {
12
  "cell_type": "code",
13
+ "execution_count": 1,
14
  "id": "1eaa3a9f-0b39-4d77-91d6-f935d226ac98",
15
  "metadata": {},
16
  "outputs": [],
 
41
  },
42
  {
43
  "cell_type": "code",
44
+ "execution_count": 2,
45
  "id": "bb1bc7ed-227e-4c0b-b769-ead4daf01c57",
46
  "metadata": {},
47
  "outputs": [
 
155
  },
156
  {
157
  "cell_type": "code",
158
+ "execution_count": 12,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  "id": "4b3a1bcb-3450-4128-b941-952f145baf99",
160
  "metadata": {},
161
  "outputs": [
 
191
  }
192
  ],
193
  "source": [
194
+ "key = keys_list[0]\n",
195
  "model_name = \"facebook/bart-large-mnli\"\n",
196
  "trip_descr = \"I am planning a trip to Greece with my boyfriend, where we will visit two islands. We have booked an apartment on each island for a few days and plan to spend most of our time relaxing. Our main goals are to enjoy the beach, try delicious local food, and possibly go on a hike—if it’s not too hot. We will be relying solely on public transport. We’re in our late 20s and traveling from the Netherlands.\"\n",
197
  "classifier = pipeline(\"zero-shot-classification\", model = model_name)\n",
 
206
  },
207
  {
208
  "cell_type": "code",
209
+ "execution_count": 5,
210
  "id": "04208f9e-59bb-408b-92c6-941d064bf43d",
211
  "metadata": {},
212
  "outputs": [
 
226
  },
227
  {
228
  "cell_type": "code",
229
+ "execution_count": 6,
230
  "id": "9f5f1c45-b411-4de1-a0a6-a7ecde5d8eae",
231
  "metadata": {},
232
  "outputs": [
 
265
  " \"Label\": result[\"labels\"],\n",
266
  " \"Score\": result[\"scores\"]\n",
267
  "})\n",
268
+ "print(df)\n",
269
+ "print(classes)"
270
  ]
271
  },
272
  {
273
  "cell_type": "code",
274
+ "execution_count": 7,
275
  "id": "7c5c50c4-7d58-4f5a-8f22-e4c06298a2f7",
276
  "metadata": {},
277
  "outputs": [
 
283
  ]
284
  }
285
  ],
286
+ "source": []
 
 
287
  },
288
  {
289
  "cell_type": "code",
290
+ "execution_count": 8,
291
  "id": "3a7287c2-78f0-4a53-af72-1bc0f62da36f",
292
  "metadata": {},
293
  "outputs": [],
 
323
  },
324
  {
325
  "cell_type": "code",
326
+ "execution_count": 9,
327
  "id": "43481d4c-039a-4a37-bd6d-dfe638bf9732",
328
  "metadata": {},
329
  "outputs": [
 
338
  "name": "stdout",
339
  "output_type": "stream",
340
  "text": [
341
+ "Processing 9/9 superclass pred_class\n",
342
  "0 activity_type beach vacation\n",
343
  "1 activities [going to the beach, relaxing, hiking]\n",
344
  "2 climate_or_season warm destination / summer\n",
 
366
  },
367
  {
368
  "cell_type": "code",
369
+ "execution_count": 10,
370
  "id": "35e14ac8-4445-4586-a115-081cf1ef2686",
371
  "metadata": {},
372
  "outputs": [],
 
382
  " candidate_labels = json.load(file)\n",
383
  "keys_list = list(candidate_labels.keys())\n",
384
  "\n",
 
 
 
 
385
  "# Load packing item data\n",
386
  "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
387
  " packing_items = json.load(file)"
 
389
  },
390
  {
391
  "cell_type": "code",
392
+ "execution_count": 11,
393
  "id": "8eefd4cc-c375-4cc0-956b-472b36bafdb7",
394
  "metadata": {},
395
  "outputs": [
 
397
  "name": "stdout",
398
  "output_type": "stream",
399
  "text": [
400
+ "Running on local URL: http://127.0.0.1:7860\n",
 
 
401
  "\n",
402
  "To create a public link, set `share=True` in `launch()`.\n"
403
  ]
 
405
  {
406
  "data": {
407
  "text/html": [
408
+ "<div><iframe src=\"http://127.0.0.1:7860/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
409
  ],
410
  "text/plain": [
411
  "<IPython.core.display.HTML object>"
 
413
  },
414
  "metadata": {},
415
  "output_type": "display_data"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  }
417
  ],
418
  "source": [
app.py CHANGED
@@ -12,10 +12,6 @@ with open("packing_label_structure.json", "r") as file:
12
  candidate_labels = json.load(file)
13
  keys_list = list(candidate_labels.keys())
14
 
15
- # Load test data (in list of dictionaries)
16
- with open("test_data.json", "r") as file:
17
- packing_data = json.load(file)
18
-
19
  # Load packing item data
20
  with open("packing_templates_self_supported_offgrid_expanded.json", "r") as file:
21
  packing_items = json.load(file)
 
12
  candidate_labels = json.load(file)
13
  keys_list = list(candidate_labels.keys())
14
 
 
 
 
 
15
  # Load packing item data
16
  with open("packing_templates_self_supported_offgrid_expanded.json", "r") as file:
17
  packing_items = json.load(file)
blog_post/.DS_Store ADDED
Binary file (6.15 kB). View file
 
blog_post/article.md CHANGED
@@ -15,58 +15,45 @@
15
 
16
  ## Implementation of packing list model
17
  ### Prerequisites before you start to code: Anja
18
- * Hugging face account also use access token, mention api
19
- Hugging face is..."The platform where the machine learning community collaborates on models, datasets, and applications."(from hugging face)
20
- "Hugging Face is a company and open-source community that builds tools for machine learning (ML) and artificial intelligence (AI) — especially in the field of natural language processing (NLP)."(from the chate)
21
- To be able to use the full funcitonality (e.g. models, spaces, data sets, api access) and most access you need to make a hugging face account here (https://huggingface.co/)
22
- There is a new course at data camp free for the remainder of 2025: https://huggingface.co/blog/huggingface/datacamp-ai-courses
23
-
24
- * Use anaconda
25
- "Without a package and environment manager like Conda"(anaconda site)
26
- We used the anaconda navigator as a package and environment manager and used the jupyter notebook through there. python is automatically installed.
27
- In the terminal activate the conda environment that you created previously by navigating (see cheat sheet here https://docs.conda.io/projects/conda/en/4.6.0/_downloads/52a95608c49671267e40c689e0bc00ca/conda-cheatsheet.pdf)
28
-
29
- View list of environments
30
- ```bash
31
- conda env list
32
- ```
33
 
34
- Activate correct environment
35
- ```bash
36
- conda activate ENVIRONMENT_NAME
37
- ```
 
 
 
 
 
38
 
39
- Install packages using pip
40
  ```bash
41
- pip install transformers torch numpy tabulate gradio pandas sklearn
42
- # pip install -r requirements.txt
43
  ```
44
 
45
- Install jupyter notebook
46
  ```bash
47
- conda install jupyter
48
  ```
49
 
50
- Start up jupyter notebook
51
  ```bash
 
52
  jupyter-notebook
53
  ```
54
- Create a new jupyter notebook
55
 
56
- #### Hugging face API
57
- Let us first try out some hugging face models using their API. The advantage of using the API is that you do not need to download the model locally and the computation is handled by hugging face on their servers.
58
- To do this you need to make an accesstoken on the hugging face website.
59
- Log in > Settings (on left side) > Access Tokens (on left side) > + Create new token
60
- Give token a name
61
- * how to implement the token in your code
62
- This access token now has to be saved in you projecct folder in a .env file. Create a plan text file that you call .env. Within it you write:
63
  ```text
64
  HF_API_TOKEN=YOUR_OWN_ACCESS_TOKEN
65
  ```
66
- and save it.
67
-
68
 
69
- Now we load a zero-shot-classification model using API and male a simple classification.
70
  ```python
71
  from dotenv import load_dotenv
72
  import os
@@ -119,21 +106,273 @@ with open("packing_label_structure.json", "r") as file:
119
  candidate_labels = json.load(file)
120
  keys_list = list(candidate_labels.keys())
121
 
122
- # Load test data (list of dictionaries)
123
- with open("test_data.json", "r") as file:
124
- packing_data = json.load(file)
125
- # Extract trip descriptions and classification (trip_types)
126
- trip_descriptions = [trip['description'] for trip in packing_data]
127
- trip_types = [trip['trip_types'] for trip in packing_data]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  ```
129
 
 
 
130
  ```python
131
- classifier = pipeline("zero-shot-classification", model=model_name)
132
- result = classifier(trip_descr, candidate_labels[key])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  print(result)
134
  ```
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  ### Using gradio app: Anja
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
  ### Share your model: Anja
139
  * created space
@@ -152,7 +391,7 @@ And connect your hugging face space as a remote repository
152
  git remote add origin https://huggingface.co/spaces/<username>/<space-name>
153
  ```
154
 
155
- generate an access token for your space here
156
 
157
 
158
  * you need to install the required dependencies in the environment where your Hugging Face Space is running.
 
15
 
16
  ## Implementation of packing list model
17
  ### Prerequisites before you start to code: Anja
18
+ **Hugging face account**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
+ Hugging face is a company and platform for machine learning community to collaborate on models, datasets and applications especially in the field of natural language processing.
21
+ To be able to use the full funcitonality (e.g. acces to models, spaces, datasets, api access) and you need to make a hugging face account [here](https://huggingface.co/).
22
+
23
+ There is a new course at data camp, which is free for the remainder of 2025: https://huggingface.co/blog/huggingface/datacamp-ai-courses
24
+
25
+ **Anaconda navigator**
26
+ We will use anaconda navigator with thepackage and environment manager conda and use jupyter notebook to write our python code. You can download the Anaconda navigator [here](https://www.anaconda.com/products/navigator). (python is automatically installed)
27
+
28
+ Using the command line you can create a new environment in which you will work and isntall the necessary packages. The following code creates a new environment that is called hf_env and activate it ([conda cheat sheet](https://docs.conda.io/projects/conda/en/4.6.0/_downloads/52a95608c49671267e40c689e0bc00ca/conda-cheatsheet.pdf)):
29
 
 
30
  ```bash
31
+ conda create --name hf_env
32
+ conda activate hf_env
33
  ```
34
 
35
+ Install necessary packages using pip
36
  ```bash
37
+ pip install transformers torch numpy tabulate gradio pandas scikit-learn
38
  ```
39
 
40
+ Install jupyter notebook and start it up
41
  ```bash
42
+ conda install jupyter
43
  jupyter-notebook
44
  ```
45
+ Create a new jupyter notebook in which you write your code.
46
 
47
+ ### Hugging face API
48
+ Let us first try out some Hugging Face models using their API. The advantage of using API is that you do not need to download the model locally and the computation is handled on Hugging Face servers.
49
+ To use their API you need to first create an access token.
50
+ Log in to your Hugging Face account and go to Settings (on left side) > Access Tokens (on left side) > + Create new token. Select token type Read and give your token a name.
51
+ This access token now has to be saved in you project folder in a .env file. Create a plain text file that you call .env. Within it you write and save:
 
 
52
  ```text
53
  HF_API_TOKEN=YOUR_OWN_ACCESS_TOKEN
54
  ```
 
 
55
 
56
+ Now we load a zero-shot-classification model using API and make a simple classification.
57
  ```python
58
  from dotenv import load_dotenv
59
  import os
 
106
  candidate_labels = json.load(file)
107
  keys_list = list(candidate_labels.keys())
108
 
109
+ for key in candidate_labels:
110
+ print("\n", key, ":")
111
+ for item in candidate_labels[key]:
112
+ print("\t", item)
113
+ ```
114
+
115
+ ```text
116
+ activity_type :
117
+ hut trek (summer)
118
+ hut trek (winter)
119
+ camping trip (wild camping)
120
+ camping trip (campground)
121
+ ski tour / skitour
122
+ snowboard / splitboard trip
123
+ long-distance hike / thru-hike
124
+ digital nomad trip
125
+ city trip
126
+ road trip (car/camper)
127
+ festival trip
128
+ yoga / wellness retreat
129
+ micro-adventure / weekend trip
130
+ beach vacation
131
+ cultural exploration
132
+ nature escape
133
+
134
+ activities :
135
+ swimming
136
+ going to the beach
137
+ relaxing
138
+ sightseeing
139
+ biking
140
+ running
141
+ skiing
142
+ cross-country skiing
143
+ ski touring
144
+ hiking
145
+ hut-to-hut hiking
146
+ rock climbing
147
+ ice climbing
148
+ snowshoe hiking
149
+ kayaking / canoeing
150
+ stand-up paddleboarding (SUP)
151
+ snorkeling
152
+ scuba diving
153
+ surfing
154
+ paragliding
155
+ horseback riding
156
+ photography
157
+ fishing
158
+ rafting
159
+ yoga
160
+
161
+ climate_or_season :
162
+ cold destination / winter
163
+ warm destination / summer
164
+ variable weather / spring / autumn
165
+ tropical / humid
166
+ dry / desert-like
167
+ rainy climate
168
+
169
+ style_or_comfort :
170
+ ultralight
171
+ lightweight (but comfortable)
172
+ luxury (including evening wear)
173
+ minimalist
174
+
175
+ dress_code :
176
+ casual
177
+ formal (business trip)
178
+ conservative
179
+
180
+ accommodation :
181
+ indoor
182
+ huts with half board
183
+ sleeping in a tent
184
+ sleeping in a car
185
+
186
+ transportation :
187
+ own vehicle
188
+ no own vehicle
189
+
190
+ special_conditions :
191
+ off-grid / no electricity
192
+ self-supported (bring your own cooking gear)
193
+ travel with children
194
+ pet-friendly
195
+ snow and ice
196
+ high alpine terrain
197
+ snow, ice and avalanche-prone terrain
198
+ no special conditions to consider
199
+
200
+ trip_length_days :
201
+ 1 day
202
+ 2 days
203
+ 3 days
204
+ 4 days
205
+ 5 days
206
+ 6 days
207
+ 7 days
208
+ 7+ days
209
+ ```
210
+
211
+
212
+ We can use the pipeline function to load the model from hugging face locally and give the classifier function the trip description together with the candidate labels.
213
+
214
+ ```python
215
+ key = keys_list[0]
216
+ model_name = "facebook/bart-large-mnli"
217
+ trip_descr = "I am planning a trip to Greece with my boyfriend, where we will visit two islands. We have booked an apartment on each island for a few days and plan to spend most of our time relaxing. Our main goals are to enjoy the beach, try delicious local food, and possibly go on a hike—if it’s not too hot. We will be relying solely on public transport. We’re in our late 20s and traveling from the Netherlands."
218
+ classifier = pipeline("zero-shot-classification", model = model_name)
219
+ result = classifier(trip_descr, candidate_labels[keys_list[0]])
220
+ # Create DataFrame
221
+ df = pd.DataFrame({
222
+ "Label": result["labels"],
223
+ "Score": result["scores"]
224
+ })
225
+ print(df)
226
+ ```
227
+
228
+ ```text
229
+ Label Score
230
+ 0 beach vacation 0.376311
231
+ 1 micro-adventure / weekend trip 0.350168
232
+ 2 nature escape 0.133974
233
+ 3 digital nomad trip 0.031636
234
+ 4 cultural exploration 0.031271
235
+ 5 yoga / wellness retreat 0.012846
236
+ 6 festival trip 0.012700
237
+ 7 long-distance hike / thru-hike 0.009527
238
+ 8 hut trek (summer) 0.008148
239
+ 9 city trip 0.007793
240
+ 10 road trip (car/camper) 0.006512
241
+ 11 ski tour / skitour 0.005670
242
+ 12 camping trip (campground) 0.004448
243
+ 13 snowboard / splitboard trip 0.004113
244
+ 14 camping trip (wild camping) 0.002714
245
+ 15 hut trek (winter) 0.002170
246
+ ```
247
+
248
+ Now we will do this for every superclass. We do something slightly different for the activities superclass since it is possible and likely to do more than one activity during your travels. Within the classifier function we set the multi_label option to True, which means that the text can belong to more than one class and each label is evaluated independently and a probability of belonging to that class is returned. We choose a
249
+
250
+ ```python
251
+ cut_off = 0.5
252
+ result_activ = classifier(trip_descr, candidate_labels["activities"], multi_label=True)
253
+ indices = [i for i, score in enumerate(result_activ['scores']) if score > cut_off]
254
+ classes = [result_activ['labels'][i] for i in indices]
255
+
256
+ df = pd.DataFrame({
257
+ "Label": result["labels"],
258
+ "Score": result["scores"]
259
+ })
260
+ print(df)
261
+ print(classes)
262
+ ```
263
+
264
+ ```text
265
+ Label Score
266
+ 0 beach vacation 0.376311
267
+ 1 micro-adventure / weekend trip 0.350168
268
+ 2 nature escape 0.133974
269
+ 3 digital nomad trip 0.031636
270
+ 4 cultural exploration 0.031271
271
+ 5 yoga / wellness retreat 0.012846
272
+ 6 festival trip 0.012700
273
+ 7 long-distance hike / thru-hike 0.009527
274
+ 8 hut trek (summer) 0.008148
275
+ 9 city trip 0.007793
276
+ 10 road trip (car/camper) 0.006512
277
+ 11 ski tour / skitour 0.005670
278
+ 12 camping trip (campground) 0.004448
279
+ 13 snowboard / splitboard trip 0.004113
280
+ 14 camping trip (wild camping) 0.002714
281
+ 15 hut trek (winter) 0.002170
282
+
283
+ ['going to the beach', 'relaxing', 'hiking']
284
  ```
285
 
286
+ To do this for all superclasses we use the following function
287
+
288
  ```python
289
+ # doing this for all superclasses, depending on local machine this might take a while
290
+ def pred_trip(model_name, trip_descr, cut_off = 0.5):
291
+ """
292
+ Classifies trip
293
+
294
+ Parameters:
295
+ model_name: name of hugging-face model
296
+ trip_descr: text describing the trip
297
+ cut_off: cut_off for choosing activities
298
+
299
+ Returns:
300
+ pd Dataframe: with class predictions and true values
301
+ """
302
+
303
+ classifier = pipeline("zero-shot-classification", model=model_name)
304
+ df = pd.DataFrame(columns=['superclass', 'pred_class'])
305
+ for i, key in enumerate(keys_list):
306
+ print(f"\rProcessing {i + 1}/{len(keys_list)}", end="", flush=True)
307
+ if key == 'activities':
308
+ result = classifier(trip_descr, candidate_labels[key], multi_label=True)
309
+ indices = [i for i, score in enumerate(result['scores']) if score > cut_off]
310
+ classes = [result['labels'][i] for i in indices]
311
+ else:
312
+ result = classifier(trip_descr, candidate_labels[key])
313
+ classes = result["labels"][0]
314
+ df.loc[i] = [key, classes]
315
+ return df
316
+
317
+ result = pred_trip(model_name, trip_descr, cut_off = 0.5)
318
  print(result)
319
  ```
320
 
321
+ ```text
322
+ Processing 9/9 superclass pred_class
323
+ 0 activity_type beach vacation
324
+ 1 activities [going to the beach, relaxing, hiking]
325
+ 2 climate_or_season warm destination / summer
326
+ 3 style_or_comfort minimalist
327
+ 4 dress_code casual
328
+ 5 accommodation huts with half board
329
+ 6 transportation no own vehicle
330
+ 7 special_conditions off-grid / no electricity
331
+ 8 trip_length_days 7+ days
332
+ ```
333
+
334
  ### Using gradio app: Anja
335
+ Now we want to make it more user friendly using hte gradio app. You can for now run the app in your jupyter notebook.
336
+
337
+ ```python
338
+ # Prerequisites
339
+ from transformers import pipeline
340
+ import json
341
+ import pandas as pd
342
+ import gradio as gr
343
+
344
+ # get candidate labels
345
+ with open("packing_label_structure.json", "r") as file:
346
+ candidate_labels = json.load(file)
347
+ keys_list = list(candidate_labels.keys())
348
+
349
+ # Load packing item data
350
+ with open("packing_templates_self_supported_offgrid_expanded.json", "r") as file:
351
+ packing_items = json.load(file)
352
+ ```
353
+
354
+ ```python
355
+ emo = gr.Interface(
356
+ fn=pred_trip,
357
+ inputs=[
358
+ gr.Textbox(label="Model name", value = "MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli"),
359
+ gr.Textbox(label="Trip description"),
360
+ gr.Number(label="Activity cut-off", value = 0.5),
361
+ ],
362
+ # outputs="dataframe",
363
+ outputs=[gr.Dataframe(label="DataFrame"), gr.Textbox(label="List of words")],
364
+ title="Trip classification",
365
+ description="Enter a text describing your trip",
366
+ )
367
+
368
+ # Launch the Gradio app
369
+ if __name__ == "__main__":
370
+ demo.launch()
371
+
372
+ ```
373
+
374
+ ![Demo of my Gradio app](./img/gradio_pred_trip.png)
375
+
376
 
377
  ### Share your model: Anja
378
  * created space
 
391
  git remote add origin https://huggingface.co/spaces/<username>/<space-name>
392
  ```
393
 
394
+ generate an access token for your space by clicking on your icon and then selecting Access Tokens > + Create new token and as token type select Write. Give your tokena. name and click on Creat Token. Store your token securely. Use it
395
 
396
 
397
  * you need to install the required dependencies in the environment where your Hugging Face Space is running.
blog_post/img/gradio_pred_trip.png ADDED
code_blog_post.ipynb CHANGED
@@ -10,7 +10,7 @@
10
  },
11
  {
12
  "cell_type": "code",
13
- "execution_count": 14,
14
  "id": "1eaa3a9f-0b39-4d77-91d6-f935d226ac98",
15
  "metadata": {},
16
  "outputs": [],
@@ -41,7 +41,7 @@
41
  },
42
  {
43
  "cell_type": "code",
44
- "execution_count": 19,
45
  "id": "bb1bc7ed-227e-4c0b-b769-ead4daf01c57",
46
  "metadata": {},
47
  "outputs": [
@@ -155,26 +155,7 @@
155
  },
156
  {
157
  "cell_type": "code",
158
- "execution_count": 20,
159
- "id": "e114d7ab-9bd3-4214-a630-7f9166c3b8a5",
160
- "metadata": {},
161
- "outputs": [
162
- {
163
- "name": "stdout",
164
- "output_type": "stream",
165
- "text": [
166
- "activity_type\n"
167
- ]
168
- }
169
- ],
170
- "source": [
171
- "# First classify using first dimension of classes ()\n",
172
- "print(keys_list[0])"
173
- ]
174
- },
175
- {
176
- "cell_type": "code",
177
- "execution_count": 40,
178
  "id": "4b3a1bcb-3450-4128-b941-952f145baf99",
179
  "metadata": {},
180
  "outputs": [
@@ -210,6 +191,7 @@
210
  }
211
  ],
212
  "source": [
 
213
  "model_name = \"facebook/bart-large-mnli\"\n",
214
  "trip_descr = \"I am planning a trip to Greece with my boyfriend, where we will visit two islands. We have booked an apartment on each island for a few days and plan to spend most of our time relaxing. Our main goals are to enjoy the beach, try delicious local food, and possibly go on a hike—if it’s not too hot. We will be relying solely on public transport. We’re in our late 20s and traveling from the Netherlands.\"\n",
215
  "classifier = pipeline(\"zero-shot-classification\", model = model_name)\n",
@@ -224,7 +206,7 @@
224
  },
225
  {
226
  "cell_type": "code",
227
- "execution_count": 25,
228
  "id": "04208f9e-59bb-408b-92c6-941d064bf43d",
229
  "metadata": {},
230
  "outputs": [
@@ -244,7 +226,7 @@
244
  },
245
  {
246
  "cell_type": "code",
247
- "execution_count": 30,
248
  "id": "9f5f1c45-b411-4de1-a0a6-a7ecde5d8eae",
249
  "metadata": {},
250
  "outputs": [
@@ -283,12 +265,13 @@
283
  " \"Label\": result[\"labels\"],\n",
284
  " \"Score\": result[\"scores\"]\n",
285
  "})\n",
286
- "print(df)"
 
287
  ]
288
  },
289
  {
290
  "cell_type": "code",
291
- "execution_count": 31,
292
  "id": "7c5c50c4-7d58-4f5a-8f22-e4c06298a2f7",
293
  "metadata": {},
294
  "outputs": [
@@ -300,13 +283,11 @@
300
  ]
301
  }
302
  ],
303
- "source": [
304
- "print(classes)"
305
- ]
306
  },
307
  {
308
  "cell_type": "code",
309
- "execution_count": 45,
310
  "id": "3a7287c2-78f0-4a53-af72-1bc0f62da36f",
311
  "metadata": {},
312
  "outputs": [],
@@ -342,7 +323,7 @@
342
  },
343
  {
344
  "cell_type": "code",
345
- "execution_count": 35,
346
  "id": "43481d4c-039a-4a37-bd6d-dfe638bf9732",
347
  "metadata": {},
348
  "outputs": [
@@ -357,7 +338,7 @@
357
  "name": "stdout",
358
  "output_type": "stream",
359
  "text": [
360
- "Processing 8/9... superclass pred_class\n",
361
  "0 activity_type beach vacation\n",
362
  "1 activities [going to the beach, relaxing, hiking]\n",
363
  "2 climate_or_season warm destination / summer\n",
@@ -385,7 +366,7 @@
385
  },
386
  {
387
  "cell_type": "code",
388
- "execution_count": 37,
389
  "id": "35e14ac8-4445-4586-a115-081cf1ef2686",
390
  "metadata": {},
391
  "outputs": [],
@@ -401,10 +382,6 @@
401
  " candidate_labels = json.load(file)\n",
402
  "keys_list = list(candidate_labels.keys())\n",
403
  "\n",
404
- "# Load test data (in list of dictionaries)\n",
405
- "with open(\"test_data.json\", \"r\") as file:\n",
406
- " packing_data = json.load(file)\n",
407
- "\n",
408
  "# Load packing item data\n",
409
  "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
410
  " packing_items = json.load(file)"
@@ -412,7 +389,7 @@
412
  },
413
  {
414
  "cell_type": "code",
415
- "execution_count": 39,
416
  "id": "8eefd4cc-c375-4cc0-956b-472b36bafdb7",
417
  "metadata": {},
418
  "outputs": [
@@ -420,9 +397,7 @@
420
  "name": "stdout",
421
  "output_type": "stream",
422
  "text": [
423
- "Running on local URL: http://127.0.0.1:7861\n",
424
- "\n",
425
- "Thanks for being a Gradio user! If you have questions or feedback, please join our Discord server and chat with us: https://discord.gg/feTf9x3ZSB\n",
426
  "\n",
427
  "To create a public link, set `share=True` in `launch()`.\n"
428
  ]
@@ -430,7 +405,7 @@
430
  {
431
  "data": {
432
  "text/html": [
433
- "<div><iframe src=\"http://127.0.0.1:7861/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
434
  ],
435
  "text/plain": [
436
  "<IPython.core.display.HTML object>"
@@ -438,78 +413,6 @@
438
  },
439
  "metadata": {},
440
  "output_type": "display_data"
441
- },
442
- {
443
- "name": "stderr",
444
- "output_type": "stream",
445
- "text": [
446
- "Traceback (most recent call last):\n",
447
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/utils/_http.py\", line 406, in hf_raise_for_status\n",
448
- " response.raise_for_status()\n",
449
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/requests/models.py\", line 1024, in raise_for_status\n",
450
- " raise HTTPError(http_error_msg, response=self)\n",
451
- "requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli/resolve/main/config.json\n",
452
- "\n",
453
- "The above exception was the direct cause of the following exception:\n",
454
- "\n",
455
- "Traceback (most recent call last):\n",
456
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/utils/hub.py\", line 403, in cached_file\n",
457
- " resolved_file = hf_hub_download(\n",
458
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py\", line 114, in _inner_fn\n",
459
- " return fn(*args, **kwargs)\n",
460
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 860, in hf_hub_download\n",
461
- " return _hf_hub_download_to_cache_dir(\n",
462
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 967, in _hf_hub_download_to_cache_dir\n",
463
- " _raise_on_head_call_error(head_call_error, force_download, local_files_only)\n",
464
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 1482, in _raise_on_head_call_error\n",
465
- " raise head_call_error\n",
466
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 1374, in _get_metadata_or_catch_error\n",
467
- " metadata = get_hf_file_metadata(\n",
468
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py\", line 114, in _inner_fn\n",
469
- " return fn(*args, **kwargs)\n",
470
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 1294, in get_hf_file_metadata\n",
471
- " r = _request_wrapper(\n",
472
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 278, in _request_wrapper\n",
473
- " response = _request_wrapper(\n",
474
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 302, in _request_wrapper\n",
475
- " hf_raise_for_status(response)\n",
476
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/utils/_http.py\", line 454, in hf_raise_for_status\n",
477
- " raise _format(RepositoryNotFoundError, message, response) from e\n",
478
- "huggingface_hub.errors.RepositoryNotFoundError: 401 Client Error. (Request ID: Root=1-68fa0a8b-0d531523246f6614068c359e;d99d5b5d-694d-4d4b-b774-bb70066228d2)\n",
479
- "\n",
480
- "Repository Not Found for url: https://huggingface.co/MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli/resolve/main/config.json.\n",
481
- "Please make sure you specified the correct `repo_id` and `repo_type`.\n",
482
- "If you are trying to access a private or gated repo, make sure you are authenticated.\n",
483
- "Invalid username or password.\n",
484
- "\n",
485
- "The above exception was the direct cause of the following exception:\n",
486
- "\n",
487
- "Traceback (most recent call last):\n",
488
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/queueing.py\", line 536, in process_events\n",
489
- " response = await route_utils.call_process_api(\n",
490
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/route_utils.py\", line 322, in call_process_api\n",
491
- " output = await app.get_blocks().process_api(\n",
492
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/blocks.py\", line 1935, in process_api\n",
493
- " result = await self.call_function(\n",
494
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/blocks.py\", line 1520, in call_function\n",
495
- " prediction = await anyio.to_thread.run_sync( # type: ignore\n",
496
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/anyio/to_thread.py\", line 56, in run_sync\n",
497
- " return await get_async_backend().run_sync_in_worker_thread(\n",
498
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/anyio/_backends/_asyncio.py\", line 2134, in run_sync_in_worker_thread\n",
499
- " return await future\n",
500
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/anyio/_backends/_asyncio.py\", line 851, in run\n",
501
- " result = context.run(func, *args)\n",
502
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/utils.py\", line 826, in wrapper\n",
503
- " response = f(*args, **kwargs)\n",
504
- " File \"/var/folders/r5/y63bxy5d4_zfxf6cgwtwysbc0000gn/T/ipykernel_22464/1188444081.py\", line 3, in classify\n",
505
- " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
506
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/pipelines/__init__.py\", line 798, in pipeline\n",
507
- " resolved_config_file = cached_file(\n",
508
- " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/utils/hub.py\", line 426, in cached_file\n",
509
- " raise EnvironmentError(\n",
510
- "OSError: MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'\n",
511
- "If this is a private repository, make sure to pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`\n"
512
- ]
513
  }
514
  ],
515
  "source": [
 
10
  },
11
  {
12
  "cell_type": "code",
13
+ "execution_count": 1,
14
  "id": "1eaa3a9f-0b39-4d77-91d6-f935d226ac98",
15
  "metadata": {},
16
  "outputs": [],
 
41
  },
42
  {
43
  "cell_type": "code",
44
+ "execution_count": 2,
45
  "id": "bb1bc7ed-227e-4c0b-b769-ead4daf01c57",
46
  "metadata": {},
47
  "outputs": [
 
155
  },
156
  {
157
  "cell_type": "code",
158
+ "execution_count": 12,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  "id": "4b3a1bcb-3450-4128-b941-952f145baf99",
160
  "metadata": {},
161
  "outputs": [
 
191
  }
192
  ],
193
  "source": [
194
+ "key = keys_list[0]\n",
195
  "model_name = \"facebook/bart-large-mnli\"\n",
196
  "trip_descr = \"I am planning a trip to Greece with my boyfriend, where we will visit two islands. We have booked an apartment on each island for a few days and plan to spend most of our time relaxing. Our main goals are to enjoy the beach, try delicious local food, and possibly go on a hike—if it’s not too hot. We will be relying solely on public transport. We’re in our late 20s and traveling from the Netherlands.\"\n",
197
  "classifier = pipeline(\"zero-shot-classification\", model = model_name)\n",
 
206
  },
207
  {
208
  "cell_type": "code",
209
+ "execution_count": 5,
210
  "id": "04208f9e-59bb-408b-92c6-941d064bf43d",
211
  "metadata": {},
212
  "outputs": [
 
226
  },
227
  {
228
  "cell_type": "code",
229
+ "execution_count": 6,
230
  "id": "9f5f1c45-b411-4de1-a0a6-a7ecde5d8eae",
231
  "metadata": {},
232
  "outputs": [
 
265
  " \"Label\": result[\"labels\"],\n",
266
  " \"Score\": result[\"scores\"]\n",
267
  "})\n",
268
+ "print(df)\n",
269
+ "print(classes)"
270
  ]
271
  },
272
  {
273
  "cell_type": "code",
274
+ "execution_count": 7,
275
  "id": "7c5c50c4-7d58-4f5a-8f22-e4c06298a2f7",
276
  "metadata": {},
277
  "outputs": [
 
283
  ]
284
  }
285
  ],
286
+ "source": []
 
 
287
  },
288
  {
289
  "cell_type": "code",
290
+ "execution_count": 8,
291
  "id": "3a7287c2-78f0-4a53-af72-1bc0f62da36f",
292
  "metadata": {},
293
  "outputs": [],
 
323
  },
324
  {
325
  "cell_type": "code",
326
+ "execution_count": 9,
327
  "id": "43481d4c-039a-4a37-bd6d-dfe638bf9732",
328
  "metadata": {},
329
  "outputs": [
 
338
  "name": "stdout",
339
  "output_type": "stream",
340
  "text": [
341
+ "Processing 9/9 superclass pred_class\n",
342
  "0 activity_type beach vacation\n",
343
  "1 activities [going to the beach, relaxing, hiking]\n",
344
  "2 climate_or_season warm destination / summer\n",
 
366
  },
367
  {
368
  "cell_type": "code",
369
+ "execution_count": 10,
370
  "id": "35e14ac8-4445-4586-a115-081cf1ef2686",
371
  "metadata": {},
372
  "outputs": [],
 
382
  " candidate_labels = json.load(file)\n",
383
  "keys_list = list(candidate_labels.keys())\n",
384
  "\n",
 
 
 
 
385
  "# Load packing item data\n",
386
  "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
387
  " packing_items = json.load(file)"
 
389
  },
390
  {
391
  "cell_type": "code",
392
+ "execution_count": 11,
393
  "id": "8eefd4cc-c375-4cc0-956b-472b36bafdb7",
394
  "metadata": {},
395
  "outputs": [
 
397
  "name": "stdout",
398
  "output_type": "stream",
399
  "text": [
400
+ "Running on local URL: http://127.0.0.1:7860\n",
 
 
401
  "\n",
402
  "To create a public link, set `share=True` in `launch()`.\n"
403
  ]
 
405
  {
406
  "data": {
407
  "text/html": [
408
+ "<div><iframe src=\"http://127.0.0.1:7860/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
409
  ],
410
  "text/plain": [
411
  "<IPython.core.display.HTML object>"
 
413
  },
414
  "metadata": {},
415
  "output_type": "display_data"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  }
417
  ],
418
  "source": [
space/.ipynb_checkpoints/app-checkpoint.py CHANGED
@@ -1,4 +1,7 @@
1
  # Prerequisites
 
 
 
2
  from transformers import pipeline
3
  import json
4
  import pandas as pd
@@ -9,10 +12,6 @@ with open("packing_label_structure.json", "r") as file:
9
  candidate_labels = json.load(file)
10
  keys_list = list(candidate_labels.keys())
11
 
12
- # Load test data (in list of dictionaries)
13
- with open("test_data.json", "r") as file:
14
- packing_data = json.load(file)
15
-
16
  # Load packing item data
17
  with open("packing_templates_self_supported_offgrid_expanded.json", "r") as file:
18
  packing_items = json.load(file)
 
1
  # Prerequisites
2
+ import os
3
+ os.environ["OMP_NUM_THREADS"] = "1" # Set 1, 2, or 4 depending on CPU usage
4
+
5
  from transformers import pipeline
6
  import json
7
  import pandas as pd
 
12
  candidate_labels = json.load(file)
13
  keys_list = list(candidate_labels.keys())
14
 
 
 
 
 
15
  # Load packing item data
16
  with open("packing_templates_self_supported_offgrid_expanded.json", "r") as file:
17
  packing_items = json.load(file)
space/app.py CHANGED
@@ -1,4 +1,7 @@
1
  # Prerequisites
 
 
 
2
  from transformers import pipeline
3
  import json
4
  import pandas as pd
@@ -9,10 +12,6 @@ with open("packing_label_structure.json", "r") as file:
9
  candidate_labels = json.load(file)
10
  keys_list = list(candidate_labels.keys())
11
 
12
- # Load test data (in list of dictionaries)
13
- with open("test_data.json", "r") as file:
14
- packing_data = json.load(file)
15
-
16
  # Load packing item data
17
  with open("packing_templates_self_supported_offgrid_expanded.json", "r") as file:
18
  packing_items = json.load(file)
 
1
  # Prerequisites
2
+ import os
3
+ os.environ["OMP_NUM_THREADS"] = "1" # Set 1, 2, or 4 depending on CPU usage
4
+
5
  from transformers import pipeline
6
  import json
7
  import pandas as pd
 
12
  candidate_labels = json.load(file)
13
  keys_list = list(candidate_labels.keys())
14
 
 
 
 
 
15
  # Load packing item data
16
  with open("packing_templates_self_supported_offgrid_expanded.json", "r") as file:
17
  packing_items = json.load(file)
space/main_model.ipynb CHANGED
@@ -997,6 +997,13 @@
997
  },
998
  "metadata": {},
999
  "output_type": "display_data"
 
 
 
 
 
 
 
1000
  }
1001
  ],
1002
  "source": [
 
997
  },
998
  "metadata": {},
999
  "output_type": "display_data"
1000
+ },
1001
+ {
1002
+ "name": "stderr",
1003
+ "output_type": "stream",
1004
+ "text": [
1005
+ "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n"
1006
+ ]
1007
  }
1008
  ],
1009
  "source": [
space/space/.DS_Store CHANGED
Binary files a/space/space/.DS_Store and b/space/space/.DS_Store differ
 
space/space/.ipynb_checkpoints/app-checkpoint.py CHANGED
@@ -1,4 +1,7 @@
1
  # Prerequisites
 
 
 
2
  from transformers import pipeline
3
  import json
4
  import pandas as pd
@@ -9,10 +12,6 @@ with open("packing_label_structure.json", "r") as file:
9
  candidate_labels = json.load(file)
10
  keys_list = list(candidate_labels.keys())
11
 
12
- # Load test data (in list of dictionaries)
13
- with open("test_data.json", "r") as file:
14
- packing_data = json.load(file)
15
-
16
  # Load packing item data
17
  with open("packing_templates_self_supported_offgrid_expanded.json", "r") as file:
18
  packing_items = json.load(file)
@@ -50,7 +49,7 @@ def classify(model_name, trip_descr, cut_off = 0.5):
50
  demo = gr.Interface(
51
  fn=classify,
52
  inputs=[
53
- gr.Textbox(label="Model name", value = "MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli"),
54
  gr.Textbox(label="Trip description"),
55
  gr.Number(label="Activity cut-off", value = 0.5),
56
  ],
 
1
  # Prerequisites
2
+ import os
3
+ os.environ["OMP_NUM_THREADS"] = "1" # Set 1, 2, or 4 depending on CPU usage
4
+
5
  from transformers import pipeline
6
  import json
7
  import pandas as pd
 
12
  candidate_labels = json.load(file)
13
  keys_list = list(candidate_labels.keys())
14
 
 
 
 
 
15
  # Load packing item data
16
  with open("packing_templates_self_supported_offgrid_expanded.json", "r") as file:
17
  packing_items = json.load(file)
 
49
  demo = gr.Interface(
50
  fn=classify,
51
  inputs=[
52
+ gr.Textbox(label="Model name", value = "MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli"),
53
  gr.Textbox(label="Trip description"),
54
  gr.Number(label="Activity cut-off", value = 0.5),
55
  ],
space/space/app.py CHANGED
@@ -1,4 +1,7 @@
1
  # Prerequisites
 
 
 
2
  from transformers import pipeline
3
  import json
4
  import pandas as pd
@@ -9,10 +12,6 @@ with open("packing_label_structure.json", "r") as file:
9
  candidate_labels = json.load(file)
10
  keys_list = list(candidate_labels.keys())
11
 
12
- # Load test data (in list of dictionaries)
13
- with open("test_data.json", "r") as file:
14
- packing_data = json.load(file)
15
-
16
  # Load packing item data
17
  with open("packing_templates_self_supported_offgrid_expanded.json", "r") as file:
18
  packing_items = json.load(file)
@@ -50,7 +49,7 @@ def classify(model_name, trip_descr, cut_off = 0.5):
50
  demo = gr.Interface(
51
  fn=classify,
52
  inputs=[
53
- gr.Textbox(label="Model name", value = "MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli"),
54
  gr.Textbox(label="Trip description"),
55
  gr.Number(label="Activity cut-off", value = 0.5),
56
  ],
 
1
  # Prerequisites
2
+ import os
3
+ os.environ["OMP_NUM_THREADS"] = "1" # Set 1, 2, or 4 depending on CPU usage
4
+
5
  from transformers import pipeline
6
  import json
7
  import pandas as pd
 
12
  candidate_labels = json.load(file)
13
  keys_list = list(candidate_labels.keys())
14
 
 
 
 
 
15
  # Load packing item data
16
  with open("packing_templates_self_supported_offgrid_expanded.json", "r") as file:
17
  packing_items = json.load(file)
 
49
  demo = gr.Interface(
50
  fn=classify,
51
  inputs=[
52
+ gr.Textbox(label="Model name", value = "MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli"),
53
  gr.Textbox(label="Trip description"),
54
  gr.Number(label="Activity cut-off", value = 0.5),
55
  ],
space/space/code_blog_post.ipynb CHANGED
@@ -516,7 +516,7 @@
516
  "demo = gr.Interface(\n",
517
  " fn=pred_trip,\n",
518
  " inputs=[\n",
519
- " gr.Textbox(label=\"Model name\", value = \"MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli\"),\n",
520
  " gr.Textbox(label=\"Trip description\"),\n",
521
  " gr.Number(label=\"Activity cut-off\", value = 0.5),\n",
522
  " ],\n",
 
516
  "demo = gr.Interface(\n",
517
  " fn=pred_trip,\n",
518
  " inputs=[\n",
519
+ " gr.Textbox(label=\"Model name\", value = \"MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli\"),\n",
520
  " gr.Textbox(label=\"Trip description\"),\n",
521
  " gr.Number(label=\"Activity cut-off\", value = 0.5),\n",
522
  " ],\n",
space/space/main_model.ipynb CHANGED
@@ -946,7 +946,7 @@
946
  },
947
  {
948
  "cell_type": "code",
949
- "execution_count": 3,
950
  "id": "5bf23e10-0a93-4b2f-9508-34bb0974d24c",
951
  "metadata": {},
952
  "outputs": [],
@@ -973,7 +973,7 @@
973
  },
974
  {
975
  "cell_type": "code",
976
- "execution_count": 4,
977
  "id": "61ebbe99-2563-4c99-ba65-d2312c9d5844",
978
  "metadata": {},
979
  "outputs": [
@@ -981,7 +981,7 @@
981
  "name": "stdout",
982
  "output_type": "stream",
983
  "text": [
984
- "Running on local URL: http://127.0.0.1:7860\n",
985
  "\n",
986
  "To create a public link, set `share=True` in `launch()`.\n"
987
  ]
@@ -989,7 +989,7 @@
989
  {
990
  "data": {
991
  "text/html": [
992
- "<div><iframe src=\"http://127.0.0.1:7860/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
993
  ],
994
  "text/plain": [
995
  "<IPython.core.display.HTML object>"
@@ -1033,7 +1033,7 @@
1033
  "demo = gr.Interface(\n",
1034
  " fn=classify,\n",
1035
  " inputs=[\n",
1036
- " gr.Textbox(label=\"Model name\", value = \"MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli\"),\n",
1037
  " gr.Textbox(label=\"Trip description\"),\n",
1038
  " gr.Number(label=\"Activity cut-off\", value = 0.5),\n",
1039
  " ],\n",
@@ -1482,7 +1482,7 @@
1482
  {
1483
  "cell_type": "code",
1484
  "execution_count": null,
1485
- "id": "2f94ec09-ec7e-405b-9df1-34cb33ff4c28",
1486
  "metadata": {},
1487
  "outputs": [],
1488
  "source": []
 
946
  },
947
  {
948
  "cell_type": "code",
949
+ "execution_count": 2,
950
  "id": "5bf23e10-0a93-4b2f-9508-34bb0974d24c",
951
  "metadata": {},
952
  "outputs": [],
 
973
  },
974
  {
975
  "cell_type": "code",
976
+ "execution_count": 3,
977
  "id": "61ebbe99-2563-4c99-ba65-d2312c9d5844",
978
  "metadata": {},
979
  "outputs": [
 
981
  "name": "stdout",
982
  "output_type": "stream",
983
  "text": [
984
+ "Running on local URL: http://127.0.0.1:7862\n",
985
  "\n",
986
  "To create a public link, set `share=True` in `launch()`.\n"
987
  ]
 
989
  {
990
  "data": {
991
  "text/html": [
992
+ "<div><iframe src=\"http://127.0.0.1:7862/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
993
  ],
994
  "text/plain": [
995
  "<IPython.core.display.HTML object>"
 
1033
  "demo = gr.Interface(\n",
1034
  " fn=classify,\n",
1035
  " inputs=[\n",
1036
+ " gr.Textbox(label=\"Model name\", value = \"MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli\"),\n",
1037
  " gr.Textbox(label=\"Trip description\"),\n",
1038
  " gr.Number(label=\"Activity cut-off\", value = 0.5),\n",
1039
  " ],\n",
 
1482
  {
1483
  "cell_type": "code",
1484
  "execution_count": null,
1485
+ "id": "e300e3f3-93e0-457b-b2f0-e05cc5c2cafb",
1486
  "metadata": {},
1487
  "outputs": [],
1488
  "source": []
space/space/space/.ipynb_checkpoints/code_blog_post-checkpoint.ipynb CHANGED
@@ -16,14 +16,15 @@
16
  "outputs": [],
17
  "source": [
18
  "import math\n",
19
- "import json\n",
20
  "import pickle\n",
21
  "import os\n",
22
  "import time\n",
23
- "import pandas as pd\n",
24
  "import matplotlib.pyplot as plt\n",
25
  "from tabulate import tabulate\n",
 
26
  "from transformers import pipeline\n",
 
 
27
  "\n",
28
  "# Get candidate labels\n",
29
  "with open(\"packing_label_structure.json\", \"r\") as file:\n",
@@ -173,7 +174,7 @@
173
  },
174
  {
175
  "cell_type": "code",
176
- "execution_count": 23,
177
  "id": "4b3a1bcb-3450-4128-b941-952f145baf99",
178
  "metadata": {},
179
  "outputs": [
@@ -305,7 +306,7 @@
305
  },
306
  {
307
  "cell_type": "code",
308
- "execution_count": 34,
309
  "id": "3a7287c2-78f0-4a53-af72-1bc0f62da36f",
310
  "metadata": {},
311
  "outputs": [],
@@ -327,7 +328,7 @@
327
  " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
328
  " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
329
  " for i, key in enumerate(keys_list):\n",
330
- " print(f\"\\rProcessing {i}/{len(keys_list)}\", end=\"\", flush=True)\n",
331
  " if key == 'activities':\n",
332
  " result = classifier(trip_descr, candidate_labels[key], multi_label=True)\n",
333
  " indices = [i for i, score in enumerate(result['scores']) if score > cut_off]\n",
@@ -341,7 +342,7 @@
341
  },
342
  {
343
  "cell_type": "code",
344
- "execution_count": null,
345
  "id": "43481d4c-039a-4a37-bd6d-dfe638bf9732",
346
  "metadata": {},
347
  "outputs": [
@@ -356,7 +357,16 @@
356
  "name": "stdout",
357
  "output_type": "stream",
358
  "text": [
359
- "Processing 0/9..."
 
 
 
 
 
 
 
 
 
360
  ]
361
  }
362
  ],
@@ -365,10 +375,221 @@
365
  "print(result)"
366
  ]
367
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
368
  {
369
  "cell_type": "code",
370
  "execution_count": null,
371
- "id": "73f6a8c7-3c5f-4620-b2a5-cd31079bfeb4",
372
  "metadata": {},
373
  "outputs": [],
374
  "source": []
 
16
  "outputs": [],
17
  "source": [
18
  "import math\n",
 
19
  "import pickle\n",
20
  "import os\n",
21
  "import time\n",
 
22
  "import matplotlib.pyplot as plt\n",
23
  "from tabulate import tabulate\n",
24
+ "\n",
25
  "from transformers import pipeline\n",
26
+ "import json\n",
27
+ "import pandas as pd\n",
28
  "\n",
29
  "# Get candidate labels\n",
30
  "with open(\"packing_label_structure.json\", \"r\") as file:\n",
 
174
  },
175
  {
176
  "cell_type": "code",
177
+ "execution_count": 40,
178
  "id": "4b3a1bcb-3450-4128-b941-952f145baf99",
179
  "metadata": {},
180
  "outputs": [
 
306
  },
307
  {
308
  "cell_type": "code",
309
+ "execution_count": 45,
310
  "id": "3a7287c2-78f0-4a53-af72-1bc0f62da36f",
311
  "metadata": {},
312
  "outputs": [],
 
328
  " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
329
  " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
330
  " for i, key in enumerate(keys_list):\n",
331
+ " print(f\"\\rProcessing {i + 1}/{len(keys_list)}\", end=\"\", flush=True)\n",
332
  " if key == 'activities':\n",
333
  " result = classifier(trip_descr, candidate_labels[key], multi_label=True)\n",
334
  " indices = [i for i, score in enumerate(result['scores']) if score > cut_off]\n",
 
342
  },
343
  {
344
  "cell_type": "code",
345
+ "execution_count": 35,
346
  "id": "43481d4c-039a-4a37-bd6d-dfe638bf9732",
347
  "metadata": {},
348
  "outputs": [
 
357
  "name": "stdout",
358
  "output_type": "stream",
359
  "text": [
360
+ "Processing 8/9... superclass pred_class\n",
361
+ "0 activity_type beach vacation\n",
362
+ "1 activities [going to the beach, relaxing, hiking]\n",
363
+ "2 climate_or_season warm destination / summer\n",
364
+ "3 style_or_comfort minimalist\n",
365
+ "4 dress_code casual\n",
366
+ "5 accommodation huts with half board\n",
367
+ "6 transportation no own vehicle\n",
368
+ "7 special_conditions off-grid / no electricity\n",
369
+ "8 trip_length_days 7+ days\n"
370
  ]
371
  }
372
  ],
 
375
  "print(result)"
376
  ]
377
  },
378
+ {
379
+ "cell_type": "markdown",
380
+ "id": "c4799d6b-6ab5-42da-a992-afe3666d0015",
381
+ "metadata": {},
382
+ "source": [
383
+ "Now use gradio app"
384
+ ]
385
+ },
386
+ {
387
+ "cell_type": "code",
388
+ "execution_count": 37,
389
+ "id": "35e14ac8-4445-4586-a115-081cf1ef2686",
390
+ "metadata": {},
391
+ "outputs": [],
392
+ "source": [
393
+ "# Prerequisites\n",
394
+ "from transformers import pipeline\n",
395
+ "import json\n",
396
+ "import pandas as pd\n",
397
+ "import gradio as gr\n",
398
+ "\n",
399
+ "# get candidate labels\n",
400
+ "with open(\"packing_label_structure.json\", \"r\") as file:\n",
401
+ " candidate_labels = json.load(file)\n",
402
+ "keys_list = list(candidate_labels.keys())\n",
403
+ "\n",
404
+ "# Load test data (in list of dictionaries)\n",
405
+ "with open(\"test_data.json\", \"r\") as file:\n",
406
+ " packing_data = json.load(file)\n",
407
+ "\n",
408
+ "# Load packing item data\n",
409
+ "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
410
+ " packing_items = json.load(file)"
411
+ ]
412
+ },
413
+ {
414
+ "cell_type": "code",
415
+ "execution_count": 39,
416
+ "id": "8eefd4cc-c375-4cc0-956b-472b36bafdb7",
417
+ "metadata": {},
418
+ "outputs": [
419
+ {
420
+ "name": "stdout",
421
+ "output_type": "stream",
422
+ "text": [
423
+ "Running on local URL: http://127.0.0.1:7861\n",
424
+ "\n",
425
+ "Thanks for being a Gradio user! If you have questions or feedback, please join our Discord server and chat with us: https://discord.gg/feTf9x3ZSB\n",
426
+ "\n",
427
+ "To create a public link, set `share=True` in `launch()`.\n"
428
+ ]
429
+ },
430
+ {
431
+ "data": {
432
+ "text/html": [
433
+ "<div><iframe src=\"http://127.0.0.1:7861/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
434
+ ],
435
+ "text/plain": [
436
+ "<IPython.core.display.HTML object>"
437
+ ]
438
+ },
439
+ "metadata": {},
440
+ "output_type": "display_data"
441
+ },
442
+ {
443
+ "name": "stderr",
444
+ "output_type": "stream",
445
+ "text": [
446
+ "Traceback (most recent call last):\n",
447
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/utils/_http.py\", line 406, in hf_raise_for_status\n",
448
+ " response.raise_for_status()\n",
449
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/requests/models.py\", line 1024, in raise_for_status\n",
450
+ " raise HTTPError(http_error_msg, response=self)\n",
451
+ "requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli/resolve/main/config.json\n",
452
+ "\n",
453
+ "The above exception was the direct cause of the following exception:\n",
454
+ "\n",
455
+ "Traceback (most recent call last):\n",
456
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/utils/hub.py\", line 403, in cached_file\n",
457
+ " resolved_file = hf_hub_download(\n",
458
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py\", line 114, in _inner_fn\n",
459
+ " return fn(*args, **kwargs)\n",
460
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 860, in hf_hub_download\n",
461
+ " return _hf_hub_download_to_cache_dir(\n",
462
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 967, in _hf_hub_download_to_cache_dir\n",
463
+ " _raise_on_head_call_error(head_call_error, force_download, local_files_only)\n",
464
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 1482, in _raise_on_head_call_error\n",
465
+ " raise head_call_error\n",
466
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 1374, in _get_metadata_or_catch_error\n",
467
+ " metadata = get_hf_file_metadata(\n",
468
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py\", line 114, in _inner_fn\n",
469
+ " return fn(*args, **kwargs)\n",
470
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 1294, in get_hf_file_metadata\n",
471
+ " r = _request_wrapper(\n",
472
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 278, in _request_wrapper\n",
473
+ " response = _request_wrapper(\n",
474
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 302, in _request_wrapper\n",
475
+ " hf_raise_for_status(response)\n",
476
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/utils/_http.py\", line 454, in hf_raise_for_status\n",
477
+ " raise _format(RepositoryNotFoundError, message, response) from e\n",
478
+ "huggingface_hub.errors.RepositoryNotFoundError: 401 Client Error. (Request ID: Root=1-68fa0a8b-0d531523246f6614068c359e;d99d5b5d-694d-4d4b-b774-bb70066228d2)\n",
479
+ "\n",
480
+ "Repository Not Found for url: https://huggingface.co/MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli/resolve/main/config.json.\n",
481
+ "Please make sure you specified the correct `repo_id` and `repo_type`.\n",
482
+ "If you are trying to access a private or gated repo, make sure you are authenticated.\n",
483
+ "Invalid username or password.\n",
484
+ "\n",
485
+ "The above exception was the direct cause of the following exception:\n",
486
+ "\n",
487
+ "Traceback (most recent call last):\n",
488
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/queueing.py\", line 536, in process_events\n",
489
+ " response = await route_utils.call_process_api(\n",
490
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/route_utils.py\", line 322, in call_process_api\n",
491
+ " output = await app.get_blocks().process_api(\n",
492
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/blocks.py\", line 1935, in process_api\n",
493
+ " result = await self.call_function(\n",
494
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/blocks.py\", line 1520, in call_function\n",
495
+ " prediction = await anyio.to_thread.run_sync( # type: ignore\n",
496
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/anyio/to_thread.py\", line 56, in run_sync\n",
497
+ " return await get_async_backend().run_sync_in_worker_thread(\n",
498
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/anyio/_backends/_asyncio.py\", line 2134, in run_sync_in_worker_thread\n",
499
+ " return await future\n",
500
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/anyio/_backends/_asyncio.py\", line 851, in run\n",
501
+ " result = context.run(func, *args)\n",
502
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/utils.py\", line 826, in wrapper\n",
503
+ " response = f(*args, **kwargs)\n",
504
+ " File \"/var/folders/r5/y63bxy5d4_zfxf6cgwtwysbc0000gn/T/ipykernel_22464/1188444081.py\", line 3, in classify\n",
505
+ " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
506
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/pipelines/__init__.py\", line 798, in pipeline\n",
507
+ " resolved_config_file = cached_file(\n",
508
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/utils/hub.py\", line 426, in cached_file\n",
509
+ " raise EnvironmentError(\n",
510
+ "OSError: MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'\n",
511
+ "If this is a private repository, make sure to pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`\n"
512
+ ]
513
+ }
514
+ ],
515
+ "source": [
516
+ "demo = gr.Interface(\n",
517
+ " fn=pred_trip,\n",
518
+ " inputs=[\n",
519
+ " gr.Textbox(label=\"Model name\", value = \"MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli\"),\n",
520
+ " gr.Textbox(label=\"Trip description\"),\n",
521
+ " gr.Number(label=\"Activity cut-off\", value = 0.5),\n",
522
+ " ],\n",
523
+ " # outputs=\"dataframe\",\n",
524
+ " outputs=[gr.Dataframe(label=\"DataFrame\"), gr.Textbox(label=\"List of words\")],\n",
525
+ " title=\"Trip classification\",\n",
526
+ " description=\"Enter a text describing your trip\",\n",
527
+ ")\n",
528
+ "\n",
529
+ "# Launch the Gradio app\n",
530
+ "if __name__ == \"__main__\":\n",
531
+ " demo.launch()\n"
532
+ ]
533
+ },
534
+ {
535
+ "cell_type": "code",
536
+ "execution_count": 46,
537
+ "id": "11006b67-bfd5-42a7-99c4-36c3db3affac",
538
+ "metadata": {},
539
+ "outputs": [
540
+ {
541
+ "name": "stderr",
542
+ "output_type": "stream",
543
+ "text": [
544
+ "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n"
545
+ ]
546
+ },
547
+ {
548
+ "name": "stdout",
549
+ "output_type": "stream",
550
+ "text": [
551
+ "Processing 9/9"
552
+ ]
553
+ }
554
+ ],
555
+ "source": [
556
+ "test = pred_trip(model_name, trip_descr, cut_off = 0.5)"
557
+ ]
558
+ },
559
+ {
560
+ "cell_type": "code",
561
+ "execution_count": null,
562
+ "id": "0f6cd8d1-b742-4034-a3e2-e55c3ddd2904",
563
+ "metadata": {},
564
+ "outputs": [],
565
+ "source": [
566
+ "print(test)"
567
+ ]
568
+ },
569
+ {
570
+ "cell_type": "code",
571
+ "execution_count": 41,
572
+ "id": "5db16415-47c1-42c6-861c-5d26f4b3bb03",
573
+ "metadata": {},
574
+ "outputs": [
575
+ {
576
+ "name": "stdout",
577
+ "output_type": "stream",
578
+ "text": [
579
+ "facebook/bart-large-mnli\n",
580
+ "I am planning a trip to Greece with my boyfriend, where we will visit two islands. We have booked an apartment on each island for a few days and plan to spend most of our time relaxing. Our main goals are to enjoy the beach, try delicious local food, and possibly go on a hike—if it’s not too hot. We will be relying solely on public transport. We’re in our late 20s and traveling from the Netherlands.\n"
581
+ ]
582
+ }
583
+ ],
584
+ "source": [
585
+ "print(model_name)\n",
586
+ "print(trip_descr)"
587
+ ]
588
+ },
589
  {
590
  "cell_type": "code",
591
  "execution_count": null,
592
+ "id": "bbca6bc6-bd97-4d43-8a6e-fe338f2735f2",
593
  "metadata": {},
594
  "outputs": [],
595
  "source": []
space/space/space/.ipynb_checkpoints/main_model-checkpoint.ipynb CHANGED
@@ -18,7 +18,7 @@
18
  },
19
  {
20
  "cell_type": "code",
21
- "execution_count": 2,
22
  "id": "f8c28d2d-8458-49fd-8ebf-5e729d6e861f",
23
  "metadata": {},
24
  "outputs": [],
@@ -59,9 +59,6 @@
59
  "execution_count": 2,
60
  "id": "89d42ca7-e871-4eda-b428-69e9bd965428",
61
  "metadata": {
62
- "jupyter": {
63
- "source_hidden": true
64
- },
65
  "scrolled": true
66
  },
67
  "outputs": [
@@ -176,14 +173,14 @@
176
  "8 . I go on a skitouring trip where we also make videos/photos and the destination is Japan. Mainly sports clothes and isolation are needed (it is winter). We stay in a guesthouse. It will be 10 days. \n",
177
  "\n",
178
  "ski tour / skitour\n",
179
- "['ski touring', 'photography', 'swimming']\n",
180
  "cold destination / winter\n",
181
  "minimalist\n",
182
  "conservative\n",
183
  "indoor\n",
184
  "no own vehicle\n",
185
  "avalanche-prone terrain\n",
186
- "5 days\n",
187
  "\n",
188
  "\n",
189
  "9 . We plan a wild camping trip with activities such as snorkeling, kayaking and canoeing. It is a warm place and we want to bring little stuff. We stay in tents and hammocks and travel with a car, it will be 3 days. \n",
@@ -192,10 +189,10 @@
192
  "['scuba diving', 'kayaking / canoeing']\n",
193
  "tropical / humid\n",
194
  "lightweight (but comfortable)\n",
195
- "conservative\n",
196
  "sleeping in a tent\n",
197
  "own vehicle\n",
198
- "no special conditions to consider\n",
199
  "3 days\n",
200
  "\n",
201
  "\n"
@@ -949,7 +946,7 @@
949
  },
950
  {
951
  "cell_type": "code",
952
- "execution_count": 1,
953
  "id": "5bf23e10-0a93-4b2f-9508-34bb0974d24c",
954
  "metadata": {},
955
  "outputs": [],
@@ -976,7 +973,7 @@
976
  },
977
  {
978
  "cell_type": "code",
979
- "execution_count": 2,
980
  "id": "61ebbe99-2563-4c99-ba65-d2312c9d5844",
981
  "metadata": {},
982
  "outputs": [
@@ -984,7 +981,7 @@
984
  "name": "stdout",
985
  "output_type": "stream",
986
  "text": [
987
- "Running on local URL: http://127.0.0.1:7860\n",
988
  "\n",
989
  "To create a public link, set `share=True` in `launch()`.\n"
990
  ]
@@ -992,7 +989,7 @@
992
  {
993
  "data": {
994
  "text/html": [
995
- "<div><iframe src=\"http://127.0.0.1:7860/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
996
  ],
997
  "text/plain": [
998
  "<IPython.core.display.HTML object>"
@@ -1000,13 +997,6 @@
1000
  },
1001
  "metadata": {},
1002
  "output_type": "display_data"
1003
- },
1004
- {
1005
- "name": "stderr",
1006
- "output_type": "stream",
1007
- "text": [
1008
- "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n"
1009
- ]
1010
  }
1011
  ],
1012
  "source": [
@@ -1043,7 +1033,7 @@
1043
  "demo = gr.Interface(\n",
1044
  " fn=classify,\n",
1045
  " inputs=[\n",
1046
- " gr.Textbox(label=\"Model name\", value = \"MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli\"),\n",
1047
  " gr.Textbox(label=\"Trip description\"),\n",
1048
  " gr.Number(label=\"Activity cut-off\", value = 0.5),\n",
1049
  " ],\n",
@@ -1062,7 +1052,9 @@
1062
  "cell_type": "code",
1063
  "execution_count": 32,
1064
  "id": "1f5df949-a527-4b11-8e5e-23786e1cde12",
1065
- "metadata": {},
 
 
1066
  "outputs": [
1067
  {
1068
  "name": "stdout",
@@ -1083,10 +1075,414 @@
1083
  "print(first_trip)"
1084
  ]
1085
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1086
  {
1087
  "cell_type": "code",
1088
  "execution_count": null,
1089
- "id": "9d74d4e7-80f6-44d3-a5c7-b41025b7d8fc",
1090
  "metadata": {},
1091
  "outputs": [],
1092
  "source": []
 
18
  },
19
  {
20
  "cell_type": "code",
21
+ "execution_count": 1,
22
  "id": "f8c28d2d-8458-49fd-8ebf-5e729d6e861f",
23
  "metadata": {},
24
  "outputs": [],
 
59
  "execution_count": 2,
60
  "id": "89d42ca7-e871-4eda-b428-69e9bd965428",
61
  "metadata": {
 
 
 
62
  "scrolled": true
63
  },
64
  "outputs": [
 
173
  "8 . I go on a skitouring trip where we also make videos/photos and the destination is Japan. Mainly sports clothes and isolation are needed (it is winter). We stay in a guesthouse. It will be 10 days. \n",
174
  "\n",
175
  "ski tour / skitour\n",
176
+ "['ski touring', 'photography']\n",
177
  "cold destination / winter\n",
178
  "minimalist\n",
179
  "conservative\n",
180
  "indoor\n",
181
  "no own vehicle\n",
182
  "avalanche-prone terrain\n",
183
+ "7+ days\n",
184
  "\n",
185
  "\n",
186
  "9 . We plan a wild camping trip with activities such as snorkeling, kayaking and canoeing. It is a warm place and we want to bring little stuff. We stay in tents and hammocks and travel with a car, it will be 3 days. \n",
 
189
  "['scuba diving', 'kayaking / canoeing']\n",
190
  "tropical / humid\n",
191
  "lightweight (but comfortable)\n",
192
+ "casual\n",
193
  "sleeping in a tent\n",
194
  "own vehicle\n",
195
+ "self-supported (bring your own cooking gear)\n",
196
  "3 days\n",
197
  "\n",
198
  "\n"
 
946
  },
947
  {
948
  "cell_type": "code",
949
+ "execution_count": 2,
950
  "id": "5bf23e10-0a93-4b2f-9508-34bb0974d24c",
951
  "metadata": {},
952
  "outputs": [],
 
973
  },
974
  {
975
  "cell_type": "code",
976
+ "execution_count": 3,
977
  "id": "61ebbe99-2563-4c99-ba65-d2312c9d5844",
978
  "metadata": {},
979
  "outputs": [
 
981
  "name": "stdout",
982
  "output_type": "stream",
983
  "text": [
984
+ "Running on local URL: http://127.0.0.1:7862\n",
985
  "\n",
986
  "To create a public link, set `share=True` in `launch()`.\n"
987
  ]
 
989
  {
990
  "data": {
991
  "text/html": [
992
+ "<div><iframe src=\"http://127.0.0.1:7862/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
993
  ],
994
  "text/plain": [
995
  "<IPython.core.display.HTML object>"
 
997
  },
998
  "metadata": {},
999
  "output_type": "display_data"
 
 
 
 
 
 
 
1000
  }
1001
  ],
1002
  "source": [
 
1033
  "demo = gr.Interface(\n",
1034
  " fn=classify,\n",
1035
  " inputs=[\n",
1036
+ " gr.Textbox(label=\"Model name\", value = \"MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli\"),\n",
1037
  " gr.Textbox(label=\"Trip description\"),\n",
1038
  " gr.Number(label=\"Activity cut-off\", value = 0.5),\n",
1039
  " ],\n",
 
1052
  "cell_type": "code",
1053
  "execution_count": 32,
1054
  "id": "1f5df949-a527-4b11-8e5e-23786e1cde12",
1055
+ "metadata": {
1056
+ "scrolled": true
1057
+ },
1058
  "outputs": [
1059
  {
1060
  "name": "stdout",
 
1075
  "print(first_trip)"
1076
  ]
1077
  },
1078
+ {
1079
+ "cell_type": "markdown",
1080
+ "id": "4ba29d94-88e4-4fb9-b42b-4e013ec2faa0",
1081
+ "metadata": {},
1082
+ "source": [
1083
+ "**Check for duplicate entries, which to combine?**"
1084
+ ]
1085
+ },
1086
+ {
1087
+ "cell_type": "code",
1088
+ "execution_count": 3,
1089
+ "id": "66311e68-c7ab-47a0-8d42-02991bc048f2",
1090
+ "metadata": {},
1091
+ "outputs": [
1092
+ {
1093
+ "name": "stdout",
1094
+ "output_type": "stream",
1095
+ "text": [
1096
+ "<class 'dict'>\n"
1097
+ ]
1098
+ }
1099
+ ],
1100
+ "source": [
1101
+ "print(type(packing_items))"
1102
+ ]
1103
+ },
1104
+ {
1105
+ "cell_type": "code",
1106
+ "execution_count": 9,
1107
+ "id": "9b2a01e7-55ac-405a-bb34-2b759c1f2d8e",
1108
+ "metadata": {},
1109
+ "outputs": [
1110
+ {
1111
+ "name": "stdout",
1112
+ "output_type": "stream",
1113
+ "text": [
1114
+ "1 set of clothing for every situation\n",
1115
+ "GPS or offline maps\n",
1116
+ "Gore‑Tex clothing\n",
1117
+ "Gore‑Tex jacket and pants\n",
1118
+ "MiFi router or portable WiFi hotspot\n",
1119
+ "SUP board and paddle\n",
1120
+ "USB hub (for multiple devices)\n",
1121
+ "WiFi hotspot or local SIM card\n",
1122
+ "accessories\n",
1123
+ "activity book or tablet with films\n",
1124
+ "airbag backpack (if available)\n",
1125
+ "all‑in‑one soap\n",
1126
+ "at least 2 liters of water storage per person\n",
1127
+ "avalanche beacon (transceiver)\n",
1128
+ "baby monitor (for staying at location)\n",
1129
+ "backpack\n",
1130
+ "backup lighting (e.g. small flashlight)\n",
1131
+ "bags for waste\n",
1132
+ "bait / lures\n",
1133
+ "bank card / cash\n",
1134
+ "beach bag\n",
1135
+ "beach chair\n",
1136
+ "beach towel\n",
1137
+ "belay device\n",
1138
+ "bike light and lock\n",
1139
+ "bike or rental bike\n",
1140
+ "biodegradable soap + sponge\n",
1141
+ "bivvy bag or tarp\n",
1142
+ "blister plasters or tape\n",
1143
+ "board leash\n",
1144
+ "book / meditation material\n",
1145
+ "book or e‑reader\n",
1146
+ "boots or waders\n",
1147
+ "bottles and food (if applicable)\n",
1148
+ "breathable thermal clothing\n",
1149
+ "buff or neck warmer\n",
1150
+ "business cards / documents\n",
1151
+ "camera + lenses\n",
1152
+ "camera or smartphone\n",
1153
+ "camping gear (if staying overnight)\n",
1154
+ "camping table (optional)\n",
1155
+ "cap or hat\n",
1156
+ "car documents\n",
1157
+ "cash / card\n",
1158
+ "cash for hut\n",
1159
+ "cash for payments\n",
1160
+ "chair\n",
1161
+ "chair and table\n",
1162
+ "chalk bag\n",
1163
+ "charger\n",
1164
+ "child carrier or stroller\n",
1165
+ "child sleeping bag or pad\n",
1166
+ "children’s sunscreen\n",
1167
+ "children’s travel pharmacy\n",
1168
+ "chlorine drops or purification tablets\n",
1169
+ "city map / offline maps\n",
1170
+ "climbing harness\n",
1171
+ "climbing rope\n",
1172
+ "climbing shoes\n",
1173
+ "climbing skins\n",
1174
+ "closed shoes\n",
1175
+ "comfortable backpack or trolley\n",
1176
+ "comfortable clothing\n",
1177
+ "comfortable shoes\n",
1178
+ "comfortable sleeping pad\n",
1179
+ "compact clothing pack\n",
1180
+ "compact rain jacket\n",
1181
+ "compact sleeping gear (if overnighting)\n",
1182
+ "compact toothbrush\n",
1183
+ "cookset + stove\n",
1184
+ "cooler\n",
1185
+ "cooler box\n",
1186
+ "cooler box (optional)\n",
1187
+ "covering clothing\n",
1188
+ "crampons\n",
1189
+ "cross-country ski boots\n",
1190
+ "cross-country skis and poles\n",
1191
+ "daypack\n",
1192
+ "diapers or potty (depending on age)\n",
1193
+ "dishes & cutlery\n",
1194
+ "dive computer\n",
1195
+ "dog leash or harness\n",
1196
+ "down jacket or warm insulation layer\n",
1197
+ "dress or shirt\n",
1198
+ "dress shoes\n",
1199
+ "dried or freeze‑dried meals\n",
1200
+ "driver’s license\n",
1201
+ "dry bag\n",
1202
+ "earplugs\n",
1203
+ "emergency communication (e.g. GPS beacon or satellite messenger)\n",
1204
+ "energy bars or sports nutrition\n",
1205
+ "entertainment (book, music, games)\n",
1206
+ "essential oils (optional)\n",
1207
+ "extension cord (for powered campsites)\n",
1208
+ "extra batteries\n",
1209
+ "extra charger cables\n",
1210
+ "extra clothing\n",
1211
+ "extra clothing layer\n",
1212
+ "extra clothing or gear if needed\n",
1213
+ "extra clothing set per day\n",
1214
+ "extra food\n",
1215
+ "extra snacks for children\n",
1216
+ "favorite toy or stuffed animal\n",
1217
+ "fins\n",
1218
+ "first aid kit\n",
1219
+ "fishing license\n",
1220
+ "fishing rod\n",
1221
+ "flashlight or headlamp\n",
1222
+ "flip flops\n",
1223
+ "foldable cutting board (optional)\n",
1224
+ "foldable solar panel (if on longer trips)\n",
1225
+ "food and snacks\n",
1226
+ "food and water bowl\n",
1227
+ "food bag or hanging bag (wild-safe)\n",
1228
+ "food supply\n",
1229
+ "friend meetups\n",
1230
+ "fuel (enough for several days)\n",
1231
+ "gaiters (in deep snow)\n",
1232
+ "general items for this situation\n",
1233
+ "glitter / outfit\n",
1234
+ "gloves\n",
1235
+ "gloves (2 pairs)\n",
1236
+ "groceries\n",
1237
+ "groundsheet\n",
1238
+ "guidebook or highlights list\n",
1239
+ "hat and gloves\n",
1240
+ "hat or cap\n",
1241
+ "hat or headband\n",
1242
+ "head cover\n",
1243
+ "head protection\n",
1244
+ "headband or cap\n",
1245
+ "headlamp\n",
1246
+ "headlamp + extra batteries\n",
1247
+ "headlamp or flashlight\n",
1248
+ "helmet\n",
1249
+ "hiking boots\n",
1250
+ "hiking boots or trail runners\n",
1251
+ "hiking poles\n",
1252
+ "hiking socks (anti-blister)\n",
1253
+ "hut slippers / Crocs\n",
1254
+ "hydrating cream (for sensitive skin)\n",
1255
+ "ice axes\n",
1256
+ "identity document or passport\n",
1257
+ "indoor hut clothing (thermo / fleece)\n",
1258
+ "insect repellent\n",
1259
+ "insurance card / travel insurance info\n",
1260
+ "jeans or comfortable pants\n",
1261
+ "journal / pen\n",
1262
+ "kayak or canoe\n",
1263
+ "kids first aid kit (including thermometer and bandages)\n",
1264
+ "knife or multitool\n",
1265
+ "knowledge of avalanche safety / course\n",
1266
+ "lamp or lantern\n",
1267
+ "laptop and charger\n",
1268
+ "layered clothing\n",
1269
+ "layers for temperature control\n",
1270
+ "layers of clothing\n",
1271
+ "lens cloth\n",
1272
+ "life jacket\n",
1273
+ "light backpack with water and snacks\n",
1274
+ "light clothing\n",
1275
+ "light down jacket or warm layer\n",
1276
+ "light gloves for climbing\n",
1277
+ "light jacket or raincoat\n",
1278
+ "light long sleeves\n",
1279
+ "light pajamas or sleepwear\n",
1280
+ "light shoes\n",
1281
+ "light tent or tarp\n",
1282
+ "light towel\n",
1283
+ "lighter\n",
1284
+ "lighter + matches (waterproof packed)\n",
1285
+ "lightweight backpack\n",
1286
+ "lightweight backpack (< 1kg)\n",
1287
+ "lightweight clothing\n",
1288
+ "lightweight cookset\n",
1289
+ "lightweight sleeping pad\n",
1290
+ "lightweight stove (gas, petrol or alcohol)\n",
1291
+ "lightweight towel\n",
1292
+ "lightweight trekking backpack (30–45 liters)\n",
1293
+ "limited clothing (layers!)\n",
1294
+ "lip balm\n",
1295
+ "long pants or skirt\n",
1296
+ "lots of water\n",
1297
+ "map and compass\n",
1298
+ "map and compass / GPS\n",
1299
+ "map or GPS\n",
1300
+ "map or offline maps\n",
1301
+ "mask and snorkel\n",
1302
+ "memory card(s)\n",
1303
+ "minimalist shelter (tarp or tent)\n",
1304
+ "music / headphones\n",
1305
+ "navigation\n",
1306
+ "navigation (map/compass/GPS)\n",
1307
+ "navigation device with offline maps\n",
1308
+ "navigation or smartphone\n",
1309
+ "noise‑cancelling headphones\n",
1310
+ "notebook + pen\n",
1311
+ "number of meals/snacks matched to duration\n",
1312
+ "optional own saddle or stirrups\n",
1313
+ "pacifier or dummy\n",
1314
+ "packaging to keep electronics dry\n",
1315
+ "pad and sleeping bag\n",
1316
+ "paddle\n",
1317
+ "pajamas\n",
1318
+ "pan or small pot\n",
1319
+ "paper map and compass\n",
1320
+ "paraglider\n",
1321
+ "partner check before departure\n",
1322
+ "payment methods (debit card / cash)\n",
1323
+ "perfume / deodorant\n",
1324
+ "phone + charger\n",
1325
+ "phone charger\n",
1326
+ "phone holder\n",
1327
+ "phone holder / navigation\n",
1328
+ "pillow or inflatable pillow\n",
1329
+ "poncho or rain jacket\n",
1330
+ "poncho or towel\n",
1331
+ "poop bags\n",
1332
+ "power bank\n",
1333
+ "power bank (at least 10,000 mAh)\n",
1334
+ "power bank or 12V charger\n",
1335
+ "press‑on bowl or mug\n",
1336
+ "probe\n",
1337
+ "probe and shovel\n",
1338
+ "public transport app or ticket\n",
1339
+ "quick snacks for en route\n",
1340
+ "quick‑dry base layers\n",
1341
+ "quick‑dry clothing\n",
1342
+ "quick‑dry towel\n",
1343
+ "quilt or down blanket\n",
1344
+ "rain cover for stroller or carrier\n",
1345
+ "rain jacket\n",
1346
+ "rain jacket or poncho\n",
1347
+ "rain jacket or windbreaker\n",
1348
+ "rain poncho\n",
1349
+ "rain protection\n",
1350
+ "rechargeable batteries and charger\n",
1351
+ "regulator (if own)\n",
1352
+ "repair kit\n",
1353
+ "reservation confirmation\n",
1354
+ "reusable bag\n",
1355
+ "reusable cup\n",
1356
+ "riding boots or shoes with heel\n",
1357
+ "riding pants\n",
1358
+ "rubber shoes\n",
1359
+ "running shoes\n",
1360
+ "sandals\n",
1361
+ "scarf or shawl\n",
1362
+ "seat cushion or beach mat\n",
1363
+ "sheet liner\n",
1364
+ "sheet liner (often required)\n",
1365
+ "shirt / blouse\n",
1366
+ "shovel\n",
1367
+ "ski boots\n",
1368
+ "ski goggles\n",
1369
+ "ski or sunglasses\n",
1370
+ "ski pass\n",
1371
+ "skis and poles\n",
1372
+ "sleep mask\n",
1373
+ "sleeping bag\n",
1374
+ "sleeping bag (light, warm variant)\n",
1375
+ "sleeping bag (suitable for temperature)\n",
1376
+ "sleeping pad\n",
1377
+ "sleeping pad that fits in car\n",
1378
+ "slippers\n",
1379
+ "slippers or indoor shoes for inside\n",
1380
+ "small backpack\n",
1381
+ "small toiletry bag\n",
1382
+ "smart jacket\n",
1383
+ "snacks\n",
1384
+ "snacks / emergency bars\n",
1385
+ "snacks / energy bars\n",
1386
+ "snacks and drinks\n",
1387
+ "snacks and toys\n",
1388
+ "snacks for along the way\n",
1389
+ "snacks for the night\n",
1390
+ "sneakers\n",
1391
+ "snorkel and mask\n",
1392
+ "snow goggles\n",
1393
+ "socks\n",
1394
+ "socks per day\n",
1395
+ "solar panel or portable charging system\n",
1396
+ "splitboard or snowboard\n",
1397
+ "spork or spoon\n",
1398
+ "sports clothing\n",
1399
+ "sports watch (optional)\n",
1400
+ "sun hat\n",
1401
+ "sun hat or cap\n",
1402
+ "sun protection\n",
1403
+ "sunglasses\n",
1404
+ "sunglasses or sport glasses\n",
1405
+ "sunglasses with strap\n",
1406
+ "sunscreen\n",
1407
+ "sunscreen and sunglasses\n",
1408
+ "sunshades or blackout covers\n",
1409
+ "surfboard\n",
1410
+ "sweater or hoodie\n",
1411
+ "swimming goggles\n",
1412
+ "swimwear\n",
1413
+ "t-shirts\n",
1414
+ "tent\n",
1415
+ "tent (1‑ or 2‑person, depending on trip)\n",
1416
+ "tent or tarp\n",
1417
+ "thermal blanket (for cold nights)\n",
1418
+ "thermal clothing\n",
1419
+ "thermos bottle\n",
1420
+ "thick gloves\n",
1421
+ "thin gloves\n",
1422
+ "tissues or toilet paper\n",
1423
+ "titanium cookset\n",
1424
+ "toiletry bag\n",
1425
+ "toiletry bag (toothpaste, brush, deodorant, soap)\n",
1426
+ "toiletry bag with biodegradable soap\n",
1427
+ "toiletry bag with essentials\n",
1428
+ "toothbrush (shortened ;))\n",
1429
+ "tour bindings (for splitboard)\n",
1430
+ "touring backpack with ski attachment\n",
1431
+ "touring skis or splitboard\n",
1432
+ "towel\n",
1433
+ "traction soles / spikes\n",
1434
+ "trail runners or lightweight hiking shoes\n",
1435
+ "travel chair or sling\n",
1436
+ "travel crib or mattress (for young children)\n",
1437
+ "travel guide or maps\n",
1438
+ "travel mat or blanket\n",
1439
+ "trekking poles\n",
1440
+ "tripod\n",
1441
+ "underwear per day\n",
1442
+ "vaccination booklet\n",
1443
+ "warm boots\n",
1444
+ "warm insulation layers\n",
1445
+ "warm jacket\n",
1446
+ "warm layer\n",
1447
+ "warm sleeping bag\n",
1448
+ "warm sweater\n",
1449
+ "warm sweater or scarf\n",
1450
+ "washing up supplies\n",
1451
+ "water bottle\n",
1452
+ "water bottle or belt\n",
1453
+ "water bottle within reach\n",
1454
+ "water bottle(s) or hydration bladder\n",
1455
+ "water filter or pump\n",
1456
+ "water shoes\n",
1457
+ "waterproof backpack cover\n",
1458
+ "waterproof bag\n",
1459
+ "waterproof shoes\n",
1460
+ "wax\n",
1461
+ "wet wipes\n",
1462
+ "wetsuit\n",
1463
+ "wind jacket\n",
1464
+ "windproof and water-repellent outer layer\n",
1465
+ "wind‑ and waterproof jacket\n",
1466
+ "world adapter plug\n",
1467
+ "yoga mat or yoga towel\n"
1468
+ ]
1469
+ }
1470
+ ],
1471
+ "source": [
1472
+ "# Load packing item data\n",
1473
+ "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
1474
+ " packing_items = json.load(file)\n",
1475
+ "\n",
1476
+ "unique_sorted = sorted({item for values in packing_items.values() for item in values})\n",
1477
+ "\n",
1478
+ "for item in unique_sorted:\n",
1479
+ " print(item)\n"
1480
+ ]
1481
+ },
1482
  {
1483
  "cell_type": "code",
1484
  "execution_count": null,
1485
+ "id": "e300e3f3-93e0-457b-b2f0-e05cc5c2cafb",
1486
  "metadata": {},
1487
  "outputs": [],
1488
  "source": []
space/space/space/space/requirements.txt CHANGED
@@ -1,8 +1,5 @@
1
  transformers
2
- json
3
  torch
4
  numpy
5
- tabulate
6
  pandas
7
- sklearn
8
  gradio
 
1
  transformers
 
2
  torch
3
  numpy
 
4
  pandas
 
5
  gradio
space/space/space/space/space/space/.ipynb_checkpoints/code_blog_post-checkpoint.ipynb ADDED
@@ -0,0 +1,398 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "fce70006-809b-4c98-b89c-00910b8bbea1",
6
+ "metadata": {},
7
+ "source": [
8
+ "Implementation for blog post"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "code",
13
+ "execution_count": 14,
14
+ "id": "1eaa3a9f-0b39-4d77-91d6-f935d226ac98",
15
+ "metadata": {},
16
+ "outputs": [],
17
+ "source": [
18
+ "import math\n",
19
+ "import json\n",
20
+ "import pickle\n",
21
+ "import os\n",
22
+ "import time\n",
23
+ "import pandas as pd\n",
24
+ "import matplotlib.pyplot as plt\n",
25
+ "from tabulate import tabulate\n",
26
+ "from transformers import pipeline\n",
27
+ "\n",
28
+ "# Get candidate labels\n",
29
+ "with open(\"packing_label_structure.json\", \"r\") as file:\n",
30
+ " candidate_labels = json.load(file)\n",
31
+ "keys_list = list(candidate_labels.keys())\n",
32
+ "\n",
33
+ "# Load test data (list of dictionaries)\n",
34
+ "# with open(\"test_data.json\", \"r\") as file:\n",
35
+ "# packing_data = json.load(file)\n",
36
+ "# Extract trip descriptions and classification (trip_types)\n",
37
+ "# trip_descriptions = [trip['description'] for trip in packing_data]\n",
38
+ "# trip_types = [trip['trip_types'] for trip in packing_data]\n"
39
+ ]
40
+ },
41
+ {
42
+ "cell_type": "code",
43
+ "execution_count": 19,
44
+ "id": "bb1bc7ed-227e-4c0b-b769-ead4daf01c57",
45
+ "metadata": {},
46
+ "outputs": [
47
+ {
48
+ "name": "stdout",
49
+ "output_type": "stream",
50
+ "text": [
51
+ "\n",
52
+ " activity_type :\n",
53
+ "\t hut trek (summer)\n",
54
+ "\t hut trek (winter)\n",
55
+ "\t camping trip (wild camping)\n",
56
+ "\t camping trip (campground)\n",
57
+ "\t ski tour / skitour\n",
58
+ "\t snowboard / splitboard trip\n",
59
+ "\t long-distance hike / thru-hike\n",
60
+ "\t digital nomad trip\n",
61
+ "\t city trip\n",
62
+ "\t road trip (car/camper)\n",
63
+ "\t festival trip\n",
64
+ "\t yoga / wellness retreat\n",
65
+ "\t micro-adventure / weekend trip\n",
66
+ "\t beach vacation\n",
67
+ "\t cultural exploration\n",
68
+ "\t nature escape\n",
69
+ "\n",
70
+ " activities :\n",
71
+ "\t swimming\n",
72
+ "\t going to the beach\n",
73
+ "\t relaxing\n",
74
+ "\t sightseeing\n",
75
+ "\t biking\n",
76
+ "\t running\n",
77
+ "\t skiing\n",
78
+ "\t cross-country skiing\n",
79
+ "\t ski touring\n",
80
+ "\t hiking\n",
81
+ "\t hut-to-hut hiking\n",
82
+ "\t rock climbing\n",
83
+ "\t ice climbing\n",
84
+ "\t snowshoe hiking\n",
85
+ "\t kayaking / canoeing\n",
86
+ "\t stand-up paddleboarding (SUP)\n",
87
+ "\t snorkeling\n",
88
+ "\t scuba diving\n",
89
+ "\t surfing\n",
90
+ "\t paragliding\n",
91
+ "\t horseback riding\n",
92
+ "\t photography\n",
93
+ "\t fishing\n",
94
+ "\t rafting\n",
95
+ "\t yoga\n",
96
+ "\n",
97
+ " climate_or_season :\n",
98
+ "\t cold destination / winter\n",
99
+ "\t warm destination / summer\n",
100
+ "\t variable weather / spring / autumn\n",
101
+ "\t tropical / humid\n",
102
+ "\t dry / desert-like\n",
103
+ "\t rainy climate\n",
104
+ "\n",
105
+ " style_or_comfort :\n",
106
+ "\t ultralight\n",
107
+ "\t lightweight (but comfortable)\n",
108
+ "\t luxury (including evening wear)\n",
109
+ "\t minimalist\n",
110
+ "\n",
111
+ " dress_code :\n",
112
+ "\t casual\n",
113
+ "\t formal (business trip)\n",
114
+ "\t conservative\n",
115
+ "\n",
116
+ " accommodation :\n",
117
+ "\t indoor\n",
118
+ "\t huts with half board\n",
119
+ "\t sleeping in a tent\n",
120
+ "\t sleeping in a car\n",
121
+ "\n",
122
+ " transportation :\n",
123
+ "\t own vehicle\n",
124
+ "\t no own vehicle\n",
125
+ "\n",
126
+ " special_conditions :\n",
127
+ "\t off-grid / no electricity\n",
128
+ "\t self-supported (bring your own cooking gear)\n",
129
+ "\t travel with children\n",
130
+ "\t pet-friendly\n",
131
+ "\t snow and ice\n",
132
+ "\t high alpine terrain\n",
133
+ "\t snow, ice and avalanche-prone terrain\n",
134
+ "\t no special conditions to consider\n",
135
+ "\n",
136
+ " trip_length_days :\n",
137
+ "\t 1 day\n",
138
+ "\t 2 days\n",
139
+ "\t 3 days\n",
140
+ "\t 4 days\n",
141
+ "\t 5 days\n",
142
+ "\t 6 days\n",
143
+ "\t 7 days\n",
144
+ "\t 7+ days\n"
145
+ ]
146
+ }
147
+ ],
148
+ "source": [
149
+ "for key in candidate_labels:\n",
150
+ " print(\"\\n\", key, \":\")\n",
151
+ " for item in candidate_labels[key]:\n",
152
+ " print(\"\\t\", item)\n"
153
+ ]
154
+ },
155
+ {
156
+ "cell_type": "code",
157
+ "execution_count": 20,
158
+ "id": "e114d7ab-9bd3-4214-a630-7f9166c3b8a5",
159
+ "metadata": {},
160
+ "outputs": [
161
+ {
162
+ "name": "stdout",
163
+ "output_type": "stream",
164
+ "text": [
165
+ "activity_type\n"
166
+ ]
167
+ }
168
+ ],
169
+ "source": [
170
+ "# First classify using first dimension of classes ()\n",
171
+ "print(keys_list[0])"
172
+ ]
173
+ },
174
+ {
175
+ "cell_type": "code",
176
+ "execution_count": 23,
177
+ "id": "4b3a1bcb-3450-4128-b941-952f145baf99",
178
+ "metadata": {},
179
+ "outputs": [
180
+ {
181
+ "name": "stderr",
182
+ "output_type": "stream",
183
+ "text": [
184
+ "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n"
185
+ ]
186
+ },
187
+ {
188
+ "name": "stdout",
189
+ "output_type": "stream",
190
+ "text": [
191
+ " Label Score\n",
192
+ "0 beach vacation 0.376311\n",
193
+ "1 micro-adventure / weekend trip 0.350168\n",
194
+ "2 nature escape 0.133974\n",
195
+ "3 digital nomad trip 0.031636\n",
196
+ "4 cultural exploration 0.031271\n",
197
+ "5 yoga / wellness retreat 0.012846\n",
198
+ "6 festival trip 0.012700\n",
199
+ "7 long-distance hike / thru-hike 0.009527\n",
200
+ "8 hut trek (summer) 0.008148\n",
201
+ "9 city trip 0.007793\n",
202
+ "10 road trip (car/camper) 0.006512\n",
203
+ "11 ski tour / skitour 0.005670\n",
204
+ "12 camping trip (campground) 0.004448\n",
205
+ "13 snowboard / splitboard trip 0.004113\n",
206
+ "14 camping trip (wild camping) 0.002714\n",
207
+ "15 hut trek (winter) 0.002170\n"
208
+ ]
209
+ }
210
+ ],
211
+ "source": [
212
+ "model_name = \"facebook/bart-large-mnli\"\n",
213
+ "trip_descr = \"I am planning a trip to Greece with my boyfriend, where we will visit two islands. We have booked an apartment on each island for a few days and plan to spend most of our time relaxing. Our main goals are to enjoy the beach, try delicious local food, and possibly go on a hike—if it’s not too hot. We will be relying solely on public transport. We’re in our late 20s and traveling from the Netherlands.\"\n",
214
+ "classifier = pipeline(\"zero-shot-classification\", model = model_name)\n",
215
+ "result = classifier(trip_descr, candidate_labels[keys_list[0]])\n",
216
+ "# Create DataFrame\n",
217
+ "df = pd.DataFrame({\n",
218
+ " \"Label\": result[\"labels\"],\n",
219
+ " \"Score\": result[\"scores\"]\n",
220
+ "})\n",
221
+ "print(df)"
222
+ ]
223
+ },
224
+ {
225
+ "cell_type": "code",
226
+ "execution_count": 25,
227
+ "id": "04208f9e-59bb-408b-92c6-941d064bf43d",
228
+ "metadata": {},
229
+ "outputs": [
230
+ {
231
+ "name": "stdout",
232
+ "output_type": "stream",
233
+ "text": [
234
+ "beach vacation\n"
235
+ ]
236
+ }
237
+ ],
238
+ "source": [
239
+ "# the labels are sorted by score. We choose the first one as our best guess for a class label\n",
240
+ "class_label = result[\"labels\"][0]\n",
241
+ "print(class_label)"
242
+ ]
243
+ },
244
+ {
245
+ "cell_type": "code",
246
+ "execution_count": 30,
247
+ "id": "9f5f1c45-b411-4de1-a0a6-a7ecde5d8eae",
248
+ "metadata": {},
249
+ "outputs": [
250
+ {
251
+ "name": "stdout",
252
+ "output_type": "stream",
253
+ "text": [
254
+ " Label Score\n",
255
+ "0 beach vacation 0.376311\n",
256
+ "1 micro-adventure / weekend trip 0.350168\n",
257
+ "2 nature escape 0.133974\n",
258
+ "3 digital nomad trip 0.031636\n",
259
+ "4 cultural exploration 0.031271\n",
260
+ "5 yoga / wellness retreat 0.012846\n",
261
+ "6 festival trip 0.012700\n",
262
+ "7 long-distance hike / thru-hike 0.009527\n",
263
+ "8 hut trek (summer) 0.008148\n",
264
+ "9 city trip 0.007793\n",
265
+ "10 road trip (car/camper) 0.006512\n",
266
+ "11 ski tour / skitour 0.005670\n",
267
+ "12 camping trip (campground) 0.004448\n",
268
+ "13 snowboard / splitboard trip 0.004113\n",
269
+ "14 camping trip (wild camping) 0.002714\n",
270
+ "15 hut trek (winter) 0.002170\n"
271
+ ]
272
+ }
273
+ ],
274
+ "source": [
275
+ "# we do this for each superclass and receive a list of class labels for our trip. We did do things differently for activities\n",
276
+ "cut_off = 0.5\n",
277
+ "result_activ = classifier(trip_descr, candidate_labels[\"activities\"], multi_label=True)\n",
278
+ "indices = [i for i, score in enumerate(result_activ['scores']) if score > cut_off]\n",
279
+ "classes = [result_activ['labels'][i] for i in indices]\n",
280
+ "\n",
281
+ "df = pd.DataFrame({\n",
282
+ " \"Label\": result[\"labels\"],\n",
283
+ " \"Score\": result[\"scores\"]\n",
284
+ "})\n",
285
+ "print(df)"
286
+ ]
287
+ },
288
+ {
289
+ "cell_type": "code",
290
+ "execution_count": 31,
291
+ "id": "7c5c50c4-7d58-4f5a-8f22-e4c06298a2f7",
292
+ "metadata": {},
293
+ "outputs": [
294
+ {
295
+ "name": "stdout",
296
+ "output_type": "stream",
297
+ "text": [
298
+ "['going to the beach', 'relaxing', 'hiking']\n"
299
+ ]
300
+ }
301
+ ],
302
+ "source": [
303
+ "print(classes)"
304
+ ]
305
+ },
306
+ {
307
+ "cell_type": "code",
308
+ "execution_count": 34,
309
+ "id": "3a7287c2-78f0-4a53-af72-1bc0f62da36f",
310
+ "metadata": {},
311
+ "outputs": [],
312
+ "source": [
313
+ "# doing this for all superclasses, depending on local machine this might take a while\n",
314
+ "def pred_trip(model_name, trip_descr, cut_off = 0.5):\n",
315
+ " \"\"\"\n",
316
+ " Classifies trip\n",
317
+ " \n",
318
+ " Parameters:\n",
319
+ " model_name: name of hugging-face model\n",
320
+ " trip_descr: text describing the trip\n",
321
+ " cut_off: cut_off for choosing activities\n",
322
+ "\n",
323
+ " Returns:\n",
324
+ " pd Dataframe: with class predictions and true values\n",
325
+ " \"\"\"\n",
326
+ " \n",
327
+ " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
328
+ " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
329
+ " for i, key in enumerate(keys_list):\n",
330
+ " print(f\"\\rProcessing {i}/{len(keys_list)}\", end=\"\", flush=True)\n",
331
+ " if key == 'activities':\n",
332
+ " result = classifier(trip_descr, candidate_labels[key], multi_label=True)\n",
333
+ " indices = [i for i, score in enumerate(result['scores']) if score > cut_off]\n",
334
+ " classes = [result['labels'][i] for i in indices]\n",
335
+ " else:\n",
336
+ " result = classifier(trip_descr, candidate_labels[key])\n",
337
+ " classes = result[\"labels\"][0]\n",
338
+ " df.loc[i] = [key, classes]\n",
339
+ " return df"
340
+ ]
341
+ },
342
+ {
343
+ "cell_type": "code",
344
+ "execution_count": null,
345
+ "id": "43481d4c-039a-4a37-bd6d-dfe638bf9732",
346
+ "metadata": {},
347
+ "outputs": [
348
+ {
349
+ "name": "stderr",
350
+ "output_type": "stream",
351
+ "text": [
352
+ "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n"
353
+ ]
354
+ },
355
+ {
356
+ "name": "stdout",
357
+ "output_type": "stream",
358
+ "text": [
359
+ "Processing 0/9..."
360
+ ]
361
+ }
362
+ ],
363
+ "source": [
364
+ "result = pred_trip(model_name, trip_descr, cut_off = 0.5)\n",
365
+ "print(result)"
366
+ ]
367
+ },
368
+ {
369
+ "cell_type": "code",
370
+ "execution_count": null,
371
+ "id": "73f6a8c7-3c5f-4620-b2a5-cd31079bfeb4",
372
+ "metadata": {},
373
+ "outputs": [],
374
+ "source": []
375
+ }
376
+ ],
377
+ "metadata": {
378
+ "kernelspec": {
379
+ "display_name": "Python (huggingface_env)",
380
+ "language": "python",
381
+ "name": "huggingface_env"
382
+ },
383
+ "language_info": {
384
+ "codemirror_mode": {
385
+ "name": "ipython",
386
+ "version": 3
387
+ },
388
+ "file_extension": ".py",
389
+ "mimetype": "text/x-python",
390
+ "name": "python",
391
+ "nbconvert_exporter": "python",
392
+ "pygments_lexer": "ipython3",
393
+ "version": "3.8.20"
394
+ }
395
+ },
396
+ "nbformat": 4,
397
+ "nbformat_minor": 5
398
+ }
space/space/space/space/space/space/.ipynb_checkpoints/packing_list_api-checkpoint.ipynb CHANGED
@@ -10,169 +10,621 @@
10
  },
11
  {
12
  "cell_type": "code",
13
- "execution_count": 1,
14
- "id": "05a29daa-b70e-4c7c-ba03-9ab641f424cb",
15
  "metadata": {},
16
- "outputs": [],
 
 
 
 
 
 
 
 
17
  "source": [
18
  "from dotenv import load_dotenv\n",
19
  "import os\n",
20
  "import requests\n",
21
  "\n",
22
  "load_dotenv() # Load environment variables from .env file, contains personal access token (HF_API_TOKEN=your_token)\n",
23
- "\n",
24
- "API_URL = \"https://api-inference.huggingface.co/models/facebook/bart-large-mnli\"\n",
25
- "# API_URL = \"https://api-inference.huggingface.co/models/MoritzLaurer/mDeBERTa-v3-base-mnli-xnli\"\n",
26
- "# API_URL = \"https://api-inference.huggingface.co/models/cross-encoder/nli-deberta-v3-base\"\n",
27
- "# API_URL = \"https://api-inference.huggingface.co/models/valhalla/distilbart-mnli-12-3\"\n",
28
  "headers = {\"Authorization\": f\"Bearer {os.getenv('HF_API_TOKEN')}\"}\n",
29
  "\n",
30
- "def query(payload):\n",
 
 
 
 
 
 
 
31
  " response = requests.post(API_URL, headers=headers, json=payload)\n",
32
  " return response.json()\n",
33
- "\n"
 
 
 
 
 
 
 
 
 
 
 
 
34
  ]
35
  },
36
  {
37
  "cell_type": "code",
38
- "execution_count": 2,
39
- "id": "21b4f8b6-e774-45ad-8054-bf5db2b7b07c",
40
  "metadata": {},
41
  "outputs": [
42
  {
43
  "name": "stdout",
44
  "output_type": "stream",
45
  "text": [
46
- "{'sequence': 'I just bought a new laptop, and it works amazing!', 'labels': ['technology', 'health', 'sports', 'politics'], 'scores': [0.9709171652793884, 0.014999167993664742, 0.008272457867860794, 0.005811102222651243]}\n"
 
 
47
  ]
48
  }
49
  ],
50
  "source": [
51
- "# Input text to classify\n",
52
- "input_text = \"I just bought a new laptop, and it works amazing!\"\n",
 
 
53
  "\n",
54
- "# Candidate labels\n",
55
- "candidate_labels = [\"technology\", \"sports\", \"politics\", \"health\"]\n",
 
 
 
 
56
  "\n",
57
- "# Get the prediction\n",
58
- "output = query({\"inputs\": input_text, \"parameters\": {\"candidate_labels\": candidate_labels}})\n",
59
- "print(output)\n"
 
 
 
 
 
 
 
 
 
60
  ]
61
  },
62
  {
63
  "cell_type": "markdown",
64
- "id": "fb7e69c7-b590-4b40-8478-76d055583f2a",
65
  "metadata": {},
66
  "source": [
67
- "**Try packing list labels**"
68
  ]
69
  },
70
  {
71
  "cell_type": "code",
72
- "execution_count": 25,
73
- "id": "c5f75916-aaf2-4ca7-8d1a-070579940952",
74
  "metadata": {},
75
  "outputs": [
76
  {
77
- "name": "stdout",
78
  "output_type": "stream",
79
  "text": [
80
- "{'error': ['Error in `parameters.candidate_labels`: ensure this value has at most 10 items']}\n"
 
 
 
81
  ]
82
  }
83
  ],
84
  "source": [
85
- "# Input text to classify\n",
86
- "input_text = \"I like to cycle and I burn easily. I also love culture and like to post on social media about my food. I will go on a trip to italy in july.\"\n",
87
- "\n",
88
- "# Candidate labels\n",
89
- "candidate_labels = [\n",
90
- " \"Swimsuit\", \"Sunscreen\", \"Flip-flops\", \"Beach towel\", \"Sunglasses\", \n",
91
- " \"Waterproof phone case\", \"Hat\", \"Beach bag\", \"Snorkel gear\", \"Aloe vera gel\",\n",
92
- " \"Tent\", \"Sleeping bag\", \"Camping stove\", \"Flashlight\", \"Hiking boots\",\n",
93
- " \"Water filter\", \"Compass\", \"First aid kit\", \"Bug spray\", \"Multi-tool\",\n",
94
- " \"Thermal clothing\", \"Ski jacket\", \"Ski goggles\", \"Snow boots\", \"Gloves\",\n",
95
- " \"Hand warmers\", \"Beanie\", \"Lip balm\", \"Snowboard\", \"Base layers\",\n",
96
- " \"Passport\", \"Visa documents\", \"Travel adapter\", \"Currency\", \"Language phrasebook\",\n",
97
- " \"SIM card\", \"Travel pillow\", \"Neck wallet\", \"Travel insurance documents\", \"Power bank\",\n",
98
- " \"Laptop\", \"Notebook\", \"Business attire\", \"Dress shoes\", \"Charging cables\",\n",
99
- " \"Presentation materials\", \"Work ID badge\", \"Pen\", \"Headphones\", \n",
100
- " \"Lightweight backpack\", \"Travel-sized toiletries\", \"Packable rain jacket\",\n",
101
- " \"Reusable water bottle\", \"Dry bag\", \"Trekking poles\", \"Hostel lock\", \"Quick-dry towel\",\n",
102
- " \"Travel journal\", \"Energy bars\", \"Car charger\", \"Snacks\", \"Map\",\n",
103
- " \"Sunglasses\", \"Cooler\", \"Blanket\", \"Emergency roadside kit\", \"Reusable coffee mug\",\n",
104
- " \"Playlist\", \"Reusable shopping bags\", \"Earplugs\", \"Fanny pack\", \"Portable charger\",\n",
105
- " \"Poncho\", \"Bandana\", \"Comfortable shoes\", \"Tent\", \"Refillable water bottle\",\n",
106
- " \"Glow sticks\", \"Festival tickets\", \"Diapers\", \"Baby wipes\", \"Baby food\",\n",
107
- " \"Stroller\", \"Pacifier\", \"Baby clothes\", \"Baby blanket\", \"Travel crib\",\n",
108
- " \"Toys\", \"Nursing cover\"\n",
109
- "]\n",
110
- "\n",
111
- "\n",
112
- "# Get the prediction\n",
113
- "output = query({\"inputs\": input_text, \"parameters\": {\"candidate_labels\": candidate_labels}})\n",
114
- "print(output)"
115
  ]
116
  },
117
  {
118
  "cell_type": "markdown",
119
- "id": "8a6318c1-fa5f-4d16-8507-eaebe6294ac0",
120
  "metadata": {},
121
  "source": [
122
- "**Use batches of 10 labels and combine results**"
123
  ]
124
  },
125
  {
126
  "cell_type": "code",
127
- "execution_count": 11,
128
- "id": "fe42a222-5ff4-4442-93f4-42fc22001af6",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  "metadata": {},
130
  "outputs": [
131
  {
132
  "name": "stdout",
133
  "output_type": "stream",
134
  "text": [
135
- "{'sequence': \"I'm going on a 2-week hiking trip in the Alps during winter.\", 'labels': ['Map', 'Backpack', 'Tent', 'Thermal clothing', 'Hiking boots', 'Flashlight', 'Gloves', 'Camping stove', 'Water filter', 'Sleeping bag'], 'scores': [0.30358555912971497, 0.12884855270385742, 0.10985139012336731, 0.10500500351190567, 0.10141848027706146, 0.08342219144105911, 0.0704946368932724, 0.05127469450235367, 0.024876652285456657, 0.021222807466983795]}\n",
136
- "{'sequence': \"I'm going on a 2-week hiking trip in the Alps during winter.\", 'labels': ['Ski jacket', 'Snow boots', 'Hand warmers', 'Beanie', 'Ski goggles', 'Flip-flops', 'First aid kit', 'Sunscreen', 'Swimsuit', 'Lip balm'], 'scores': [0.20171622931957245, 0.1621972620487213, 0.12313881516456604, 0.10742709040641785, 0.09418268501758575, 0.08230196684598923, 0.07371978461742401, 0.06208840385079384, 0.05506424233317375, 0.038163457065820694]}\n",
137
- "\n",
138
- "Recommended packing list: ['Map', 'Backpack', 'Tent', 'Thermal clothing', 'Hiking boots', 'Ski jacket', 'Snow boots', 'Hand warmers', 'Beanie']\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  ]
140
  }
141
  ],
142
  "source": [
 
 
 
 
143
  "\n",
144
- "input_text = \"I'm going on a 2-week hiking trip in the Alps during winter.\"\n",
145
- "\n",
146
- "\n",
147
- "# Define the full list of possible packing items (split into groups of 10)\n",
148
- "candidate_labels = [\n",
149
- " [\"Hiking boots\", \"Tent\", \"Sleeping bag\", \"Camping stove\", \"Backpack\",\n",
150
- " \"Water filter\", \"Flashlight\", \"Thermal clothing\", \"Gloves\", \"Map\"],\n",
151
- " \n",
152
- " [\"Swimsuit\", \"Sunscreen\", \"Flip-flops\", \"Ski jacket\", \"Ski goggles\",\n",
153
- " \"Snow boots\", \"Beanie\", \"Hand warmers\", \"Lip balm\", \"First aid kit\"]\n",
154
- "]\n",
 
 
 
 
 
 
 
 
 
 
155
  "\n",
156
- "# Run classification in batches\n",
157
- "packing_list = []\n",
158
- "for batch in candidate_labels:\n",
159
- " result = query({\"inputs\": input_text, \"parameters\": {\"candidate_labels\": batch}})\n",
160
- " print(result)\n",
161
- " for label, score in zip(result[\"labels\"], result[\"scores\"]):\n",
162
- " if score > 0.1: # Adjust threshold as needed\n",
163
- " packing_list.append(label)\n",
164
  "\n",
165
- "# Print the final packing list\n",
166
- "print(\"\\nRecommended packing list:\", packing_list)"
 
167
  ]
168
  },
169
  {
170
  "cell_type": "code",
171
- "execution_count": null,
172
- "id": "953b244c-0611-4706-a941-eac5064c643f",
173
  "metadata": {},
174
- "outputs": [],
175
- "source": []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  }
177
  ],
178
  "metadata": {
 
10
  },
11
  {
12
  "cell_type": "code",
13
+ "execution_count": 14,
14
+ "id": "966c6d6a-c2d7-405c-bf9b-1e1f1415234e",
15
  "metadata": {},
16
+ "outputs": [
17
+ {
18
+ "name": "stdout",
19
+ "output_type": "stream",
20
+ "text": [
21
+ "{'sequence': 'I just bought a new laptop, and it works amazing!', 'labels': ['technology', 'health', 'sports', 'politics'], 'scores': [0.970917284488678, 0.014999152161180973, 0.008272469975054264, 0.005811101291328669]}\n"
22
+ ]
23
+ }
24
+ ],
25
  "source": [
26
  "from dotenv import load_dotenv\n",
27
  "import os\n",
28
  "import requests\n",
29
  "\n",
30
  "load_dotenv() # Load environment variables from .env file, contains personal access token (HF_API_TOKEN=your_token)\n",
 
 
 
 
 
31
  "headers = {\"Authorization\": f\"Bearer {os.getenv('HF_API_TOKEN')}\"}\n",
32
  "\n",
33
+ "candidate_labels = [\"technology\", \"sports\", \"politics\", \"health\"]\n",
34
+ "\n",
35
+ "def query(model, input_text):\n",
36
+ " API_URL = f\"https://api-inference.huggingface.co/models/{model}\"\n",
37
+ " payload = {\n",
38
+ " \"inputs\": input_text,\n",
39
+ " \"parameters\": {\"candidate_labels\": candidate_labels}\n",
40
+ " }\n",
41
  " response = requests.post(API_URL, headers=headers, json=payload)\n",
42
  " return response.json()\n",
43
+ "\n",
44
+ "input_text = \"I just bought a new laptop, and it works amazing!\"\n",
45
+ "\n",
46
+ "output = query(\"facebook/bart-large-mnli\", input_text)\n",
47
+ "print(output)"
48
+ ]
49
+ },
50
+ {
51
+ "cell_type": "markdown",
52
+ "id": "edf44387-d166-4e0f-a8ad-621230aee115",
53
+ "metadata": {},
54
+ "source": [
55
+ "**Try to run a model locally**"
56
  ]
57
  },
58
  {
59
  "cell_type": "code",
60
+ "execution_count": 35,
61
+ "id": "1d01a363-572b-450c-8fce-0721234f9a1a",
62
  "metadata": {},
63
  "outputs": [
64
  {
65
  "name": "stdout",
66
  "output_type": "stream",
67
  "text": [
68
+ "First trip: 7-Day Island Beach Holiday in Greece (Summer). I am planning a trip to Greece with my boyfriend, where we will visit two islands. We have booked an apartment on each island for a few days and plan to spend most of our time relaxing. Our main goals are to enjoy the beach, try delicious local food, and possibly go on a hike—if it’s not too hot. We will be relying solely on public transport. We’re in our late 20s and traveling from the Netherlands. \n",
69
+ "\n",
70
+ "Packing list: ['bathing suit', 'beach towel', 'beach bag', 'sandals', 'comfortable walking shoes', 'light jacket', 'sunscreen', 'sunglasses', 'sunhat', 'entertainment for downtime (e.g. book/ebook, games, laptop, journal)', 'short pants/skirts', 't-shirts/tops']\n"
71
  ]
72
  }
73
  ],
74
  "source": [
75
+ "# Prerequisites\n",
76
+ "from tabulate import tabulate\n",
77
+ "from transformers import pipeline\n",
78
+ "import json\n",
79
  "\n",
80
+ "# input text\n",
81
+ "input_text = \"I like to cycle and I burn easily. I also love culture and like to post on social media about my food. I will go on a trip to italy in july.\"\n",
82
+ "\n",
83
+ "# Load labels from a txt file\n",
84
+ "with open(\"labels.txt\", \"r\", encoding=\"utf-8\") as f:\n",
85
+ " class_labels = [line.strip() for line in f if line.strip()]\n",
86
  "\n",
87
+ "# Load test data (in dictionary)\n",
88
+ "with open(\"test_data.json\", \"r\") as file:\n",
89
+ " packing_data = json.load(file)\n",
90
+ "# Get a list of trip descriptions (keys)\n",
91
+ "trips = list(packing_data.keys())\n",
92
+ "# Access the first trip description\n",
93
+ "first_trip = trips[0]\n",
94
+ "# Get the packing list for the secondfirst trip\n",
95
+ "first_trip_items = packing_data[first_trip]\n",
96
+ "\n",
97
+ "print(f\"First trip: {first_trip} \\n\")\n",
98
+ "print(f\"Packing list: {first_trip_items}\")"
99
  ]
100
  },
101
  {
102
  "cell_type": "markdown",
103
+ "id": "88aa1d7e-8a32-4530-9ddd-60fa38e4a342",
104
  "metadata": {},
105
  "source": [
106
+ "Load classifiers"
107
  ]
108
  },
109
  {
110
  "cell_type": "code",
111
+ "execution_count": 36,
112
+ "id": "d0d8f7c0-c2d9-4fbe-b1a7-699a5b99466c",
113
  "metadata": {},
114
  "outputs": [
115
  {
116
+ "name": "stderr",
117
  "output_type": "stream",
118
  "text": [
119
+ "Some weights of BartForSequenceClassification were not initialized from the model checkpoint at facebook/bart-base and are newly initialized: ['classification_head.dense.bias', 'classification_head.dense.weight', 'classification_head.out_proj.bias', 'classification_head.out_proj.weight']\n",
120
+ "You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n",
121
+ "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n",
122
+ "Failed to determine 'entailment' label id from the label2id mapping in the model config. Setting to -1. Define a descriptive label2id mapping in the model config to ensure correct outputs.\n"
123
  ]
124
  }
125
  ],
126
  "source": [
127
+ "# Load smaller the model and create a pipeline for zero-shot classification (1min loading + classifying with 89 labels)\n",
128
+ "classifier_bart_base = pipeline(\"zero-shot-classification\", model=\"facebook/bart-base\")"
129
+ ]
130
+ },
131
+ {
132
+ "cell_type": "code",
133
+ "execution_count": 37,
134
+ "id": "a971ca1c-d478-489f-9592-bc243d587eb4",
135
+ "metadata": {},
136
+ "outputs": [
137
+ {
138
+ "name": "stderr",
139
+ "output_type": "stream",
140
+ "text": [
141
+ "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n"
142
+ ]
143
+ }
144
+ ],
145
+ "source": [
146
+ "# Load larger the model and create a pipeline for zero-shot classification (5min loading model + classifying with 89 labels)\n",
147
+ "classifier_bart_large_mnli = pipeline(\"zero-shot-classification\", model=\"facebook/bart-large-mnli\")"
 
 
 
 
 
 
 
 
 
148
  ]
149
  },
150
  {
151
  "cell_type": "markdown",
152
+ "id": "38805499-9919-40fe-9d42-de6869ba01dc",
153
  "metadata": {},
154
  "source": [
155
+ "Try classifiers"
156
  ]
157
  },
158
  {
159
  "cell_type": "code",
160
+ "execution_count": 38,
161
+ "id": "abb13524-71c6-448d-948d-fb22a0e0ceeb",
162
+ "metadata": {},
163
+ "outputs": [
164
+ {
165
+ "name": "stderr",
166
+ "output_type": "stream",
167
+ "text": [
168
+ "Asking to truncate to max_length but no maximum length is provided and the model has no predefined maximum length. Default to no truncation.\n"
169
+ ]
170
+ }
171
+ ],
172
+ "source": [
173
+ "# Run the classification (ca 30 seconds classifying)\n",
174
+ "result_bart_base = classifier_bart_base(first_trip, class_labels)"
175
+ ]
176
+ },
177
+ {
178
+ "cell_type": "code",
179
+ "execution_count": 39,
180
+ "id": "116c7ee3-2b59-4623-a416-162c487aab70",
181
+ "metadata": {},
182
+ "outputs": [],
183
+ "source": [
184
+ "# Run the classification (ca 1 minute classifying)\n",
185
+ "result_bart_large_mnli = classifier_bart_large_mnli(first_trip, class_labels)"
186
+ ]
187
+ },
188
+ {
189
+ "cell_type": "code",
190
+ "execution_count": 40,
191
+ "id": "8591425b-ce55-4a36-a4b6-70974e8d4e59",
192
  "metadata": {},
193
  "outputs": [
194
  {
195
  "name": "stdout",
196
  "output_type": "stream",
197
  "text": [
198
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
199
+ "| bart_base | bart_large_mnli |\n",
200
+ "+======================================================================+======================================================================+\n",
201
+ "| bandana | travel adapter |\n",
202
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
203
+ "| lip balm | travel journal |\n",
204
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
205
+ "| hand warmers | light jacket |\n",
206
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
207
+ "| sim card | sim card |\n",
208
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
209
+ "| neck wallet | bathing suit |\n",
210
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
211
+ "| tent | multi-tool |\n",
212
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
213
+ "| poncho | dry bag |\n",
214
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
215
+ "| gloves | travel pillow |\n",
216
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
217
+ "| painkiller | base layers |\n",
218
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
219
+ "| pen | day pack |\n",
220
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
221
+ "| thin scarf | entertainment for downtime (e.g. book/ebook, games, laptop, journal) |\n",
222
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
223
+ "| wallet | passport |\n",
224
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
225
+ "| sleeping bag | thin scarf |\n",
226
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
227
+ "| dry bag | comfortable shoes |\n",
228
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
229
+ "| gifts | lightweight backpack |\n",
230
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
231
+ "| fanny pack | beach bag |\n",
232
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
233
+ "| beach towel | swimsuit |\n",
234
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
235
+ "| underwear | short pants/skirts |\n",
236
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
237
+ "| swimsuit | quick-dry towel |\n",
238
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
239
+ "| blanket | sunhat |\n",
240
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
241
+ "| laptop | local currency |\n",
242
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
243
+ "| quick-dry towel | tickets |\n",
244
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
245
+ "| ski jacket | wallet |\n",
246
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
247
+ "| emergency roadside kit | cardigan/sweater |\n",
248
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
249
+ "| passport | refillable water bottle |\n",
250
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
251
+ "| necessary medication | fanny pack |\n",
252
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
253
+ "| snacks for the journey | poncho |\n",
254
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
255
+ "| snow boots | thermal clothing |\n",
256
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
257
+ "| sunglasses | laptop |\n",
258
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
259
+ "| flip-flops | pen |\n",
260
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
261
+ "| phone and charger | big backpack/suitcase |\n",
262
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
263
+ "| socks | beach towel |\n",
264
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
265
+ "| local currency | currency |\n",
266
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
267
+ "| t-shirts/tops | blanket |\n",
268
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
269
+ "| bathing suit | compass |\n",
270
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
271
+ "| currency | beanie |\n",
272
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
273
+ "| cardigan/sweater | sunscreen |\n",
274
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
275
+ "| snowboard | phone and charger |\n",
276
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
277
+ "| visa documents | reusable coffee mug |\n",
278
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
279
+ "| shirts | power bank |\n",
280
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
281
+ "| headphones | personal toiletries (e.g. toothbrush, toothpaste) |\n",
282
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
283
+ "| pants | packable rain jacket |\n",
284
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
285
+ "| refillable water bottle | bandana |\n",
286
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
287
+ "| beach bag | short pants |\n",
288
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
289
+ "| big backpack/suitcase | business attire |\n",
290
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
291
+ "| multi-tool | sleeping bag |\n",
292
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
293
+ "| sandals | flashlight |\n",
294
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
295
+ "| tickets | t-shirts/tops |\n",
296
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
297
+ "| thermal clothing | waterproof phone case |\n",
298
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
299
+ "| short pants/skirts | long pants |\n",
300
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
301
+ "| light jacket | travel-sized toiletries |\n",
302
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
303
+ "| base layers | visa documents |\n",
304
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
305
+ "| snacks | sandals |\n",
306
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
307
+ "| comfortable shoes | hand warmers |\n",
308
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
309
+ "| lightweight backpack | hostel lock |\n",
310
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
311
+ "| winter shoes | headphones |\n",
312
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
313
+ "| dress shoes | emergency roadside kit |\n",
314
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
315
+ "| power bank | ski jacket |\n",
316
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
317
+ "| packable rain jacket | shirts |\n",
318
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
319
+ "| first aid kit | first aid kit |\n",
320
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
321
+ "| water filter | reusable shopping bags |\n",
322
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
323
+ "| short pants | flip-flops |\n",
324
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
325
+ "| ski goggles | camping stove |\n",
326
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
327
+ "| waterproof phone case | water filter |\n",
328
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
329
+ "| sunhat | gloves |\n",
330
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
331
+ "| flashlight | dress shoes |\n",
332
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
333
+ "| earplugs | tent |\n",
334
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
335
+ "| beanie | sunglasses |\n",
336
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
337
+ "| hostel lock | pants |\n",
338
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
339
+ "| personal toiletries (e.g. toothbrush, toothpaste) | charging cables |\n",
340
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
341
+ "| travel journal | snacks |\n",
342
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
343
+ "| reusable coffee mug | neck wallet |\n",
344
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
345
+ "| sunscreen | snacks for the journey |\n",
346
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
347
+ "| travel pillow | ski goggles |\n",
348
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
349
+ "| trekking poles | mosquito repellant |\n",
350
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
351
+ "| business attire | snorkel gear |\n",
352
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
353
+ "| snorkel gear | bug spray |\n",
354
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
355
+ "| reusable shopping bags | earplugs |\n",
356
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
357
+ "| sleep wear | travel insurance documents |\n",
358
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
359
+ "| camping stove | painkiller |\n",
360
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
361
+ "| travel-sized toiletries | hiking boots |\n",
362
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
363
+ "| hiking boots | necessary medication |\n",
364
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
365
+ "| travel insurance documents | socks |\n",
366
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
367
+ "| long pants | underwear |\n",
368
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
369
+ "| charging cables | trekking poles |\n",
370
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
371
+ "| entertainment for downtime (e.g. book/ebook, games, laptop, journal) | sleep wear |\n",
372
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
373
+ "| bug spray | gifts |\n",
374
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
375
+ "| day pack | lip balm |\n",
376
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
377
+ "| travel adapter | snowboard |\n",
378
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
379
+ "| malaria medication | malaria medication |\n",
380
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
381
+ "| compass | snow boots |\n",
382
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n",
383
+ "| mosquito repellant | winter shoes |\n",
384
+ "+----------------------------------------------------------------------+----------------------------------------------------------------------+\n"
385
  ]
386
  }
387
  ],
388
  "source": [
389
+ "# Creating a table\n",
390
+ "table = zip(result_bart_base[\"labels\"], \n",
391
+ " result_bart_large_mnli[\"labels\"])\n",
392
+ "headers = [\"bart_base\", \"bart_large_mnli\"]\n",
393
  "\n",
394
+ "print(tabulate(table, headers=headers, tablefmt=\"grid\"))\n"
395
+ ]
396
+ },
397
+ {
398
+ "cell_type": "markdown",
399
+ "id": "21a35d0c-9451-433a-b14c-87e8dac21d68",
400
+ "metadata": {},
401
+ "source": [
402
+ "**Try simple prompt engineering**"
403
+ ]
404
+ },
405
+ {
406
+ "cell_type": "code",
407
+ "execution_count": 12,
408
+ "id": "ee734de6-bbcb-427d-8987-ab41286f7907",
409
+ "metadata": {},
410
+ "outputs": [],
411
+ "source": [
412
+ "# No prompt\n",
413
+ "no_prompt = input_text\n",
414
+ "no_result = classifier(no_prompt, class_labels)\n",
415
  "\n",
416
+ "# Simple prompt\n",
417
+ "simple_prompt = \"Classify the following text: \" + input_text\n",
418
+ "simple_result = classifier(simple_prompt, class_labels)\n",
 
 
 
 
 
419
  "\n",
420
+ "# Primed prompt\n",
421
+ "primed_prompt = input_text + \"What are the most important things to pack for the trip?\"\n",
422
+ "primed_result = classifier(primed_prompt, class_labels)"
423
  ]
424
  },
425
  {
426
  "cell_type": "code",
427
+ "execution_count": 13,
428
+ "id": "96deb877-b3b0-4048-9960-d8b0b0d56cd0",
429
  "metadata": {},
430
+ "outputs": [
431
+ {
432
+ "name": "stdout",
433
+ "output_type": "stream",
434
+ "text": [
435
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
436
+ "| no_prompt | no_prompt | simple_prompt | simple_prompt | primed_prompt | primed_prompt |\n",
437
+ "+============================+=============+============================+=================+============================+=================+\n",
438
+ "| Travel-sized toiletries | 0.0141621 | Beanie | 0.0126489 | First aid kit | 0.0126422 |\n",
439
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
440
+ "| Refillable water bottle | 0.013635 | Baby wipes | 0.0125994 | Work ID badge | 0.0125781 |\n",
441
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
442
+ "| Aloe vera gel | 0.0135288 | Bandana | 0.0125701 | Travel insurance documents | 0.0125387 |\n",
443
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
444
+ "| Snorkel gear | 0.0135229 | Blanket | 0.0125266 | Business attire | 0.0124256 |\n",
445
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
446
+ "| Waterproof phone case | 0.0135219 | Sunglasses | 0.0123896 | Baby wipes | 0.012401 |\n",
447
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
448
+ "| Packable rain jacket | 0.0133905 | Sunglasses | 0.0123896 | Blanket | 0.0122619 |\n",
449
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
450
+ "| Reusable shopping bags | 0.0133134 | Laptop | 0.0123645 | Lightweight backpack | 0.0122291 |\n",
451
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
452
+ "| Reusable coffee mug | 0.012921 | Snacks | 0.0123038 | Sunglasses | 0.0121536 |\n",
453
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
454
+ "| Reusable water bottle | 0.012695 | Sunscreen | 0.0122985 | Sunglasses | 0.0121536 |\n",
455
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
456
+ "| First aid kit | 0.0124969 | Pen | 0.0122703 | Laptop | 0.0121034 |\n",
457
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
458
+ "| Travel insurance documents | 0.0124186 | Cooler | 0.0122299 | Passport | 0.0121023 |\n",
459
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
460
+ "| Work ID badge | 0.0123513 | Snowboard | 0.012205 | Beanie | 0.0120397 |\n",
461
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
462
+ "| Lightweight backpack | 0.0122867 | Passport | 0.0121188 | Baby clothes | 0.0120325 |\n",
463
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
464
+ "| Presentation materials | 0.0121707 | Visa documents | 0.0121176 | Snacks | 0.0119757 |\n",
465
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
466
+ "| Flip-flops | 0.0121665 | Swimsuit | 0.0120711 | Packable rain jacket | 0.011946 |\n",
467
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
468
+ "| Charging cables | 0.0121361 | Flashlight | 0.0120105 | Baby food | 0.0119228 |\n",
469
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
470
+ "| Hiking boots | 0.0121118 | Stroller | 0.0119368 | Baby blanket | 0.0118852 |\n",
471
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
472
+ "| Comfortable shoes | 0.0120349 | Map | 0.01193 | Dress shoes | 0.0118458 |\n",
473
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
474
+ "| Fanny pack | 0.011914 | First aid kit | 0.0119121 | Bug spray | 0.0118403 |\n",
475
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
476
+ "| Trekking poles | 0.0118607 | Notebook | 0.0118809 | Travel journal | 0.0118067 |\n",
477
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
478
+ "| Visa documents | 0.0118408 | Hat | 0.011833 | Travel pillow | 0.0118006 |\n",
479
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
480
+ "| Baby wipes | 0.0117297 | Currency | 0.0118279 | Visa documents | 0.0117734 |\n",
481
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
482
+ "| Quick-dry towel | 0.0116303 | Work ID badge | 0.0117867 | Emergency roadside kit | 0.0117412 |\n",
483
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
484
+ "| Baby blanket | 0.011586 | Travel insurance documents | 0.01168 | SIM card | 0.0117407 |\n",
485
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
486
+ "| Hostel lock | 0.0115573 | Business attire | 0.0116774 | Cooler | 0.0117317 |\n",
487
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
488
+ "| Blanket | 0.0114867 | Compass | 0.0116575 | Snowboard | 0.0117232 |\n",
489
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
490
+ "| Business attire | 0.0114801 | Playlist | 0.0116254 | Diapers | 0.0117056 |\n",
491
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
492
+ "| Laptop | 0.0112665 | Bug spray | 0.0115941 | Notebook | 0.011676 |\n",
493
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
494
+ "| Beanie | 0.0112438 | Tent | 0.0115531 | Bandana | 0.0116441 |\n",
495
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
496
+ "| Bug spray | 0.0112397 | Tent | 0.0115531 | Pen | 0.011614 |\n",
497
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
498
+ "| Travel pillow | 0.0111955 | Diapers | 0.0115231 | Flashlight | 0.011587 |\n",
499
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
500
+ "| Baby clothes | 0.0111946 | Travel journal | 0.0114808 | Playlist | 0.0115787 |\n",
501
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
502
+ "| Passport | 0.0111815 | Hiking boots | 0.0114734 | Sunscreen | 0.0115577 |\n",
503
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
504
+ "| Earplugs | 0.0111681 | Reusable shopping bags | 0.0114722 | Swimsuit | 0.0115468 |\n",
505
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
506
+ "| Camping stove | 0.0111419 | SIM card | 0.0114319 | Reusable coffee mug | 0.0115091 |\n",
507
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
508
+ "| Travel journal | 0.01114 | Toys | 0.0114257 | Trekking poles | 0.011476 |\n",
509
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
510
+ "| Emergency roadside kit | 0.011128 | Dress shoes | 0.0113439 | Sleeping bag | 0.0114472 |\n",
511
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
512
+ "| Baby food | 0.0110848 | Waterproof phone case | 0.0113438 | Hiking boots | 0.0114388 |\n",
513
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
514
+ "| Pen | 0.0110799 | Travel pillow | 0.0113271 | Snorkel gear | 0.0114219 |\n",
515
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
516
+ "| Bandana | 0.0110713 | Refillable water bottle | 0.0113269 | Reusable shopping bags | 0.0113664 |\n",
517
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
518
+ "| Dress shoes | 0.0110698 | Fanny pack | 0.0113193 | Portable charger | 0.0113632 |\n",
519
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
520
+ "| Snacks | 0.0110153 | Baby blanket | 0.0113175 | Fanny pack | 0.011333 |\n",
521
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
522
+ "| Travel crib | 0.0110133 | Aloe vera gel | 0.0113123 | Headphones | 0.0113156 |\n",
523
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
524
+ "| Sunscreen | 0.0109995 | Snorkel gear | 0.011283 | Currency | 0.0112893 |\n",
525
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
526
+ "| Ski goggles | 0.010981 | Pacifier | 0.0112826 | Travel adapter | 0.0112652 |\n",
527
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
528
+ "| Sunglasses | 0.0109759 | Headphones | 0.0112543 | Travel crib | 0.011224 |\n",
529
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
530
+ "| Sunglasses | 0.0109759 | Packable rain jacket | 0.0112416 | Presentation materials | 0.0112228 |\n",
531
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
532
+ "| Stroller | 0.0109661 | Poncho | 0.0112411 | Waterproof phone case | 0.0112181 |\n",
533
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
534
+ "| Lip balm | 0.0109645 | Nursing cover | 0.0112323 | Nursing cover | 0.0111811 |\n",
535
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
536
+ "| Notebook | 0.0109306 | Comfortable shoes | 0.0112138 | Beach bag | 0.0111739 |\n",
537
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
538
+ "| Glow sticks | 0.0108928 | Reusable coffee mug | 0.0112081 | Stroller | 0.0111447 |\n",
539
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
540
+ "| Cooler | 0.0108527 | Travel crib | 0.0111724 | Car charger | 0.0110935 |\n",
541
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
542
+ "| Snowboard | 0.0108444 | Baby clothes | 0.0111683 | Neck wallet | 0.0110586 |\n",
543
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
544
+ "| Map | 0.0108275 | Presentation materials | 0.0111555 | Lip balm | 0.0110534 |\n",
545
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
546
+ "| Thermal clothing | 0.0108054 | Baby food | 0.0111165 | Comfortable shoes | 0.0110398 |\n",
547
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
548
+ "| Neck wallet | 0.0107892 | Sleeping bag | 0.0110978 | Poncho | 0.0109919 |\n",
549
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
550
+ "| Water filter | 0.0107846 | Lightweight backpack | 0.011038 | Reusable water bottle | 0.0109792 |\n",
551
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
552
+ "| Travel adapter | 0.0107792 | Gloves | 0.010946 | Energy bars | 0.0109684 |\n",
553
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
554
+ "| Currency | 0.010762 | Portable charger | 0.0108962 | Map | 0.0109623 |\n",
555
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
556
+ "| Nursing cover | 0.0107438 | Trekking poles | 0.0108781 | Hostel lock | 0.0109603 |\n",
557
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
558
+ "| Snow boots | 0.0107272 | Charging cables | 0.0108504 | Power bank | 0.0109483 |\n",
559
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
560
+ "| Pacifier | 0.0107227 | Reusable water bottle | 0.0108255 | Thermal clothing | 0.0109311 |\n",
561
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
562
+ "| Sleeping bag | 0.0106966 | Neck wallet | 0.0108161 | Earplugs | 0.0109061 |\n",
563
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
564
+ "| Car charger | 0.0106959 | Beach bag | 0.0108042 | Charging cables | 0.0108819 |\n",
565
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
566
+ "| Diapers | 0.010669 | Travel-sized toiletries | 0.0107921 | Toys | 0.0108427 |\n",
567
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
568
+ "| Flashlight | 0.0106647 | Travel adapter | 0.0107415 | Ski jacket | 0.0108272 |\n",
569
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
570
+ "| Ski jacket | 0.0106418 | Hostel lock | 0.0106021 | Base layers | 0.0107343 |\n",
571
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
572
+ "| Portable charger | 0.0106307 | Thermal clothing | 0.0105911 | Glow sticks | 0.0106845 |\n",
573
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
574
+ "| Playlist | 0.0106083 | Car charger | 0.0105783 | Beach towel | 0.010634 |\n",
575
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
576
+ "| Swimsuit | 0.0105832 | Ski goggles | 0.0105752 | Water filter | 0.0106173 |\n",
577
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
578
+ "| Tent | 0.010549 | Ski jacket | 0.0105524 | Festival tickets | 0.0106124 |\n",
579
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
580
+ "| Tent | 0.010549 | Water filter | 0.010523 | Dry bag | 0.0105999 |\n",
581
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
582
+ "| SIM card | 0.0105225 | Festival tickets | 0.0105077 | Hat | 0.010555 |\n",
583
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
584
+ "| Compass | 0.0105095 | Dry bag | 0.0104999 | Tent | 0.0105432 |\n",
585
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
586
+ "| Multi-tool | 0.0104697 | Glow sticks | 0.0104861 | Tent | 0.0105432 |\n",
587
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
588
+ "| Hat | 0.0104314 | Beach towel | 0.0104595 | Refillable water bottle | 0.0105226 |\n",
589
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
590
+ "| Base layers | 0.0104078 | Earplugs | 0.0104484 | Language phrasebook | 0.0104878 |\n",
591
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
592
+ "| Energy bars | 0.0103765 | Emergency roadside kit | 0.01042 | Aloe vera gel | 0.0104495 |\n",
593
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
594
+ "| Toys | 0.0103667 | Energy bars | 0.010328 | Compass | 0.0102844 |\n",
595
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
596
+ "| Power bank | 0.010329 | Flip-flops | 0.010279 | Pacifier | 0.0102553 |\n",
597
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
598
+ "| Dry bag | 0.0102989 | Power bank | 0.0102667 | Flip-flops | 0.0102396 |\n",
599
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
600
+ "| Beach towel | 0.0102733 | Base layers | 0.0102346 | Ski goggles | 0.010229 |\n",
601
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
602
+ "| Beach bag | 0.0102259 | Multi-tool | 0.0101584 | Multi-tool | 0.0100441 |\n",
603
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
604
+ "| Poncho | 0.0100634 | Lip balm | 0.0101392 | Gloves | 0.0100095 |\n",
605
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
606
+ "| Headphones | 0.010053 | Snow boots | 0.0101161 | Hand warmers | 0.00999101 |\n",
607
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
608
+ "| Gloves | 0.010049 | Camping stove | 0.00999308 | Camping stove | 0.00982307 |\n",
609
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
610
+ "| Festival tickets | 0.00984126 | Language phrasebook | 0.00958238 | Travel-sized toiletries | 0.0097547 |\n",
611
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
612
+ "| Hand warmers | 0.00967844 | Quick-dry towel | 0.00957849 | Snow boots | 0.00964112 |\n",
613
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n",
614
+ "| Language phrasebook | 0.0093065 | Hand warmers | 0.00916433 | Quick-dry towel | 0.00960495 |\n",
615
+ "+----------------------------+-------------+----------------------------+-----------------+----------------------------+-----------------+\n"
616
+ ]
617
+ }
618
+ ],
619
+ "source": [
620
+ "# Creating a table\n",
621
+ "table = zip(no_result[\"labels\"], no_result[\"scores\"], \n",
622
+ " simple_result[\"labels\"], simple_result[\"scores\"], \n",
623
+ " primed_result[\"labels\"], primed_result[\"scores\"])\n",
624
+ "headers = [\"no_prompt\", \"no_prompt\", \"simple_prompt\", \"simple_prompt\", \"primed_prompt\", \"primed_prompt\"]\n",
625
+ "\n",
626
+ "print(tabulate(table, headers=headers, tablefmt=\"grid\"))\n"
627
+ ]
628
  }
629
  ],
630
  "metadata": {
space/space/space/space/space/space/README.md CHANGED
@@ -1,14 +1,14 @@
1
  ---
2
- title: Packing List
3
- emoji: 📚
4
  colorFrom: yellow
5
- colorTo: red
6
  sdk: gradio
7
- sdk_version: 5.20.1
8
  app_file: app.py
9
  pinned: false
10
- license: mit
11
- short_description: Receives a trip description and returns a packing list
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Test Space
3
+ emoji: 🌍
4
  colorFrom: yellow
5
+ colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 5.49.1
8
  app_file: app.py
9
  pinned: false
10
+ license: apache-2.0
11
+ short_description: Test for github access token
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
space/space/space/space/space/space/blog_post/article.md CHANGED
@@ -16,21 +16,145 @@
16
  ## Implementation of packing list model
17
  ### Prerequisites before you start to code: Anja
18
  * Hugging face account also use access token, mention api
 
 
 
 
 
19
  * Use anaconda
20
- * Install python and libraries
21
- * create jupyter notebook
22
- * pip install stuff
23
- * Hugging face API (or mention during implementation)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  ### Predefine outputs/classes: Nikky
26
 
27
  ### Model implementation: Anja
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  ### Using gradio app: Anja
30
 
31
  ### Share your model: Anja
32
  * created space
33
- * created github access token on huffing face and then github actions workflow
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  * you need to install the required dependencies in the environment where your Hugging Face Space is running.
35
  * create requirements.txt file with necessary libraries
36
 
 
16
  ## Implementation of packing list model
17
  ### Prerequisites before you start to code: Anja
18
  * Hugging face account also use access token, mention api
19
+ Hugging face is..."The platform where the machine learning community collaborates on models, datasets, and applications."(from hugging face)
20
+ "Hugging Face is a company and open-source community that builds tools for machine learning (ML) and artificial intelligence (AI) — especially in the field of natural language processing (NLP)."(from the chate)
21
+ To be able to use the full funcitonality (e.g. models, spaces, data sets, api access) and most access you need to make a hugging face account here (https://huggingface.co/)
22
+ There is a new course at data camp free for the remainder of 2025: https://huggingface.co/blog/huggingface/datacamp-ai-courses
23
+
24
  * Use anaconda
25
+ "Without a package and environment manager like Conda"(anaconda site)
26
+ We used the anaconda navigator as a package and environment manager and used the jupyter notebook through there. python is automatically installed.
27
+ In the terminal activate the conda environment that you created previously by navigating (see cheat sheet here https://docs.conda.io/projects/conda/en/4.6.0/_downloads/52a95608c49671267e40c689e0bc00ca/conda-cheatsheet.pdf)
28
+
29
+ View list of environments
30
+ ```bash
31
+ conda env list
32
+ ```
33
+
34
+ Activate correct environment
35
+ ```bash
36
+ conda activate ENVIRONMENT_NAME
37
+ ```
38
+
39
+ Install packages using pip
40
+ ```bash
41
+ pip install transformers torch numpy tabulate gradio pandas sklearn
42
+ # pip install -r requirements.txt
43
+ ```
44
+
45
+ Install jupyter notebook
46
+ ```bash
47
+ conda install jupyter
48
+ ```
49
+
50
+ Start up jupyter notebook
51
+ ```bash
52
+ jupyter-notebook
53
+ ```
54
+ Create a new jupyter notebook
55
+
56
+ #### Hugging face API
57
+ Let us first try out some hugging face models using their API. The advantage of using the API is that you do not need to download the model locally and the computation is handled by hugging face on their servers.
58
+ To do this you need to make an accesstoken on the hugging face website.
59
+ Log in > Settings (on left side) > Access Tokens (on left side) > + Create new token
60
+ Give token a name
61
+ * how to implement the token in your code
62
+ This access token now has to be saved in you projecct folder in a .env file. Create a plan text file that you call .env. Within it you write:
63
+ ```text
64
+ HF_API_TOKEN=YOUR_OWN_ACCESS_TOKEN
65
+ ```
66
+ and save it.
67
+
68
+
69
+ Now we load a zero-shot-classification model using API and male a simple classification.
70
+ ```python
71
+ from dotenv import load_dotenv
72
+ import os
73
+ import requests
74
+
75
+ load_dotenv() # Load environment variables from .env file, contains personal access token (HF_API_TOKEN=your_token)
76
+ headers = {"Authorization": f"Bearer {os.getenv('HF_API_TOKEN')}"}
77
+
78
+ candidate_labels = ["technology", "sports", "politics", "health"]
79
+
80
+ def query(model, input_text):
81
+ API_URL = f"https://api-inference.huggingface.co/models/{model}"
82
+ payload = {
83
+ "inputs": input_text,
84
+ "parameters": {"candidate_labels": candidate_labels}
85
+ }
86
+ response = requests.post(API_URL, headers=headers, json=payload)
87
+ return response.json()
88
+
89
+ input_text = "I just bought a new laptop, and it works amazing!"
90
+
91
+ output = query("facebook/bart-large-mnli", input_text)
92
+ print(output)
93
+ ```
94
+
95
+ ```json
96
+ {'sequence': 'I just bought a new laptop, and it works amazing!', 'labels': ['technology', 'health', 'sports', 'politics'], 'scores': [0.970917284488678, 0.014999152161180973, 0.008272469975054264, 0.005811101291328669]}
97
+ ```
98
+
99
+ However the functionality using API is limited and we were only allowed to use 10 candidate labels for our models. This was not sufficient for our packing list example.
100
+
101
 
102
  ### Predefine outputs/classes: Nikky
103
 
104
  ### Model implementation: Anja
105
+ Prerequisites
106
+ ```python
107
+ import math
108
+ import json
109
+ import pickle
110
+ import os
111
+ import time
112
+ import pandas as pd
113
+ import matplotlib.pyplot as plt
114
+ from tabulate import tabulate
115
+ from transformers import pipeline
116
+
117
+ # Get candidate labels
118
+ with open("packing_label_structure.json", "r") as file:
119
+ candidate_labels = json.load(file)
120
+ keys_list = list(candidate_labels.keys())
121
+
122
+ # Load test data (list of dictionaries)
123
+ with open("test_data.json", "r") as file:
124
+ packing_data = json.load(file)
125
+ # Extract trip descriptions and classification (trip_types)
126
+ trip_descriptions = [trip['description'] for trip in packing_data]
127
+ trip_types = [trip['trip_types'] for trip in packing_data]
128
+ ```
129
+
130
+ ```python
131
+ classifier = pipeline("zero-shot-classification", model=model_name)
132
+ result = classifier(trip_descr, candidate_labels[key])
133
+ print(result)
134
+ ```
135
 
136
  ### Using gradio app: Anja
137
 
138
  ### Share your model: Anja
139
  * created space
140
+ An easy way to share your modle is using hugging face spaces. Go to https://huggingface.co/spaces and click on "+ New Space", as SDK choose Gradio and as template Blank, as Space hardware you can choose "CPU Basic", and click on "Create Space" to create your space.
141
+ * space as remote repository
142
+ connected to your space is a remote git repository that you can push your code to. For this navigate to your project folder in the terminal
143
+
144
+ ```bash
145
+ cd path/to/your/project
146
+ git init
147
+ ```
148
+
149
+ And connect your hugging face space as a remote repository
150
+
151
+ ```bash
152
+ git remote add origin https://huggingface.co/spaces/<username>/<space-name>
153
+ ```
154
+
155
+ generate an access token for your space here
156
+
157
+
158
  * you need to install the required dependencies in the environment where your Hugging Face Space is running.
159
  * create requirements.txt file with necessary libraries
160
 
space/space/space/space/space/space/code_blog_post.ipynb ADDED
@@ -0,0 +1,619 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "fce70006-809b-4c98-b89c-00910b8bbea1",
6
+ "metadata": {},
7
+ "source": [
8
+ "Implementation for blog post"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "code",
13
+ "execution_count": 14,
14
+ "id": "1eaa3a9f-0b39-4d77-91d6-f935d226ac98",
15
+ "metadata": {},
16
+ "outputs": [],
17
+ "source": [
18
+ "import math\n",
19
+ "import pickle\n",
20
+ "import os\n",
21
+ "import time\n",
22
+ "import matplotlib.pyplot as plt\n",
23
+ "from tabulate import tabulate\n",
24
+ "\n",
25
+ "from transformers import pipeline\n",
26
+ "import json\n",
27
+ "import pandas as pd\n",
28
+ "\n",
29
+ "# Get candidate labels\n",
30
+ "with open(\"packing_label_structure.json\", \"r\") as file:\n",
31
+ " candidate_labels = json.load(file)\n",
32
+ "keys_list = list(candidate_labels.keys())\n",
33
+ "\n",
34
+ "# Load test data (list of dictionaries)\n",
35
+ "# with open(\"test_data.json\", \"r\") as file:\n",
36
+ "# packing_data = json.load(file)\n",
37
+ "# Extract trip descriptions and classification (trip_types)\n",
38
+ "# trip_descriptions = [trip['description'] for trip in packing_data]\n",
39
+ "# trip_types = [trip['trip_types'] for trip in packing_data]\n"
40
+ ]
41
+ },
42
+ {
43
+ "cell_type": "code",
44
+ "execution_count": 19,
45
+ "id": "bb1bc7ed-227e-4c0b-b769-ead4daf01c57",
46
+ "metadata": {},
47
+ "outputs": [
48
+ {
49
+ "name": "stdout",
50
+ "output_type": "stream",
51
+ "text": [
52
+ "\n",
53
+ " activity_type :\n",
54
+ "\t hut trek (summer)\n",
55
+ "\t hut trek (winter)\n",
56
+ "\t camping trip (wild camping)\n",
57
+ "\t camping trip (campground)\n",
58
+ "\t ski tour / skitour\n",
59
+ "\t snowboard / splitboard trip\n",
60
+ "\t long-distance hike / thru-hike\n",
61
+ "\t digital nomad trip\n",
62
+ "\t city trip\n",
63
+ "\t road trip (car/camper)\n",
64
+ "\t festival trip\n",
65
+ "\t yoga / wellness retreat\n",
66
+ "\t micro-adventure / weekend trip\n",
67
+ "\t beach vacation\n",
68
+ "\t cultural exploration\n",
69
+ "\t nature escape\n",
70
+ "\n",
71
+ " activities :\n",
72
+ "\t swimming\n",
73
+ "\t going to the beach\n",
74
+ "\t relaxing\n",
75
+ "\t sightseeing\n",
76
+ "\t biking\n",
77
+ "\t running\n",
78
+ "\t skiing\n",
79
+ "\t cross-country skiing\n",
80
+ "\t ski touring\n",
81
+ "\t hiking\n",
82
+ "\t hut-to-hut hiking\n",
83
+ "\t rock climbing\n",
84
+ "\t ice climbing\n",
85
+ "\t snowshoe hiking\n",
86
+ "\t kayaking / canoeing\n",
87
+ "\t stand-up paddleboarding (SUP)\n",
88
+ "\t snorkeling\n",
89
+ "\t scuba diving\n",
90
+ "\t surfing\n",
91
+ "\t paragliding\n",
92
+ "\t horseback riding\n",
93
+ "\t photography\n",
94
+ "\t fishing\n",
95
+ "\t rafting\n",
96
+ "\t yoga\n",
97
+ "\n",
98
+ " climate_or_season :\n",
99
+ "\t cold destination / winter\n",
100
+ "\t warm destination / summer\n",
101
+ "\t variable weather / spring / autumn\n",
102
+ "\t tropical / humid\n",
103
+ "\t dry / desert-like\n",
104
+ "\t rainy climate\n",
105
+ "\n",
106
+ " style_or_comfort :\n",
107
+ "\t ultralight\n",
108
+ "\t lightweight (but comfortable)\n",
109
+ "\t luxury (including evening wear)\n",
110
+ "\t minimalist\n",
111
+ "\n",
112
+ " dress_code :\n",
113
+ "\t casual\n",
114
+ "\t formal (business trip)\n",
115
+ "\t conservative\n",
116
+ "\n",
117
+ " accommodation :\n",
118
+ "\t indoor\n",
119
+ "\t huts with half board\n",
120
+ "\t sleeping in a tent\n",
121
+ "\t sleeping in a car\n",
122
+ "\n",
123
+ " transportation :\n",
124
+ "\t own vehicle\n",
125
+ "\t no own vehicle\n",
126
+ "\n",
127
+ " special_conditions :\n",
128
+ "\t off-grid / no electricity\n",
129
+ "\t self-supported (bring your own cooking gear)\n",
130
+ "\t travel with children\n",
131
+ "\t pet-friendly\n",
132
+ "\t snow and ice\n",
133
+ "\t high alpine terrain\n",
134
+ "\t snow, ice and avalanche-prone terrain\n",
135
+ "\t no special conditions to consider\n",
136
+ "\n",
137
+ " trip_length_days :\n",
138
+ "\t 1 day\n",
139
+ "\t 2 days\n",
140
+ "\t 3 days\n",
141
+ "\t 4 days\n",
142
+ "\t 5 days\n",
143
+ "\t 6 days\n",
144
+ "\t 7 days\n",
145
+ "\t 7+ days\n"
146
+ ]
147
+ }
148
+ ],
149
+ "source": [
150
+ "for key in candidate_labels:\n",
151
+ " print(\"\\n\", key, \":\")\n",
152
+ " for item in candidate_labels[key]:\n",
153
+ " print(\"\\t\", item)\n"
154
+ ]
155
+ },
156
+ {
157
+ "cell_type": "code",
158
+ "execution_count": 20,
159
+ "id": "e114d7ab-9bd3-4214-a630-7f9166c3b8a5",
160
+ "metadata": {},
161
+ "outputs": [
162
+ {
163
+ "name": "stdout",
164
+ "output_type": "stream",
165
+ "text": [
166
+ "activity_type\n"
167
+ ]
168
+ }
169
+ ],
170
+ "source": [
171
+ "# First classify using first dimension of classes ()\n",
172
+ "print(keys_list[0])"
173
+ ]
174
+ },
175
+ {
176
+ "cell_type": "code",
177
+ "execution_count": 40,
178
+ "id": "4b3a1bcb-3450-4128-b941-952f145baf99",
179
+ "metadata": {},
180
+ "outputs": [
181
+ {
182
+ "name": "stderr",
183
+ "output_type": "stream",
184
+ "text": [
185
+ "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n"
186
+ ]
187
+ },
188
+ {
189
+ "name": "stdout",
190
+ "output_type": "stream",
191
+ "text": [
192
+ " Label Score\n",
193
+ "0 beach vacation 0.376311\n",
194
+ "1 micro-adventure / weekend trip 0.350168\n",
195
+ "2 nature escape 0.133974\n",
196
+ "3 digital nomad trip 0.031636\n",
197
+ "4 cultural exploration 0.031271\n",
198
+ "5 yoga / wellness retreat 0.012846\n",
199
+ "6 festival trip 0.012700\n",
200
+ "7 long-distance hike / thru-hike 0.009527\n",
201
+ "8 hut trek (summer) 0.008148\n",
202
+ "9 city trip 0.007793\n",
203
+ "10 road trip (car/camper) 0.006512\n",
204
+ "11 ski tour / skitour 0.005670\n",
205
+ "12 camping trip (campground) 0.004448\n",
206
+ "13 snowboard / splitboard trip 0.004113\n",
207
+ "14 camping trip (wild camping) 0.002714\n",
208
+ "15 hut trek (winter) 0.002170\n"
209
+ ]
210
+ }
211
+ ],
212
+ "source": [
213
+ "model_name = \"facebook/bart-large-mnli\"\n",
214
+ "trip_descr = \"I am planning a trip to Greece with my boyfriend, where we will visit two islands. We have booked an apartment on each island for a few days and plan to spend most of our time relaxing. Our main goals are to enjoy the beach, try delicious local food, and possibly go on a hike—if it’s not too hot. We will be relying solely on public transport. We’re in our late 20s and traveling from the Netherlands.\"\n",
215
+ "classifier = pipeline(\"zero-shot-classification\", model = model_name)\n",
216
+ "result = classifier(trip_descr, candidate_labels[keys_list[0]])\n",
217
+ "# Create DataFrame\n",
218
+ "df = pd.DataFrame({\n",
219
+ " \"Label\": result[\"labels\"],\n",
220
+ " \"Score\": result[\"scores\"]\n",
221
+ "})\n",
222
+ "print(df)"
223
+ ]
224
+ },
225
+ {
226
+ "cell_type": "code",
227
+ "execution_count": 25,
228
+ "id": "04208f9e-59bb-408b-92c6-941d064bf43d",
229
+ "metadata": {},
230
+ "outputs": [
231
+ {
232
+ "name": "stdout",
233
+ "output_type": "stream",
234
+ "text": [
235
+ "beach vacation\n"
236
+ ]
237
+ }
238
+ ],
239
+ "source": [
240
+ "# the labels are sorted by score. We choose the first one as our best guess for a class label\n",
241
+ "class_label = result[\"labels\"][0]\n",
242
+ "print(class_label)"
243
+ ]
244
+ },
245
+ {
246
+ "cell_type": "code",
247
+ "execution_count": 30,
248
+ "id": "9f5f1c45-b411-4de1-a0a6-a7ecde5d8eae",
249
+ "metadata": {},
250
+ "outputs": [
251
+ {
252
+ "name": "stdout",
253
+ "output_type": "stream",
254
+ "text": [
255
+ " Label Score\n",
256
+ "0 beach vacation 0.376311\n",
257
+ "1 micro-adventure / weekend trip 0.350168\n",
258
+ "2 nature escape 0.133974\n",
259
+ "3 digital nomad trip 0.031636\n",
260
+ "4 cultural exploration 0.031271\n",
261
+ "5 yoga / wellness retreat 0.012846\n",
262
+ "6 festival trip 0.012700\n",
263
+ "7 long-distance hike / thru-hike 0.009527\n",
264
+ "8 hut trek (summer) 0.008148\n",
265
+ "9 city trip 0.007793\n",
266
+ "10 road trip (car/camper) 0.006512\n",
267
+ "11 ski tour / skitour 0.005670\n",
268
+ "12 camping trip (campground) 0.004448\n",
269
+ "13 snowboard / splitboard trip 0.004113\n",
270
+ "14 camping trip (wild camping) 0.002714\n",
271
+ "15 hut trek (winter) 0.002170\n"
272
+ ]
273
+ }
274
+ ],
275
+ "source": [
276
+ "# we do this for each superclass and receive a list of class labels for our trip. We did do things differently for activities\n",
277
+ "cut_off = 0.5\n",
278
+ "result_activ = classifier(trip_descr, candidate_labels[\"activities\"], multi_label=True)\n",
279
+ "indices = [i for i, score in enumerate(result_activ['scores']) if score > cut_off]\n",
280
+ "classes = [result_activ['labels'][i] for i in indices]\n",
281
+ "\n",
282
+ "df = pd.DataFrame({\n",
283
+ " \"Label\": result[\"labels\"],\n",
284
+ " \"Score\": result[\"scores\"]\n",
285
+ "})\n",
286
+ "print(df)"
287
+ ]
288
+ },
289
+ {
290
+ "cell_type": "code",
291
+ "execution_count": 31,
292
+ "id": "7c5c50c4-7d58-4f5a-8f22-e4c06298a2f7",
293
+ "metadata": {},
294
+ "outputs": [
295
+ {
296
+ "name": "stdout",
297
+ "output_type": "stream",
298
+ "text": [
299
+ "['going to the beach', 'relaxing', 'hiking']\n"
300
+ ]
301
+ }
302
+ ],
303
+ "source": [
304
+ "print(classes)"
305
+ ]
306
+ },
307
+ {
308
+ "cell_type": "code",
309
+ "execution_count": 45,
310
+ "id": "3a7287c2-78f0-4a53-af72-1bc0f62da36f",
311
+ "metadata": {},
312
+ "outputs": [],
313
+ "source": [
314
+ "# doing this for all superclasses, depending on local machine this might take a while\n",
315
+ "def pred_trip(model_name, trip_descr, cut_off = 0.5):\n",
316
+ " \"\"\"\n",
317
+ " Classifies trip\n",
318
+ " \n",
319
+ " Parameters:\n",
320
+ " model_name: name of hugging-face model\n",
321
+ " trip_descr: text describing the trip\n",
322
+ " cut_off: cut_off for choosing activities\n",
323
+ "\n",
324
+ " Returns:\n",
325
+ " pd Dataframe: with class predictions and true values\n",
326
+ " \"\"\"\n",
327
+ " \n",
328
+ " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
329
+ " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
330
+ " for i, key in enumerate(keys_list):\n",
331
+ " print(f\"\\rProcessing {i + 1}/{len(keys_list)}\", end=\"\", flush=True)\n",
332
+ " if key == 'activities':\n",
333
+ " result = classifier(trip_descr, candidate_labels[key], multi_label=True)\n",
334
+ " indices = [i for i, score in enumerate(result['scores']) if score > cut_off]\n",
335
+ " classes = [result['labels'][i] for i in indices]\n",
336
+ " else:\n",
337
+ " result = classifier(trip_descr, candidate_labels[key])\n",
338
+ " classes = result[\"labels\"][0]\n",
339
+ " df.loc[i] = [key, classes]\n",
340
+ " return df"
341
+ ]
342
+ },
343
+ {
344
+ "cell_type": "code",
345
+ "execution_count": 35,
346
+ "id": "43481d4c-039a-4a37-bd6d-dfe638bf9732",
347
+ "metadata": {},
348
+ "outputs": [
349
+ {
350
+ "name": "stderr",
351
+ "output_type": "stream",
352
+ "text": [
353
+ "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n"
354
+ ]
355
+ },
356
+ {
357
+ "name": "stdout",
358
+ "output_type": "stream",
359
+ "text": [
360
+ "Processing 8/9... superclass pred_class\n",
361
+ "0 activity_type beach vacation\n",
362
+ "1 activities [going to the beach, relaxing, hiking]\n",
363
+ "2 climate_or_season warm destination / summer\n",
364
+ "3 style_or_comfort minimalist\n",
365
+ "4 dress_code casual\n",
366
+ "5 accommodation huts with half board\n",
367
+ "6 transportation no own vehicle\n",
368
+ "7 special_conditions off-grid / no electricity\n",
369
+ "8 trip_length_days 7+ days\n"
370
+ ]
371
+ }
372
+ ],
373
+ "source": [
374
+ "result = pred_trip(model_name, trip_descr, cut_off = 0.5)\n",
375
+ "print(result)"
376
+ ]
377
+ },
378
+ {
379
+ "cell_type": "markdown",
380
+ "id": "c4799d6b-6ab5-42da-a992-afe3666d0015",
381
+ "metadata": {},
382
+ "source": [
383
+ "Now use gradio app"
384
+ ]
385
+ },
386
+ {
387
+ "cell_type": "code",
388
+ "execution_count": 37,
389
+ "id": "35e14ac8-4445-4586-a115-081cf1ef2686",
390
+ "metadata": {},
391
+ "outputs": [],
392
+ "source": [
393
+ "# Prerequisites\n",
394
+ "from transformers import pipeline\n",
395
+ "import json\n",
396
+ "import pandas as pd\n",
397
+ "import gradio as gr\n",
398
+ "\n",
399
+ "# get candidate labels\n",
400
+ "with open(\"packing_label_structure.json\", \"r\") as file:\n",
401
+ " candidate_labels = json.load(file)\n",
402
+ "keys_list = list(candidate_labels.keys())\n",
403
+ "\n",
404
+ "# Load test data (in list of dictionaries)\n",
405
+ "with open(\"test_data.json\", \"r\") as file:\n",
406
+ " packing_data = json.load(file)\n",
407
+ "\n",
408
+ "# Load packing item data\n",
409
+ "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
410
+ " packing_items = json.load(file)"
411
+ ]
412
+ },
413
+ {
414
+ "cell_type": "code",
415
+ "execution_count": 39,
416
+ "id": "8eefd4cc-c375-4cc0-956b-472b36bafdb7",
417
+ "metadata": {},
418
+ "outputs": [
419
+ {
420
+ "name": "stdout",
421
+ "output_type": "stream",
422
+ "text": [
423
+ "Running on local URL: http://127.0.0.1:7861\n",
424
+ "\n",
425
+ "Thanks for being a Gradio user! If you have questions or feedback, please join our Discord server and chat with us: https://discord.gg/feTf9x3ZSB\n",
426
+ "\n",
427
+ "To create a public link, set `share=True` in `launch()`.\n"
428
+ ]
429
+ },
430
+ {
431
+ "data": {
432
+ "text/html": [
433
+ "<div><iframe src=\"http://127.0.0.1:7861/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
434
+ ],
435
+ "text/plain": [
436
+ "<IPython.core.display.HTML object>"
437
+ ]
438
+ },
439
+ "metadata": {},
440
+ "output_type": "display_data"
441
+ },
442
+ {
443
+ "name": "stderr",
444
+ "output_type": "stream",
445
+ "text": [
446
+ "Traceback (most recent call last):\n",
447
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/utils/_http.py\", line 406, in hf_raise_for_status\n",
448
+ " response.raise_for_status()\n",
449
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/requests/models.py\", line 1024, in raise_for_status\n",
450
+ " raise HTTPError(http_error_msg, response=self)\n",
451
+ "requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli/resolve/main/config.json\n",
452
+ "\n",
453
+ "The above exception was the direct cause of the following exception:\n",
454
+ "\n",
455
+ "Traceback (most recent call last):\n",
456
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/utils/hub.py\", line 403, in cached_file\n",
457
+ " resolved_file = hf_hub_download(\n",
458
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py\", line 114, in _inner_fn\n",
459
+ " return fn(*args, **kwargs)\n",
460
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 860, in hf_hub_download\n",
461
+ " return _hf_hub_download_to_cache_dir(\n",
462
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 967, in _hf_hub_download_to_cache_dir\n",
463
+ " _raise_on_head_call_error(head_call_error, force_download, local_files_only)\n",
464
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 1482, in _raise_on_head_call_error\n",
465
+ " raise head_call_error\n",
466
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 1374, in _get_metadata_or_catch_error\n",
467
+ " metadata = get_hf_file_metadata(\n",
468
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py\", line 114, in _inner_fn\n",
469
+ " return fn(*args, **kwargs)\n",
470
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 1294, in get_hf_file_metadata\n",
471
+ " r = _request_wrapper(\n",
472
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 278, in _request_wrapper\n",
473
+ " response = _request_wrapper(\n",
474
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/file_download.py\", line 302, in _request_wrapper\n",
475
+ " hf_raise_for_status(response)\n",
476
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/huggingface_hub/utils/_http.py\", line 454, in hf_raise_for_status\n",
477
+ " raise _format(RepositoryNotFoundError, message, response) from e\n",
478
+ "huggingface_hub.errors.RepositoryNotFoundError: 401 Client Error. (Request ID: Root=1-68fa0a8b-0d531523246f6614068c359e;d99d5b5d-694d-4d4b-b774-bb70066228d2)\n",
479
+ "\n",
480
+ "Repository Not Found for url: https://huggingface.co/MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli/resolve/main/config.json.\n",
481
+ "Please make sure you specified the correct `repo_id` and `repo_type`.\n",
482
+ "If you are trying to access a private or gated repo, make sure you are authenticated.\n",
483
+ "Invalid username or password.\n",
484
+ "\n",
485
+ "The above exception was the direct cause of the following exception:\n",
486
+ "\n",
487
+ "Traceback (most recent call last):\n",
488
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/queueing.py\", line 536, in process_events\n",
489
+ " response = await route_utils.call_process_api(\n",
490
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/route_utils.py\", line 322, in call_process_api\n",
491
+ " output = await app.get_blocks().process_api(\n",
492
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/blocks.py\", line 1935, in process_api\n",
493
+ " result = await self.call_function(\n",
494
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/blocks.py\", line 1520, in call_function\n",
495
+ " prediction = await anyio.to_thread.run_sync( # type: ignore\n",
496
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/anyio/to_thread.py\", line 56, in run_sync\n",
497
+ " return await get_async_backend().run_sync_in_worker_thread(\n",
498
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/anyio/_backends/_asyncio.py\", line 2134, in run_sync_in_worker_thread\n",
499
+ " return await future\n",
500
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/anyio/_backends/_asyncio.py\", line 851, in run\n",
501
+ " result = context.run(func, *args)\n",
502
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/gradio/utils.py\", line 826, in wrapper\n",
503
+ " response = f(*args, **kwargs)\n",
504
+ " File \"/var/folders/r5/y63bxy5d4_zfxf6cgwtwysbc0000gn/T/ipykernel_22464/1188444081.py\", line 3, in classify\n",
505
+ " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
506
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/pipelines/__init__.py\", line 798, in pipeline\n",
507
+ " resolved_config_file = cached_file(\n",
508
+ " File \"/Users/anjaruetenbudde/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/utils/hub.py\", line 426, in cached_file\n",
509
+ " raise EnvironmentError(\n",
510
+ "OSError: MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'\n",
511
+ "If this is a private repository, make sure to pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`\n"
512
+ ]
513
+ }
514
+ ],
515
+ "source": [
516
+ "demo = gr.Interface(\n",
517
+ " fn=pred_trip,\n",
518
+ " inputs=[\n",
519
+ " gr.Textbox(label=\"Model name\", value = \"MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli\"),\n",
520
+ " gr.Textbox(label=\"Trip description\"),\n",
521
+ " gr.Number(label=\"Activity cut-off\", value = 0.5),\n",
522
+ " ],\n",
523
+ " # outputs=\"dataframe\",\n",
524
+ " outputs=[gr.Dataframe(label=\"DataFrame\"), gr.Textbox(label=\"List of words\")],\n",
525
+ " title=\"Trip classification\",\n",
526
+ " description=\"Enter a text describing your trip\",\n",
527
+ ")\n",
528
+ "\n",
529
+ "# Launch the Gradio app\n",
530
+ "if __name__ == \"__main__\":\n",
531
+ " demo.launch()\n"
532
+ ]
533
+ },
534
+ {
535
+ "cell_type": "code",
536
+ "execution_count": 46,
537
+ "id": "11006b67-bfd5-42a7-99c4-36c3db3affac",
538
+ "metadata": {},
539
+ "outputs": [
540
+ {
541
+ "name": "stderr",
542
+ "output_type": "stream",
543
+ "text": [
544
+ "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n"
545
+ ]
546
+ },
547
+ {
548
+ "name": "stdout",
549
+ "output_type": "stream",
550
+ "text": [
551
+ "Processing 9/9"
552
+ ]
553
+ }
554
+ ],
555
+ "source": [
556
+ "test = pred_trip(model_name, trip_descr, cut_off = 0.5)"
557
+ ]
558
+ },
559
+ {
560
+ "cell_type": "code",
561
+ "execution_count": null,
562
+ "id": "0f6cd8d1-b742-4034-a3e2-e55c3ddd2904",
563
+ "metadata": {},
564
+ "outputs": [],
565
+ "source": [
566
+ "print(test)"
567
+ ]
568
+ },
569
+ {
570
+ "cell_type": "code",
571
+ "execution_count": 41,
572
+ "id": "5db16415-47c1-42c6-861c-5d26f4b3bb03",
573
+ "metadata": {},
574
+ "outputs": [
575
+ {
576
+ "name": "stdout",
577
+ "output_type": "stream",
578
+ "text": [
579
+ "facebook/bart-large-mnli\n",
580
+ "I am planning a trip to Greece with my boyfriend, where we will visit two islands. We have booked an apartment on each island for a few days and plan to spend most of our time relaxing. Our main goals are to enjoy the beach, try delicious local food, and possibly go on a hike—if it’s not too hot. We will be relying solely on public transport. We’re in our late 20s and traveling from the Netherlands.\n"
581
+ ]
582
+ }
583
+ ],
584
+ "source": [
585
+ "print(model_name)\n",
586
+ "print(trip_descr)"
587
+ ]
588
+ },
589
+ {
590
+ "cell_type": "code",
591
+ "execution_count": null,
592
+ "id": "bbca6bc6-bd97-4d43-8a6e-fe338f2735f2",
593
+ "metadata": {},
594
+ "outputs": [],
595
+ "source": []
596
+ }
597
+ ],
598
+ "metadata": {
599
+ "kernelspec": {
600
+ "display_name": "Python (huggingface_env)",
601
+ "language": "python",
602
+ "name": "huggingface_env"
603
+ },
604
+ "language_info": {
605
+ "codemirror_mode": {
606
+ "name": "ipython",
607
+ "version": 3
608
+ },
609
+ "file_extension": ".py",
610
+ "mimetype": "text/x-python",
611
+ "name": "python",
612
+ "nbconvert_exporter": "python",
613
+ "pygments_lexer": "ipython3",
614
+ "version": "3.8.20"
615
+ }
616
+ },
617
+ "nbformat": 4,
618
+ "nbformat_minor": 5
619
+ }
space/space/space/space/space/space/packing_list_api.ipynb CHANGED
@@ -10,53 +10,41 @@
10
  },
11
  {
12
  "cell_type": "code",
13
- "execution_count": 2,
14
- "id": "05a29daa-b70e-4c7c-ba03-9ab641f424cb",
15
- "metadata": {},
16
- "outputs": [],
17
- "source": [
18
- "from dotenv import load_dotenv\n",
19
- "import os\n",
20
- "import requests\n",
21
- "\n",
22
- "load_dotenv() # Load environment variables from .env file, contains personal access token (HF_API_TOKEN=your_token)\n",
23
- "\n",
24
- "API_URL = \"https://api-inference.huggingface.co/models/facebook/bart-large-mnli\"\n",
25
- "# API_URL = \"https://api-inference.huggingface.co/models/MoritzLaurer/mDeBERTa-v3-base-mnli-xnli\"\n",
26
- "# API_URL = \"https://api-inference.huggingface.co/models/cross-encoder/nli-deberta-v3-base\"\n",
27
- "# API_URL = \"https://api-inference.huggingface.co/models/valhalla/distilbart-mnli-12-3\"\n",
28
- "headers = {\"Authorization\": f\"Bearer {os.getenv('HF_API_TOKEN')}\"}\n",
29
- "\n",
30
- "def query(payload):\n",
31
- " response = requests.post(API_URL, headers=headers, json=payload)\n",
32
- " return response.json()\n",
33
- "\n"
34
- ]
35
- },
36
- {
37
- "cell_type": "code",
38
- "execution_count": 3,
39
- "id": "21b4f8b6-e774-45ad-8054-bf5db2b7b07c",
40
  "metadata": {},
41
  "outputs": [
42
  {
43
  "name": "stdout",
44
  "output_type": "stream",
45
  "text": [
46
- "{'sequence': 'I just bought a new laptop, and it works amazing!', 'labels': ['technology', 'health', 'sports', 'politics'], 'scores': [0.9709171652793884, 0.014999167993664742, 0.008272457867860794, 0.005811102222651243]}\n"
47
  ]
48
  }
49
  ],
50
  "source": [
51
- "# Input text to classify\n",
52
- "input_text = \"I just bought a new laptop, and it works amazing!\"\n",
 
 
 
 
53
  "\n",
54
- "# Candidate labels\n",
55
  "candidate_labels = [\"technology\", \"sports\", \"politics\", \"health\"]\n",
56
  "\n",
57
- "# Get the prediction\n",
58
- "output = query({\"inputs\": input_text, \"parameters\": {\"candidate_labels\": candidate_labels}})\n",
59
- "print(output)\n"
 
 
 
 
 
 
 
 
 
 
60
  ]
61
  },
62
  {
 
10
  },
11
  {
12
  "cell_type": "code",
13
+ "execution_count": 14,
14
+ "id": "966c6d6a-c2d7-405c-bf9b-1e1f1415234e",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  "metadata": {},
16
  "outputs": [
17
  {
18
  "name": "stdout",
19
  "output_type": "stream",
20
  "text": [
21
+ "{'sequence': 'I just bought a new laptop, and it works amazing!', 'labels': ['technology', 'health', 'sports', 'politics'], 'scores': [0.970917284488678, 0.014999152161180973, 0.008272469975054264, 0.005811101291328669]}\n"
22
  ]
23
  }
24
  ],
25
  "source": [
26
+ "from dotenv import load_dotenv\n",
27
+ "import os\n",
28
+ "import requests\n",
29
+ "\n",
30
+ "load_dotenv() # Load environment variables from .env file, contains personal access token (HF_API_TOKEN=your_token)\n",
31
+ "headers = {\"Authorization\": f\"Bearer {os.getenv('HF_API_TOKEN')}\"}\n",
32
  "\n",
 
33
  "candidate_labels = [\"technology\", \"sports\", \"politics\", \"health\"]\n",
34
  "\n",
35
+ "def query(model, input_text):\n",
36
+ " API_URL = f\"https://api-inference.huggingface.co/models/{model}\"\n",
37
+ " payload = {\n",
38
+ " \"inputs\": input_text,\n",
39
+ " \"parameters\": {\"candidate_labels\": candidate_labels}\n",
40
+ " }\n",
41
+ " response = requests.post(API_URL, headers=headers, json=payload)\n",
42
+ " return response.json()\n",
43
+ "\n",
44
+ "input_text = \"I just bought a new laptop, and it works amazing!\"\n",
45
+ "\n",
46
+ "output = query(\"facebook/bart-large-mnli\", input_text)\n",
47
+ "print(output)"
48
  ]
49
  },
50
  {
space/space/space/space/space/space/requirements.txt CHANGED
@@ -1,3 +1,8 @@
1
  transformers
2
- gradio
3
- torch
 
 
 
 
 
 
1
  transformers
2
+ json
3
+ torch
4
+ numpy
5
+ tabulate
6
+ pandas
7
+ sklearn
8
+ gradio
space/space/space/space/space/space/space/space/packing_templates_self_supported_offgrid_expanded_dutch_original.json ADDED
@@ -0,0 +1,696 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "hut trek (summer)": [
3
+ "lichtgewicht trekkingrugzak (30\u201345 liter)",
4
+ "waterzak of drinkflessen",
5
+ "sneldrogende kleding",
6
+ "regenjas",
7
+ "snacks/energierepen",
8
+ "wandelschoenen",
9
+ "hoed of pet",
10
+ "zonnebrandcr\u00e8me",
11
+ "lakenzak",
12
+ "oordoppen"
13
+ ],
14
+ "hut trek (winter)": [
15
+ "slaapzak (lichte, warme variant)",
16
+ "lakenzak",
17
+ "binnenkleding voor hut (thermo / fleece)",
18
+ "hutpantoffels / Crocs",
19
+ "oordoppen",
20
+ "snacks voor onderweg",
21
+ "contant geld voor hutbetalingen"
22
+ ],
23
+ "camping trip (wild camping)": [
24
+ "tent of tarp",
25
+ "slaapmat",
26
+ "slaapzak",
27
+ "hoofdlamp",
28
+ "mes of multitool",
29
+ "waterfilter",
30
+ "kookset + brander",
31
+ "voedsel en snacks",
32
+ "aansteker",
33
+ "toilettas met biologisch afbreekbare zeep"
34
+ ],
35
+ "camping trip (campground)": [
36
+ "tent",
37
+ "kussen",
38
+ "stoeltje",
39
+ "kampeertafel (optioneel)",
40
+ "lamp of lantaarn",
41
+ "verlengsnoer (voor stroomcamping)",
42
+ "koelbox",
43
+ "servies & bestek",
44
+ "afwasspullen",
45
+ "boodschappen"
46
+ ],
47
+ "skitocht / skitour": [
48
+ "touringski's of splitboard",
49
+ "stijgvellen",
50
+ "lawinepieper (transceiver)",
51
+ "schep",
52
+ "sonde",
53
+ "gore-tex jas en broek",
54
+ "donsjas of warme isolatielaag",
55
+ "helm",
56
+ "handschoenen (2 paar)",
57
+ "ski- of zonnebril",
58
+ "thermosfles",
59
+ "sneldrogende baselayers",
60
+ "gamaschen (bij diepe sneeuw)",
61
+ "tourrugzak met ski-bevestiging",
62
+ "laagjes voor temperatuurregeling",
63
+ "energierepen of sportvoeding",
64
+ "GPS of offline kaarten",
65
+ "EHBO-set",
66
+ "lichte handschoenen voor het stijgen"
67
+ ],
68
+ "snowboard / splitboard trip": [
69
+ "splitboard of snowboard",
70
+ "lawinepieper",
71
+ "helm",
72
+ "dikke handschoenen",
73
+ "skibril",
74
+ "laagjes kleding",
75
+ "tourbindingen (voor splitboard)",
76
+ "stijgvellen",
77
+ "sonde en schep",
78
+ "lichte handschoenen voor het stijgen"
79
+ ],
80
+ "long-distance hike / thru-hike": [
81
+ "lichtgewicht rugzak",
82
+ "waterfilter",
83
+ "voedselvoorraad",
84
+ "navigatie (kaart/kompas/GPS)",
85
+ "first aid kit",
86
+ "trail runners of lichte wandelschoenen",
87
+ "zonbescherming",
88
+ "regenbescherming",
89
+ "natte doekjes",
90
+ "sneldrogende handdoek"
91
+ ],
92
+ "digital nomad trip": [
93
+ "laptop en oplader",
94
+ "wereldstekker",
95
+ "noise-cancelling koptelefoon",
96
+ "wifi-hotspot of lokale simkaart",
97
+ "powerbank",
98
+ "notitieboekje",
99
+ "lichte kleding",
100
+ "comfortabele rugzak of trolley",
101
+ "mifi-router of portable wifi-hotspot"
102
+ ],
103
+ "city trip": [
104
+ "dagrugzak",
105
+ "oplader voor telefoon",
106
+ "stadsplattegrond / offline maps",
107
+ "betaalkaart / contant geld",
108
+ "comfortabele schoenen",
109
+ "waterfles",
110
+ "reisgids of highlightslijst",
111
+ "lichte jas of regenjas"
112
+ ],
113
+ "road trip (car/camper)": [
114
+ "autopapieren",
115
+ "EHBO-kit",
116
+ "snacks en drinken",
117
+ "telefoonhouder / navigatie",
118
+ "kampeeruitrusting (indien overnachten)",
119
+ "reisgids of kaarten",
120
+ "zonnebril",
121
+ "stoel en tafel",
122
+ "vermaak (boek, muziek, spelletjes)"
123
+ ],
124
+ "festivaltrip": [
125
+ "tent",
126
+ "matje en slaapzak",
127
+ "oordoppen",
128
+ "poncho of regenjas",
129
+ "glitter / outfit",
130
+ "herbruikbare beker",
131
+ "zonnebrand",
132
+ "cash / pinpas",
133
+ "vriendenafspraken",
134
+ "snacks"
135
+ ],
136
+ "yoga / wellness retreat": [
137
+ "yogamat of yogahanddoek",
138
+ "comfortabele kleding",
139
+ "waterfles",
140
+ "dagboek / pen",
141
+ "warme trui of sjaal",
142
+ "sandalen",
143
+ "etherische olie (optioneel)",
144
+ "boek / meditatiemateriaal"
145
+ ],
146
+ "micro-adventure / weekend trip": [
147
+ "dagrugzak",
148
+ "snacks en drinken",
149
+ "regenjas",
150
+ "warme laag",
151
+ "kaart of GPS",
152
+ "toilettasje",
153
+ "hoofddeksel",
154
+ "compacte slaapuitrusting (indien overnachting)"
155
+ ],
156
+ "beach vacation": [
157
+ "zwemkleding",
158
+ "strandlaken",
159
+ "zonnebrandcr\u00e8me",
160
+ "zonnebril",
161
+ "hoed of pet",
162
+ "slippers",
163
+ "luchtige kleding",
164
+ "waterfles",
165
+ "strandtas",
166
+ "boek of e-reader"
167
+ ],
168
+ "cultural exploration": [
169
+ "dagrugzak",
170
+ "oplader voor telefoon",
171
+ "stadsplattegrond / offline maps",
172
+ "betaalkaart / contant geld",
173
+ "comfortabele schoenen",
174
+ "waterfles",
175
+ "reisgids of highlightslijst",
176
+ "lichte jas of regenjas"
177
+ ],
178
+ "nature escape": [
179
+ "dagrugzak",
180
+ "oplader voor telefoon",
181
+ "betaalkaart / contant geld",
182
+ "comfortabele schoenen",
183
+ "waterfles",
184
+ "downtime entertainment (e.g. book/ebook, games, laptop, journal)"
185
+ ],
186
+ "swimming": [
187
+ "badkleding",
188
+ "handdoek",
189
+ "zonnebrandcr\u00e8me",
190
+ "slippers",
191
+ "zwembril",
192
+ "waterfles"
193
+ ],
194
+ "going to the beach": [
195
+ "strandlaken",
196
+ "zwemkleding",
197
+ "zonnebrand",
198
+ "koeltas",
199
+ "strandstoel",
200
+ "zonnehoed"
201
+ ],
202
+ "relaxing": [
203
+ "comfortabele kleding",
204
+ "boek of e-reader",
205
+ "zitkussen of strandmat",
206
+ "muziek / koptelefoon"
207
+ ],
208
+ "sightseeing": [
209
+ "dagrugzak",
210
+ "waterfles",
211
+ "camera of smartphone",
212
+ "kaart of offline maps",
213
+ "zonnebril"
214
+ ],
215
+ "biking": [
216
+ "fiets of huurfiets",
217
+ "helm",
218
+ "sportkleding",
219
+ "fietslicht en slot",
220
+ "reparatieset"
221
+ ],
222
+ "running": [
223
+ "hardloopschoenen",
224
+ "sportkleding",
225
+ "zweetband of pet",
226
+ "waterfles of belt",
227
+ "sporthorloge (optioneel)"
228
+ ],
229
+ "skiing": [
230
+ "ski\u2019s en stokken",
231
+ "skischoenen",
232
+ "helm",
233
+ "skibril",
234
+ "skipas",
235
+ "dikke handschoenen",
236
+ "gore-tex kleding"
237
+ ],
238
+ "cross-country skiing": [
239
+ "langlaufski's en stokken",
240
+ "langlaufschoenen",
241
+ "ademende thermokleding",
242
+ "winddichte en waterafstotende buitenlaag",
243
+ "dunne handschoenen",
244
+ "muts of hoofdband",
245
+ "zonnebril of sportbril",
246
+ "buff of nekwarmer",
247
+ "lichte rugzak met water en snacks",
248
+ "EHBO-set"
249
+ ],
250
+ "ski touring": [
251
+ "algemene items voor deze situatie",
252
+ "extra kleding of uitrusting indien nodig"
253
+ ],
254
+ "hiking": [
255
+ "wandelschoenen of trailrunners",
256
+ "hiking sokken (anti-blaren)",
257
+ "hikingstokken",
258
+ "dagrugzak",
259
+ "regenjas of poncho",
260
+ "waterfles of waterzak",
261
+ "snacks / energierepen",
262
+ "zonnebrand en zonnebril",
263
+ "pet of hoed",
264
+ "blarenpleisters of tape",
265
+ "EHBO-set",
266
+ "navigatie (kaart, kompas of GPS)"
267
+ ],
268
+ "hut-to-hut hiking": [
269
+ "lichtgewicht trekkingrugzak (30\u201345 liter)",
270
+ "waterflessen of waterzak",
271
+ "snacks voor onderweg",
272
+ "regenjas",
273
+ "licht donsjack of warme laag",
274
+ "sneldrogende kleding",
275
+ "wandelschoenen",
276
+ "lakenzak",
277
+ "pantoffels of slippers voor hut",
278
+ "oordoppen",
279
+ "reserveringsbevestiging / contant geld voor hut"
280
+ ],
281
+ "rock climbing": [
282
+ "klimschoenen",
283
+ "klimgordel",
284
+ "zekeringsapparaat",
285
+ "chalk bag",
286
+ "helm"
287
+ ],
288
+ "ice climbing": [
289
+ "ijsbijlen",
290
+ "crampons",
291
+ "klimtouw",
292
+ "warme isolatielagen",
293
+ "klimgordel en helm"
294
+ ],
295
+ "snowshoe hiking": [
296
+ "algemene items voor deze situatie",
297
+ "extra kleding of uitrusting indien nodig"
298
+ ],
299
+ "kayaking / canoeing": [
300
+ "kayak of kano",
301
+ "peddel",
302
+ "reddingsvest",
303
+ "drybag",
304
+ "waterschoenen"
305
+ ],
306
+ "stand-up paddleboarding (SUP)": [
307
+ "SUP-board en peddel",
308
+ "reddingsvest",
309
+ "drybag",
310
+ "zonnebril met koord"
311
+ ],
312
+ "snorkeling": [
313
+ "snorkel en duikbril",
314
+ "zwemvliezen",
315
+ "badkleding",
316
+ "waterdichte tas"
317
+ ],
318
+ "scuba diving": [
319
+ "duikbril en snorkel",
320
+ "wetsuit",
321
+ "vinnen",
322
+ "duikcomputer",
323
+ "ademautomaat (indien eigen)"
324
+ ],
325
+ "surfing": [
326
+ "surfboard",
327
+ "wetsuit",
328
+ "wax",
329
+ "board leash",
330
+ "poncho of handdoek"
331
+ ],
332
+ "paragliding": [
333
+ "paraglider",
334
+ "helm",
335
+ "handschoenen",
336
+ "wandelschoenen",
337
+ "windjack"
338
+ ],
339
+ "horseback riding": [
340
+ "rijbroek",
341
+ "rijlaarzen of schoenen met hak",
342
+ "handschoenen",
343
+ "helm",
344
+ "eventueel eigen zadel of stijgbeugels"
345
+ ],
346
+ "photography": [
347
+ "camera + lenzen",
348
+ "statief",
349
+ "geheugenkaart(en)",
350
+ "extra accu's",
351
+ "lensdoekje"
352
+ ],
353
+ "fishing": [
354
+ "hengel",
355
+ "aas / kunstaas",
356
+ "visvergunning",
357
+ "laarzen of waadpak",
358
+ "koelbox (optioneel)"
359
+ ],
360
+ "rafting": [
361
+ "reddingsvest",
362
+ "waterdichte tas",
363
+ "waterschoenen",
364
+ "sneldrogende kleding",
365
+ "helm"
366
+ ],
367
+ "yoga": [
368
+ "algemene items voor deze situatie",
369
+ "extra kleding of uitrusting indien nodig"
370
+ ],
371
+ "cold destination / winter": [
372
+ "thermokleding",
373
+ "muts en handschoenen",
374
+ "warme jas",
375
+ "waterdichte schoenen",
376
+ "lippenbalsem"
377
+ ],
378
+ "warm destination / summer": [
379
+ "luchtige kleding",
380
+ "zonnebril",
381
+ "zonnecr\u00e8me",
382
+ "waterfles",
383
+ "hoed of pet"
384
+ ],
385
+ "variable weather / spring / autumn": [
386
+ "regenjas",
387
+ "laagjeskleding",
388
+ "warme trui",
389
+ "waterdichte schoenen"
390
+ ],
391
+ "tropical / humid": [
392
+ "lichtgewicht kleding",
393
+ "insectenspray",
394
+ "zonnecr\u00e8me",
395
+ "regenponcho",
396
+ "sneldrogende handdoek"
397
+ ],
398
+ "dry / desert-like": [
399
+ "zonnebril",
400
+ "zonnecr\u00e8me",
401
+ "hoofdbescherming",
402
+ "lichte lange mouwen",
403
+ "veel water"
404
+ ],
405
+ "ultralight": [
406
+ "lichtgewicht rugzak (< 1kg)",
407
+ "minimalistische shelter (tarp of tent)",
408
+ "lichtgewicht slaapmat",
409
+ "quilt of donsdeken",
410
+ "titanium kookset",
411
+ "beperkte kleding (laagjes!)",
412
+ "compacte regenjas",
413
+ "sneldrogende handdoek",
414
+ "tandenborstel (afgezaagd ;))"
415
+ ],
416
+ "lightweight (but comfortable)": [
417
+ "lichte tent of tarp",
418
+ "comfortabele slaapmat",
419
+ "lichtgewicht kookset",
420
+ "compact kledingpakket",
421
+ "sneldrogende handdoek"
422
+ ],
423
+ "luxury (including evening wear)": [
424
+ "nette schoenen",
425
+ "jurk of overhemd",
426
+ "parfum/deodorant",
427
+ "accessoires",
428
+ "reistoilettas met essentials"
429
+ ],
430
+ "minimalist": [
431
+ "1 set kleding voor elke situatie",
432
+ "compacte tandenborstel",
433
+ "alles-in-\u00e9\u00e9n zeep",
434
+ "lichtgewicht handdoek",
435
+ "kleine rugzak"
436
+ ],
437
+ "casual": [
438
+ "jeans of comfortabele broek",
439
+ "t-shirts",
440
+ "trui of hoodie",
441
+ "sneakers",
442
+ "zonnebril"
443
+ ],
444
+ "formal (business trip)": [
445
+ "overhemd / blouse",
446
+ "net jasje",
447
+ "nette schoenen",
448
+ "laptop en oplader",
449
+ "naamkaartjes / documenten"
450
+ ],
451
+ "conservative": [
452
+ "bedekkende kleding",
453
+ "sjaal of omslagdoek",
454
+ "lange broek of rok",
455
+ "gesloten schoenen"
456
+ ],
457
+ "outdoor": [
458
+ "regenjas",
459
+ "waterdichte schoenen",
460
+ "bivakzak of tarp",
461
+ "hoofdlamp",
462
+ "navigatie"
463
+ ],
464
+ "indoor": [
465
+ "pantoffels",
466
+ "comfortabele kleding",
467
+ "pyjama",
468
+ "oplader",
469
+ "toilettas"
470
+ ],
471
+ "huts with half board": [
472
+ "reserveringsbevestiging",
473
+ "lakenzak (vaak verplicht)",
474
+ "pantoffels of slippers voor binnen",
475
+ "lichte pyjama of slaapkleding",
476
+ "oorstopjes",
477
+ "waterfles",
478
+ "snacks voor onderweg",
479
+ "kleine toilettas",
480
+ "contant geld voor betalingen",
481
+ "lichte handdoek",
482
+ "zaklamp of hoofdlamp"
483
+ ],
484
+ "sleeping in a tent": [
485
+ "tent (1- of 2-persoons, afhankelijk van reis)",
486
+ "grondzeil",
487
+ "slaapmat",
488
+ "slaapzak (passend bij temperatuur)",
489
+ "hoofdlamp of zaklamp",
490
+ "sneldrogende handdoek",
491
+ "kussen of opblaasbaar hoofdkussen",
492
+ "oorstopjes",
493
+ "toilettas",
494
+ "powerbank",
495
+ "waterfles",
496
+ "boek of e-reader",
497
+ "EHBO-set"
498
+ ],
499
+ "sleeping in a car": [
500
+ "slaapmat die past in auto",
501
+ "warme slaapzak",
502
+ "zonneschermen of verduistering",
503
+ "kussen",
504
+ "waterfles binnen handbereik",
505
+ "powerbank of 12V-lader",
506
+ "toilettas",
507
+ "snacks voor de nacht",
508
+ "thermische deken (voor koude nachten)"
509
+ ],
510
+ "own vehicle": [
511
+ "rijbewijs",
512
+ "autopapieren",
513
+ "EHBO-set",
514
+ "navigatie of smartphone",
515
+ "telefoonhouder"
516
+ ],
517
+ "no own vehicle": [
518
+ "rugzak",
519
+ "waterfles",
520
+ "lichte schoenen",
521
+ "openbaar vervoer app of ticket"
522
+ ],
523
+ "off-grid / no electricity": [
524
+ "powerbank (minstens 10.000 mAh)",
525
+ "zonnepaneel of draagbaar laadsysteem",
526
+ "hoofdlamp + extra batterijen",
527
+ "oplaadbare batterijen en oplader",
528
+ "back-up verlichting (bijv. kleine zaklamp)",
529
+ "papieren kaart en kompas",
530
+ "notitieboekje + pen",
531
+ "noodcommunicatie (bijv. GPS beacon of satellietboodschapper)",
532
+ "opvouwbaar zonnepaneel (indien langere tochten)",
533
+ "navigatieapparaat met offline kaarten",
534
+ "extra opladerkabels",
535
+ "USB-hub (voor meerdere devices)",
536
+ "verpakking om elektronica droog te houden"
537
+ ],
538
+ "self-supported (bring your own cooking gear)": [
539
+ "lichtgewicht kooktoestel (gas, benzine of alcohol)",
540
+ "brandstof (voldoende voor aantal dagen)",
541
+ "pan of keteltje",
542
+ "spork of lepel",
543
+ "opvouwbaar snijplankje (optioneel)",
544
+ "aandrukbare kom of beker",
545
+ "aansteker + lucifers (waterdicht verpakt)",
546
+ "gedroogde of gevriesdroogde maaltijden",
547
+ "snacks / noodbars",
548
+ "afwasmiddel (biologisch afbreekbaar) + sponsje",
549
+ "opslagzakken voor afval",
550
+ "waterfilter of -pomp",
551
+ "chloordruppels of zuiveringstabletten",
552
+ "minstens 2 liter wateropslag per persoon",
553
+ "food bag of hangzak voor voedsel (wild-safe)"
554
+ ],
555
+ "travel with children": [
556
+ "snacks en speelgoed",
557
+ "EHBO-set met pleisters",
558
+ "extra kleding",
559
+ "kinderdrager of buggy",
560
+ "zonbescherming",
561
+ "extra snacks voor kinderen",
562
+ "favoriet speelgoed of knuffel",
563
+ "reisstoel of draagzak",
564
+ "natte doekjes",
565
+ "luiers of potje (afhankelijk van leeftijd)",
566
+ "extra set kleding per dag",
567
+ "reisapotheek voor kinderen",
568
+ "kinderzonnebrand",
569
+ "activiteitenboekje of tablet met filmpjes",
570
+ "snelle snacks voor onderweg",
571
+ "kinder slaapzak of slaapmat",
572
+ "reisbedje of matrasje (voor jonge kinderen)",
573
+ "luiers of oefenbroekjes",
574
+ "flesjes en voeding (indien van toepassing)",
575
+ "babyfoon (voor verblijf op locatie)",
576
+ "speen of fopspeen",
577
+ "kinder EHBO-set (inclusief thermometer)",
578
+ "zonnehoedje of muts",
579
+ "regenhoes voor kinderwagen of draagzak",
580
+ "hydraterende cr\u00e8me (voor gevoelige huid)"
581
+ ],
582
+ "pet-friendly": [
583
+ "voer en waterbak",
584
+ "hondenriem of tuigje",
585
+ "poepzakjes",
586
+ "reismatje of deken",
587
+ "vaccinatieboekje"
588
+ ],
589
+ "rainy climate": [
590
+ "regenjas of poncho",
591
+ "waterdichte rugzakhoes",
592
+ "sneldrogende kleding",
593
+ "rubberen schoenen"
594
+ ],
595
+ "snow and ice": [
596
+ "warme laarzen",
597
+ "dikke handschoenen",
598
+ "sneeuwbril",
599
+ "thermokleding",
600
+ "gripzolen / spikes"
601
+ ],
602
+ "high alpine terrain": [
603
+ "wandelstokken",
604
+ "kaart en kompas",
605
+ "wind- en waterdichte jas",
606
+ "extra voeding",
607
+ "EHBO-kit"
608
+ ],
609
+ "snow, ice and avalanche-prone terrain": [
610
+ "lawinepieper",
611
+ "schep",
612
+ "sonde",
613
+ "airbag rugzak (indien beschikbaar)",
614
+ "kennis van lawineveiligheid / cursus",
615
+ "kaart en kompas / GPS",
616
+ "partner check voor vertrek"
617
+ ],
618
+ "no special conditions": [
619
+ ],
620
+ "1 day": [
621
+ "ondergoed per dag",
622
+ "sokken per dag",
623
+ "toilettas",
624
+ "extra kledinglaag",
625
+ "aantal maaltijden/snacks afgestemd op duur"
626
+ ],
627
+ "2 days": [
628
+ "ondergoed per dag",
629
+ "sokken per dag",
630
+ "toilettas",
631
+ "extra kledinglaag",
632
+ "aantal maaltijden/snacks afgestemd op duur"
633
+ ],
634
+ "3 days": [
635
+ "ondergoed per dag",
636
+ "sokken per dag",
637
+ "toilettas",
638
+ "extra kledinglaag",
639
+ "aantal maaltijden/snacks afgestemd op duur"
640
+ ],
641
+ "4 days": [
642
+ "ondergoed per dag",
643
+ "sokken per dag",
644
+ "toilettas",
645
+ "extra kledinglaag",
646
+ "aantal maaltijden/snacks afgestemd op duur"
647
+ ],
648
+ "5 days": [
649
+ "ondergoed per dag",
650
+ "sokken per dag",
651
+ "toilettas",
652
+ "extra kledinglaag",
653
+ "aantal maaltijden/snacks afgestemd op duur"
654
+ ],
655
+ "6 days": [
656
+ "ondergoed per dag",
657
+ "sokken per dag",
658
+ "toilettas",
659
+ "extra kledinglaag",
660
+ "aantal maaltijden/snacks afgestemd op duur"
661
+ ],
662
+ "7 days": [
663
+ "ondergoed per dag",
664
+ "sokken per dag",
665
+ "toilettas",
666
+ "extra kledinglaag",
667
+ "aantal maaltijden/snacks afgestemd op duur"
668
+ ],
669
+ "7+ days": [
670
+ "ondergoed per dag",
671
+ "sokken per dag",
672
+ "toilettas",
673
+ "extra kledinglaag",
674
+ "aantal maaltijden/snacks afgestemd op duur"
675
+ ],
676
+ "default_items": [
677
+ "telefoon + oplader",
678
+ "powerbank",
679
+ "identiteitsbewijs of paspoort",
680
+ "betaalmiddelen (pinpas / contant geld)",
681
+ "verzekeringspas / reisverzekering-info",
682
+ "toilettas (tandpasta, borstel, deodorant, zeep)",
683
+ "zonnebrandcr\u00e8me",
684
+ "lippenbalsem",
685
+ "ondergoed",
686
+ "sokken",
687
+ "regenjas of windjack",
688
+ "waterfles",
689
+ "snacks",
690
+ "zonnebril",
691
+ "oorstopjes",
692
+ "slaapmasker",
693
+ "herbruikbare tas",
694
+ "zakdoekjes of toiletpapier"
695
+ ]
696
+ }
space/space/space/space/space/space/space/space/space/.ipynb_checkpoints/app-checkpoint.py CHANGED
@@ -13,15 +13,14 @@ keys_list = list(candidate_labels.keys())
13
  with open("test_data.json", "r") as file:
14
  packing_data = json.load(file)
15
 
16
- # function and gradio app
17
- model_name = "facebook/bart-large-mnli"
18
- classifier = pipeline("zero-shot-classification", model=model_name)
19
- cut_off = 0.5 # used to choose which activities are relevant
20
 
21
- def classify(#model_name,
22
- trip_descr, cut_off):
23
-
24
- # Create an empty DataFrame with specified columns
25
  df = pd.DataFrame(columns=['superclass', 'pred_class'])
26
  for i, key in enumerate(keys_list):
27
  if key == 'activities':
@@ -32,16 +31,31 @@ def classify(#model_name,
32
  result = classifier(trip_descr, candidate_labels[key])
33
  classes = result["labels"][0]
34
  df.loc[i] = [key, classes]
35
- return df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  demo = gr.Interface(
38
  fn=classify,
39
  inputs=[
40
- #gr.Textbox(label="Model name", value = "facebook/bart-large-mnli"),
41
  gr.Textbox(label="Trip description"),
42
  gr.Number(label="Activity cut-off", value = 0.5),
43
  ],
44
- outputs="dataframe",
 
45
  title="Trip classification",
46
  description="Enter a text describing your trip",
47
  )
 
13
  with open("test_data.json", "r") as file:
14
  packing_data = json.load(file)
15
 
16
+ # Load packing item data
17
+ with open("packing_templates_self_supported_offgrid_expanded.json", "r") as file:
18
+ packing_items = json.load(file)
 
19
 
20
+ # function and gradio app
21
+ def classify(model_name, trip_descr, cut_off = 0.5):
22
+ classifier = pipeline("zero-shot-classification", model=model_name)
23
+ ## Create and fill dataframe with class predictions
24
  df = pd.DataFrame(columns=['superclass', 'pred_class'])
25
  for i, key in enumerate(keys_list):
26
  if key == 'activities':
 
31
  result = classifier(trip_descr, candidate_labels[key])
32
  classes = result["labels"][0]
33
  df.loc[i] = [key, classes]
34
+
35
+ ## Look up and return list of items to pack based on class predictions
36
+ # make list from dataframe column
37
+ all_classes = [elem for x in df["pred_class"] for elem in (x if isinstance(x, list) else [x])]
38
+ # look up packing items for each class/key
39
+ list_of_list_of_items = [packing_items.get(k, []) for k in all_classes]
40
+ # combine lists and remove doubble entries
41
+ flat_unique = []
42
+ for sublist in list_of_list_of_items:
43
+ for item in sublist:
44
+ if item not in flat_unique:
45
+ flat_unique.append(item)
46
+ # sort alphabetically to notice duplicates
47
+ sorted_list = sorted(flat_unique)
48
+ return df, "\n".join(sorted_list)
49
 
50
  demo = gr.Interface(
51
  fn=classify,
52
  inputs=[
53
+ gr.Textbox(label="Model name", value = "MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli"),
54
  gr.Textbox(label="Trip description"),
55
  gr.Number(label="Activity cut-off", value = 0.5),
56
  ],
57
+ # outputs="dataframe",
58
+ outputs=[gr.Dataframe(label="DataFrame"), gr.Textbox(label="List of words")],
59
  title="Trip classification",
60
  description="Enter a text describing your trip",
61
  )
space/space/space/space/space/space/space/space/space/.ipynb_checkpoints/labels-checkpoint.txt ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ sunscreen
2
+ sunglasses
3
+ sunhat
4
+ flip-flops
5
+ swimsuit
6
+ beach towel
7
+ waterproof phone case
8
+ beach bag
9
+ snorkel gear
10
+ tent
11
+ sleeping bag
12
+ camping stove
13
+ flashlight
14
+ hiking boots
15
+ water filter
16
+ compass
17
+ first aid kit
18
+ bug spray
19
+ multi-tool
20
+ thermal clothing
21
+ ski jacket
22
+ ski goggles
23
+ snow boots
24
+ gloves
25
+ hand warmers
26
+ beanie
27
+ lip balm
28
+ snowboard
29
+ base layers
30
+ passport
31
+ visa documents
32
+ travel adapter
33
+ currency
34
+ sim card
35
+ travel pillow
36
+ neck wallet
37
+ travel insurance documents
38
+ power bank
39
+ laptop
40
+ business attire
41
+ dress shoes
42
+ charging cables
43
+ pen
44
+ headphones
45
+ lightweight backpack
46
+ travel-sized toiletries
47
+ packable rain jacket
48
+ dry bag
49
+ trekking poles
50
+ hostel lock
51
+ quick-dry towel
52
+ travel journal
53
+ snacks
54
+ blanket
55
+ emergency roadside kit
56
+ reusable coffee mug
57
+ reusable shopping bags
58
+ earplugs
59
+ fanny pack
60
+ poncho
61
+ bandana
62
+ comfortable shoes
63
+ bathing suit
64
+ sandals
65
+ light jacket
66
+ entertainment for downtime (e.g. book/ebook, games, laptop, journal)
67
+ short pants/skirts
68
+ t-shirts/tops
69
+ thin scarf
70
+ pants
71
+ shirts
72
+ cardigan/sweater
73
+ gifts
74
+ winter shoes
75
+ long pants
76
+ short pants
77
+ malaria medication
78
+ mosquito repellant
79
+ local currency
80
+ wallet
81
+ tickets
82
+ phone and charger
83
+ painkiller
84
+ necessary medication
85
+ personal toiletries (e.g. toothbrush, toothpaste)
86
+ underwear
87
+ socks
88
+ sleep wear
89
+ snacks for the journey
90
+ refillable water bottle
91
+ day pack
92
+ big backpack/suitcase
93
+
space/space/space/space/space/space/space/space/space/.ipynb_checkpoints/main_model-checkpoint.ipynb CHANGED
The diff for this file is too large to render. See raw diff
 
space/space/space/space/space/space/space/space/space/app.py CHANGED
@@ -13,15 +13,14 @@ keys_list = list(candidate_labels.keys())
13
  with open("test_data.json", "r") as file:
14
  packing_data = json.load(file)
15
 
16
- # function and gradio app
17
- model_name = "facebook/bart-large-mnli"
18
- classifier = pipeline("zero-shot-classification", model=model_name)
19
- cut_off = 0.5 # used to choose which activities are relevant
20
 
21
- def classify(#model_name,
22
- trip_descr, cut_off):
23
-
24
- # Create an empty DataFrame with specified columns
25
  df = pd.DataFrame(columns=['superclass', 'pred_class'])
26
  for i, key in enumerate(keys_list):
27
  if key == 'activities':
@@ -32,16 +31,31 @@ def classify(#model_name,
32
  result = classifier(trip_descr, candidate_labels[key])
33
  classes = result["labels"][0]
34
  df.loc[i] = [key, classes]
35
- return df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  demo = gr.Interface(
38
  fn=classify,
39
  inputs=[
40
- #gr.Textbox(label="Model name", value = "facebook/bart-large-mnli"),
41
  gr.Textbox(label="Trip description"),
42
  gr.Number(label="Activity cut-off", value = 0.5),
43
  ],
44
- outputs="dataframe",
 
45
  title="Trip classification",
46
  description="Enter a text describing your trip",
47
  )
 
13
  with open("test_data.json", "r") as file:
14
  packing_data = json.load(file)
15
 
16
+ # Load packing item data
17
+ with open("packing_templates_self_supported_offgrid_expanded.json", "r") as file:
18
+ packing_items = json.load(file)
 
19
 
20
+ # function and gradio app
21
+ def classify(model_name, trip_descr, cut_off = 0.5):
22
+ classifier = pipeline("zero-shot-classification", model=model_name)
23
+ ## Create and fill dataframe with class predictions
24
  df = pd.DataFrame(columns=['superclass', 'pred_class'])
25
  for i, key in enumerate(keys_list):
26
  if key == 'activities':
 
31
  result = classifier(trip_descr, candidate_labels[key])
32
  classes = result["labels"][0]
33
  df.loc[i] = [key, classes]
34
+
35
+ ## Look up and return list of items to pack based on class predictions
36
+ # make list from dataframe column
37
+ all_classes = [elem for x in df["pred_class"] for elem in (x if isinstance(x, list) else [x])]
38
+ # look up packing items for each class/key
39
+ list_of_list_of_items = [packing_items.get(k, []) for k in all_classes]
40
+ # combine lists and remove doubble entries
41
+ flat_unique = []
42
+ for sublist in list_of_list_of_items:
43
+ for item in sublist:
44
+ if item not in flat_unique:
45
+ flat_unique.append(item)
46
+ # sort alphabetically to notice duplicates
47
+ sorted_list = sorted(flat_unique)
48
+ return df, "\n".join(sorted_list)
49
 
50
  demo = gr.Interface(
51
  fn=classify,
52
  inputs=[
53
+ gr.Textbox(label="Model name", value = "MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli"),
54
  gr.Textbox(label="Trip description"),
55
  gr.Number(label="Activity cut-off", value = 0.5),
56
  ],
57
+ # outputs="dataframe",
58
+ outputs=[gr.Dataframe(label="DataFrame"), gr.Textbox(label="List of words")],
59
  title="Trip classification",
60
  description="Enter a text describing your trip",
61
  )
space/space/space/space/space/space/space/space/space/blog_post/article.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Working with Large Language Models
2
+ ## Introduction: Nikky
3
+ * What are LLMs and why are they popular
4
+ * How to use the open source platform to use LLMs for own application; example of creating a packing list.
5
+
6
+ ## Why bother to adapt models to your application: Nikky
7
+ * Problems of LLMS: Hallucination and wrong outputs
8
+ * Controll outputs by using zero-shot-calssification
9
+ * briefly mention other types of classification
10
+ * How we do it with our packing list model
11
+ * Why not use packing items as classes
12
+ * Use superclasses to categories trip and have packing items correspond to superclasses
13
+ * Asses performance with small test data set
14
+ * mention gradio app to make it user friendly and spaces to share model
15
+
16
+ ## Implementation of packing list model
17
+ ### Prerequisites before you start to code: Anja
18
+ * Hugging face account also use access token, mention api
19
+ * Use anaconda
20
+ * Install python and libraries
21
+ * create jupyter notebook
22
+ * pip install stuff
23
+ * Hugging face API (or mention during implementation)
24
+
25
+ ### Predefine outputs/classes: Nikky
26
+
27
+ ### Model implementation: Anja
28
+
29
+ ### Using gradio app: Anja
30
+
31
+ ### Share your model: Anja
32
+ * created space
33
+ * created github access token on huffing face and then github actions workflow
34
+ * you need to install the required dependencies in the environment where your Hugging Face Space is running.
35
+ * create requirements.txt file with necessary libraries
36
+
37
+
38
+ ## Performance assessment: Anja
39
+ * Test data creation
40
+
41
+
42
+ ## Closing
43
+ * Summary
44
+ * Limitations
space/space/space/space/space/space/space/space/space/main_model.ipynb CHANGED
@@ -5,7 +5,7 @@
5
  "id": "e25090fa-f990-4f1a-84f3-b12159eedae8",
6
  "metadata": {},
7
  "source": [
8
- "# Implement and test prediciton model"
9
  ]
10
  },
11
  {
@@ -23,36 +23,27 @@
23
  "metadata": {},
24
  "outputs": [],
25
  "source": [
26
- "# Prerequisites\n",
27
- "from tabulate import tabulate\n",
28
- "from transformers import pipeline\n",
29
  "import json\n",
30
- "import pandas as pd\n",
31
- "import matplotlib.pyplot as plt\n",
32
  "import pickle\n",
33
  "import os\n",
34
  "import time\n",
35
- "import math\n",
 
 
 
36
  "\n",
37
- "# get candidate labels\n",
38
  "with open(\"packing_label_structure.json\", \"r\") as file:\n",
39
  " candidate_labels = json.load(file)\n",
40
  "keys_list = list(candidate_labels.keys())\n",
41
  "\n",
42
- "# Load test data (in list of dictionaries)\n",
43
  "with open(\"test_data.json\", \"r\") as file:\n",
44
  " packing_data = json.load(file)\n",
45
- "# Extract all trip descriptions and trip_types\n",
46
  "trip_descriptions = [trip['description'] for trip in packing_data]\n",
47
- "trip_types = [trip['trip_types'] for trip in packing_data]\n",
48
- "\n",
49
- "# Access the first trip description\n",
50
- "first_trip = trip_descriptions[0]\n",
51
- "# Get the packing list for the secondfirst trip\n",
52
- "first_trip_type = trip_types[0]\n",
53
- "\n",
54
- "# print(f\"First trip: {first_trip} \\n\")\n",
55
- "# print(f\"Trip type: {first_trip_type}\")"
56
  ]
57
  },
58
  {
@@ -68,9 +59,6 @@
68
  "execution_count": 2,
69
  "id": "89d42ca7-e871-4eda-b428-69e9bd965428",
70
  "metadata": {
71
- "jupyter": {
72
- "source_hidden": true
73
- },
74
  "scrolled": true
75
  },
76
  "outputs": [
@@ -185,14 +173,14 @@
185
  "8 . I go on a skitouring trip where we also make videos/photos and the destination is Japan. Mainly sports clothes and isolation are needed (it is winter). We stay in a guesthouse. It will be 10 days. \n",
186
  "\n",
187
  "ski tour / skitour\n",
188
- "['ski touring', 'photography', 'swimming']\n",
189
  "cold destination / winter\n",
190
  "minimalist\n",
191
  "conservative\n",
192
  "indoor\n",
193
  "no own vehicle\n",
194
  "avalanche-prone terrain\n",
195
- "5 days\n",
196
  "\n",
197
  "\n",
198
  "9 . We plan a wild camping trip with activities such as snorkeling, kayaking and canoeing. It is a warm place and we want to bring little stuff. We stay in tents and hammocks and travel with a car, it will be 3 days. \n",
@@ -201,10 +189,10 @@
201
  "['scuba diving', 'kayaking / canoeing']\n",
202
  "tropical / humid\n",
203
  "lightweight (but comfortable)\n",
204
- "conservative\n",
205
  "sleeping in a tent\n",
206
  "own vehicle\n",
207
- "no special conditions to consider\n",
208
  "3 days\n",
209
  "\n",
210
  "\n"
@@ -229,20 +217,29 @@
229
  },
230
  {
231
  "cell_type": "code",
232
- "execution_count": 2,
233
  "id": "fac51224-9575-4b4b-8567-4ad4e759ecc9",
234
  "metadata": {},
235
  "outputs": [],
236
  "source": [
237
- "# function that returns pandas data frame with predictions and true values\n",
238
- "\n",
239
- "cut_off = 0.5 # used to choose which activities are relevant\n",
 
 
 
 
 
 
240
  "\n",
241
- "def pred_trip(model_name, trip_descr, trip_type, cut_off):\n",
 
 
 
242
  " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
243
- " # Create an empty DataFrame with specified columns\n",
244
  " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
245
  " for i, key in enumerate(keys_list):\n",
 
246
  " if key == 'activities':\n",
247
  " result = classifier(trip_descr, candidate_labels[key], multi_label=True)\n",
248
  " indices = [i for i, score in enumerate(result['scores']) if score > cut_off]\n",
@@ -250,9 +247,6 @@
250
  " else:\n",
251
  " result = classifier(trip_descr, candidate_labels[key])\n",
252
  " classes = result[\"labels\"][0]\n",
253
- " print(result)\n",
254
- " print(classes)\n",
255
- " print(i)\n",
256
  " df.loc[i] = [key, classes]\n",
257
  " df['true_class'] = trip_type\n",
258
  " return df"
@@ -260,14 +254,25 @@
260
  },
261
  {
262
  "cell_type": "code",
263
- "execution_count": 3,
264
  "id": "b36ab806-2f35-4950-ac5a-7c192190cba7",
265
  "metadata": {},
266
  "outputs": [],
267
  "source": [
268
- "# function for accuracy, perc true classes identified and perc wrong pred classes\n",
269
- "\n",
270
  "def perf_measure(df):\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  " df['same_value'] = df['pred_class'] == df['true_class']\n",
272
  " correct = sum(df.loc[df.index != 1, 'same_value'])\n",
273
  " total = len(df['same_value'])\n",
@@ -365,10 +370,10 @@
365
  "model_names = [\n",
366
  " \"facebook/bart-large-mnli\",\n",
367
  " \"MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli\",\n",
368
- " ##\"cross-encoder/nli-deberta-v3-base\",\n",
369
  " \"cross-encoder/nli-deberta-v3-large\",\n",
370
  " \"MoritzLaurer/mDeBERTa-v3-base-mnli-xnli\",\n",
371
- " ##\"joeddav/bart-large-mnli-yahoo-answers\",\n",
372
  " \"MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli\",\n",
373
  " \"MoritzLaurer/deberta-v3-large-zeroshot-v2.0\",\n",
374
  " \"valhalla/distilbart-mnli-12-1\",\n",
@@ -386,31 +391,24 @@
386
  " current_trip = trip_descriptions[i]\n",
387
  " current_type = trip_types[i]\n",
388
  " df = pred_trip(model_name, current_trip, current_type, cut_off = 0.5)\n",
389
- " print(df)\n",
390
- " # accuracy, perc true classes identified and perc wrong pred classes\n",
391
  " performance = pd.concat([performance, perf_measure(df)])\n",
392
- " print(performance)\n",
393
- " \n",
394
  " result_list.append(df)\n",
395
  " end_time = time.time()\n",
396
  " elapsed_time = end_time - start_time\n",
397
- " # Extract \"same_value\" column from each DataFrame\n",
398
- " sv_columns = [df['same_value'] for df in result_list] # 'same' needs to be changed\n",
 
399
  " sv_columns.insert(0, result_list[0]['superclass'])\n",
400
- " # Combine into a new DataFrame (columns side-by-side)\n",
401
  " sv_df = pd.concat(sv_columns, axis=1)\n",
402
- " print(sv_df)\n",
403
- " # Compute accuracy per superclass (row means of same_value matrix excluding the first column)\n",
404
  " row_means = sv_df.iloc[:, 1:].mean(axis=1)\n",
405
  " df_row_means = pd.DataFrame({\n",
406
  " 'superclass': sv_df['superclass'],\n",
407
  " 'accuracy': row_means\n",
408
  " })\n",
409
- " print(df_row_means)\n",
410
  " # Compute performance measures per trip (mean for each column of performance table)\n",
411
  " column_means = performance.mean()\n",
412
- " print(column_means)\n",
413
- " # save results\n",
414
  " model = model_name.replace(\"/\", \"-\")\n",
415
  " model_result = {\n",
416
  " 'model': model,\n",
@@ -420,9 +418,7 @@
420
  " 'perf_superclass': df_row_means,\n",
421
  " 'elapsed_time': elapsed_time\n",
422
  " }\n",
423
- " # File path with folder\n",
424
  " filename = os.path.join('results', f'{model}_results.pkl')\n",
425
- " # Save the object\n",
426
  " with open(filename, 'wb') as f:\n",
427
  " pickle.dump(model_result, f)\n",
428
  "\n",
@@ -440,116 +436,7 @@
440
  },
441
  {
442
  "cell_type": "code",
443
- "execution_count": 4,
444
- "id": "62ca82b0-6909-4e6c-9d2c-fed87971e5b6",
445
- "metadata": {
446
- "scrolled": true
447
- },
448
- "outputs": [
449
- {
450
- "name": "stdout",
451
- "output_type": "stream",
452
- "text": [
453
- "Model: cross-encoder-nli-deberta-v3-base\n",
454
- "Performance Summary:\n",
455
- "accuracy 0.444444\n",
456
- "true_ident 0.533333\n",
457
- "false_pred 0.712500\n",
458
- "dtype: float64\n",
459
- "----------------------------------------\n",
460
- "Model: joeddav-bart-large-mnli-yahoo-answers\n",
461
- "Performance Summary:\n",
462
- "accuracy 0.344444\n",
463
- "true_ident 0.650000\n",
464
- "false_pred 0.553792\n",
465
- "dtype: float64\n",
466
- "----------------------------------------\n",
467
- "Model: cross-encoder-nli-deberta-v3-large\n",
468
- "Performance Summary:\n",
469
- "accuracy 0.466667\n",
470
- "true_ident 0.566667\n",
471
- "false_pred 0.541667\n",
472
- "dtype: float64\n",
473
- "----------------------------------------\n",
474
- "Model: MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli\n",
475
- "Performance Summary:\n",
476
- "accuracy 0.566667\n",
477
- "true_ident 0.841667\n",
478
- "false_pred 0.546667\n",
479
- "dtype: float64\n",
480
- "----------------------------------------\n",
481
- "Model: MoritzLaurer-mDeBERTa-v3-base-mnli-xnli\n",
482
- "Performance Summary:\n",
483
- "accuracy 0.466667\n",
484
- "true_ident 0.408333\n",
485
- "false_pred 0.481250\n",
486
- "dtype: float64\n",
487
- "----------------------------------------\n",
488
- "Model: MoritzLaurer-deberta-v3-large-zeroshot-v2.0\n",
489
- "Performance Summary:\n",
490
- "accuracy 0.455556\n",
491
- "true_ident 0.325000\n",
492
- "false_pred 0.500000\n",
493
- "dtype: float64\n",
494
- "----------------------------------------\n",
495
- "Model: facebook-bart-large-mnli\n",
496
- "Performance Summary:\n",
497
- "accuracy 0.466667\n",
498
- "true_ident 0.708333\n",
499
- "false_pred 0.400000\n",
500
- "dtype: float64\n",
501
- "----------------------------------------\n",
502
- "Model: valhalla-distilbart-mnli-12-1\n",
503
- "Performance Summary:\n",
504
- "accuracy 0.522222\n",
505
- "true_ident 0.300000\n",
506
- "false_pred 0.533333\n",
507
- "dtype: float64\n",
508
- "----------------------------------------\n",
509
- "Model: MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli\n",
510
- "Performance Summary:\n",
511
- "accuracy 0.522222\n",
512
- "true_ident 0.841667\n",
513
- "false_pred 0.572381\n",
514
- "dtype: float64\n",
515
- "----------------------------------------\n"
516
- ]
517
- }
518
- ],
519
- "source": [
520
- "# Folder where .pkl files are saved\n",
521
- "results_dir = 'results/before'\n",
522
- "\n",
523
- "# Dictionary to store all loaded results\n",
524
- "all_results = {}\n",
525
- "\n",
526
- "# Loop through all .pkl files in the folder\n",
527
- "for filename in os.listdir(results_dir):\n",
528
- " if filename.endswith('.pkl'):\n",
529
- " model_name = filename.replace('_results.pkl', '') # Extract model name\n",
530
- " file_path = os.path.join(results_dir, filename)\n",
531
- " \n",
532
- " # Load the result\n",
533
- " with open(file_path, 'rb') as f:\n",
534
- " result = pickle.load(f)\n",
535
- " all_results[model_name] = result\n",
536
- "\n",
537
- "# Compare performance across models\n",
538
- "for model, data in all_results.items():\n",
539
- " print(f\"Model: {model}\")\n",
540
- " print(f\"Performance Summary:\\n{data['perf_summary']}\")\n",
541
- " print(\"-\" * 40)\n",
542
- "\n",
543
- "# Compare performance across models\n",
544
- "#for model, data in all_results.items():\n",
545
- "# print(f\"Model: {model}\")\n",
546
- "# print(f\"Performance Summary:\\n{data['perf_superclass']}\")\n",
547
- "# print(\"-\" * 40)"
548
- ]
549
- },
550
- {
551
- "cell_type": "code",
552
- "execution_count": 5,
553
  "id": "37849e0b-864e-4377-b06c-0ac70c3861f9",
554
  "metadata": {
555
  "scrolled": true
@@ -701,6 +588,8 @@
701
  ],
702
  "source": [
703
  "def get_difficult_trips(model_result, cut_off = 0.6):\n",
 
 
704
  " # model_result is a dict with dict_keys(['model', 'predictions', \n",
705
  " # 'performance', 'perf_summary', 'perf_superclass', 'elapsed_time'])\n",
706
  " # get performance dataframe and repair index\n",
@@ -808,7 +697,7 @@
808
  },
809
  {
810
  "cell_type": "code",
811
- "execution_count": 6,
812
  "id": "adb491b1-3ac3-4c32-934f-5eb6171f2ec9",
813
  "metadata": {},
814
  "outputs": [
@@ -904,26 +793,27 @@
904
  },
905
  {
906
  "cell_type": "code",
907
- "execution_count": 26,
908
  "id": "b020f584-1468-4c84-9dac-7ca7fac6e8ca",
909
- "metadata": {},
 
 
910
  "outputs": [
911
  {
912
  "name": "stdout",
913
  "output_type": "stream",
914
  "text": [
915
  "[]\n",
916
- "<class 'list'>\n",
917
- " accuracy true_ident false_pred \\\n",
918
- "0 0.444444 0.533333 0.7125 \n",
919
- "1 0.355556 0.65 0.553792 \n",
920
- "2 0.466667 0.566667 0.541667 \n",
921
- "3 0.611111 0.841667 0.546667 \n",
922
- "4 0.455556 0.408333 0.48125 \n",
923
- "5 0.5 0.325 0.5 \n",
924
- "6 0.466667 0.708333 0.4 \n",
925
- "7 0.5 0.3 0.533333 \n",
926
- "8 0.522222 0.841667 0.572381 \n",
927
  "\n",
928
  " model \n",
929
  "0 cross-encoder-nli-deberta-v3-base \n",
@@ -968,20 +858,82 @@
968
  },
969
  {
970
  "cell_type": "code",
971
- "execution_count": 17,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
972
  "id": "0f7376bd-a50b-47cc-8055-48a6de5dfee6",
973
  "metadata": {},
974
  "outputs": [
 
 
 
 
 
 
 
975
  {
976
  "name": "stdout",
977
  "output_type": "stream",
978
  "text": [
979
- "<class 'dict'>\n"
 
 
 
 
 
 
 
 
 
980
  ]
981
  }
982
  ],
983
  "source": [
984
- "print(type(all_results))"
 
 
 
985
  ]
986
  },
987
  {
@@ -994,7 +946,7 @@
994
  },
995
  {
996
  "cell_type": "code",
997
- "execution_count": 1,
998
  "id": "5bf23e10-0a93-4b2f-9508-34bb0974d24c",
999
  "metadata": {},
1000
  "outputs": [],
@@ -1013,14 +965,15 @@
1013
  "# Load test data (in list of dictionaries)\n",
1014
  "with open(\"test_data.json\", \"r\") as file:\n",
1015
  " packing_data = json.load(file)\n",
1016
- "# Extract all trip descriptions and trip_types\n",
1017
- "# trip_descriptions = [trip['description'] for trip in packing_data]\n",
1018
- "# trip_types = [trip['trip_types'] for trip in packing_data]"
 
1019
  ]
1020
  },
1021
  {
1022
  "cell_type": "code",
1023
- "execution_count": 2,
1024
  "id": "61ebbe99-2563-4c99-ba65-d2312c9d5844",
1025
  "metadata": {},
1026
  "outputs": [
@@ -1029,15 +982,14 @@
1029
  "output_type": "stream",
1030
  "text": [
1031
  "Running on local URL: http://127.0.0.1:7860\n",
1032
- "Running on public URL: https://91493051ab28db8a5a.gradio.live\n",
1033
  "\n",
1034
- "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
1035
  ]
1036
  },
1037
  {
1038
  "data": {
1039
  "text/html": [
1040
- "<div><iframe src=\"https://91493051ab28db8a5a.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
1041
  ],
1042
  "text/plain": [
1043
  "<IPython.core.display.HTML object>"
@@ -1045,22 +997,13 @@
1045
  },
1046
  "metadata": {},
1047
  "output_type": "display_data"
1048
- },
1049
- {
1050
- "name": "stderr",
1051
- "output_type": "stream",
1052
- "text": [
1053
- "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n"
1054
- ]
1055
  }
1056
  ],
1057
  "source": [
1058
  "# function and gradio app\n",
1059
- "cut_off = 0.5 # used to choose which activities are relevant\n",
1060
- "\n",
1061
- "def classify(model_name, trip_descr, cut_off):\n",
1062
  " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
1063
- " # Create an empty DataFrame with specified columns\n",
1064
  " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
1065
  " for i, key in enumerate(keys_list):\n",
1066
  " if key == 'activities':\n",
@@ -1071,24 +1014,478 @@
1071
  " result = classifier(trip_descr, candidate_labels[key])\n",
1072
  " classes = result[\"labels\"][0]\n",
1073
  " df.loc[i] = [key, classes]\n",
1074
- " return df\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1075
  "\n",
1076
  "demo = gr.Interface(\n",
1077
  " fn=classify,\n",
1078
  " inputs=[\n",
1079
- " gr.Textbox(label=\"Model name\", value = \"facebook/bart-large-mnli\"),\n",
1080
  " gr.Textbox(label=\"Trip description\"),\n",
1081
  " gr.Number(label=\"Activity cut-off\", value = 0.5),\n",
1082
  " ],\n",
1083
- " outputs=\"dataframe\",\n",
 
1084
  " title=\"Trip classification\",\n",
1085
  " description=\"Enter a text describing your trip\",\n",
1086
  ")\n",
1087
  "\n",
1088
  "# Launch the Gradio app\n",
1089
  "if __name__ == \"__main__\":\n",
1090
- " demo.launch(share=True)\n"
1091
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1092
  }
1093
  ],
1094
  "metadata": {
 
5
  "id": "e25090fa-f990-4f1a-84f3-b12159eedae8",
6
  "metadata": {},
7
  "source": [
8
+ "# Working with a Large Language Model (LLM)"
9
  ]
10
  },
11
  {
 
23
  "metadata": {},
24
  "outputs": [],
25
  "source": [
26
+ "import math\n",
 
 
27
  "import json\n",
 
 
28
  "import pickle\n",
29
  "import os\n",
30
  "import time\n",
31
+ "import pandas as pd\n",
32
+ "import matplotlib.pyplot as plt\n",
33
+ "from tabulate import tabulate\n",
34
+ "from transformers import pipeline\n",
35
  "\n",
36
+ "# Get candidate labels\n",
37
  "with open(\"packing_label_structure.json\", \"r\") as file:\n",
38
  " candidate_labels = json.load(file)\n",
39
  "keys_list = list(candidate_labels.keys())\n",
40
  "\n",
41
+ "# Load test data (list of dictionaries)\n",
42
  "with open(\"test_data.json\", \"r\") as file:\n",
43
  " packing_data = json.load(file)\n",
44
+ "# Extract trip descriptions and classification (trip_types)\n",
45
  "trip_descriptions = [trip['description'] for trip in packing_data]\n",
46
+ "trip_types = [trip['trip_types'] for trip in packing_data]"
 
 
 
 
 
 
 
 
47
  ]
48
  },
49
  {
 
59
  "execution_count": 2,
60
  "id": "89d42ca7-e871-4eda-b428-69e9bd965428",
61
  "metadata": {
 
 
 
62
  "scrolled": true
63
  },
64
  "outputs": [
 
173
  "8 . I go on a skitouring trip where we also make videos/photos and the destination is Japan. Mainly sports clothes and isolation are needed (it is winter). We stay in a guesthouse. It will be 10 days. \n",
174
  "\n",
175
  "ski tour / skitour\n",
176
+ "['ski touring', 'photography']\n",
177
  "cold destination / winter\n",
178
  "minimalist\n",
179
  "conservative\n",
180
  "indoor\n",
181
  "no own vehicle\n",
182
  "avalanche-prone terrain\n",
183
+ "7+ days\n",
184
  "\n",
185
  "\n",
186
  "9 . We plan a wild camping trip with activities such as snorkeling, kayaking and canoeing. It is a warm place and we want to bring little stuff. We stay in tents and hammocks and travel with a car, it will be 3 days. \n",
 
189
  "['scuba diving', 'kayaking / canoeing']\n",
190
  "tropical / humid\n",
191
  "lightweight (but comfortable)\n",
192
+ "casual\n",
193
  "sleeping in a tent\n",
194
  "own vehicle\n",
195
+ "self-supported (bring your own cooking gear)\n",
196
  "3 days\n",
197
  "\n",
198
  "\n"
 
217
  },
218
  {
219
  "cell_type": "code",
220
+ "execution_count": 3,
221
  "id": "fac51224-9575-4b4b-8567-4ad4e759ecc9",
222
  "metadata": {},
223
  "outputs": [],
224
  "source": [
225
+ "def pred_trip(model_name, trip_descr, trip_type, cut_off = 0.5):\n",
226
+ " \"\"\"\n",
227
+ " Classifies trip\n",
228
+ " \n",
229
+ " Parameters:\n",
230
+ " model_name: name of hugging-face model\n",
231
+ " trip_descr: text describing the trip\n",
232
+ " trip_type: true trip classification\n",
233
+ " cut_off: cut_off for choosing activities\n",
234
  "\n",
235
+ " Returns:\n",
236
+ " pd Dataframe: with class predictions and true values\n",
237
+ " \"\"\"\n",
238
+ " \n",
239
  " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
 
240
  " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
241
  " for i, key in enumerate(keys_list):\n",
242
+ " print(i)\n",
243
  " if key == 'activities':\n",
244
  " result = classifier(trip_descr, candidate_labels[key], multi_label=True)\n",
245
  " indices = [i for i, score in enumerate(result['scores']) if score > cut_off]\n",
 
247
  " else:\n",
248
  " result = classifier(trip_descr, candidate_labels[key])\n",
249
  " classes = result[\"labels\"][0]\n",
 
 
 
250
  " df.loc[i] = [key, classes]\n",
251
  " df['true_class'] = trip_type\n",
252
  " return df"
 
254
  },
255
  {
256
  "cell_type": "code",
257
+ "execution_count": 4,
258
  "id": "b36ab806-2f35-4950-ac5a-7c192190cba7",
259
  "metadata": {},
260
  "outputs": [],
261
  "source": [
 
 
262
  "def perf_measure(df):\n",
263
+ " \"\"\"\n",
264
+ " Calculates performance measures:\n",
265
+ " Accuracy of classification excluding activities superclass\n",
266
+ " Percentage of correctly identified activities (#correctly predicted/#true activities)\n",
267
+ " Percentage of wrongly identified activities (#wrongly predicted/#predicted activities)\n",
268
+ "\n",
269
+ " Parameters:\n",
270
+ " df: pd Dataframe returned from pred_trip()\n",
271
+ "\n",
272
+ " Returns:\n",
273
+ " pd Dataframe: containing performance measures\n",
274
+ " \"\"\"\n",
275
+ " \n",
276
  " df['same_value'] = df['pred_class'] == df['true_class']\n",
277
  " correct = sum(df.loc[df.index != 1, 'same_value'])\n",
278
  " total = len(df['same_value'])\n",
 
370
  "model_names = [\n",
371
  " \"facebook/bart-large-mnli\",\n",
372
  " \"MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli\",\n",
373
+ " \"cross-encoder/nli-deberta-v3-base\",\n",
374
  " \"cross-encoder/nli-deberta-v3-large\",\n",
375
  " \"MoritzLaurer/mDeBERTa-v3-base-mnli-xnli\",\n",
376
+ " \"joeddav/bart-large-mnli-yahoo-answers\",\n",
377
  " \"MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli\",\n",
378
  " \"MoritzLaurer/deberta-v3-large-zeroshot-v2.0\",\n",
379
  " \"valhalla/distilbart-mnli-12-1\",\n",
 
391
  " current_trip = trip_descriptions[i]\n",
392
  " current_type = trip_types[i]\n",
393
  " df = pred_trip(model_name, current_trip, current_type, cut_off = 0.5)\n",
 
 
394
  " performance = pd.concat([performance, perf_measure(df)])\n",
 
 
395
  " result_list.append(df)\n",
396
  " end_time = time.time()\n",
397
  " elapsed_time = end_time - start_time\n",
398
+ " \n",
399
+ " # Extract and combine columns identifying correct prediction (for each trip)\n",
400
+ " sv_columns = [df['same_value'] for df in result_list]\n",
401
  " sv_columns.insert(0, result_list[0]['superclass'])\n",
 
402
  " sv_df = pd.concat(sv_columns, axis=1)\n",
403
+ " # Compute accuracy per superclass\n",
 
404
  " row_means = sv_df.iloc[:, 1:].mean(axis=1)\n",
405
  " df_row_means = pd.DataFrame({\n",
406
  " 'superclass': sv_df['superclass'],\n",
407
  " 'accuracy': row_means\n",
408
  " })\n",
 
409
  " # Compute performance measures per trip (mean for each column of performance table)\n",
410
  " column_means = performance.mean()\n",
411
+ " # Save results\n",
 
412
  " model = model_name.replace(\"/\", \"-\")\n",
413
  " model_result = {\n",
414
  " 'model': model,\n",
 
418
  " 'perf_superclass': df_row_means,\n",
419
  " 'elapsed_time': elapsed_time\n",
420
  " }\n",
 
421
  " filename = os.path.join('results', f'{model}_results.pkl')\n",
 
422
  " with open(filename, 'wb') as f:\n",
423
  " pickle.dump(model_result, f)\n",
424
  "\n",
 
436
  },
437
  {
438
  "cell_type": "code",
439
+ "execution_count": 6,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
440
  "id": "37849e0b-864e-4377-b06c-0ac70c3861f9",
441
  "metadata": {
442
  "scrolled": true
 
588
  ],
589
  "source": [
590
  "def get_difficult_trips(model_result, cut_off = 0.6):\n",
591
+ " \"\"\"\n",
592
+ " \"\"\"\n",
593
  " # model_result is a dict with dict_keys(['model', 'predictions', \n",
594
  " # 'performance', 'perf_summary', 'perf_superclass', 'elapsed_time'])\n",
595
  " # get performance dataframe and repair index\n",
 
697
  },
698
  {
699
  "cell_type": "code",
700
+ "execution_count": 9,
701
  "id": "adb491b1-3ac3-4c32-934f-5eb6171f2ec9",
702
  "metadata": {},
703
  "outputs": [
 
793
  },
794
  {
795
  "cell_type": "code",
796
+ "execution_count": 10,
797
  "id": "b020f584-1468-4c84-9dac-7ca7fac6e8ca",
798
+ "metadata": {
799
+ "scrolled": true
800
+ },
801
  "outputs": [
802
  {
803
  "name": "stdout",
804
  "output_type": "stream",
805
  "text": [
806
  "[]\n",
807
+ " accuracy true_ident false_pred \\\n",
808
+ "0 0.444444 0.533333 0.712500 \n",
809
+ "1 0.355556 0.650000 0.553792 \n",
810
+ "2 0.466667 0.566667 0.541667 \n",
811
+ "3 0.611111 0.841667 0.546667 \n",
812
+ "4 0.455556 0.408333 0.481250 \n",
813
+ "5 0.500000 0.325000 0.500000 \n",
814
+ "6 0.466667 0.708333 0.400000 \n",
815
+ "7 0.500000 0.300000 0.533333 \n",
816
+ "8 0.522222 0.841667 0.572381 \n",
 
817
  "\n",
818
  " model \n",
819
  "0 cross-encoder-nli-deberta-v3-base \n",
 
858
  },
859
  {
860
  "cell_type": "code",
861
+ "execution_count": 25,
862
+ "id": "222a70fc-8d3c-4ebb-9954-d5c72baed9e5",
863
+ "metadata": {},
864
+ "outputs": [],
865
+ "source": [
866
+ "# return packing list additionally to classes\n",
867
+ "# Load packing item data\n",
868
+ "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
869
+ " packing_items = json.load(file)\n",
870
+ "\n",
871
+ "# function and gradio app\n",
872
+ "def classify(model_name, trip_descr, cut_off = 0.5):\n",
873
+ " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
874
+ " ## Create and fill dataframe with class predictions\n",
875
+ " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
876
+ " for i, key in enumerate(keys_list):\n",
877
+ " if key == 'activities':\n",
878
+ " result = classifier(trip_descr, candidate_labels[key], multi_label=True)\n",
879
+ " indices = [i for i, score in enumerate(result['scores']) if score > cut_off]\n",
880
+ " classes = [result['labels'][i] for i in indices]\n",
881
+ " else:\n",
882
+ " result = classifier(trip_descr, candidate_labels[key])\n",
883
+ " classes = result[\"labels\"][0]\n",
884
+ " df.loc[i] = [key, classes]\n",
885
+ "\n",
886
+ " ## Look up and return list of items to pack based on class predictions\n",
887
+ " # make list from dataframe column\n",
888
+ " all_classes = [elem for x in df[\"pred_class\"] for elem in (x if isinstance(x, list) else [x])]\n",
889
+ " # look up packing items for each class/key\n",
890
+ " list_of_list_of_items = [packing_items.get(k, []) for k in all_classes]\n",
891
+ " # combine lists and remove doubble entries\n",
892
+ " flat_unique = []\n",
893
+ " for sublist in list_of_list_of_items:\n",
894
+ " for item in sublist:\n",
895
+ " if item not in flat_unique:\n",
896
+ " flat_unique.append(item)\n",
897
+ " # sort alphabetically to notice duplicates\n",
898
+ " sorted_list = sorted(flat_unique) \n",
899
+ " return df, sorted_list"
900
+ ]
901
+ },
902
+ {
903
+ "cell_type": "code",
904
+ "execution_count": 26,
905
  "id": "0f7376bd-a50b-47cc-8055-48a6de5dfee6",
906
  "metadata": {},
907
  "outputs": [
908
+ {
909
+ "name": "stderr",
910
+ "output_type": "stream",
911
+ "text": [
912
+ "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n"
913
+ ]
914
+ },
915
  {
916
  "name": "stdout",
917
  "output_type": "stream",
918
  "text": [
919
+ "( superclass pred_class\n",
920
+ "0 activity_type beach vacation\n",
921
+ "1 activities [going to the beach, relaxing, hiking]\n",
922
+ "2 climate_or_season warm destination / summer\n",
923
+ "3 style_or_comfort minimalist\n",
924
+ "4 dress_code casual\n",
925
+ "5 accommodation huts with half board\n",
926
+ "6 transportation no own vehicle\n",
927
+ "7 special_conditions off-grid / no electricity\n",
928
+ "8 trip_length_days 7+ days, ['1 set kleding voor elke situatie', 'EHBO-set', 'USB-hub (voor meerdere devices)', 'aantal maaltijden/snacks afgestemd op duur', 'alles-in-één zeep', 'back-up verlichting (bijv. kleine zaklamp)', 'blarenpleisters of tape', 'boek of e-reader', 'comfortabele kleding', 'compacte tandenborstel', 'contant geld voor betalingen', 'dagrugzak', 'extra kledinglaag', 'extra opladerkabels', 'hiking sokken (anti-blaren)', 'hikingstokken', 'hoed of pet', 'hoofdlamp + extra batterijen', 'jeans of comfortabele broek', 'kleine rugzak', 'kleine toilettas', 'koeltas', 'lakenzak (vaak verplicht)', 'lichte handdoek', 'lichte pyjama of slaapkleding', 'lichte schoenen', 'lichtgewicht handdoek', 'luchtige kleding', 'muziek / koptelefoon', 'navigatie (kaart, kompas of GPS)', 'navigatieapparaat met offline kaarten', 'noodcommunicatie (bijv. GPS beacon of satellietboodschapper)', 'notitieboekje + pen', 'ondergoed per dag', 'oorstopjes', 'openbaar vervoer app of ticket', 'oplaadbare batterijen en oplader', 'opvouwbaar zonnepaneel (indien langere tochten)', 'pantoffels of slippers voor binnen', 'papieren kaart en kompas', 'pet of hoed', 'powerbank (minstens 10.000 mAh)', 'regenjas of poncho', 'reserveringsbevestiging', 'rugzak', 'slippers', 'snacks / energierepen', 'snacks voor onderweg', 'sneakers', 'sokken per dag', 'strandlaken', 'strandstoel', 'strandtas', 't-shirts', 'toilettas', 'trui of hoodie', 'verpakking om elektronica droog te houden', 'wandelschoenen of trailrunners', 'waterfles', 'waterfles of waterzak', 'zaklamp of hoofdlamp', 'zitkussen of strandmat', 'zonnebrand', 'zonnebrand en zonnebril', 'zonnebrandcrème', 'zonnebril', 'zonnecrème', 'zonnehoed', 'zonnepaneel of draagbaar laadsysteem', 'zwemkleding'])\n"
929
  ]
930
  }
931
  ],
932
  "source": [
933
+ "# Access the first trip description\n",
934
+ "first_trip = trip_descriptions[0]\n",
935
+ "tmp = classify(\"facebook/bart-large-mnli\", first_trip )\n",
936
+ "print(tmp)"
937
  ]
938
  },
939
  {
 
946
  },
947
  {
948
  "cell_type": "code",
949
+ "execution_count": 3,
950
  "id": "5bf23e10-0a93-4b2f-9508-34bb0974d24c",
951
  "metadata": {},
952
  "outputs": [],
 
965
  "# Load test data (in list of dictionaries)\n",
966
  "with open(\"test_data.json\", \"r\") as file:\n",
967
  " packing_data = json.load(file)\n",
968
+ "\n",
969
+ "# Load packing item data\n",
970
+ "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
971
+ " packing_items = json.load(file)"
972
  ]
973
  },
974
  {
975
  "cell_type": "code",
976
+ "execution_count": 4,
977
  "id": "61ebbe99-2563-4c99-ba65-d2312c9d5844",
978
  "metadata": {},
979
  "outputs": [
 
982
  "output_type": "stream",
983
  "text": [
984
  "Running on local URL: http://127.0.0.1:7860\n",
 
985
  "\n",
986
+ "To create a public link, set `share=True` in `launch()`.\n"
987
  ]
988
  },
989
  {
990
  "data": {
991
  "text/html": [
992
+ "<div><iframe src=\"http://127.0.0.1:7860/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
993
  ],
994
  "text/plain": [
995
  "<IPython.core.display.HTML object>"
 
997
  },
998
  "metadata": {},
999
  "output_type": "display_data"
 
 
 
 
 
 
 
1000
  }
1001
  ],
1002
  "source": [
1003
  "# function and gradio app\n",
1004
+ "def classify(model_name, trip_descr, cut_off = 0.5):\n",
 
 
1005
  " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
1006
+ " ## Create and fill dataframe with class predictions\n",
1007
  " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
1008
  " for i, key in enumerate(keys_list):\n",
1009
  " if key == 'activities':\n",
 
1014
  " result = classifier(trip_descr, candidate_labels[key])\n",
1015
  " classes = result[\"labels\"][0]\n",
1016
  " df.loc[i] = [key, classes]\n",
1017
+ "\n",
1018
+ " ## Look up and return list of items to pack based on class predictions\n",
1019
+ " # make list from dataframe column\n",
1020
+ " all_classes = [elem for x in df[\"pred_class\"] for elem in (x if isinstance(x, list) else [x])]\n",
1021
+ " # look up packing items for each class/key\n",
1022
+ " list_of_list_of_items = [packing_items.get(k, []) for k in all_classes]\n",
1023
+ " # combine lists and remove doubble entries\n",
1024
+ " flat_unique = []\n",
1025
+ " for sublist in list_of_list_of_items:\n",
1026
+ " for item in sublist:\n",
1027
+ " if item not in flat_unique:\n",
1028
+ " flat_unique.append(item)\n",
1029
+ " # sort alphabetically to notice duplicates\n",
1030
+ " sorted_list = sorted(flat_unique) \n",
1031
+ " return df, \"\\n\".join(sorted_list)\n",
1032
  "\n",
1033
  "demo = gr.Interface(\n",
1034
  " fn=classify,\n",
1035
  " inputs=[\n",
1036
+ " gr.Textbox(label=\"Model name\", value = \"MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli\"),\n",
1037
  " gr.Textbox(label=\"Trip description\"),\n",
1038
  " gr.Number(label=\"Activity cut-off\", value = 0.5),\n",
1039
  " ],\n",
1040
+ " # outputs=\"dataframe\",\n",
1041
+ " outputs=[gr.Dataframe(label=\"DataFrame\"), gr.Textbox(label=\"List of words\")],\n",
1042
  " title=\"Trip classification\",\n",
1043
  " description=\"Enter a text describing your trip\",\n",
1044
  ")\n",
1045
  "\n",
1046
  "# Launch the Gradio app\n",
1047
  "if __name__ == \"__main__\":\n",
1048
+ " demo.launch()\n"
1049
  ]
1050
+ },
1051
+ {
1052
+ "cell_type": "code",
1053
+ "execution_count": 32,
1054
+ "id": "1f5df949-a527-4b11-8e5e-23786e1cde12",
1055
+ "metadata": {
1056
+ "scrolled": true
1057
+ },
1058
+ "outputs": [
1059
+ {
1060
+ "name": "stdout",
1061
+ "output_type": "stream",
1062
+ "text": [
1063
+ "I am planning a trip to Greece with my boyfriend, where we will visit two islands. We have booked an apartment on each island for a few days and plan to spend most of our time relaxing. Our main goals are to enjoy the beach, try delicious local food, and possibly go on a hike—if it’s not too hot. We will be relying solely on public transport. We’re in our late 20s and traveling from the Netherlands.\n"
1064
+ ]
1065
+ },
1066
+ {
1067
+ "name": "stderr",
1068
+ "output_type": "stream",
1069
+ "text": [
1070
+ "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n"
1071
+ ]
1072
+ }
1073
+ ],
1074
+ "source": [
1075
+ "print(first_trip)"
1076
+ ]
1077
+ },
1078
+ {
1079
+ "cell_type": "markdown",
1080
+ "id": "4ba29d94-88e4-4fb9-b42b-4e013ec2faa0",
1081
+ "metadata": {},
1082
+ "source": [
1083
+ "**Check for duplicate entries, which to combine?**"
1084
+ ]
1085
+ },
1086
+ {
1087
+ "cell_type": "code",
1088
+ "execution_count": 3,
1089
+ "id": "66311e68-c7ab-47a0-8d42-02991bc048f2",
1090
+ "metadata": {},
1091
+ "outputs": [
1092
+ {
1093
+ "name": "stdout",
1094
+ "output_type": "stream",
1095
+ "text": [
1096
+ "<class 'dict'>\n"
1097
+ ]
1098
+ }
1099
+ ],
1100
+ "source": [
1101
+ "print(type(packing_items))"
1102
+ ]
1103
+ },
1104
+ {
1105
+ "cell_type": "code",
1106
+ "execution_count": 9,
1107
+ "id": "9b2a01e7-55ac-405a-bb34-2b759c1f2d8e",
1108
+ "metadata": {},
1109
+ "outputs": [
1110
+ {
1111
+ "name": "stdout",
1112
+ "output_type": "stream",
1113
+ "text": [
1114
+ "1 set of clothing for every situation\n",
1115
+ "GPS or offline maps\n",
1116
+ "Gore‑Tex clothing\n",
1117
+ "Gore‑Tex jacket and pants\n",
1118
+ "MiFi router or portable WiFi hotspot\n",
1119
+ "SUP board and paddle\n",
1120
+ "USB hub (for multiple devices)\n",
1121
+ "WiFi hotspot or local SIM card\n",
1122
+ "accessories\n",
1123
+ "activity book or tablet with films\n",
1124
+ "airbag backpack (if available)\n",
1125
+ "all‑in‑one soap\n",
1126
+ "at least 2 liters of water storage per person\n",
1127
+ "avalanche beacon (transceiver)\n",
1128
+ "baby monitor (for staying at location)\n",
1129
+ "backpack\n",
1130
+ "backup lighting (e.g. small flashlight)\n",
1131
+ "bags for waste\n",
1132
+ "bait / lures\n",
1133
+ "bank card / cash\n",
1134
+ "beach bag\n",
1135
+ "beach chair\n",
1136
+ "beach towel\n",
1137
+ "belay device\n",
1138
+ "bike light and lock\n",
1139
+ "bike or rental bike\n",
1140
+ "biodegradable soap + sponge\n",
1141
+ "bivvy bag or tarp\n",
1142
+ "blister plasters or tape\n",
1143
+ "board leash\n",
1144
+ "book / meditation material\n",
1145
+ "book or e‑reader\n",
1146
+ "boots or waders\n",
1147
+ "bottles and food (if applicable)\n",
1148
+ "breathable thermal clothing\n",
1149
+ "buff or neck warmer\n",
1150
+ "business cards / documents\n",
1151
+ "camera + lenses\n",
1152
+ "camera or smartphone\n",
1153
+ "camping gear (if staying overnight)\n",
1154
+ "camping table (optional)\n",
1155
+ "cap or hat\n",
1156
+ "car documents\n",
1157
+ "cash / card\n",
1158
+ "cash for hut\n",
1159
+ "cash for payments\n",
1160
+ "chair\n",
1161
+ "chair and table\n",
1162
+ "chalk bag\n",
1163
+ "charger\n",
1164
+ "child carrier or stroller\n",
1165
+ "child sleeping bag or pad\n",
1166
+ "children’s sunscreen\n",
1167
+ "children’s travel pharmacy\n",
1168
+ "chlorine drops or purification tablets\n",
1169
+ "city map / offline maps\n",
1170
+ "climbing harness\n",
1171
+ "climbing rope\n",
1172
+ "climbing shoes\n",
1173
+ "climbing skins\n",
1174
+ "closed shoes\n",
1175
+ "comfortable backpack or trolley\n",
1176
+ "comfortable clothing\n",
1177
+ "comfortable shoes\n",
1178
+ "comfortable sleeping pad\n",
1179
+ "compact clothing pack\n",
1180
+ "compact rain jacket\n",
1181
+ "compact sleeping gear (if overnighting)\n",
1182
+ "compact toothbrush\n",
1183
+ "cookset + stove\n",
1184
+ "cooler\n",
1185
+ "cooler box\n",
1186
+ "cooler box (optional)\n",
1187
+ "covering clothing\n",
1188
+ "crampons\n",
1189
+ "cross-country ski boots\n",
1190
+ "cross-country skis and poles\n",
1191
+ "daypack\n",
1192
+ "diapers or potty (depending on age)\n",
1193
+ "dishes & cutlery\n",
1194
+ "dive computer\n",
1195
+ "dog leash or harness\n",
1196
+ "down jacket or warm insulation layer\n",
1197
+ "dress or shirt\n",
1198
+ "dress shoes\n",
1199
+ "dried or freeze‑dried meals\n",
1200
+ "driver’s license\n",
1201
+ "dry bag\n",
1202
+ "earplugs\n",
1203
+ "emergency communication (e.g. GPS beacon or satellite messenger)\n",
1204
+ "energy bars or sports nutrition\n",
1205
+ "entertainment (book, music, games)\n",
1206
+ "essential oils (optional)\n",
1207
+ "extension cord (for powered campsites)\n",
1208
+ "extra batteries\n",
1209
+ "extra charger cables\n",
1210
+ "extra clothing\n",
1211
+ "extra clothing layer\n",
1212
+ "extra clothing or gear if needed\n",
1213
+ "extra clothing set per day\n",
1214
+ "extra food\n",
1215
+ "extra snacks for children\n",
1216
+ "favorite toy or stuffed animal\n",
1217
+ "fins\n",
1218
+ "first aid kit\n",
1219
+ "fishing license\n",
1220
+ "fishing rod\n",
1221
+ "flashlight or headlamp\n",
1222
+ "flip flops\n",
1223
+ "foldable cutting board (optional)\n",
1224
+ "foldable solar panel (if on longer trips)\n",
1225
+ "food and snacks\n",
1226
+ "food and water bowl\n",
1227
+ "food bag or hanging bag (wild-safe)\n",
1228
+ "food supply\n",
1229
+ "friend meetups\n",
1230
+ "fuel (enough for several days)\n",
1231
+ "gaiters (in deep snow)\n",
1232
+ "general items for this situation\n",
1233
+ "glitter / outfit\n",
1234
+ "gloves\n",
1235
+ "gloves (2 pairs)\n",
1236
+ "groceries\n",
1237
+ "groundsheet\n",
1238
+ "guidebook or highlights list\n",
1239
+ "hat and gloves\n",
1240
+ "hat or cap\n",
1241
+ "hat or headband\n",
1242
+ "head cover\n",
1243
+ "head protection\n",
1244
+ "headband or cap\n",
1245
+ "headlamp\n",
1246
+ "headlamp + extra batteries\n",
1247
+ "headlamp or flashlight\n",
1248
+ "helmet\n",
1249
+ "hiking boots\n",
1250
+ "hiking boots or trail runners\n",
1251
+ "hiking poles\n",
1252
+ "hiking socks (anti-blister)\n",
1253
+ "hut slippers / Crocs\n",
1254
+ "hydrating cream (for sensitive skin)\n",
1255
+ "ice axes\n",
1256
+ "identity document or passport\n",
1257
+ "indoor hut clothing (thermo / fleece)\n",
1258
+ "insect repellent\n",
1259
+ "insurance card / travel insurance info\n",
1260
+ "jeans or comfortable pants\n",
1261
+ "journal / pen\n",
1262
+ "kayak or canoe\n",
1263
+ "kids first aid kit (including thermometer and bandages)\n",
1264
+ "knife or multitool\n",
1265
+ "knowledge of avalanche safety / course\n",
1266
+ "lamp or lantern\n",
1267
+ "laptop and charger\n",
1268
+ "layered clothing\n",
1269
+ "layers for temperature control\n",
1270
+ "layers of clothing\n",
1271
+ "lens cloth\n",
1272
+ "life jacket\n",
1273
+ "light backpack with water and snacks\n",
1274
+ "light clothing\n",
1275
+ "light down jacket or warm layer\n",
1276
+ "light gloves for climbing\n",
1277
+ "light jacket or raincoat\n",
1278
+ "light long sleeves\n",
1279
+ "light pajamas or sleepwear\n",
1280
+ "light shoes\n",
1281
+ "light tent or tarp\n",
1282
+ "light towel\n",
1283
+ "lighter\n",
1284
+ "lighter + matches (waterproof packed)\n",
1285
+ "lightweight backpack\n",
1286
+ "lightweight backpack (< 1kg)\n",
1287
+ "lightweight clothing\n",
1288
+ "lightweight cookset\n",
1289
+ "lightweight sleeping pad\n",
1290
+ "lightweight stove (gas, petrol or alcohol)\n",
1291
+ "lightweight towel\n",
1292
+ "lightweight trekking backpack (30–45 liters)\n",
1293
+ "limited clothing (layers!)\n",
1294
+ "lip balm\n",
1295
+ "long pants or skirt\n",
1296
+ "lots of water\n",
1297
+ "map and compass\n",
1298
+ "map and compass / GPS\n",
1299
+ "map or GPS\n",
1300
+ "map or offline maps\n",
1301
+ "mask and snorkel\n",
1302
+ "memory card(s)\n",
1303
+ "minimalist shelter (tarp or tent)\n",
1304
+ "music / headphones\n",
1305
+ "navigation\n",
1306
+ "navigation (map/compass/GPS)\n",
1307
+ "navigation device with offline maps\n",
1308
+ "navigation or smartphone\n",
1309
+ "noise‑cancelling headphones\n",
1310
+ "notebook + pen\n",
1311
+ "number of meals/snacks matched to duration\n",
1312
+ "optional own saddle or stirrups\n",
1313
+ "pacifier or dummy\n",
1314
+ "packaging to keep electronics dry\n",
1315
+ "pad and sleeping bag\n",
1316
+ "paddle\n",
1317
+ "pajamas\n",
1318
+ "pan or small pot\n",
1319
+ "paper map and compass\n",
1320
+ "paraglider\n",
1321
+ "partner check before departure\n",
1322
+ "payment methods (debit card / cash)\n",
1323
+ "perfume / deodorant\n",
1324
+ "phone + charger\n",
1325
+ "phone charger\n",
1326
+ "phone holder\n",
1327
+ "phone holder / navigation\n",
1328
+ "pillow or inflatable pillow\n",
1329
+ "poncho or rain jacket\n",
1330
+ "poncho or towel\n",
1331
+ "poop bags\n",
1332
+ "power bank\n",
1333
+ "power bank (at least 10,000 mAh)\n",
1334
+ "power bank or 12V charger\n",
1335
+ "press‑on bowl or mug\n",
1336
+ "probe\n",
1337
+ "probe and shovel\n",
1338
+ "public transport app or ticket\n",
1339
+ "quick snacks for en route\n",
1340
+ "quick‑dry base layers\n",
1341
+ "quick‑dry clothing\n",
1342
+ "quick‑dry towel\n",
1343
+ "quilt or down blanket\n",
1344
+ "rain cover for stroller or carrier\n",
1345
+ "rain jacket\n",
1346
+ "rain jacket or poncho\n",
1347
+ "rain jacket or windbreaker\n",
1348
+ "rain poncho\n",
1349
+ "rain protection\n",
1350
+ "rechargeable batteries and charger\n",
1351
+ "regulator (if own)\n",
1352
+ "repair kit\n",
1353
+ "reservation confirmation\n",
1354
+ "reusable bag\n",
1355
+ "reusable cup\n",
1356
+ "riding boots or shoes with heel\n",
1357
+ "riding pants\n",
1358
+ "rubber shoes\n",
1359
+ "running shoes\n",
1360
+ "sandals\n",
1361
+ "scarf or shawl\n",
1362
+ "seat cushion or beach mat\n",
1363
+ "sheet liner\n",
1364
+ "sheet liner (often required)\n",
1365
+ "shirt / blouse\n",
1366
+ "shovel\n",
1367
+ "ski boots\n",
1368
+ "ski goggles\n",
1369
+ "ski or sunglasses\n",
1370
+ "ski pass\n",
1371
+ "skis and poles\n",
1372
+ "sleep mask\n",
1373
+ "sleeping bag\n",
1374
+ "sleeping bag (light, warm variant)\n",
1375
+ "sleeping bag (suitable for temperature)\n",
1376
+ "sleeping pad\n",
1377
+ "sleeping pad that fits in car\n",
1378
+ "slippers\n",
1379
+ "slippers or indoor shoes for inside\n",
1380
+ "small backpack\n",
1381
+ "small toiletry bag\n",
1382
+ "smart jacket\n",
1383
+ "snacks\n",
1384
+ "snacks / emergency bars\n",
1385
+ "snacks / energy bars\n",
1386
+ "snacks and drinks\n",
1387
+ "snacks and toys\n",
1388
+ "snacks for along the way\n",
1389
+ "snacks for the night\n",
1390
+ "sneakers\n",
1391
+ "snorkel and mask\n",
1392
+ "snow goggles\n",
1393
+ "socks\n",
1394
+ "socks per day\n",
1395
+ "solar panel or portable charging system\n",
1396
+ "splitboard or snowboard\n",
1397
+ "spork or spoon\n",
1398
+ "sports clothing\n",
1399
+ "sports watch (optional)\n",
1400
+ "sun hat\n",
1401
+ "sun hat or cap\n",
1402
+ "sun protection\n",
1403
+ "sunglasses\n",
1404
+ "sunglasses or sport glasses\n",
1405
+ "sunglasses with strap\n",
1406
+ "sunscreen\n",
1407
+ "sunscreen and sunglasses\n",
1408
+ "sunshades or blackout covers\n",
1409
+ "surfboard\n",
1410
+ "sweater or hoodie\n",
1411
+ "swimming goggles\n",
1412
+ "swimwear\n",
1413
+ "t-shirts\n",
1414
+ "tent\n",
1415
+ "tent (1‑ or 2‑person, depending on trip)\n",
1416
+ "tent or tarp\n",
1417
+ "thermal blanket (for cold nights)\n",
1418
+ "thermal clothing\n",
1419
+ "thermos bottle\n",
1420
+ "thick gloves\n",
1421
+ "thin gloves\n",
1422
+ "tissues or toilet paper\n",
1423
+ "titanium cookset\n",
1424
+ "toiletry bag\n",
1425
+ "toiletry bag (toothpaste, brush, deodorant, soap)\n",
1426
+ "toiletry bag with biodegradable soap\n",
1427
+ "toiletry bag with essentials\n",
1428
+ "toothbrush (shortened ;))\n",
1429
+ "tour bindings (for splitboard)\n",
1430
+ "touring backpack with ski attachment\n",
1431
+ "touring skis or splitboard\n",
1432
+ "towel\n",
1433
+ "traction soles / spikes\n",
1434
+ "trail runners or lightweight hiking shoes\n",
1435
+ "travel chair or sling\n",
1436
+ "travel crib or mattress (for young children)\n",
1437
+ "travel guide or maps\n",
1438
+ "travel mat or blanket\n",
1439
+ "trekking poles\n",
1440
+ "tripod\n",
1441
+ "underwear per day\n",
1442
+ "vaccination booklet\n",
1443
+ "warm boots\n",
1444
+ "warm insulation layers\n",
1445
+ "warm jacket\n",
1446
+ "warm layer\n",
1447
+ "warm sleeping bag\n",
1448
+ "warm sweater\n",
1449
+ "warm sweater or scarf\n",
1450
+ "washing up supplies\n",
1451
+ "water bottle\n",
1452
+ "water bottle or belt\n",
1453
+ "water bottle within reach\n",
1454
+ "water bottle(s) or hydration bladder\n",
1455
+ "water filter or pump\n",
1456
+ "water shoes\n",
1457
+ "waterproof backpack cover\n",
1458
+ "waterproof bag\n",
1459
+ "waterproof shoes\n",
1460
+ "wax\n",
1461
+ "wet wipes\n",
1462
+ "wetsuit\n",
1463
+ "wind jacket\n",
1464
+ "windproof and water-repellent outer layer\n",
1465
+ "wind‑ and waterproof jacket\n",
1466
+ "world adapter plug\n",
1467
+ "yoga mat or yoga towel\n"
1468
+ ]
1469
+ }
1470
+ ],
1471
+ "source": [
1472
+ "# Load packing item data\n",
1473
+ "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
1474
+ " packing_items = json.load(file)\n",
1475
+ "\n",
1476
+ "unique_sorted = sorted({item for values in packing_items.values() for item in values})\n",
1477
+ "\n",
1478
+ "for item in unique_sorted:\n",
1479
+ " print(item)\n"
1480
+ ]
1481
+ },
1482
+ {
1483
+ "cell_type": "code",
1484
+ "execution_count": null,
1485
+ "id": "2f94ec09-ec7e-405b-9df1-34cb33ff4c28",
1486
+ "metadata": {},
1487
+ "outputs": [],
1488
+ "source": []
1489
  }
1490
  ],
1491
  "metadata": {
space/space/space/space/space/space/space/space/space/packing_templates_self_supported_offgrid_expanded.json CHANGED
@@ -1,696 +1,695 @@
1
  {
2
  "hut trek (summer)": [
3
- "lichtgewicht trekkingrugzak (30\u201345 liter)",
4
- "waterzak of drinkflessen",
5
- "sneldrogende kleding",
6
- "regenjas",
7
- "snacks/energierepen",
8
- "wandelschoenen",
9
- "hoed of pet",
10
- "zonnebrandcr\u00e8me",
11
- "lakenzak",
12
- "oordoppen"
13
  ],
14
  "hut trek (winter)": [
15
- "slaapzak (lichte, warme variant)",
16
- "lakenzak",
17
- "binnenkleding voor hut (thermo / fleece)",
18
- "hutpantoffels / Crocs",
19
- "oordoppen",
20
- "snacks voor onderweg",
21
- "contant geld voor hutbetalingen"
22
  ],
23
  "camping trip (wild camping)": [
24
- "tent of tarp",
25
- "slaapmat",
26
- "slaapzak",
27
- "hoofdlamp",
28
- "mes of multitool",
29
- "waterfilter",
30
- "kookset + brander",
31
- "voedsel en snacks",
32
- "aansteker",
33
- "toilettas met biologisch afbreekbare zeep"
34
  ],
35
  "camping trip (campground)": [
36
  "tent",
37
- "kussen",
38
- "stoeltje",
39
- "kampeertafel (optioneel)",
40
- "lamp of lantaarn",
41
- "verlengsnoer (voor stroomcamping)",
42
- "koelbox",
43
- "servies & bestek",
44
- "afwasspullen",
45
- "boodschappen"
46
  ],
47
  "skitocht / skitour": [
48
- "touringski's of splitboard",
49
- "stijgvellen",
50
- "lawinepieper (transceiver)",
51
- "schep",
52
- "sonde",
53
- "gore-tex jas en broek",
54
- "donsjas of warme isolatielaag",
55
- "helm",
56
- "handschoenen (2 paar)",
57
- "ski- of zonnebril",
58
- "thermosfles",
59
- "sneldrogende baselayers",
60
- "gamaschen (bij diepe sneeuw)",
61
- "tourrugzak met ski-bevestiging",
62
- "laagjes voor temperatuurregeling",
63
- "energierepen of sportvoeding",
64
- "GPS of offline kaarten",
65
- "EHBO-set",
66
- "lichte handschoenen voor het stijgen"
67
  ],
68
  "snowboard / splitboard trip": [
69
- "splitboard of snowboard",
70
- "lawinepieper",
71
- "helm",
72
- "dikke handschoenen",
73
- "skibril",
74
- "laagjes kleding",
75
- "tourbindingen (voor splitboard)",
76
- "stijgvellen",
77
- "sonde en schep",
78
- "lichte handschoenen voor het stijgen"
79
  ],
80
  "long-distance hike / thru-hike": [
81
- "lichtgewicht rugzak",
82
- "waterfilter",
83
- "voedselvoorraad",
84
- "navigatie (kaart/kompas/GPS)",
85
  "first aid kit",
86
- "trail runners of lichte wandelschoenen",
87
- "zonbescherming",
88
- "regenbescherming",
89
- "natte doekjes",
90
- "sneldrogende handdoek"
91
  ],
92
  "digital nomad trip": [
93
- "laptop en oplader",
94
- "wereldstekker",
95
- "noise-cancelling koptelefoon",
96
- "wifi-hotspot of lokale simkaart",
97
- "powerbank",
98
- "notitieboekje",
99
- "lichte kleding",
100
- "comfortabele rugzak of trolley",
101
- "mifi-router of portable wifi-hotspot"
102
  ],
103
  "city trip": [
104
- "dagrugzak",
105
- "oplader voor telefoon",
106
- "stadsplattegrond / offline maps",
107
- "betaalkaart / contant geld",
108
- "comfortabele schoenen",
109
- "waterfles",
110
- "reisgids of highlightslijst",
111
- "lichte jas of regenjas"
112
  ],
113
  "road trip (car/camper)": [
114
- "autopapieren",
115
- "EHBO-kit",
116
- "snacks en drinken",
117
- "telefoonhouder / navigatie",
118
- "kampeeruitrusting (indien overnachten)",
119
- "reisgids of kaarten",
120
- "zonnebril",
121
- "stoel en tafel",
122
- "vermaak (boek, muziek, spelletjes)"
123
  ],
124
  "festivaltrip": [
125
  "tent",
126
- "matje en slaapzak",
127
- "oordoppen",
128
- "poncho of regenjas",
129
  "glitter / outfit",
130
- "herbruikbare beker",
131
- "zonnebrand",
132
- "cash / pinpas",
133
- "vriendenafspraken",
134
  "snacks"
135
  ],
136
  "yoga / wellness retreat": [
137
- "yogamat of yogahanddoek",
138
- "comfortabele kleding",
139
- "waterfles",
140
- "dagboek / pen",
141
- "warme trui of sjaal",
142
- "sandalen",
143
- "etherische olie (optioneel)",
144
- "boek / meditatiemateriaal"
145
  ],
146
  "micro-adventure / weekend trip": [
147
- "dagrugzak",
148
- "snacks en drinken",
149
- "regenjas",
150
- "warme laag",
151
- "kaart of GPS",
152
- "toilettasje",
153
- "hoofddeksel",
154
- "compacte slaapuitrusting (indien overnachting)"
155
  ],
156
  "beach vacation": [
157
- "zwemkleding",
158
- "strandlaken",
159
- "zonnebrandcr\u00e8me",
160
- "zonnebril",
161
- "hoed of pet",
162
- "slippers",
163
- "luchtige kleding",
164
- "waterfles",
165
- "strandtas",
166
- "boek of e-reader"
167
  ],
168
  "cultural exploration": [
169
- "dagrugzak",
170
- "oplader voor telefoon",
171
- "stadsplattegrond / offline maps",
172
- "betaalkaart / contant geld",
173
- "comfortabele schoenen",
174
- "waterfles",
175
- "reisgids of highlightslijst",
176
- "lichte jas of regenjas"
177
  ],
178
  "nature escape": [
179
- "dagrugzak",
180
- "oplader voor telefoon",
181
- "betaalkaart / contant geld",
182
- "comfortabele schoenen",
183
- "waterfles",
184
- "downtime entertainment (e.g. book/ebook, games, laptop, journal)"
185
  ],
186
  "swimming": [
187
- "badkleding",
188
- "handdoek",
189
- "zonnebrandcr\u00e8me",
190
- "slippers",
191
- "zwembril",
192
- "waterfles"
193
  ],
194
  "going to the beach": [
195
- "strandlaken",
196
- "zwemkleding",
197
- "zonnebrand",
198
- "koeltas",
199
- "strandstoel",
200
- "zonnehoed"
201
  ],
202
  "relaxing": [
203
- "comfortabele kleding",
204
- "boek of e-reader",
205
- "zitkussen of strandmat",
206
- "muziek / koptelefoon"
207
  ],
208
  "sightseeing": [
209
- "dagrugzak",
210
- "waterfles",
211
- "camera of smartphone",
212
- "kaart of offline maps",
213
- "zonnebril"
214
  ],
215
  "biking": [
216
- "fiets of huurfiets",
217
- "helm",
218
- "sportkleding",
219
- "fietslicht en slot",
220
- "reparatieset"
221
  ],
222
  "running": [
223
- "hardloopschoenen",
224
- "sportkleding",
225
- "zweetband of pet",
226
- "waterfles of belt",
227
- "sporthorloge (optioneel)"
228
  ],
229
  "skiing": [
230
- "ski\u2019s en stokken",
231
- "skischoenen",
232
- "helm",
233
- "skibril",
234
- "skipas",
235
- "dikke handschoenen",
236
- "gore-tex kleding"
237
  ],
238
  "cross-country skiing": [
239
- "langlaufski's en stokken",
240
- "langlaufschoenen",
241
- "ademende thermokleding",
242
- "winddichte en waterafstotende buitenlaag",
243
- "dunne handschoenen",
244
- "muts of hoofdband",
245
- "zonnebril of sportbril",
246
- "buff of nekwarmer",
247
- "lichte rugzak met water en snacks",
248
- "EHBO-set"
249
  ],
250
  "ski touring": [
251
- "algemene items voor deze situatie",
252
- "extra kleding of uitrusting indien nodig"
253
  ],
254
  "hiking": [
255
- "wandelschoenen of trailrunners",
256
- "hiking sokken (anti-blaren)",
257
- "hikingstokken",
258
- "dagrugzak",
259
- "regenjas of poncho",
260
- "waterfles of waterzak",
261
- "snacks / energierepen",
262
- "zonnebrand en zonnebril",
263
- "pet of hoed",
264
- "blarenpleisters of tape",
265
- "EHBO-set",
266
- "navigatie (kaart, kompas of GPS)"
267
  ],
268
  "hut-to-hut hiking": [
269
- "lichtgewicht trekkingrugzak (30\u201345 liter)",
270
- "waterflessen of waterzak",
271
- "snacks voor onderweg",
272
- "regenjas",
273
- "licht donsjack of warme laag",
274
- "sneldrogende kleding",
275
- "wandelschoenen",
276
- "lakenzak",
277
- "pantoffels of slippers voor hut",
278
- "oordoppen",
279
- "reserveringsbevestiging / contant geld voor hut"
 
280
  ],
281
  "rock climbing": [
282
- "klimschoenen",
283
- "klimgordel",
284
- "zekeringsapparaat",
285
  "chalk bag",
286
- "helm"
287
  ],
288
  "ice climbing": [
289
- "ijsbijlen",
290
  "crampons",
291
- "klimtouw",
292
- "warme isolatielagen",
293
- "klimgordel en helm"
 
294
  ],
295
  "snowshoe hiking": [
296
- "algemene items voor deze situatie",
297
- "extra kleding of uitrusting indien nodig"
298
  ],
299
  "kayaking / canoeing": [
300
- "kayak of kano",
301
- "peddel",
302
- "reddingsvest",
303
- "drybag",
304
- "waterschoenen"
305
  ],
306
  "stand-up paddleboarding (SUP)": [
307
- "SUP-board en peddel",
308
- "reddingsvest",
309
- "drybag",
310
- "zonnebril met koord"
311
  ],
312
  "snorkeling": [
313
- "snorkel en duikbril",
314
- "zwemvliezen",
315
- "badkleding",
316
- "waterdichte tas"
317
  ],
318
  "scuba diving": [
319
- "duikbril en snorkel",
320
  "wetsuit",
321
- "vinnen",
322
- "duikcomputer",
323
- "ademautomaat (indien eigen)"
324
  ],
325
  "surfing": [
326
  "surfboard",
327
  "wetsuit",
328
  "wax",
329
  "board leash",
330
- "poncho of handdoek"
331
  ],
332
  "paragliding": [
333
  "paraglider",
334
- "helm",
335
- "handschoenen",
336
- "wandelschoenen",
337
- "windjack"
338
  ],
339
  "horseback riding": [
340
- "rijbroek",
341
- "rijlaarzen of schoenen met hak",
342
- "handschoenen",
343
- "helm",
344
- "eventueel eigen zadel of stijgbeugels"
345
  ],
346
  "photography": [
347
- "camera + lenzen",
348
- "statief",
349
- "geheugenkaart(en)",
350
- "extra accu's",
351
- "lensdoekje"
352
  ],
353
  "fishing": [
354
- "hengel",
355
- "aas / kunstaas",
356
- "visvergunning",
357
- "laarzen of waadpak",
358
- "koelbox (optioneel)"
359
  ],
360
  "rafting": [
361
- "reddingsvest",
362
- "waterdichte tas",
363
- "waterschoenen",
364
- "sneldrogende kleding",
365
- "helm"
366
  ],
367
  "yoga": [
368
- "algemene items voor deze situatie",
369
- "extra kleding of uitrusting indien nodig"
370
  ],
371
  "cold destination / winter": [
372
- "thermokleding",
373
- "muts en handschoenen",
374
- "warme jas",
375
- "waterdichte schoenen",
376
- "lippenbalsem"
377
  ],
378
  "warm destination / summer": [
379
- "luchtige kleding",
380
- "zonnebril",
381
- "zonnecr\u00e8me",
382
- "waterfles",
383
- "hoed of pet"
384
  ],
385
  "variable weather / spring / autumn": [
386
- "regenjas",
387
- "laagjeskleding",
388
- "warme trui",
389
- "waterdichte schoenen"
390
  ],
391
  "tropical / humid": [
392
- "lichtgewicht kleding",
393
- "insectenspray",
394
- "zonnecr\u00e8me",
395
- "regenponcho",
396
- "sneldrogende handdoek"
397
  ],
398
  "dry / desert-like": [
399
- "zonnebril",
400
- "zonnecr\u00e8me",
401
- "hoofdbescherming",
402
- "lichte lange mouwen",
403
- "veel water"
404
  ],
405
  "ultralight": [
406
- "lichtgewicht rugzak (< 1kg)",
407
- "minimalistische shelter (tarp of tent)",
408
- "lichtgewicht slaapmat",
409
- "quilt of donsdeken",
410
- "titanium kookset",
411
- "beperkte kleding (laagjes!)",
412
- "compacte regenjas",
413
- "sneldrogende handdoek",
414
- "tandenborstel (afgezaagd ;))"
415
  ],
416
  "lightweight (but comfortable)": [
417
- "lichte tent of tarp",
418
- "comfortabele slaapmat",
419
- "lichtgewicht kookset",
420
- "compact kledingpakket",
421
- "sneldrogende handdoek"
422
  ],
423
  "luxury (including evening wear)": [
424
- "nette schoenen",
425
- "jurk of overhemd",
426
- "parfum/deodorant",
427
- "accessoires",
428
- "reistoilettas met essentials"
429
  ],
430
  "minimalist": [
431
- "1 set kleding voor elke situatie",
432
- "compacte tandenborstel",
433
- "alles-in-\u00e9\u00e9n zeep",
434
- "lichtgewicht handdoek",
435
- "kleine rugzak"
436
  ],
437
  "casual": [
438
- "jeans of comfortabele broek",
439
  "t-shirts",
440
- "trui of hoodie",
441
  "sneakers",
442
- "zonnebril"
443
  ],
444
  "formal (business trip)": [
445
- "overhemd / blouse",
446
- "net jasje",
447
- "nette schoenen",
448
- "laptop en oplader",
449
- "naamkaartjes / documenten"
450
  ],
451
  "conservative": [
452
- "bedekkende kleding",
453
- "sjaal of omslagdoek",
454
- "lange broek of rok",
455
- "gesloten schoenen"
456
  ],
457
  "outdoor": [
458
- "regenjas",
459
- "waterdichte schoenen",
460
- "bivakzak of tarp",
461
- "hoofdlamp",
462
- "navigatie"
463
  ],
464
  "indoor": [
465
- "pantoffels",
466
- "comfortabele kleding",
467
- "pyjama",
468
- "oplader",
469
- "toilettas"
470
  ],
471
  "huts with half board": [
472
- "reserveringsbevestiging",
473
- "lakenzak (vaak verplicht)",
474
- "pantoffels of slippers voor binnen",
475
- "lichte pyjama of slaapkleding",
476
- "oorstopjes",
477
- "waterfles",
478
- "snacks voor onderweg",
479
- "kleine toilettas",
480
- "contant geld voor betalingen",
481
- "lichte handdoek",
482
- "zaklamp of hoofdlamp"
483
  ],
484
  "sleeping in a tent": [
485
- "tent (1- of 2-persoons, afhankelijk van reis)",
486
- "grondzeil",
487
- "slaapmat",
488
- "slaapzak (passend bij temperatuur)",
489
- "hoofdlamp of zaklamp",
490
- "sneldrogende handdoek",
491
- "kussen of opblaasbaar hoofdkussen",
492
- "oorstopjes",
493
- "toilettas",
494
- "powerbank",
495
- "waterfles",
496
- "boek of e-reader",
497
- "EHBO-set"
498
  ],
499
  "sleeping in a car": [
500
- "slaapmat die past in auto",
501
- "warme slaapzak",
502
- "zonneschermen of verduistering",
503
- "kussen",
504
- "waterfles binnen handbereik",
505
- "powerbank of 12V-lader",
506
- "toilettas",
507
- "snacks voor de nacht",
508
- "thermische deken (voor koude nachten)"
509
  ],
510
  "own vehicle": [
511
- "rijbewijs",
512
- "autopapieren",
513
- "EHBO-set",
514
- "navigatie of smartphone",
515
- "telefoonhouder"
516
  ],
517
  "no own vehicle": [
518
- "rugzak",
519
- "waterfles",
520
- "lichte schoenen",
521
- "openbaar vervoer app of ticket"
522
  ],
523
  "off-grid / no electricity": [
524
- "powerbank (minstens 10.000 mAh)",
525
- "zonnepaneel of draagbaar laadsysteem",
526
- "hoofdlamp + extra batterijen",
527
- "oplaadbare batterijen en oplader",
528
- "back-up verlichting (bijv. kleine zaklamp)",
529
- "papieren kaart en kompas",
530
- "notitieboekje + pen",
531
- "noodcommunicatie (bijv. GPS beacon of satellietboodschapper)",
532
- "opvouwbaar zonnepaneel (indien langere tochten)",
533
- "navigatieapparaat met offline kaarten",
534
- "extra opladerkabels",
535
- "USB-hub (voor meerdere devices)",
536
- "verpakking om elektronica droog te houden"
537
  ],
538
  "self-supported (bring your own cooking gear)": [
539
- "lichtgewicht kooktoestel (gas, benzine of alcohol)",
540
- "brandstof (voldoende voor aantal dagen)",
541
- "pan of keteltje",
542
- "spork of lepel",
543
- "opvouwbaar snijplankje (optioneel)",
544
- "aandrukbare kom of beker",
545
- "aansteker + lucifers (waterdicht verpakt)",
546
- "gedroogde of gevriesdroogde maaltijden",
547
- "snacks / noodbars",
548
- "afwasmiddel (biologisch afbreekbaar) + sponsje",
549
- "opslagzakken voor afval",
550
- "waterfilter of -pomp",
551
- "chloordruppels of zuiveringstabletten",
552
- "minstens 2 liter wateropslag per persoon",
553
- "food bag of hangzak voor voedsel (wild-safe)"
554
  ],
555
  "travel with children": [
556
- "snacks en speelgoed",
557
- "EHBO-set met pleisters",
558
- "extra kleding",
559
- "kinderdrager of buggy",
560
- "zonbescherming",
561
- "extra snacks voor kinderen",
562
- "favoriet speelgoed of knuffel",
563
- "reisstoel of draagzak",
564
- "natte doekjes",
565
- "luiers of potje (afhankelijk van leeftijd)",
566
- "extra set kleding per dag",
567
- "reisapotheek voor kinderen",
568
- "kinderzonnebrand",
569
- "activiteitenboekje of tablet met filmpjes",
570
- "snelle snacks voor onderweg",
571
- "kinder slaapzak of slaapmat",
572
- "reisbedje of matrasje (voor jonge kinderen)",
573
- "luiers of oefenbroekjes",
574
- "flesjes en voeding (indien van toepassing)",
575
- "babyfoon (voor verblijf op locatie)",
576
- "speen of fopspeen",
577
- "kinder EHBO-set (inclusief thermometer)",
578
- "zonnehoedje of muts",
579
- "regenhoes voor kinderwagen of draagzak",
580
- "hydraterende cr\u00e8me (voor gevoelige huid)"
581
  ],
582
  "pet-friendly": [
583
- "voer en waterbak",
584
- "hondenriem of tuigje",
585
- "poepzakjes",
586
- "reismatje of deken",
587
- "vaccinatieboekje"
588
  ],
589
  "rainy climate": [
590
- "regenjas of poncho",
591
- "waterdichte rugzakhoes",
592
- "sneldrogende kleding",
593
- "rubberen schoenen"
594
  ],
595
  "snow and ice": [
596
- "warme laarzen",
597
- "dikke handschoenen",
598
- "sneeuwbril",
599
- "thermokleding",
600
- "gripzolen / spikes"
601
  ],
602
  "high alpine terrain": [
603
- "wandelstokken",
604
- "kaart en kompas",
605
- "wind- en waterdichte jas",
606
- "extra voeding",
607
- "EHBO-kit"
608
  ],
609
  "snow, ice and avalanche-prone terrain": [
610
- "lawinepieper",
611
- "schep",
612
- "sonde",
613
- "airbag rugzak (indien beschikbaar)",
614
- "kennis van lawineveiligheid / cursus",
615
- "kaart en kompas / GPS",
616
- "partner check voor vertrek"
617
- ],
618
- "no special conditions": [
619
- ]
620
  "1 day": [
621
- "ondergoed per dag",
622
- "sokken per dag",
623
- "toilettas",
624
- "extra kledinglaag",
625
- "aantal maaltijden/snacks afgestemd op duur"
626
  ],
627
  "2 days": [
628
- "ondergoed per dag",
629
- "sokken per dag",
630
- "toilettas",
631
- "extra kledinglaag",
632
- "aantal maaltijden/snacks afgestemd op duur"
633
  ],
634
  "3 days": [
635
- "ondergoed per dag",
636
- "sokken per dag",
637
- "toilettas",
638
- "extra kledinglaag",
639
- "aantal maaltijden/snacks afgestemd op duur"
640
  ],
641
  "4 days": [
642
- "ondergoed per dag",
643
- "sokken per dag",
644
- "toilettas",
645
- "extra kledinglaag",
646
- "aantal maaltijden/snacks afgestemd op duur"
647
  ],
648
  "5 days": [
649
- "ondergoed per dag",
650
- "sokken per dag",
651
- "toilettas",
652
- "extra kledinglaag",
653
- "aantal maaltijden/snacks afgestemd op duur"
654
  ],
655
  "6 days": [
656
- "ondergoed per dag",
657
- "sokken per dag",
658
- "toilettas",
659
- "extra kledinglaag",
660
- "aantal maaltijden/snacks afgestemd op duur"
661
  ],
662
  "7 days": [
663
- "ondergoed per dag",
664
- "sokken per dag",
665
- "toilettas",
666
- "extra kledinglaag",
667
- "aantal maaltijden/snacks afgestemd op duur"
668
  ],
669
  "7+ days": [
670
- "ondergoed per dag",
671
- "sokken per dag",
672
- "toilettas",
673
- "extra kledinglaag",
674
- "aantal maaltijden/snacks afgestemd op duur"
675
  ],
676
  "default_items": [
677
- "telefoon + oplader",
678
- "powerbank",
679
- "identiteitsbewijs of paspoort",
680
- "betaalmiddelen (pinpas / contant geld)",
681
- "verzekeringspas / reisverzekering-info",
682
- "toilettas (tandpasta, borstel, deodorant, zeep)",
683
- "zonnebrandcr\u00e8me",
684
- "lippenbalsem",
685
- "ondergoed",
686
- "sokken",
687
- "regenjas of windjack",
688
- "waterfles",
689
  "snacks",
690
- "zonnebril",
691
- "oorstopjes",
692
- "slaapmasker",
693
- "herbruikbare tas",
694
- "zakdoekjes of toiletpapier"
695
  ]
696
- }
 
1
  {
2
  "hut trek (summer)": [
3
+ "lightweight trekking backpack (30–45 liters)",
4
+ "water bottle(s) or hydration bladder",
5
+ "quick‑dry clothing",
6
+ "rain jacket",
7
+ "snacks / energy bars",
8
+ "hiking boots",
9
+ "hat or cap",
10
+ "sunscreen",
11
+ "sheet liner",
12
+ "earplugs"
13
  ],
14
  "hut trek (winter)": [
15
+ "sleeping bag (light, warm variant)",
16
+ "sheet liner",
17
+ "indoor hut clothing (thermo / fleece)",
18
+ "hut slippers / Crocs",
19
+ "earplugs",
20
+ "snacks for along the way",
21
+ "cash for payments"
22
  ],
23
  "camping trip (wild camping)": [
24
+ "tent or tarp",
25
+ "sleeping pad",
26
+ "sleeping bag",
27
+ "headlamp",
28
+ "knife or multitool",
29
+ "water filter or pump",
30
+ "cookset + stove",
31
+ "food and snacks",
32
+ "lighter",
33
+ "toiletry bag with biodegradable soap"
34
  ],
35
  "camping trip (campground)": [
36
  "tent",
37
+ "pillow or inflatable pillow",
38
+ "chair",
39
+ "camping table (optional)",
40
+ "lamp or lantern",
41
+ "extension cord (for powered campsites)",
42
+ "cooler box",
43
+ "dishes & cutlery",
44
+ "washing up supplies",
45
+ "groceries"
46
  ],
47
  "skitocht / skitour": [
48
+ "touring skis or splitboard",
49
+ "climbing skins",
50
+ "avalanche beacon (transceiver)",
51
+ "shovel",
52
+ "probe",
53
+ "Gore‑Tex jacket and pants",
54
+ "down jacket or warm insulation layer",
55
+ "helmet",
56
+ "gloves (2 pairs)",
57
+ "ski or sunglasses",
58
+ "thermos bottle",
59
+ "quick‑dry base layers",
60
+ "gaiters (in deep snow)",
61
+ "touring backpack with ski attachment",
62
+ "layers for temperature control",
63
+ "energy bars or sports nutrition",
64
+ "GPS or offline maps",
65
+ "first aid kit",
66
+ "light gloves for climbing"
67
  ],
68
  "snowboard / splitboard trip": [
69
+ "splitboard or snowboard",
70
+ "avalanche beacon (transceiver)",
71
+ "helmet",
72
+ "thick gloves",
73
+ "ski goggles",
74
+ "layers of clothing",
75
+ "tour bindings (for splitboard)",
76
+ "climbing skins",
77
+ "probe and shovel",
78
+ "light gloves for climbing"
79
  ],
80
  "long-distance hike / thru-hike": [
81
+ "lightweight backpack",
82
+ "water filter or pump",
83
+ "food supply",
84
+ "navigation (map/compass/GPS)",
85
  "first aid kit",
86
+ "trail runners or lightweight hiking shoes",
87
+ "sun protection",
88
+ "rain protection",
89
+ "wet wipes",
90
+ "quick‑dry towel"
91
  ],
92
  "digital nomad trip": [
93
+ "laptop and charger",
94
+ "world adapter plug",
95
+ "noisecancelling headphones",
96
+ "WiFi hotspot or local SIM card",
97
+ "power bank",
98
+ "notebook + pen",
99
+ "light clothing",
100
+ "comfortable backpack or trolley",
101
+ "MiFi router or portable WiFi hotspot"
102
  ],
103
  "city trip": [
104
+ "daypack",
105
+ "phone charger",
106
+ "city map / offline maps",
107
+ "bank card / cash",
108
+ "comfortable shoes",
109
+ "water bottle",
110
+ "guidebook or highlights list",
111
+ "light jacket or raincoat"
112
  ],
113
  "road trip (car/camper)": [
114
+ "car documents",
115
+ "first aid kit",
116
+ "snacks and drinks",
117
+ "phone holder / navigation",
118
+ "camping gear (if staying overnight)",
119
+ "travel guide or maps",
120
+ "sunglasses",
121
+ "chair and table",
122
+ "entertainment (book, music, games)"
123
  ],
124
  "festivaltrip": [
125
  "tent",
126
+ "pad and sleeping bag",
127
+ "earplugs",
128
+ "poncho or rain jacket",
129
  "glitter / outfit",
130
+ "reusable cup",
131
+ "sunscreen",
132
+ "cash / card",
133
+ "friend meetups",
134
  "snacks"
135
  ],
136
  "yoga / wellness retreat": [
137
+ "yoga mat or yoga towel",
138
+ "comfortable clothing",
139
+ "water bottle",
140
+ "journal / pen",
141
+ "warm sweater or scarf",
142
+ "sandals",
143
+ "essential oils (optional)",
144
+ "book / meditation material"
145
  ],
146
  "micro-adventure / weekend trip": [
147
+ "daypack",
148
+ "snacks and drinks",
149
+ "rain jacket",
150
+ "warm layer",
151
+ "map or GPS",
152
+ "toiletry bag",
153
+ "head cover",
154
+ "compact sleeping gear (if overnighting)"
155
  ],
156
  "beach vacation": [
157
+ "swimwear",
158
+ "beach towel",
159
+ "sunscreen",
160
+ "sunglasses",
161
+ "hat or cap",
162
+ "flip flops",
163
+ "lightweight clothing",
164
+ "water bottle",
165
+ "beach bag",
166
+ "book or ereader"
167
  ],
168
  "cultural exploration": [
169
+ "daypack",
170
+ "phone charger",
171
+ "city map / offline maps",
172
+ "bank card / cash",
173
+ "comfortable shoes",
174
+ "water bottle",
175
+ "guidebook or highlights list",
176
+ "light jacket or raincoat"
177
  ],
178
  "nature escape": [
179
+ "daypack",
180
+ "phone charger",
181
+ "bank card / cash",
182
+ "comfortable shoes",
183
+ "water bottle",
184
+ "entertainment (book, music, games)"
185
  ],
186
  "swimming": [
187
+ "swimwear",
188
+ "towel",
189
+ "sunscreen",
190
+ "flip flops",
191
+ "swimming goggles",
192
+ "water bottle"
193
  ],
194
  "going to the beach": [
195
+ "beach towel",
196
+ "swimwear",
197
+ "sunscreen",
198
+ "cooler",
199
+ "beach chair",
200
+ "sun hat"
201
  ],
202
  "relaxing": [
203
+ "comfortable clothing",
204
+ "book or ereader",
205
+ "seat cushion or beach mat",
206
+ "music / headphones"
207
  ],
208
  "sightseeing": [
209
+ "daypack",
210
+ "water bottle",
211
+ "camera or smartphone",
212
+ "map or offline maps",
213
+ "sunglasses"
214
  ],
215
  "biking": [
216
+ "bike or rental bike",
217
+ "helmet",
218
+ "sports clothing",
219
+ "bike light and lock",
220
+ "repair kit"
221
  ],
222
  "running": [
223
+ "running shoes",
224
+ "sports clothing",
225
+ "headband or cap",
226
+ "water bottle or belt",
227
+ "sports watch (optional)"
228
  ],
229
  "skiing": [
230
+ "skis and poles",
231
+ "ski boots",
232
+ "helmet",
233
+ "ski goggles",
234
+ "ski pass",
235
+ "thick gloves",
236
+ "Gore‑Tex clothing"
237
  ],
238
  "cross-country skiing": [
239
+ "cross-country skis and poles",
240
+ "cross-country ski boots",
241
+ "breathable thermal clothing",
242
+ "windproof and water-repellent outer layer",
243
+ "thin gloves",
244
+ "hat or headband",
245
+ "sunglasses or sport glasses",
246
+ "buff or neck warmer",
247
+ "light backpack with water and snacks",
248
+ "first aid kit"
249
  ],
250
  "ski touring": [
251
+ "general items for this situation",
252
+ "extra clothing or gear if needed"
253
  ],
254
  "hiking": [
255
+ "hiking boots or trail runners",
256
+ "hiking socks (anti-blister)",
257
+ "hiking poles",
258
+ "daypack",
259
+ "rain jacket or poncho",
260
+ "water bottle(s) or hydration bladder",
261
+ "snacks / energy bars",
262
+ "sunscreen and sunglasses",
263
+ "cap or hat",
264
+ "blister plasters or tape",
265
+ "first aid kit",
266
+ "navigation (map/compass/GPS)"
267
  ],
268
  "hut-to-hut hiking": [
269
+ "lightweight trekking backpack (30–45 liters)",
270
+ "water bottle(s) or hydration bladder",
271
+ "snacks for along the way",
272
+ "rain jacket",
273
+ "light down jacket or warm layer",
274
+ "quick‑dry clothing",
275
+ "hiking boots",
276
+ "sheet liner",
277
+ "slippers or indoor shoes for inside",
278
+ "earplugs",
279
+ "reservation confirmation",
280
+ "cash for hut"
281
  ],
282
  "rock climbing": [
283
+ "climbing shoes",
284
+ "climbing harness",
285
+ "belay device",
286
  "chalk bag",
287
+ "helmet"
288
  ],
289
  "ice climbing": [
290
+ "ice axes",
291
  "crampons",
292
+ "climbing rope",
293
+ "warm insulation layers",
294
+ "climbing harness",
295
+ "helmet"
296
  ],
297
  "snowshoe hiking": [
298
+ "general items for this situation",
299
+ "extra clothing or gear if needed"
300
  ],
301
  "kayaking / canoeing": [
302
+ "kayak or canoe",
303
+ "paddle",
304
+ "life jacket",
305
+ "dry bag",
306
+ "water shoes"
307
  ],
308
  "stand-up paddleboarding (SUP)": [
309
+ "SUP board and paddle",
310
+ "life jacket",
311
+ "dry bag",
312
+ "sunglasses with strap"
313
  ],
314
  "snorkeling": [
315
+ "snorkel and mask",
316
+ "fins",
317
+ "swimwear",
318
+ "waterproof bag"
319
  ],
320
  "scuba diving": [
321
+ "mask and snorkel",
322
  "wetsuit",
323
+ "fins",
324
+ "dive computer",
325
+ "regulator (if own)"
326
  ],
327
  "surfing": [
328
  "surfboard",
329
  "wetsuit",
330
  "wax",
331
  "board leash",
332
+ "poncho or towel"
333
  ],
334
  "paragliding": [
335
  "paraglider",
336
+ "helmet",
337
+ "gloves",
338
+ "hiking boots",
339
+ "wind jacket"
340
  ],
341
  "horseback riding": [
342
+ "riding pants",
343
+ "riding boots or shoes with heel",
344
+ "gloves",
345
+ "helmet",
346
+ "optional own saddle or stirrups"
347
  ],
348
  "photography": [
349
+ "camera + lenses",
350
+ "tripod",
351
+ "memory card(s)",
352
+ "extra batteries",
353
+ "lens cloth"
354
  ],
355
  "fishing": [
356
+ "fishing rod",
357
+ "bait / lures",
358
+ "fishing license",
359
+ "boots or waders",
360
+ "cooler box (optional)"
361
  ],
362
  "rafting": [
363
+ "life jacket",
364
+ "waterproof bag",
365
+ "water shoes",
366
+ "quick‑dry clothing",
367
+ "helmet"
368
  ],
369
  "yoga": [
370
+ "general items for this situation",
371
+ "extra clothing or gear if needed"
372
  ],
373
  "cold destination / winter": [
374
+ "thermal clothing",
375
+ "hat and gloves",
376
+ "warm jacket",
377
+ "waterproof shoes",
378
+ "lip balm"
379
  ],
380
  "warm destination / summer": [
381
+ "lightweight clothing",
382
+ "sunglasses",
383
+ "sunscreen",
384
+ "water bottle",
385
+ "hat or cap"
386
  ],
387
  "variable weather / spring / autumn": [
388
+ "rain jacket",
389
+ "layered clothing",
390
+ "warm sweater",
391
+ "waterproof shoes"
392
  ],
393
  "tropical / humid": [
394
+ "lightweight clothing",
395
+ "insect repellent",
396
+ "sunscreen",
397
+ "rain poncho",
398
+ "quick‑dry towel"
399
  ],
400
  "dry / desert-like": [
401
+ "sunglasses",
402
+ "sunscreen",
403
+ "head protection",
404
+ "light long sleeves",
405
+ "lots of water"
406
  ],
407
  "ultralight": [
408
+ "lightweight backpack (< 1kg)",
409
+ "minimalist shelter (tarp or tent)",
410
+ "lightweight sleeping pad",
411
+ "quilt or down blanket",
412
+ "titanium cookset",
413
+ "limited clothing (layers!)",
414
+ "compact rain jacket",
415
+ "quick‑dry towel",
416
+ "toothbrush (shortened ;))"
417
  ],
418
  "lightweight (but comfortable)": [
419
+ "light tent or tarp",
420
+ "comfortable sleeping pad",
421
+ "lightweight cookset",
422
+ "compact clothing pack",
423
+ "quick‑dry towel"
424
  ],
425
  "luxury (including evening wear)": [
426
+ "dress shoes",
427
+ "dress or shirt",
428
+ "perfume / deodorant",
429
+ "accessories",
430
+ "toiletry bag with essentials"
431
  ],
432
  "minimalist": [
433
+ "1 set of clothing for every situation",
434
+ "compact toothbrush",
435
+ "all‑in‑one soap",
436
+ "lightweight towel",
437
+ "small backpack"
438
  ],
439
  "casual": [
440
+ "jeans or comfortable pants",
441
  "t-shirts",
442
+ "sweater or hoodie",
443
  "sneakers",
444
+ "sunglasses"
445
  ],
446
  "formal (business trip)": [
447
+ "shirt / blouse",
448
+ "smart jacket",
449
+ "dress shoes",
450
+ "laptop and charger",
451
+ "business cards / documents"
452
  ],
453
  "conservative": [
454
+ "covering clothing",
455
+ "scarf or shawl",
456
+ "long pants or skirt",
457
+ "closed shoes"
458
  ],
459
  "outdoor": [
460
+ "rain jacket",
461
+ "waterproof shoes",
462
+ "bivvy bag or tarp",
463
+ "headlamp",
464
+ "navigation"
465
  ],
466
  "indoor": [
467
+ "slippers",
468
+ "comfortable clothing",
469
+ "pajamas",
470
+ "charger",
471
+ "toiletry bag"
472
  ],
473
  "huts with half board": [
474
+ "reservation confirmation",
475
+ "sheet liner (often required)",
476
+ "slippers or indoor shoes for inside",
477
+ "light pajamas or sleepwear",
478
+ "earplugs",
479
+ "water bottle",
480
+ "snacks for along the way",
481
+ "small toiletry bag",
482
+ "cash for payments",
483
+ "light towel",
484
+ "flashlight or headlamp"
485
  ],
486
  "sleeping in a tent": [
487
+ "tent (1 or 2‑person, depending on trip)",
488
+ "groundsheet",
489
+ "sleeping pad",
490
+ "sleeping bag (suitable for temperature)",
491
+ "headlamp or flashlight",
492
+ "quick‑dry towel",
493
+ "pillow or inflatable pillow",
494
+ "earplugs",
495
+ "toiletry bag",
496
+ "power bank",
497
+ "water bottle",
498
+ "book or ereader",
499
+ "first aid kit"
500
  ],
501
  "sleeping in a car": [
502
+ "sleeping pad that fits in car",
503
+ "warm sleeping bag",
504
+ "sunshades or blackout covers",
505
+ "pillow or inflatable pillow",
506
+ "water bottle within reach",
507
+ "power bank or 12V charger",
508
+ "toiletry bag",
509
+ "snacks for the night",
510
+ "thermal blanket (for cold nights)"
511
  ],
512
  "own vehicle": [
513
+ "driver’s license",
514
+ "car documents",
515
+ "first aid kit",
516
+ "navigation or smartphone",
517
+ "phone holder"
518
  ],
519
  "no own vehicle": [
520
+ "backpack",
521
+ "water bottle",
522
+ "light shoes",
523
+ "public transport app or ticket"
524
  ],
525
  "off-grid / no electricity": [
526
+ "power bank (at least 10,000 mAh)",
527
+ "solar panel or portable charging system",
528
+ "headlamp + extra batteries",
529
+ "rechargeable batteries and charger",
530
+ "backup lighting (e.g. small flashlight)",
531
+ "paper map and compass",
532
+ "notebook + pen",
533
+ "emergency communication (e.g. GPS beacon or satellite messenger)",
534
+ "foldable solar panel (if on longer trips)",
535
+ "navigation device with offline maps",
536
+ "extra charger cables",
537
+ "USB hub (for multiple devices)",
538
+ "packaging to keep electronics dry"
539
  ],
540
  "self-supported (bring your own cooking gear)": [
541
+ "lightweight stove (gas, petrol or alcohol)",
542
+ "fuel (enough for several days)",
543
+ "pan or small pot",
544
+ "spork or spoon",
545
+ "foldable cutting board (optional)",
546
+ "press‑on bowl or mug",
547
+ "lighter + matches (waterproof packed)",
548
+ "dried or freeze‑dried meals",
549
+ "snacks / emergency bars",
550
+ "biodegradable soap + sponge",
551
+ "bags for waste",
552
+ "water filter or pump",
553
+ "chlorine drops or purification tablets",
554
+ "at least 2 liters of water storage per person",
555
+ "food bag or hanging bag (wild-safe)"
556
  ],
557
  "travel with children": [
558
+ "snacks and toys",
559
+ "extra clothing",
560
+ "child carrier or stroller",
561
+ "sun protection",
562
+ "extra snacks for children",
563
+ "favorite toy or stuffed animal",
564
+ "travel chair or sling",
565
+ "wet wipes",
566
+ "diapers or potty (depending on age)",
567
+ "extra clothing set per day",
568
+ "children’s travel pharmacy",
569
+ "children’s sunscreen",
570
+ "activity book or tablet with films",
571
+ "quick snacks for en route",
572
+ "child sleeping bag or pad",
573
+ "travel crib or mattress (for young children)",
574
+ "bottles and food (if applicable)",
575
+ "baby monitor (for staying at location)",
576
+ "pacifier or dummy",
577
+ "kids first aid kit (including thermometer and bandages)",
578
+ "sun hat or cap",
579
+ "rain cover for stroller or carrier",
580
+ "hydrating cream (for sensitive skin)"
 
 
581
  ],
582
  "pet-friendly": [
583
+ "food and water bowl",
584
+ "dog leash or harness",
585
+ "poop bags",
586
+ "travel mat or blanket",
587
+ "vaccination booklet"
588
  ],
589
  "rainy climate": [
590
+ "rain jacket or poncho",
591
+ "waterproof backpack cover",
592
+ "quick‑dry clothing",
593
+ "rubber shoes"
594
  ],
595
  "snow and ice": [
596
+ "warm boots",
597
+ "thick gloves",
598
+ "snow goggles",
599
+ "thermal clothing",
600
+ "traction soles / spikes"
601
  ],
602
  "high alpine terrain": [
603
+ "trekking poles",
604
+ "map and compass",
605
+ "wind and waterproof jacket",
606
+ "extra food",
607
+ "first aid kit"
608
  ],
609
  "snow, ice and avalanche-prone terrain": [
610
+ "avalanche beacon (transceiver)",
611
+ "shovel",
612
+ "probe",
613
+ "airbag backpack (if available)",
614
+ "knowledge of avalanche safety / course",
615
+ "map and compass / GPS",
616
+ "partner check before departure"
617
+ ],
618
+ "no special conditions": [],
 
619
  "1 day": [
620
+ "underwear per day",
621
+ "socks per day",
622
+ "toiletry bag",
623
+ "extra clothing layer",
624
+ "number of meals/snacks matched to duration"
625
  ],
626
  "2 days": [
627
+ "underwear per day",
628
+ "socks per day",
629
+ "toiletry bag",
630
+ "extra clothing layer",
631
+ "number of meals/snacks matched to duration"
632
  ],
633
  "3 days": [
634
+ "underwear per day",
635
+ "socks per day",
636
+ "toiletry bag",
637
+ "extra clothing layer",
638
+ "number of meals/snacks matched to duration"
639
  ],
640
  "4 days": [
641
+ "underwear per day",
642
+ "socks per day",
643
+ "toiletry bag",
644
+ "extra clothing layer",
645
+ "number of meals/snacks matched to duration"
646
  ],
647
  "5 days": [
648
+ "underwear per day",
649
+ "socks per day",
650
+ "toiletry bag",
651
+ "extra clothing layer",
652
+ "number of meals/snacks matched to duration"
653
  ],
654
  "6 days": [
655
+ "underwear per day",
656
+ "socks per day",
657
+ "toiletry bag",
658
+ "extra clothing layer",
659
+ "number of meals/snacks matched to duration"
660
  ],
661
  "7 days": [
662
+ "underwear per day",
663
+ "socks per day",
664
+ "toiletry bag",
665
+ "extra clothing layer",
666
+ "number of meals/snacks matched to duration"
667
  ],
668
  "7+ days": [
669
+ "underwear per day",
670
+ "socks per day",
671
+ "toiletry bag",
672
+ "extra clothing layer",
673
+ "number of meals/snacks matched to duration"
674
  ],
675
  "default_items": [
676
+ "phone + charger",
677
+ "power bank",
678
+ "identity document or passport",
679
+ "payment methods (debit card / cash)",
680
+ "insurance card / travel insurance info",
681
+ "toiletry bag (toothpaste, brush, deodorant, soap)",
682
+ "sunscreen",
683
+ "lip balm",
684
+ "underwear per day",
685
+ "socks",
686
+ "rain jacket or windbreaker",
687
+ "water bottle",
688
  "snacks",
689
+ "sunglasses",
690
+ "earplugs",
691
+ "sleep mask",
692
+ "reusable bag",
693
+ "tissues or toilet paper"
694
  ]
695
+ }
space/space/space/space/space/space/space/space/space/space/space/space/.ipynb_checkpoints/app-checkpoint.py CHANGED
@@ -1,22 +1,48 @@
 
1
  from transformers import pipeline
 
 
2
  import gradio as gr
3
 
4
- # Load the model and create a pipeline for zero-shot classification
5
- classifier = pipeline("zero-shot-classification", model="facebook/bart-base")
 
 
6
 
7
- # Load labels from a txt file
8
- with open("labels.txt", "r", encoding="utf-8") as f:
9
- class_labels = [line.strip() for line in f if line.strip()]
10
 
11
- # Define the Gradio interface
12
- def classify(text):
13
- return classifier(text, class_labels)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  demo = gr.Interface(
16
  fn=classify,
17
- inputs="text",
18
- outputs="json",
19
- title="Zero-Shot Classification",
 
 
 
 
20
  description="Enter a text describing your trip",
21
  )
22
 
 
1
+ # Prerequisites
2
  from transformers import pipeline
3
+ import json
4
+ import pandas as pd
5
  import gradio as gr
6
 
7
+ # get candidate labels
8
+ with open("packing_label_structure.json", "r") as file:
9
+ candidate_labels = json.load(file)
10
+ keys_list = list(candidate_labels.keys())
11
 
12
+ # Load test data (in list of dictionaries)
13
+ with open("test_data.json", "r") as file:
14
+ packing_data = json.load(file)
15
 
16
+ # function and gradio app
17
+ model_name = "facebook/bart-large-mnli"
18
+ classifier = pipeline("zero-shot-classification", model=model_name)
19
+ cut_off = 0.5 # used to choose which activities are relevant
20
+
21
+ def classify(#model_name,
22
+ trip_descr, cut_off):
23
+
24
+ # Create an empty DataFrame with specified columns
25
+ df = pd.DataFrame(columns=['superclass', 'pred_class'])
26
+ for i, key in enumerate(keys_list):
27
+ if key == 'activities':
28
+ result = classifier(trip_descr, candidate_labels[key], multi_label=True)
29
+ indices = [i for i, score in enumerate(result['scores']) if score > cut_off]
30
+ classes = [result['labels'][i] for i in indices]
31
+ else:
32
+ result = classifier(trip_descr, candidate_labels[key])
33
+ classes = result["labels"][0]
34
+ df.loc[i] = [key, classes]
35
+ return df
36
 
37
  demo = gr.Interface(
38
  fn=classify,
39
+ inputs=[
40
+ #gr.Textbox(label="Model name", value = "facebook/bart-large-mnli"),
41
+ gr.Textbox(label="Trip description"),
42
+ gr.Number(label="Activity cut-off", value = 0.5),
43
+ ],
44
+ outputs="dataframe",
45
+ title="Trip classification",
46
  description="Enter a text describing your trip",
47
  )
48
 
space/space/space/space/space/space/space/space/space/space/space/space/.ipynb_checkpoints/main_model-checkpoint.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
space/space/space/space/space/space/space/space/space/space/space/space/app.py CHANGED
@@ -1,22 +1,48 @@
 
1
  from transformers import pipeline
 
 
2
  import gradio as gr
3
 
4
- # Load the model and create a pipeline for zero-shot classification
5
- classifier = pipeline("zero-shot-classification", model="facebook/bart-base")
 
 
6
 
7
- # Load labels from a txt file
8
- with open("labels.txt", "r", encoding="utf-8") as f:
9
- class_labels = [line.strip() for line in f if line.strip()]
10
 
11
- # Define the Gradio interface
12
- def classify(text):
13
- return classifier(text, class_labels)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  demo = gr.Interface(
16
  fn=classify,
17
- inputs="text",
18
- outputs="json",
19
- title="Zero-Shot Classification",
 
 
 
 
20
  description="Enter a text describing your trip",
21
  )
22
 
 
1
+ # Prerequisites
2
  from transformers import pipeline
3
+ import json
4
+ import pandas as pd
5
  import gradio as gr
6
 
7
+ # get candidate labels
8
+ with open("packing_label_structure.json", "r") as file:
9
+ candidate_labels = json.load(file)
10
+ keys_list = list(candidate_labels.keys())
11
 
12
+ # Load test data (in list of dictionaries)
13
+ with open("test_data.json", "r") as file:
14
+ packing_data = json.load(file)
15
 
16
+ # function and gradio app
17
+ model_name = "facebook/bart-large-mnli"
18
+ classifier = pipeline("zero-shot-classification", model=model_name)
19
+ cut_off = 0.5 # used to choose which activities are relevant
20
+
21
+ def classify(#model_name,
22
+ trip_descr, cut_off):
23
+
24
+ # Create an empty DataFrame with specified columns
25
+ df = pd.DataFrame(columns=['superclass', 'pred_class'])
26
+ for i, key in enumerate(keys_list):
27
+ if key == 'activities':
28
+ result = classifier(trip_descr, candidate_labels[key], multi_label=True)
29
+ indices = [i for i, score in enumerate(result['scores']) if score > cut_off]
30
+ classes = [result['labels'][i] for i in indices]
31
+ else:
32
+ result = classifier(trip_descr, candidate_labels[key])
33
+ classes = result["labels"][0]
34
+ df.loc[i] = [key, classes]
35
+ return df
36
 
37
  demo = gr.Interface(
38
  fn=classify,
39
+ inputs=[
40
+ #gr.Textbox(label="Model name", value = "facebook/bart-large-mnli"),
41
+ gr.Textbox(label="Trip description"),
42
+ gr.Number(label="Activity cut-off", value = 0.5),
43
+ ],
44
+ outputs="dataframe",
45
+ title="Trip classification",
46
  description="Enter a text describing your trip",
47
  )
48
 
space/space/space/space/space/space/space/space/space/space/space/space/main_model.ipynb ADDED
@@ -0,0 +1,1115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "e25090fa-f990-4f1a-84f3-b12159eedae8",
6
+ "metadata": {},
7
+ "source": [
8
+ "# Implement and test prediciton model"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "markdown",
13
+ "id": "3bbee2e4-55c8-4b06-9929-72026edf7932",
14
+ "metadata": {},
15
+ "source": [
16
+ "## Prerequisites"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": 1,
22
+ "id": "f8c28d2d-8458-49fd-8ebf-5e729d6e861f",
23
+ "metadata": {},
24
+ "outputs": [],
25
+ "source": [
26
+ "# Prerequisites\n",
27
+ "from tabulate import tabulate\n",
28
+ "from transformers import pipeline\n",
29
+ "import json\n",
30
+ "import pandas as pd\n",
31
+ "import matplotlib.pyplot as plt\n",
32
+ "import pickle\n",
33
+ "import os\n",
34
+ "import time\n",
35
+ "import math\n",
36
+ "\n",
37
+ "# get candidate labels\n",
38
+ "with open(\"packing_label_structure.json\", \"r\") as file:\n",
39
+ " candidate_labels = json.load(file)\n",
40
+ "keys_list = list(candidate_labels.keys())\n",
41
+ "\n",
42
+ "# Load test data (in list of dictionaries)\n",
43
+ "with open(\"test_data.json\", \"r\") as file:\n",
44
+ " packing_data = json.load(file)\n",
45
+ "# Extract all trip descriptions and trip_types\n",
46
+ "trip_descriptions = [trip['description'] for trip in packing_data]\n",
47
+ "trip_types = [trip['trip_types'] for trip in packing_data]\n",
48
+ "\n",
49
+ "# Access the first trip description\n",
50
+ "first_trip = trip_descriptions[0]\n",
51
+ "# Get the packing list for the secondfirst trip\n",
52
+ "first_trip_type = trip_types[0]\n",
53
+ "\n",
54
+ "# print(f\"First trip: {first_trip} \\n\")\n",
55
+ "# print(f\"Trip type: {first_trip_type}\")"
56
+ ]
57
+ },
58
+ {
59
+ "cell_type": "markdown",
60
+ "id": "5cf4f76f-0035-44e8-93af-52eafaec686e",
61
+ "metadata": {},
62
+ "source": [
63
+ "**All trip descriptions**"
64
+ ]
65
+ },
66
+ {
67
+ "cell_type": "code",
68
+ "execution_count": 2,
69
+ "id": "89d42ca7-e871-4eda-b428-69e9bd965428",
70
+ "metadata": {
71
+ "jupyter": {
72
+ "source_hidden": true
73
+ },
74
+ "scrolled": true
75
+ },
76
+ "outputs": [
77
+ {
78
+ "name": "stdout",
79
+ "output_type": "stream",
80
+ "text": [
81
+ "0 . I am planning a trip to Greece with my boyfriend, where we will visit two islands. We have booked an apartment on each island for a few days and plan to spend most of our time relaxing. Our main goals are to enjoy the beach, try delicious local food, and possibly go on a hike—if it’s not too hot. We will be relying solely on public transport. We’re in our late 20s and traveling from the Netherlands. \n",
82
+ "\n",
83
+ "beach vacation\n",
84
+ "['swimming', 'going to the beach', 'relaxing', 'hiking']\n",
85
+ "warm destination / summer\n",
86
+ "lightweight (but comfortable)\n",
87
+ "casual\n",
88
+ "indoor\n",
89
+ "no own vehicle\n",
90
+ "no special conditions to consider\n",
91
+ "7+ days\n",
92
+ "\n",
93
+ "\n",
94
+ "1 . We are a couple in our thirties traveling to Vienna for a three-day city trip. We’ll be staying at a friend’s house and plan to explore the city by sightseeing, strolling through the streets, visiting markets, and trying out great restaurants and cafés. We also hope to attend a classical music concert. Our journey to Vienna will be by train. \n",
95
+ "\n",
96
+ "city trip\n",
97
+ "['sightseeing']\n",
98
+ "variable weather / spring / autumn\n",
99
+ "luxury (including evening wear)\n",
100
+ "casual\n",
101
+ "indoor\n",
102
+ "no own vehicle\n",
103
+ "no special conditions to consider\n",
104
+ "3 days\n",
105
+ "\n",
106
+ "\n",
107
+ "2 . My partner and I are traveling to the Netherlands and Germany to spend Christmas with our family. We are in our late twenties and will start our journey with a two-hour flight to the Netherlands. From there, we will take a 5.5-hour train ride to northern Germany. \n",
108
+ "\n",
109
+ "city trip\n",
110
+ "['relaxing']\n",
111
+ "cold destination / winter\n",
112
+ "lightweight (but comfortable)\n",
113
+ "casual\n",
114
+ "indoor\n",
115
+ "no own vehicle\n",
116
+ "no special conditions to consider\n",
117
+ "7+ days\n",
118
+ "\n",
119
+ "\n",
120
+ "3 . I’m in my twenties and will be traveling to Peru for three weeks. I’m going solo but will meet up with a friend to explore the Sacred Valley and take part in a Machu Picchu tour. We plan to hike, go rafting, and explore the remnants of the ancient Inca Empire. We’re also excited to try Peruvian cuisine and immerse ourselves in the local culture. Depending on our plans, we might also visit the rainforest region, such as Tarapoto. I’ll be flying to Peru on a long-haul flight and will be traveling in August. \n",
121
+ "\n",
122
+ "cultural exploration\n",
123
+ "['sightseeing', 'hiking', 'rafting']\n",
124
+ "variable weather / spring / autumn\n",
125
+ "lightweight (but comfortable)\n",
126
+ "casual\n",
127
+ "indoor\n",
128
+ "no own vehicle\n",
129
+ "rainy climate\n",
130
+ "7+ days\n",
131
+ "\n",
132
+ "\n",
133
+ "4 . We’re planning a 10-day trip to Austria in the summer, combining hiking with relaxation by the lake. We love exploring scenic trails and enjoying the outdoors, but we also want to unwind and swim in the lake. It’s the perfect mix of adventure and relaxation. \n",
134
+ "\n",
135
+ "nature escape\n",
136
+ "['swimming', 'relaxing', 'hiking']\n",
137
+ "warm destination / summer\n",
138
+ "lightweight (but comfortable)\n",
139
+ "casual\n",
140
+ "indoor\n",
141
+ "no own vehicle\n",
142
+ "no special conditions to consider\n",
143
+ "7+ days\n",
144
+ "\n",
145
+ "\n",
146
+ "5 . I am going on a multiple day hike and passing though mountains and the beach in Croatia. I like to pack light and will stay in refugios/huts with half board and travel to the start of the hike by car. It will be 6-7 days. \n",
147
+ "\n",
148
+ "long-distance hike / thru-hike\n",
149
+ "['going to the beach']\n",
150
+ "tropical / humid\n",
151
+ "minimalist\n",
152
+ "casual\n",
153
+ "huts with half board\n",
154
+ "own vehicle\n",
155
+ "off-grid / no electricity\n",
156
+ "6 days\n",
157
+ "\n",
158
+ "\n",
159
+ "6 . I will go with a friend on a beach holiday and we will do stand-up paddling, and surfing in the North of Spain. The destination is windy and can get cold, but is generally sunny. We will go by car and bring a tent to sleep in. It will be two weeks. \n",
160
+ "\n",
161
+ "beach vacation\n",
162
+ "['stand-up paddleboarding (SUP)', 'surfing']\n",
163
+ "cold destination / winter\n",
164
+ "ultralight\n",
165
+ "casual\n",
166
+ "sleeping in a tent\n",
167
+ "own vehicle\n",
168
+ "off-grid / no electricity\n",
169
+ "6 days\n",
170
+ "\n",
171
+ "\n",
172
+ "7 . We will go to Sweden in the winter, to go for a yoga and sauna/wellness retreat. I prefer lightweight packing and also want clothes to go for fancy dinners and maybe on a winter hike. We stay in hotels. \n",
173
+ "\n",
174
+ "yoga / wellness retreat\n",
175
+ "['hiking', 'yoga']\n",
176
+ "cold destination / winter\n",
177
+ "lightweight (but comfortable)\n",
178
+ "casual\n",
179
+ "indoor\n",
180
+ "no own vehicle\n",
181
+ "snow and ice\n",
182
+ "7 days\n",
183
+ "\n",
184
+ "\n",
185
+ "8 . I go on a skitouring trip where we also make videos/photos and the destination is Japan. Mainly sports clothes and isolation are needed (it is winter). We stay in a guesthouse. It will be 10 days. \n",
186
+ "\n",
187
+ "ski tour / skitour\n",
188
+ "['ski touring', 'photography', 'swimming']\n",
189
+ "cold destination / winter\n",
190
+ "minimalist\n",
191
+ "conservative\n",
192
+ "indoor\n",
193
+ "no own vehicle\n",
194
+ "avalanche-prone terrain\n",
195
+ "5 days\n",
196
+ "\n",
197
+ "\n",
198
+ "9 . We plan a wild camping trip with activities such as snorkeling, kayaking and canoeing. It is a warm place and we want to bring little stuff. We stay in tents and hammocks and travel with a car, it will be 3 days. \n",
199
+ "\n",
200
+ "camping trip (wild camping)\n",
201
+ "['scuba diving', 'kayaking / canoeing']\n",
202
+ "tropical / humid\n",
203
+ "lightweight (but comfortable)\n",
204
+ "conservative\n",
205
+ "sleeping in a tent\n",
206
+ "own vehicle\n",
207
+ "no special conditions to consider\n",
208
+ "3 days\n",
209
+ "\n",
210
+ "\n"
211
+ ]
212
+ }
213
+ ],
214
+ "source": [
215
+ "for i, item in enumerate(trip_descriptions):\n",
216
+ " print(i, \".\", item, \"\\n\")\n",
217
+ " for elem in trip_types[i]:\n",
218
+ " print(elem)\n",
219
+ " print(\"\\n\")"
220
+ ]
221
+ },
222
+ {
223
+ "cell_type": "markdown",
224
+ "id": "0f60c54b-affc-4d9a-acf1-da70f68c5578",
225
+ "metadata": {},
226
+ "source": [
227
+ "**Functions**"
228
+ ]
229
+ },
230
+ {
231
+ "cell_type": "code",
232
+ "execution_count": 2,
233
+ "id": "fac51224-9575-4b4b-8567-4ad4e759ecc9",
234
+ "metadata": {},
235
+ "outputs": [],
236
+ "source": [
237
+ "# function that returns pandas data frame with predictions and true values\n",
238
+ "\n",
239
+ "cut_off = 0.5 # used to choose which activities are relevant\n",
240
+ "\n",
241
+ "def pred_trip(model_name, trip_descr, trip_type, cut_off):\n",
242
+ " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
243
+ " # Create an empty DataFrame with specified columns\n",
244
+ " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
245
+ " for i, key in enumerate(keys_list):\n",
246
+ " if key == 'activities':\n",
247
+ " result = classifier(trip_descr, candidate_labels[key], multi_label=True)\n",
248
+ " indices = [i for i, score in enumerate(result['scores']) if score > cut_off]\n",
249
+ " classes = [result['labels'][i] for i in indices]\n",
250
+ " else:\n",
251
+ " result = classifier(trip_descr, candidate_labels[key])\n",
252
+ " classes = result[\"labels\"][0]\n",
253
+ " print(result)\n",
254
+ " print(classes)\n",
255
+ " print(i)\n",
256
+ " df.loc[i] = [key, classes]\n",
257
+ " df['true_class'] = trip_type\n",
258
+ " return df"
259
+ ]
260
+ },
261
+ {
262
+ "cell_type": "code",
263
+ "execution_count": 3,
264
+ "id": "b36ab806-2f35-4950-ac5a-7c192190cba7",
265
+ "metadata": {},
266
+ "outputs": [],
267
+ "source": [
268
+ "# function for accuracy, perc true classes identified and perc wrong pred classes\n",
269
+ "\n",
270
+ "def perf_measure(df):\n",
271
+ " df['same_value'] = df['pred_class'] == df['true_class']\n",
272
+ " correct = sum(df.loc[df.index != 1, 'same_value'])\n",
273
+ " total = len(df['same_value'])\n",
274
+ " accuracy = correct/total\n",
275
+ " pred_class = df.loc[df.index == 1, 'pred_class'].iloc[0]\n",
276
+ " true_class = df.loc[df.index == 1, 'true_class'].iloc[0]\n",
277
+ " correct = [label for label in pred_class if label in true_class]\n",
278
+ " num_correct = len(correct)\n",
279
+ " correct_perc = num_correct/len(true_class)\n",
280
+ " num_pred = len(pred_class)\n",
281
+ " if num_pred == 0:\n",
282
+ " wrong_perc = math.nan\n",
283
+ " else:\n",
284
+ " wrong_perc = (num_pred - num_correct)/num_pred\n",
285
+ " df_perf = pd.DataFrame({\n",
286
+ " 'accuracy': [accuracy],\n",
287
+ " 'true_ident': [correct_perc],\n",
288
+ " 'false_pred': [wrong_perc]\n",
289
+ " })\n",
290
+ " return(df_perf)"
291
+ ]
292
+ },
293
+ {
294
+ "cell_type": "markdown",
295
+ "id": "c10aa57d-d7ed-45c7-bdf5-29af193c7fd5",
296
+ "metadata": {},
297
+ "source": [
298
+ "## Make predictions for many models and trip descriptions\n",
299
+ "\n",
300
+ "Provide a list of candidate models and apply them to the test data."
301
+ ]
302
+ },
303
+ {
304
+ "cell_type": "code",
305
+ "execution_count": 6,
306
+ "id": "dd7869a8-b436-40de-9ea0-28eb4b7d3248",
307
+ "metadata": {
308
+ "scrolled": true
309
+ },
310
+ "outputs": [
311
+ {
312
+ "name": "stdout",
313
+ "output_type": "stream",
314
+ "text": [
315
+ "\n",
316
+ "Using model: facebook/bart-large-mnli\n"
317
+ ]
318
+ },
319
+ {
320
+ "name": "stderr",
321
+ "output_type": "stream",
322
+ "text": [
323
+ "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n"
324
+ ]
325
+ },
326
+ {
327
+ "ename": "KeyboardInterrupt",
328
+ "evalue": "",
329
+ "output_type": "error",
330
+ "traceback": [
331
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
332
+ "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
333
+ "Cell \u001b[0;32mIn[6], line 25\u001b[0m\n\u001b[1;32m 23\u001b[0m current_trip \u001b[38;5;241m=\u001b[39m trip_descriptions[i]\n\u001b[1;32m 24\u001b[0m current_type \u001b[38;5;241m=\u001b[39m trip_types[i]\n\u001b[0;32m---> 25\u001b[0m df \u001b[38;5;241m=\u001b[39m \u001b[43mpred_trip\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcurrent_trip\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcurrent_type\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcut_off\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m0.5\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 26\u001b[0m \u001b[38;5;28mprint\u001b[39m(df)\n\u001b[1;32m 27\u001b[0m \u001b[38;5;66;03m# accuracy, perc true classes identified and perc wrong pred classes\u001b[39;00m\n",
334
+ "Cell \u001b[0;32mIn[3], line 15\u001b[0m, in \u001b[0;36mpred_trip\u001b[0;34m(model_name, trip_descr, trip_type, cut_off)\u001b[0m\n\u001b[1;32m 13\u001b[0m classes \u001b[38;5;241m=\u001b[39m [result[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlabels\u001b[39m\u001b[38;5;124m'\u001b[39m][i] \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m indices]\n\u001b[1;32m 14\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m---> 15\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[43mclassifier\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtrip_descr\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcandidate_labels\u001b[49m\u001b[43m[\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 16\u001b[0m classes \u001b[38;5;241m=\u001b[39m result[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlabels\u001b[39m\u001b[38;5;124m\"\u001b[39m][\u001b[38;5;241m0\u001b[39m]\n\u001b[1;32m 17\u001b[0m \u001b[38;5;28mprint\u001b[39m(result)\n",
335
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/pipelines/zero_shot_classification.py:206\u001b[0m, in \u001b[0;36mZeroShotClassificationPipeline.__call__\u001b[0;34m(self, sequences, *args, **kwargs)\u001b[0m\n\u001b[1;32m 203\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 204\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mUnable to understand extra arguments \u001b[39m\u001b[38;5;132;01m{\u001b[39;00margs\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m--> 206\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43msuper\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[38;5;21;43m__call__\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43msequences\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
336
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/pipelines/base.py:1294\u001b[0m, in \u001b[0;36mPipeline.__call__\u001b[0;34m(self, inputs, num_workers, batch_size, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1292\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39miterate(inputs, preprocess_params, forward_params, postprocess_params)\n\u001b[1;32m 1293\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mframework \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpt\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(\u001b[38;5;28mself\u001b[39m, ChunkPipeline):\n\u001b[0;32m-> 1294\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mnext\u001b[39;49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1295\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43miter\u001b[39;49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1296\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_iterator\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1297\u001b[0m \u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43minputs\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnum_workers\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbatch_size\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpreprocess_params\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mforward_params\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpostprocess_params\u001b[49m\n\u001b[1;32m 1298\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1299\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1300\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1301\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 1302\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mrun_single(inputs, preprocess_params, forward_params, postprocess_params)\n",
337
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/pipelines/pt_utils.py:124\u001b[0m, in \u001b[0;36mPipelineIterator.__next__\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 121\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mloader_batch_item()\n\u001b[1;32m 123\u001b[0m \u001b[38;5;66;03m# We're out of items within a batch\u001b[39;00m\n\u001b[0;32m--> 124\u001b[0m item \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mnext\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43miterator\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 125\u001b[0m processed \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39minfer(item, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mparams)\n\u001b[1;32m 126\u001b[0m \u001b[38;5;66;03m# We now have a batch of \"inferred things\".\u001b[39;00m\n",
338
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/pipelines/pt_utils.py:269\u001b[0m, in \u001b[0;36mPipelinePackIterator.__next__\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 266\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m accumulator\n\u001b[1;32m 268\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m is_last:\n\u001b[0;32m--> 269\u001b[0m processed \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minfer\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mnext\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43miterator\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mparams\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 270\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mloader_batch_size \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 271\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(processed, torch\u001b[38;5;241m.\u001b[39mTensor):\n",
339
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/pipelines/base.py:1209\u001b[0m, in \u001b[0;36mPipeline.forward\u001b[0;34m(self, model_inputs, **forward_params)\u001b[0m\n\u001b[1;32m 1207\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m inference_context():\n\u001b[1;32m 1208\u001b[0m model_inputs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_ensure_tensor_on_device(model_inputs, device\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdevice)\n\u001b[0;32m-> 1209\u001b[0m model_outputs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_forward\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel_inputs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mforward_params\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1210\u001b[0m model_outputs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_ensure_tensor_on_device(model_outputs, device\u001b[38;5;241m=\u001b[39mtorch\u001b[38;5;241m.\u001b[39mdevice(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcpu\u001b[39m\u001b[38;5;124m\"\u001b[39m))\n\u001b[1;32m 1211\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n",
340
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/pipelines/zero_shot_classification.py:229\u001b[0m, in \u001b[0;36mZeroShotClassificationPipeline._forward\u001b[0;34m(self, inputs)\u001b[0m\n\u001b[1;32m 227\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124muse_cache\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m inspect\u001b[38;5;241m.\u001b[39msignature(model_forward)\u001b[38;5;241m.\u001b[39mparameters\u001b[38;5;241m.\u001b[39mkeys():\n\u001b[1;32m 228\u001b[0m model_inputs[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124muse_cache\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m\n\u001b[0;32m--> 229\u001b[0m outputs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmodel\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mmodel_inputs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 231\u001b[0m model_outputs \u001b[38;5;241m=\u001b[39m {\n\u001b[1;32m 232\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcandidate_label\u001b[39m\u001b[38;5;124m\"\u001b[39m: candidate_label,\n\u001b[1;32m 233\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msequence\u001b[39m\u001b[38;5;124m\"\u001b[39m: sequence,\n\u001b[1;32m 234\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mis_last\u001b[39m\u001b[38;5;124m\"\u001b[39m: inputs[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mis_last\u001b[39m\u001b[38;5;124m\"\u001b[39m],\n\u001b[1;32m 235\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39moutputs,\n\u001b[1;32m 236\u001b[0m }\n\u001b[1;32m 237\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m model_outputs\n",
341
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/torch/nn/modules/module.py:1511\u001b[0m, in \u001b[0;36mModule._wrapped_call_impl\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1509\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_compiled_call_impl(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs) \u001b[38;5;66;03m# type: ignore[misc]\u001b[39;00m\n\u001b[1;32m 1510\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m-> 1511\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call_impl\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
342
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/torch/nn/modules/module.py:1520\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1515\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[1;32m 1516\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[1;32m 1517\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks\n\u001b[1;32m 1518\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[1;32m 1519\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[0;32m-> 1520\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1522\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 1523\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n",
343
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/bart/modeling_bart.py:1763\u001b[0m, in \u001b[0;36mBartForSequenceClassification.forward\u001b[0;34m(self, input_ids, attention_mask, decoder_input_ids, decoder_attention_mask, head_mask, decoder_head_mask, cross_attn_head_mask, encoder_outputs, inputs_embeds, decoder_inputs_embeds, labels, use_cache, output_attentions, output_hidden_states, return_dict)\u001b[0m\n\u001b[1;32m 1758\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m input_ids \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m inputs_embeds \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 1759\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mNotImplementedError\u001b[39;00m(\n\u001b[1;32m 1760\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mPassing input embeddings is currently not supported for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__class__\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 1761\u001b[0m )\n\u001b[0;32m-> 1763\u001b[0m outputs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmodel\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1764\u001b[0m \u001b[43m \u001b[49m\u001b[43minput_ids\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1765\u001b[0m \u001b[43m \u001b[49m\u001b[43mattention_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mattention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1766\u001b[0m \u001b[43m \u001b[49m\u001b[43mdecoder_input_ids\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdecoder_input_ids\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1767\u001b[0m \u001b[43m \u001b[49m\u001b[43mdecoder_attention_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdecoder_attention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1768\u001b[0m \u001b[43m \u001b[49m\u001b[43mhead_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mhead_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1769\u001b[0m \u001b[43m \u001b[49m\u001b[43mdecoder_head_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdecoder_head_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1770\u001b[0m \u001b[43m \u001b[49m\u001b[43mcross_attn_head_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcross_attn_head_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1771\u001b[0m \u001b[43m \u001b[49m\u001b[43mencoder_outputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mencoder_outputs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1772\u001b[0m \u001b[43m \u001b[49m\u001b[43minputs_embeds\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43minputs_embeds\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1773\u001b[0m \u001b[43m \u001b[49m\u001b[43mdecoder_inputs_embeds\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdecoder_inputs_embeds\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1774\u001b[0m \u001b[43m \u001b[49m\u001b[43muse_cache\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43muse_cache\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1775\u001b[0m \u001b[43m \u001b[49m\u001b[43moutput_attentions\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moutput_attentions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1776\u001b[0m \u001b[43m \u001b[49m\u001b[43moutput_hidden_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moutput_hidden_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1777\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_dict\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_dict\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1778\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1779\u001b[0m hidden_states \u001b[38;5;241m=\u001b[39m outputs[\u001b[38;5;241m0\u001b[39m] \u001b[38;5;66;03m# last hidden state\u001b[39;00m\n\u001b[1;32m 1781\u001b[0m eos_mask \u001b[38;5;241m=\u001b[39m input_ids\u001b[38;5;241m.\u001b[39meq(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconfig\u001b[38;5;241m.\u001b[39meos_token_id)\u001b[38;5;241m.\u001b[39mto(hidden_states\u001b[38;5;241m.\u001b[39mdevice)\n",
344
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/torch/nn/modules/module.py:1511\u001b[0m, in \u001b[0;36mModule._wrapped_call_impl\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1509\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_compiled_call_impl(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs) \u001b[38;5;66;03m# type: ignore[misc]\u001b[39;00m\n\u001b[1;32m 1510\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m-> 1511\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call_impl\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
345
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/torch/nn/modules/module.py:1520\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1515\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[1;32m 1516\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[1;32m 1517\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks\n\u001b[1;32m 1518\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[1;32m 1519\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[0;32m-> 1520\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1522\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 1523\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n",
346
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/bart/modeling_bart.py:1528\u001b[0m, in \u001b[0;36mBartModel.forward\u001b[0;34m(self, input_ids, attention_mask, decoder_input_ids, decoder_attention_mask, head_mask, decoder_head_mask, cross_attn_head_mask, encoder_outputs, past_key_values, inputs_embeds, decoder_inputs_embeds, use_cache, output_attentions, output_hidden_states, return_dict)\u001b[0m\n\u001b[1;32m 1521\u001b[0m encoder_outputs \u001b[38;5;241m=\u001b[39m BaseModelOutput(\n\u001b[1;32m 1522\u001b[0m last_hidden_state\u001b[38;5;241m=\u001b[39mencoder_outputs[\u001b[38;5;241m0\u001b[39m],\n\u001b[1;32m 1523\u001b[0m hidden_states\u001b[38;5;241m=\u001b[39mencoder_outputs[\u001b[38;5;241m1\u001b[39m] \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(encoder_outputs) \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m1\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[1;32m 1524\u001b[0m attentions\u001b[38;5;241m=\u001b[39mencoder_outputs[\u001b[38;5;241m2\u001b[39m] \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(encoder_outputs) \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m2\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[1;32m 1525\u001b[0m )\n\u001b[1;32m 1527\u001b[0m \u001b[38;5;66;03m# decoder outputs consists of (dec_features, past_key_value, dec_hidden, dec_attn)\u001b[39;00m\n\u001b[0;32m-> 1528\u001b[0m decoder_outputs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdecoder\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1529\u001b[0m \u001b[43m \u001b[49m\u001b[43minput_ids\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdecoder_input_ids\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1530\u001b[0m \u001b[43m \u001b[49m\u001b[43mattention_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdecoder_attention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1531\u001b[0m \u001b[43m \u001b[49m\u001b[43mencoder_hidden_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mencoder_outputs\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1532\u001b[0m \u001b[43m \u001b[49m\u001b[43mencoder_attention_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mattention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1533\u001b[0m \u001b[43m \u001b[49m\u001b[43mhead_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdecoder_head_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1534\u001b[0m \u001b[43m \u001b[49m\u001b[43mcross_attn_head_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcross_attn_head_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1535\u001b[0m \u001b[43m \u001b[49m\u001b[43mpast_key_values\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpast_key_values\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1536\u001b[0m \u001b[43m \u001b[49m\u001b[43minputs_embeds\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdecoder_inputs_embeds\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1537\u001b[0m \u001b[43m \u001b[49m\u001b[43muse_cache\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43muse_cache\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1538\u001b[0m \u001b[43m \u001b[49m\u001b[43moutput_attentions\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moutput_attentions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1539\u001b[0m \u001b[43m \u001b[49m\u001b[43moutput_hidden_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moutput_hidden_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1540\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_dict\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_dict\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1541\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1543\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m return_dict:\n\u001b[1;32m 1544\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m decoder_outputs \u001b[38;5;241m+\u001b[39m encoder_outputs\n",
347
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/torch/nn/modules/module.py:1511\u001b[0m, in \u001b[0;36mModule._wrapped_call_impl\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1509\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_compiled_call_impl(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs) \u001b[38;5;66;03m# type: ignore[misc]\u001b[39;00m\n\u001b[1;32m 1510\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m-> 1511\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call_impl\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
348
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/torch/nn/modules/module.py:1520\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1515\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[1;32m 1516\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[1;32m 1517\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks\n\u001b[1;32m 1518\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[1;32m 1519\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[0;32m-> 1520\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1522\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 1523\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n",
349
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/bart/modeling_bart.py:1380\u001b[0m, in \u001b[0;36mBartDecoder.forward\u001b[0;34m(self, input_ids, attention_mask, encoder_hidden_states, encoder_attention_mask, head_mask, cross_attn_head_mask, past_key_values, inputs_embeds, use_cache, output_attentions, output_hidden_states, return_dict)\u001b[0m\n\u001b[1;32m 1367\u001b[0m layer_outputs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_gradient_checkpointing_func(\n\u001b[1;32m 1368\u001b[0m decoder_layer\u001b[38;5;241m.\u001b[39m\u001b[38;5;21m__call__\u001b[39m,\n\u001b[1;32m 1369\u001b[0m hidden_states,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1377\u001b[0m use_cache,\n\u001b[1;32m 1378\u001b[0m )\n\u001b[1;32m 1379\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m-> 1380\u001b[0m layer_outputs \u001b[38;5;241m=\u001b[39m \u001b[43mdecoder_layer\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1381\u001b[0m \u001b[43m \u001b[49m\u001b[43mhidden_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1382\u001b[0m \u001b[43m \u001b[49m\u001b[43mattention_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mattention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1383\u001b[0m \u001b[43m \u001b[49m\u001b[43mencoder_hidden_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mencoder_hidden_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1384\u001b[0m \u001b[43m \u001b[49m\u001b[43mencoder_attention_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mencoder_attention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1385\u001b[0m \u001b[43m \u001b[49m\u001b[43mlayer_head_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mhead_mask\u001b[49m\u001b[43m[\u001b[49m\u001b[43midx\u001b[49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mhead_mask\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mis\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mnot\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01melse\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1386\u001b[0m \u001b[43m \u001b[49m\u001b[43mcross_attn_layer_head_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1387\u001b[0m \u001b[43m \u001b[49m\u001b[43mcross_attn_head_mask\u001b[49m\u001b[43m[\u001b[49m\u001b[43midx\u001b[49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mcross_attn_head_mask\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mis\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mnot\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01melse\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\n\u001b[1;32m 1388\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1389\u001b[0m \u001b[43m \u001b[49m\u001b[43mpast_key_value\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpast_key_value\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1390\u001b[0m \u001b[43m \u001b[49m\u001b[43moutput_attentions\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moutput_attentions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1391\u001b[0m \u001b[43m \u001b[49m\u001b[43muse_cache\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43muse_cache\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1392\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1393\u001b[0m hidden_states \u001b[38;5;241m=\u001b[39m layer_outputs[\u001b[38;5;241m0\u001b[39m]\n\u001b[1;32m 1395\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m use_cache:\n",
350
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/torch/nn/modules/module.py:1511\u001b[0m, in \u001b[0;36mModule._wrapped_call_impl\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1509\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_compiled_call_impl(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs) \u001b[38;5;66;03m# type: ignore[misc]\u001b[39;00m\n\u001b[1;32m 1510\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m-> 1511\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call_impl\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
351
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/torch/nn/modules/module.py:1520\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1515\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[1;32m 1516\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[1;32m 1517\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks\n\u001b[1;32m 1518\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[1;32m 1519\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[0;32m-> 1520\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1522\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 1523\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n",
352
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/bart/modeling_bart.py:666\u001b[0m, in \u001b[0;36mBartDecoderLayer.forward\u001b[0;34m(self, hidden_states, attention_mask, encoder_hidden_states, encoder_attention_mask, layer_head_mask, cross_attn_layer_head_mask, past_key_value, output_attentions, use_cache)\u001b[0m\n\u001b[1;32m 664\u001b[0m self_attn_past_key_value \u001b[38;5;241m=\u001b[39m past_key_value[:\u001b[38;5;241m2\u001b[39m] \u001b[38;5;28;01mif\u001b[39;00m past_key_value \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 665\u001b[0m \u001b[38;5;66;03m# add present self-attn cache to positions 1,2 of present_key_value tuple\u001b[39;00m\n\u001b[0;32m--> 666\u001b[0m hidden_states, self_attn_weights, present_key_value \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mself_attn\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 667\u001b[0m \u001b[43m \u001b[49m\u001b[43mhidden_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mhidden_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 668\u001b[0m \u001b[43m \u001b[49m\u001b[43mpast_key_value\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mself_attn_past_key_value\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 669\u001b[0m \u001b[43m \u001b[49m\u001b[43mattention_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mattention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 670\u001b[0m \u001b[43m \u001b[49m\u001b[43mlayer_head_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mlayer_head_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 671\u001b[0m \u001b[43m \u001b[49m\u001b[43moutput_attentions\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moutput_attentions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 672\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 673\u001b[0m hidden_states \u001b[38;5;241m=\u001b[39m nn\u001b[38;5;241m.\u001b[39mfunctional\u001b[38;5;241m.\u001b[39mdropout(hidden_states, p\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdropout, training\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtraining)\n\u001b[1;32m 674\u001b[0m hidden_states \u001b[38;5;241m=\u001b[39m residual \u001b[38;5;241m+\u001b[39m hidden_states\n",
353
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/torch/nn/modules/module.py:1511\u001b[0m, in \u001b[0;36mModule._wrapped_call_impl\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1509\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_compiled_call_impl(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs) \u001b[38;5;66;03m# type: ignore[misc]\u001b[39;00m\n\u001b[1;32m 1510\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m-> 1511\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call_impl\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
354
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/torch/nn/modules/module.py:1520\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1515\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[1;32m 1516\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[1;32m 1517\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks\n\u001b[1;32m 1518\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[1;32m 1519\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[0;32m-> 1520\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1522\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 1523\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n",
355
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/bart/modeling_bart.py:450\u001b[0m, in \u001b[0;36mBartSdpaAttention.forward\u001b[0;34m(self, hidden_states, key_value_states, past_key_value, attention_mask, layer_head_mask, output_attentions)\u001b[0m\n\u001b[1;32m 447\u001b[0m bsz, tgt_len, _ \u001b[38;5;241m=\u001b[39m hidden_states\u001b[38;5;241m.\u001b[39msize()\n\u001b[1;32m 449\u001b[0m \u001b[38;5;66;03m# get query proj\u001b[39;00m\n\u001b[0;32m--> 450\u001b[0m query_states \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mq_proj\u001b[49m\u001b[43m(\u001b[49m\u001b[43mhidden_states\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 451\u001b[0m \u001b[38;5;66;03m# get key, value proj\u001b[39;00m\n\u001b[1;32m 452\u001b[0m \u001b[38;5;66;03m# `past_key_value[0].shape[2] == key_value_states.shape[1]`\u001b[39;00m\n\u001b[1;32m 453\u001b[0m \u001b[38;5;66;03m# is checking that the `sequence_length` of the `past_key_value` is the same as\u001b[39;00m\n\u001b[1;32m 454\u001b[0m \u001b[38;5;66;03m# the provided `key_value_states` to support prefix tuning\u001b[39;00m\n\u001b[1;32m 455\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (\n\u001b[1;32m 456\u001b[0m is_cross_attention\n\u001b[1;32m 457\u001b[0m \u001b[38;5;129;01mand\u001b[39;00m past_key_value \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 458\u001b[0m \u001b[38;5;129;01mand\u001b[39;00m past_key_value[\u001b[38;5;241m0\u001b[39m]\u001b[38;5;241m.\u001b[39mshape[\u001b[38;5;241m2\u001b[39m] \u001b[38;5;241m==\u001b[39m key_value_states\u001b[38;5;241m.\u001b[39mshape[\u001b[38;5;241m1\u001b[39m]\n\u001b[1;32m 459\u001b[0m ):\n\u001b[1;32m 460\u001b[0m \u001b[38;5;66;03m# reuse k,v, cross_attentions\u001b[39;00m\n",
356
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/torch/nn/modules/module.py:1511\u001b[0m, in \u001b[0;36mModule._wrapped_call_impl\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1509\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_compiled_call_impl(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs) \u001b[38;5;66;03m# type: ignore[misc]\u001b[39;00m\n\u001b[1;32m 1510\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m-> 1511\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call_impl\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
357
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/torch/nn/modules/module.py:1520\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1515\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[1;32m 1516\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[1;32m 1517\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks\n\u001b[1;32m 1518\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[1;32m 1519\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[0;32m-> 1520\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1522\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 1523\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n",
358
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/torch/nn/modules/linear.py:116\u001b[0m, in \u001b[0;36mLinear.forward\u001b[0;34m(self, input)\u001b[0m\n\u001b[1;32m 115\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mforward\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;28minput\u001b[39m: Tensor) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Tensor:\n\u001b[0;32m--> 116\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mF\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlinear\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mweight\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mbias\u001b[49m\u001b[43m)\u001b[49m\n",
359
+ "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
360
+ ]
361
+ }
362
+ ],
363
+ "source": [
364
+ "# List of Hugging Face model names\n",
365
+ "model_names = [\n",
366
+ " \"facebook/bart-large-mnli\",\n",
367
+ " \"MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli\",\n",
368
+ " ##\"cross-encoder/nli-deberta-v3-base\",\n",
369
+ " \"cross-encoder/nli-deberta-v3-large\",\n",
370
+ " \"MoritzLaurer/mDeBERTa-v3-base-mnli-xnli\",\n",
371
+ " ##\"joeddav/bart-large-mnli-yahoo-answers\",\n",
372
+ " \"MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli\",\n",
373
+ " \"MoritzLaurer/deberta-v3-large-zeroshot-v2.0\",\n",
374
+ " \"valhalla/distilbart-mnli-12-1\",\n",
375
+ " #\"joeddav/xlm-roberta-large-xnli\" # keeps giving errors\n",
376
+ "]\n",
377
+ "\n",
378
+ "# Apply each model to the test data\n",
379
+ "for model_name in model_names:\n",
380
+ " print(f\"\\nUsing model: {model_name}\")\n",
381
+ " result_list = []\n",
382
+ " performance = pd.DataFrame(columns=['accuracy', 'true_ident', 'false_pred'])\n",
383
+ " \n",
384
+ " start_time = time.time()\n",
385
+ " for i in range(len(trip_descriptions)):\n",
386
+ " current_trip = trip_descriptions[i]\n",
387
+ " current_type = trip_types[i]\n",
388
+ " df = pred_trip(model_name, current_trip, current_type, cut_off = 0.5)\n",
389
+ " print(df)\n",
390
+ " # accuracy, perc true classes identified and perc wrong pred classes\n",
391
+ " performance = pd.concat([performance, perf_measure(df)])\n",
392
+ " print(performance)\n",
393
+ " \n",
394
+ " result_list.append(df)\n",
395
+ " end_time = time.time()\n",
396
+ " elapsed_time = end_time - start_time\n",
397
+ " # Extract \"same_value\" column from each DataFrame\n",
398
+ " sv_columns = [df['same_value'] for df in result_list] # 'same' needs to be changed\n",
399
+ " sv_columns.insert(0, result_list[0]['superclass'])\n",
400
+ " # Combine into a new DataFrame (columns side-by-side)\n",
401
+ " sv_df = pd.concat(sv_columns, axis=1)\n",
402
+ " print(sv_df)\n",
403
+ " # Compute accuracy per superclass (row means of same_value matrix excluding the first column)\n",
404
+ " row_means = sv_df.iloc[:, 1:].mean(axis=1)\n",
405
+ " df_row_means = pd.DataFrame({\n",
406
+ " 'superclass': sv_df['superclass'],\n",
407
+ " 'accuracy': row_means\n",
408
+ " })\n",
409
+ " print(df_row_means)\n",
410
+ " # Compute performance measures per trip (mean for each column of performance table)\n",
411
+ " column_means = performance.mean()\n",
412
+ " print(column_means)\n",
413
+ " # save results\n",
414
+ " model = model_name.replace(\"/\", \"-\")\n",
415
+ " model_result = {\n",
416
+ " 'model': model,\n",
417
+ " 'predictions': result_list,\n",
418
+ " 'performance': performance,\n",
419
+ " 'perf_summary': column_means,\n",
420
+ " 'perf_superclass': df_row_means,\n",
421
+ " 'elapsed_time': elapsed_time\n",
422
+ " }\n",
423
+ " # File path with folder\n",
424
+ " filename = os.path.join('results', f'{model}_results.pkl')\n",
425
+ " # Save the object\n",
426
+ " with open(filename, 'wb') as f:\n",
427
+ " pickle.dump(model_result, f)\n",
428
+ "\n",
429
+ "\n",
430
+ "\n"
431
+ ]
432
+ },
433
+ {
434
+ "cell_type": "markdown",
435
+ "id": "e1cbb54e-abe6-49b6-957e-0683196f3199",
436
+ "metadata": {},
437
+ "source": [
438
+ "## Load and compare results"
439
+ ]
440
+ },
441
+ {
442
+ "cell_type": "code",
443
+ "execution_count": 4,
444
+ "id": "62ca82b0-6909-4e6c-9d2c-fed87971e5b6",
445
+ "metadata": {
446
+ "scrolled": true
447
+ },
448
+ "outputs": [
449
+ {
450
+ "name": "stdout",
451
+ "output_type": "stream",
452
+ "text": [
453
+ "Model: cross-encoder-nli-deberta-v3-base\n",
454
+ "Performance Summary:\n",
455
+ "accuracy 0.444444\n",
456
+ "true_ident 0.533333\n",
457
+ "false_pred 0.712500\n",
458
+ "dtype: float64\n",
459
+ "----------------------------------------\n",
460
+ "Model: joeddav-bart-large-mnli-yahoo-answers\n",
461
+ "Performance Summary:\n",
462
+ "accuracy 0.344444\n",
463
+ "true_ident 0.650000\n",
464
+ "false_pred 0.553792\n",
465
+ "dtype: float64\n",
466
+ "----------------------------------------\n",
467
+ "Model: cross-encoder-nli-deberta-v3-large\n",
468
+ "Performance Summary:\n",
469
+ "accuracy 0.466667\n",
470
+ "true_ident 0.566667\n",
471
+ "false_pred 0.541667\n",
472
+ "dtype: float64\n",
473
+ "----------------------------------------\n",
474
+ "Model: MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli\n",
475
+ "Performance Summary:\n",
476
+ "accuracy 0.566667\n",
477
+ "true_ident 0.841667\n",
478
+ "false_pred 0.546667\n",
479
+ "dtype: float64\n",
480
+ "----------------------------------------\n",
481
+ "Model: MoritzLaurer-mDeBERTa-v3-base-mnli-xnli\n",
482
+ "Performance Summary:\n",
483
+ "accuracy 0.466667\n",
484
+ "true_ident 0.408333\n",
485
+ "false_pred 0.481250\n",
486
+ "dtype: float64\n",
487
+ "----------------------------------------\n",
488
+ "Model: MoritzLaurer-deberta-v3-large-zeroshot-v2.0\n",
489
+ "Performance Summary:\n",
490
+ "accuracy 0.455556\n",
491
+ "true_ident 0.325000\n",
492
+ "false_pred 0.500000\n",
493
+ "dtype: float64\n",
494
+ "----------------------------------------\n",
495
+ "Model: facebook-bart-large-mnli\n",
496
+ "Performance Summary:\n",
497
+ "accuracy 0.466667\n",
498
+ "true_ident 0.708333\n",
499
+ "false_pred 0.400000\n",
500
+ "dtype: float64\n",
501
+ "----------------------------------------\n",
502
+ "Model: valhalla-distilbart-mnli-12-1\n",
503
+ "Performance Summary:\n",
504
+ "accuracy 0.522222\n",
505
+ "true_ident 0.300000\n",
506
+ "false_pred 0.533333\n",
507
+ "dtype: float64\n",
508
+ "----------------------------------------\n",
509
+ "Model: MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli\n",
510
+ "Performance Summary:\n",
511
+ "accuracy 0.522222\n",
512
+ "true_ident 0.841667\n",
513
+ "false_pred 0.572381\n",
514
+ "dtype: float64\n",
515
+ "----------------------------------------\n"
516
+ ]
517
+ }
518
+ ],
519
+ "source": [
520
+ "# Folder where .pkl files are saved\n",
521
+ "results_dir = 'results/before'\n",
522
+ "\n",
523
+ "# Dictionary to store all loaded results\n",
524
+ "all_results = {}\n",
525
+ "\n",
526
+ "# Loop through all .pkl files in the folder\n",
527
+ "for filename in os.listdir(results_dir):\n",
528
+ " if filename.endswith('.pkl'):\n",
529
+ " model_name = filename.replace('_results.pkl', '') # Extract model name\n",
530
+ " file_path = os.path.join(results_dir, filename)\n",
531
+ " \n",
532
+ " # Load the result\n",
533
+ " with open(file_path, 'rb') as f:\n",
534
+ " result = pickle.load(f)\n",
535
+ " all_results[model_name] = result\n",
536
+ "\n",
537
+ "# Compare performance across models\n",
538
+ "for model, data in all_results.items():\n",
539
+ " print(f\"Model: {model}\")\n",
540
+ " print(f\"Performance Summary:\\n{data['perf_summary']}\")\n",
541
+ " print(\"-\" * 40)\n",
542
+ "\n",
543
+ "# Compare performance across models\n",
544
+ "#for model, data in all_results.items():\n",
545
+ "# print(f\"Model: {model}\")\n",
546
+ "# print(f\"Performance Summary:\\n{data['perf_superclass']}\")\n",
547
+ "# print(\"-\" * 40)"
548
+ ]
549
+ },
550
+ {
551
+ "cell_type": "code",
552
+ "execution_count": 5,
553
+ "id": "37849e0b-864e-4377-b06c-0ac70c3861f9",
554
+ "metadata": {
555
+ "scrolled": true
556
+ },
557
+ "outputs": [
558
+ {
559
+ "name": "stdout",
560
+ "output_type": "stream",
561
+ "text": [
562
+ "Model: cross-encoder-nli-deberta-v3-base\n",
563
+ "Performance Summary:\n",
564
+ "accuracy 0.444444\n",
565
+ "true_ident 0.533333\n",
566
+ "false_pred 0.712500\n",
567
+ "dtype: float64\n",
568
+ "----------------------------------------\n",
569
+ "Model: joeddav-bart-large-mnli-yahoo-answers\n",
570
+ "Performance Summary:\n",
571
+ "accuracy 0.355556\n",
572
+ "true_ident 0.650000\n",
573
+ "false_pred 0.553792\n",
574
+ "dtype: float64\n",
575
+ "----------------------------------------\n",
576
+ "Model: cross-encoder-nli-deberta-v3-large\n",
577
+ "Performance Summary:\n",
578
+ "accuracy 0.466667\n",
579
+ "true_ident 0.566667\n",
580
+ "false_pred 0.541667\n",
581
+ "dtype: float64\n",
582
+ "----------------------------------------\n",
583
+ "Model: MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli\n",
584
+ "Performance Summary:\n",
585
+ "accuracy 0.611111\n",
586
+ "true_ident 0.841667\n",
587
+ "false_pred 0.546667\n",
588
+ "dtype: float64\n",
589
+ "----------------------------------------\n",
590
+ "Model: MoritzLaurer-mDeBERTa-v3-base-mnli-xnli\n",
591
+ "Performance Summary:\n",
592
+ "accuracy 0.455556\n",
593
+ "true_ident 0.408333\n",
594
+ "false_pred 0.481250\n",
595
+ "dtype: float64\n",
596
+ "----------------------------------------\n",
597
+ "Model: MoritzLaurer-deberta-v3-large-zeroshot-v2.0\n",
598
+ "Performance Summary:\n",
599
+ "accuracy 0.500\n",
600
+ "true_ident 0.325\n",
601
+ "false_pred 0.500\n",
602
+ "dtype: float64\n",
603
+ "----------------------------------------\n",
604
+ "Model: facebook-bart-large-mnli\n",
605
+ "Performance Summary:\n",
606
+ "accuracy 0.466667\n",
607
+ "true_ident 0.708333\n",
608
+ "false_pred 0.400000\n",
609
+ "dtype: float64\n",
610
+ "----------------------------------------\n",
611
+ "Model: valhalla-distilbart-mnli-12-1\n",
612
+ "Performance Summary:\n",
613
+ "accuracy 0.500000\n",
614
+ "true_ident 0.300000\n",
615
+ "false_pred 0.533333\n",
616
+ "dtype: float64\n",
617
+ "----------------------------------------\n",
618
+ "Model: MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli\n",
619
+ "Performance Summary:\n",
620
+ "accuracy 0.522222\n",
621
+ "true_ident 0.841667\n",
622
+ "false_pred 0.572381\n",
623
+ "dtype: float64\n",
624
+ "----------------------------------------\n"
625
+ ]
626
+ }
627
+ ],
628
+ "source": [
629
+ "# Folder where .pkl files are saved\n",
630
+ "results_dir = 'results'\n",
631
+ "\n",
632
+ "# Dictionary to store all loaded results\n",
633
+ "all_results = {}\n",
634
+ "\n",
635
+ "# Loop through all .pkl files in the folder\n",
636
+ "for filename in os.listdir(results_dir):\n",
637
+ " if filename.endswith('.pkl'):\n",
638
+ " model_name = filename.replace('_results.pkl', '') # Extract model name\n",
639
+ " file_path = os.path.join(results_dir, filename)\n",
640
+ " \n",
641
+ " # Load the result\n",
642
+ " with open(file_path, 'rb') as f:\n",
643
+ " result = pickle.load(f)\n",
644
+ " all_results[model_name] = result\n",
645
+ "\n",
646
+ "# Compare performance across models\n",
647
+ "for model, data in all_results.items():\n",
648
+ " print(f\"Model: {model}\")\n",
649
+ " print(f\"Performance Summary:\\n{data['perf_summary']}\")\n",
650
+ " print(\"-\" * 40)\n"
651
+ ]
652
+ },
653
+ {
654
+ "cell_type": "markdown",
655
+ "id": "2f65e5b1-bc32-42c2-bbe9-9e3a6ffc72c1",
656
+ "metadata": {},
657
+ "source": [
658
+ "**Identify trips that are difficult to predict**"
659
+ ]
660
+ },
661
+ {
662
+ "cell_type": "markdown",
663
+ "id": "040055c9-5df4-49b0-921a-5bf98ff01a69",
664
+ "metadata": {},
665
+ "source": [
666
+ "Per model"
667
+ ]
668
+ },
669
+ {
670
+ "cell_type": "code",
671
+ "execution_count": 7,
672
+ "id": "57fd150d-1cda-4be5-806b-ef380469243a",
673
+ "metadata": {
674
+ "scrolled": true
675
+ },
676
+ "outputs": [
677
+ {
678
+ "name": "stdout",
679
+ "output_type": "stream",
680
+ "text": [
681
+ "cross-encoder-nli-deberta-v3-base: Index([0, 2, 3, 4, 5, 6, 7, 8, 9], dtype='int64')\n",
682
+ "\n",
683
+ "joeddav-bart-large-mnli-yahoo-answers: RangeIndex(start=0, stop=10, step=1)\n",
684
+ "\n",
685
+ "cross-encoder-nli-deberta-v3-large: Index([0, 1, 2, 3, 4, 6, 7, 8, 9], dtype='int64')\n",
686
+ "\n",
687
+ "MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli: Index([2, 3, 5, 6, 7, 8, 9], dtype='int64')\n",
688
+ "\n",
689
+ "MoritzLaurer-mDeBERTa-v3-base-mnli-xnli: RangeIndex(start=0, stop=10, step=1)\n",
690
+ "\n",
691
+ "MoritzLaurer-deberta-v3-large-zeroshot-v2.0: Index([1, 2, 3, 5, 6, 7, 9], dtype='int64')\n",
692
+ "\n",
693
+ "facebook-bart-large-mnli: RangeIndex(start=0, stop=10, step=1)\n",
694
+ "\n",
695
+ "valhalla-distilbart-mnli-12-1: Index([0, 1, 2, 3, 4, 7, 9], dtype='int64')\n",
696
+ "\n",
697
+ "MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli: Index([0, 2, 3, 4, 6, 7], dtype='int64')\n",
698
+ "\n"
699
+ ]
700
+ }
701
+ ],
702
+ "source": [
703
+ "def get_difficult_trips(model_result, cut_off = 0.6):\n",
704
+ " # model_result is a dict with dict_keys(['model', 'predictions', \n",
705
+ " # 'performance', 'perf_summary', 'perf_superclass', 'elapsed_time'])\n",
706
+ " # get performance dataframe and repair index\n",
707
+ " df = model_result['performance'].reset_index(drop=True)\n",
708
+ " # find index of trips whose accuracy is below cut_off\n",
709
+ " index_result = df[df['accuracy'] < cut_off].index\n",
710
+ " return(index_result)\n",
711
+ "\n",
712
+ "# dictionary of trips that have accuracy below cut_off default\n",
713
+ "difficult_trips_dict = {}\n",
714
+ "for model, data in all_results.items():\n",
715
+ " difficult_trips_dict[data[\"model\"]] = get_difficult_trips(data)\n",
716
+ "\n",
717
+ "for key, value in difficult_trips_dict.items():\n",
718
+ " print(f\"{key}: {value}\\n\")"
719
+ ]
720
+ },
721
+ {
722
+ "cell_type": "markdown",
723
+ "id": "d91fb932-c5aa-472a-9b8d-a0cfc83a87f8",
724
+ "metadata": {},
725
+ "source": [
726
+ "For all models"
727
+ ]
728
+ },
729
+ {
730
+ "cell_type": "code",
731
+ "execution_count": 8,
732
+ "id": "a2754cb7-59b9-4f1d-ab74-1bf711b3eba2",
733
+ "metadata": {
734
+ "scrolled": true
735
+ },
736
+ "outputs": [
737
+ {
738
+ "name": "stdout",
739
+ "output_type": "stream",
740
+ "text": [
741
+ "2 . My partner and I are traveling to the Netherlands and Germany to spend Christmas with our family. We are in our late twenties and will start our journey with a two-hour flight to the Netherlands. From there, we will take a 5.5-hour train ride to northern Germany. \n",
742
+ "\n",
743
+ "city trip\n",
744
+ "['relaxing']\n",
745
+ "cold destination / winter\n",
746
+ "lightweight (but comfortable)\n",
747
+ "casual\n",
748
+ "indoor\n",
749
+ "no own vehicle\n",
750
+ "no special conditions to consider\n",
751
+ "7+ days\n",
752
+ "\n",
753
+ "\n",
754
+ "3 . I’m in my twenties and will be traveling to Peru for three weeks. I’m going solo but will meet up with a friend to explore the Sacred Valley and take part in a Machu Picchu tour. We plan to hike, go rafting, and explore the remnants of the ancient Inca Empire. We’re also excited to try Peruvian cuisine and immerse ourselves in the local culture. Depending on our plans, we might also visit the rainforest region, such as Tarapoto. I’ll be flying to Peru on a long-haul flight and will be traveling in August. \n",
755
+ "\n",
756
+ "cultural exploration\n",
757
+ "['sightseeing', 'hiking', 'rafting']\n",
758
+ "variable weather / spring / autumn\n",
759
+ "lightweight (but comfortable)\n",
760
+ "casual\n",
761
+ "indoor\n",
762
+ "no own vehicle\n",
763
+ "rainy climate\n",
764
+ "7+ days\n",
765
+ "\n",
766
+ "\n",
767
+ "7 . We will go to Sweden in the winter, to go for a yoga and sauna/wellness retreat. I prefer lightweight packing and also want clothes to go for fancy dinners and maybe on a winter hike. We stay in hotels. \n",
768
+ "\n",
769
+ "yoga / wellness retreat\n",
770
+ "['hiking', 'yoga']\n",
771
+ "cold destination / winter\n",
772
+ "lightweight (but comfortable)\n",
773
+ "casual\n",
774
+ "indoor\n",
775
+ "no own vehicle\n",
776
+ "snow and ice\n",
777
+ "7 days\n",
778
+ "\n",
779
+ "\n"
780
+ ]
781
+ }
782
+ ],
783
+ "source": [
784
+ "# Which trips are difficult for all models\n",
785
+ "common = set.intersection(*(set(v) for v in difficult_trips_dict.values()))\n",
786
+ "for index in common:\n",
787
+ " print(index, \".\", trip_descriptions[index], \"\\n\")\n",
788
+ " for item in trip_types[index]:\n",
789
+ " print(item)\n",
790
+ " print(\"\\n\")"
791
+ ]
792
+ },
793
+ {
794
+ "cell_type": "markdown",
795
+ "id": "be58d66f-a491-4f47-98df-2c0aa4af38e7",
796
+ "metadata": {},
797
+ "source": [
798
+ "**Identify superclasses that are difficult to predict**"
799
+ ]
800
+ },
801
+ {
802
+ "cell_type": "markdown",
803
+ "id": "7e833c2d-9356-4d40-9b20-0a1eb6628a30",
804
+ "metadata": {},
805
+ "source": [
806
+ "Per model"
807
+ ]
808
+ },
809
+ {
810
+ "cell_type": "code",
811
+ "execution_count": 6,
812
+ "id": "adb491b1-3ac3-4c32-934f-5eb6171f2ec9",
813
+ "metadata": {},
814
+ "outputs": [
815
+ {
816
+ "name": "stdout",
817
+ "output_type": "stream",
818
+ "text": [
819
+ "cross-encoder-nli-deberta-v3-base: ['activities', 'climate_or_season', 'style_or_comfort', 'special_conditions']\n",
820
+ "\n",
821
+ "joeddav-bart-large-mnli-yahoo-answers: ['activities', 'climate_or_season', 'style_or_comfort', 'dress_code', 'accommodation', 'transportation', 'special_conditions']\n",
822
+ "\n",
823
+ "cross-encoder-nli-deberta-v3-large: ['activities', 'climate_or_season', 'style_or_comfort', 'transportation', 'special_conditions']\n",
824
+ "\n",
825
+ "MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli: ['activities', 'style_or_comfort']\n",
826
+ "\n",
827
+ "MoritzLaurer-mDeBERTa-v3-base-mnli-xnli: ['activities', 'style_or_comfort', 'accommodation', 'special_conditions', 'trip_length_days']\n",
828
+ "\n",
829
+ "MoritzLaurer-deberta-v3-large-zeroshot-v2.0: ['activities', 'climate_or_season', 'style_or_comfort', 'accommodation', 'special_conditions']\n",
830
+ "\n",
831
+ "facebook-bart-large-mnli: ['activities', 'style_or_comfort', 'accommodation', 'special_conditions']\n",
832
+ "\n",
833
+ "valhalla-distilbart-mnli-12-1: ['activities', 'climate_or_season', 'style_or_comfort', 'accommodation', 'special_conditions']\n",
834
+ "\n",
835
+ "MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli: ['activities', 'climate_or_season', 'style_or_comfort', 'special_conditions']\n",
836
+ "\n"
837
+ ]
838
+ }
839
+ ],
840
+ "source": [
841
+ "def get_difficult_superclasses(model_result, cut_off = 0.6):\n",
842
+ " # model_result is a dict with dict_keys(['model', 'predictions', \n",
843
+ " # 'performance', 'perf_summary', 'perf_superclass', 'elapsed_time'])\n",
844
+ " df = model_result[\"perf_superclass\"]\n",
845
+ " # find superclass whose accuracy is below cut_off\n",
846
+ " diff_spc = list(df[df['accuracy'] < cut_off][\"superclass\"])\n",
847
+ " return(diff_spc)\n",
848
+ "\n",
849
+ "# make dictionary of superclasses that have accuracy below cut_off default\n",
850
+ "difficult_superclass_dict = {}\n",
851
+ "for model, data in all_results.items():\n",
852
+ " difficult_superclass_dict[data[\"model\"]] = get_difficult_superclasses(data)\n",
853
+ "\n",
854
+ "for key, value in difficult_superclass_dict.items():\n",
855
+ " print(f\"{key}: {value}\\n\")"
856
+ ]
857
+ },
858
+ {
859
+ "cell_type": "markdown",
860
+ "id": "fbcebdf8-0975-45cb-96f5-15b4645aa7f6",
861
+ "metadata": {},
862
+ "source": [
863
+ "For all models"
864
+ ]
865
+ },
866
+ {
867
+ "cell_type": "code",
868
+ "execution_count": 10,
869
+ "id": "4e51c11b-9a0a-4f9d-b20c-a6feda2d5a3b",
870
+ "metadata": {},
871
+ "outputs": [
872
+ {
873
+ "name": "stdout",
874
+ "output_type": "stream",
875
+ "text": [
876
+ "{'style_or_comfort', 'activities'}\n"
877
+ ]
878
+ }
879
+ ],
880
+ "source": [
881
+ "# Which trips are difficult for all models\n",
882
+ "common = set.intersection(*(set(v) for v in difficult_superclass_dict.values()))\n",
883
+ "print(common)"
884
+ ]
885
+ },
886
+ {
887
+ "cell_type": "code",
888
+ "execution_count": 11,
889
+ "id": "f0e31e2c-e87d-4776-b781-991919492430",
890
+ "metadata": {},
891
+ "outputs": [],
892
+ "source": [
893
+ "# Look at particular predicitons in detail\n",
894
+ "# print(all_results[\"joeddav-bart-large-mnli-yahoo-answers\"])"
895
+ ]
896
+ },
897
+ {
898
+ "cell_type": "markdown",
899
+ "id": "01e24355-4aac-4ad6-b50c-96f75585ce45",
900
+ "metadata": {},
901
+ "source": [
902
+ "**Comparing models**"
903
+ ]
904
+ },
905
+ {
906
+ "cell_type": "code",
907
+ "execution_count": 26,
908
+ "id": "b020f584-1468-4c84-9dac-7ca7fac6e8ca",
909
+ "metadata": {},
910
+ "outputs": [
911
+ {
912
+ "name": "stdout",
913
+ "output_type": "stream",
914
+ "text": [
915
+ "[]\n",
916
+ "<class 'list'>\n",
917
+ " accuracy true_ident false_pred \\\n",
918
+ "0 0.444444 0.533333 0.7125 \n",
919
+ "1 0.355556 0.65 0.553792 \n",
920
+ "2 0.466667 0.566667 0.541667 \n",
921
+ "3 0.611111 0.841667 0.546667 \n",
922
+ "4 0.455556 0.408333 0.48125 \n",
923
+ "5 0.5 0.325 0.5 \n",
924
+ "6 0.466667 0.708333 0.4 \n",
925
+ "7 0.5 0.3 0.533333 \n",
926
+ "8 0.522222 0.841667 0.572381 \n",
927
+ "\n",
928
+ " model \n",
929
+ "0 cross-encoder-nli-deberta-v3-base \n",
930
+ "1 joeddav-bart-large-mnli-yahoo-answers \n",
931
+ "2 cross-encoder-nli-deberta-v3-large \n",
932
+ "3 MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-... \n",
933
+ "4 MoritzLaurer-mDeBERTa-v3-base-mnli-xnli \n",
934
+ "5 MoritzLaurer-deberta-v3-large-zeroshot-v2.0 \n",
935
+ "6 facebook-bart-large-mnli \n",
936
+ "7 valhalla-distilbart-mnli-12-1 \n",
937
+ "8 MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli \n"
938
+ ]
939
+ }
940
+ ],
941
+ "source": [
942
+ "# Make table of 'perf_summary' for all models inlcude time elapsed\n",
943
+ "#print(type(all_results))\n",
944
+ "#print(type(all_results[\"MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli\"]))\n",
945
+ "#print(all_results[\"MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli\"].keys())\n",
946
+ "#print(type(all_results[\"MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli\"][\"perf_summary\"]))\n",
947
+ "#print(all_results[\"MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli\"][\"perf_summary\"])\n",
948
+ "#print(all_results[\"MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli\"][\"perf_summary\"][\"accuracy\"])\n",
949
+ "# make empty data frame\n",
950
+ "perf_table = []\n",
951
+ "print(perf_table)\n",
952
+ "\n",
953
+ "# fill in for loop with perf_summary per model\n",
954
+ "for model, result in all_results.items():\n",
955
+ " row = pd.DataFrame(result[\"perf_summary\"]).T\n",
956
+ " #print(row.shape)\n",
957
+ " row[\"model\"] = model\n",
958
+ " perf_table.append(row)\n",
959
+ "# Concatenate all into one table\n",
960
+ "df_all = pd.concat(perf_table, ignore_index=True)\n",
961
+ "\n",
962
+ "print(df_all)\n",
963
+ "#print(type(df_all))\n",
964
+ " \n",
965
+ "\n",
966
+ "# Make ranking from that table for each category\n"
967
+ ]
968
+ },
969
+ {
970
+ "cell_type": "code",
971
+ "execution_count": 17,
972
+ "id": "0f7376bd-a50b-47cc-8055-48a6de5dfee6",
973
+ "metadata": {},
974
+ "outputs": [
975
+ {
976
+ "name": "stdout",
977
+ "output_type": "stream",
978
+ "text": [
979
+ "<class 'dict'>\n"
980
+ ]
981
+ }
982
+ ],
983
+ "source": [
984
+ "print(type(all_results))"
985
+ ]
986
+ },
987
+ {
988
+ "cell_type": "markdown",
989
+ "id": "17483df4-55c4-41cd-b8a9-61f7a5c7e8a3",
990
+ "metadata": {},
991
+ "source": [
992
+ "# Use gradio for user input"
993
+ ]
994
+ },
995
+ {
996
+ "cell_type": "code",
997
+ "execution_count": 1,
998
+ "id": "5bf23e10-0a93-4b2f-9508-34bb0974d24c",
999
+ "metadata": {},
1000
+ "outputs": [],
1001
+ "source": [
1002
+ "# Prerequisites\n",
1003
+ "from transformers import pipeline\n",
1004
+ "import json\n",
1005
+ "import pandas as pd\n",
1006
+ "import gradio as gr\n",
1007
+ "\n",
1008
+ "# get candidate labels\n",
1009
+ "with open(\"packing_label_structure.json\", \"r\") as file:\n",
1010
+ " candidate_labels = json.load(file)\n",
1011
+ "keys_list = list(candidate_labels.keys())\n",
1012
+ "\n",
1013
+ "# Load test data (in list of dictionaries)\n",
1014
+ "with open(\"test_data.json\", \"r\") as file:\n",
1015
+ " packing_data = json.load(file)\n",
1016
+ "# Extract all trip descriptions and trip_types\n",
1017
+ "# trip_descriptions = [trip['description'] for trip in packing_data]\n",
1018
+ "# trip_types = [trip['trip_types'] for trip in packing_data]"
1019
+ ]
1020
+ },
1021
+ {
1022
+ "cell_type": "code",
1023
+ "execution_count": 2,
1024
+ "id": "61ebbe99-2563-4c99-ba65-d2312c9d5844",
1025
+ "metadata": {},
1026
+ "outputs": [
1027
+ {
1028
+ "name": "stdout",
1029
+ "output_type": "stream",
1030
+ "text": [
1031
+ "Running on local URL: http://127.0.0.1:7860\n",
1032
+ "Running on public URL: https://91493051ab28db8a5a.gradio.live\n",
1033
+ "\n",
1034
+ "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
1035
+ ]
1036
+ },
1037
+ {
1038
+ "data": {
1039
+ "text/html": [
1040
+ "<div><iframe src=\"https://91493051ab28db8a5a.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
1041
+ ],
1042
+ "text/plain": [
1043
+ "<IPython.core.display.HTML object>"
1044
+ ]
1045
+ },
1046
+ "metadata": {},
1047
+ "output_type": "display_data"
1048
+ },
1049
+ {
1050
+ "name": "stderr",
1051
+ "output_type": "stream",
1052
+ "text": [
1053
+ "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n"
1054
+ ]
1055
+ }
1056
+ ],
1057
+ "source": [
1058
+ "# function and gradio app\n",
1059
+ "cut_off = 0.5 # used to choose which activities are relevant\n",
1060
+ "\n",
1061
+ "def classify(model_name, trip_descr, cut_off):\n",
1062
+ " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
1063
+ " # Create an empty DataFrame with specified columns\n",
1064
+ " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
1065
+ " for i, key in enumerate(keys_list):\n",
1066
+ " if key == 'activities':\n",
1067
+ " result = classifier(trip_descr, candidate_labels[key], multi_label=True)\n",
1068
+ " indices = [i for i, score in enumerate(result['scores']) if score > cut_off]\n",
1069
+ " classes = [result['labels'][i] for i in indices]\n",
1070
+ " else:\n",
1071
+ " result = classifier(trip_descr, candidate_labels[key])\n",
1072
+ " classes = result[\"labels\"][0]\n",
1073
+ " df.loc[i] = [key, classes]\n",
1074
+ " return df\n",
1075
+ "\n",
1076
+ "demo = gr.Interface(\n",
1077
+ " fn=classify,\n",
1078
+ " inputs=[\n",
1079
+ " gr.Textbox(label=\"Model name\", value = \"facebook/bart-large-mnli\"),\n",
1080
+ " gr.Textbox(label=\"Trip description\"),\n",
1081
+ " gr.Number(label=\"Activity cut-off\", value = 0.5),\n",
1082
+ " ],\n",
1083
+ " outputs=\"dataframe\",\n",
1084
+ " title=\"Trip classification\",\n",
1085
+ " description=\"Enter a text describing your trip\",\n",
1086
+ ")\n",
1087
+ "\n",
1088
+ "# Launch the Gradio app\n",
1089
+ "if __name__ == \"__main__\":\n",
1090
+ " demo.launch(share=True)\n"
1091
+ ]
1092
+ }
1093
+ ],
1094
+ "metadata": {
1095
+ "kernelspec": {
1096
+ "display_name": "Python (huggingface_env)",
1097
+ "language": "python",
1098
+ "name": "huggingface_env"
1099
+ },
1100
+ "language_info": {
1101
+ "codemirror_mode": {
1102
+ "name": "ipython",
1103
+ "version": 3
1104
+ },
1105
+ "file_extension": ".py",
1106
+ "mimetype": "text/x-python",
1107
+ "name": "python",
1108
+ "nbconvert_exporter": "python",
1109
+ "pygments_lexer": "ipython3",
1110
+ "version": "3.8.20"
1111
+ }
1112
+ },
1113
+ "nbformat": 4,
1114
+ "nbformat_minor": 5
1115
+ }
space/space/space/space/space/space/space/space/space/space/space/space/results/.DS_Store ADDED
Binary file (6.15 kB). View file
 
space/space/space/space/space/space/space/space/space/space/space/space/results/MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ff7524d88a78292aac59dd808d6409da3094dca6c480e702c723de033a64fee
3
+ size 9616
space/space/space/space/space/space/space/space/space/space/space/space/results/MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20bab421410028527f62eb5dafe383c6062dcdef4f335f99079283a5c77700e5
3
+ size 9526
space/space/space/space/space/space/space/space/space/space/space/space/results/MoritzLaurer-deberta-v3-large-zeroshot-v2.0_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:37383ba39c8fbf9fa4e0f5ab2f263a94044d30fa55c7002f2dde059371e2744a
3
+ size 9424
space/space/space/space/space/space/space/space/space/space/space/space/results/MoritzLaurer-mDeBERTa-v3-base-mnli-xnli_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5eaa0e36c292a34907b242d890251cb378e113852a472711e469d6dd246a50a7
3
+ size 9544
space/space/space/space/space/space/space/space/space/space/space/space/results/before/MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:af6a30fdc19d830ebe35e091878231b84618663781d1ed86b1f53507065d20e5
3
+ size 9533
space/space/space/space/space/space/space/space/space/space/space/space/results/before/MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4e11eadfa64ac378e24c1df9c8f952b19fcca05ca634068506713d25ef1461e2
3
+ size 9509
space/space/space/space/space/space/space/space/space/space/space/space/results/before/MoritzLaurer-deberta-v3-large-zeroshot-v2.0_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c1b48262c7ff16332488e83aaa29703469463fae39fb950aeb055cfb6bdbc70
3
+ size 9356
space/space/space/space/space/space/space/space/space/space/space/space/results/before/MoritzLaurer-mDeBERTa-v3-base-mnli-xnli_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:55172023628edf78e2663cdfb75f18852fbb1979d74332140176bcad4017a98d
3
+ size 9562
space/space/space/space/space/space/space/space/space/space/space/space/results/before/cross-encoder-nli-deberta-v3-base_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d5116d85a6fd3d1669b8c307934df35aa87bdbb8e89573a05851dcdf6078a4db
3
+ size 9643
space/space/space/space/space/space/space/space/space/space/space/space/results/before/cross-encoder-nli-deberta-v3-large_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b354f0cb55f0b398614195155e66a537d5b12f9dd657a370bfbf7f6c2c9ca5bd
3
+ size 9463
space/space/space/space/space/space/space/space/space/space/space/space/results/before/facebook-bart-large-mnli_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bee4588344312e7c93436e88f58257935a273f90ec7422a9a0fab77b57540a2e
3
+ size 9427
space/space/space/space/space/space/space/space/space/space/space/space/results/before/joeddav-bart-large-mnli-yahoo-answers_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0c17c9d623753ad38339bdf9e4204ff34b2ddf6ffc11b8077617da6349aff816
3
+ size 9718