AnjaJuana commited on
Commit
04712b6
·
1 Parent(s): 04cc170

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. main_model.ipynb +12 -9
  2. packing_templates_self_supported_offgrid_expanded.json +525 -526
  3. packing_templates_self_supported_offgrid_expanded_dutch_original.json +696 -0
  4. space/.ipynb_checkpoints/app-checkpoint.py +25 -11
  5. space/.ipynb_checkpoints/labels-checkpoint.txt +93 -0
  6. space/.ipynb_checkpoints/main_model-checkpoint.ipynb +0 -0
  7. space/app.py +25 -11
  8. space/blog_post/article.md +45 -0
  9. space/main_model.ipynb +189 -188
  10. space/packing_templates_self_supported_offgrid_expanded.json +525 -526
  11. space/space/space/space/.ipynb_checkpoints/app-checkpoint.py +37 -11
  12. space/space/space/space/.ipynb_checkpoints/main_model-checkpoint.ipynb +0 -0
  13. space/space/space/space/app.py +37 -11
  14. space/space/space/space/main_model.ipynb +1115 -0
  15. space/space/space/space/results/.DS_Store +0 -0
  16. space/space/space/space/results/MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli_results.pkl +3 -0
  17. space/space/space/space/results/MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli_results.pkl +3 -0
  18. space/space/space/space/results/MoritzLaurer-deberta-v3-large-zeroshot-v2.0_results.pkl +3 -0
  19. space/space/space/space/results/MoritzLaurer-mDeBERTa-v3-base-mnli-xnli_results.pkl +3 -0
  20. space/space/space/space/results/before/MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli_results.pkl +3 -0
  21. space/space/space/space/results/before/MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli_results.pkl +3 -0
  22. space/space/space/space/results/before/MoritzLaurer-deberta-v3-large-zeroshot-v2.0_results.pkl +3 -0
  23. space/space/space/space/results/before/MoritzLaurer-mDeBERTa-v3-base-mnli-xnli_results.pkl +3 -0
  24. space/space/space/space/results/before/cross-encoder-nli-deberta-v3-base_results.pkl +3 -0
  25. space/space/space/space/results/before/cross-encoder-nli-deberta-v3-large_results.pkl +3 -0
  26. space/space/space/space/results/before/facebook-bart-large-mnli_results.pkl +3 -0
  27. space/space/space/space/results/before/joeddav-bart-large-mnli-yahoo-answers_results.pkl +3 -0
  28. space/space/space/space/results/before/valhalla-distilbart-mnli-12-1_results.pkl +3 -0
  29. space/space/space/space/results/cross-encoder-nli-deberta-v3-base_results.pkl +3 -0
  30. space/space/space/space/results/cross-encoder-nli-deberta-v3-large_results.pkl +3 -0
  31. space/space/space/space/results/facebook-bart-large-mnli_results.pkl +3 -0
  32. space/space/space/space/results/joeddav-bart-large-mnli-yahoo-answers_results.pkl +3 -0
  33. space/space/space/space/results/valhalla-distilbart-mnli-12-1_results.pkl +3 -0
  34. space/space/space/space/space/.ipynb_checkpoints/gradio_tryout-checkpoint.ipynb +170 -165
  35. space/space/space/space/space/gradio_tryout.ipynb +153 -87
  36. space/space/space/space/space/packing_label_structure.json +6 -6
  37. space/space/space/space/space/packing_templates_self_supported_offgrid_expanded.json +3 -3
  38. space/space/space/space/space/results/model_MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli_results.pkl +3 -0
  39. space/space/space/space/space/space/results/model_b_sileod-deberta-v3-base-tasksource-nli_results.pkl +3 -0
  40. space/space/space/space/space/space/space/.ipynb_checkpoints/gradio_tryout-checkpoint.ipynb +0 -0
  41. space/space/space/space/space/space/space/packing_label_hierarchical_mapping.json +2 -2
  42. space/space/space/space/space/space/space/packing_label_structure.json +2 -2
  43. space/space/space/space/space/space/space/packing_templates_self_supported_offgrid_expanded.json +2 -2
  44. space/space/space/space/space/space/space/results/model_a_facebook-bart-large-mnli_results.pkl +3 -0
  45. space/space/space/space/space/space/space/space/.ipynb_checkpoints/gradio_tryout-checkpoint.ipynb +0 -0
  46. space/space/space/space/space/space/space/space/gradio_tryout.ipynb +327 -131
  47. space/space/space/space/space/space/space/space/space/space/space/.DS_Store +0 -0
  48. space/space/space/space/space/space/space/space/space/space/space/Candidate labels in Word en idee.docx +0 -0
  49. space/space/space/space/space/space/space/space/space/space/space/gradio_tryout.ipynb +329 -62
  50. space/space/space/space/space/space/space/space/space/space/space/packing_label_hierarchical_mapping.json +290 -0
main_model.ipynb CHANGED
@@ -949,7 +949,7 @@
949
  },
950
  {
951
  "cell_type": "code",
952
- "execution_count": 28,
953
  "id": "5bf23e10-0a93-4b2f-9508-34bb0974d24c",
954
  "metadata": {},
955
  "outputs": [],
@@ -968,9 +968,6 @@
968
  "# Load test data (in list of dictionaries)\n",
969
  "with open(\"test_data.json\", \"r\") as file:\n",
970
  " packing_data = json.load(file)\n",
971
- "# Extract all trip descriptions and trip_types\n",
972
- "# trip_descriptions = [trip['description'] for trip in packing_data]\n",
973
- "# trip_types = [trip['trip_types'] for trip in packing_data]\n",
974
  "\n",
975
  "# Load packing item data\n",
976
  "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
@@ -979,7 +976,7 @@
979
  },
980
  {
981
  "cell_type": "code",
982
- "execution_count": 31,
983
  "id": "61ebbe99-2563-4c99-ba65-d2312c9d5844",
984
  "metadata": {},
985
  "outputs": [
@@ -987,16 +984,15 @@
987
  "name": "stdout",
988
  "output_type": "stream",
989
  "text": [
990
- "Running on local URL: http://127.0.0.1:7863\n",
991
- "Running on public URL: https://ffd87a6918736e600d.gradio.live\n",
992
  "\n",
993
- "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"
994
  ]
995
  },
996
  {
997
  "data": {
998
  "text/html": [
999
- "<div><iframe src=\"https://ffd87a6918736e600d.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
1000
  ],
1001
  "text/plain": [
1002
  "<IPython.core.display.HTML object>"
@@ -1004,6 +1000,13 @@
1004
  },
1005
  "metadata": {},
1006
  "output_type": "display_data"
 
 
 
 
 
 
 
1007
  }
1008
  ],
1009
  "source": [
 
949
  },
950
  {
951
  "cell_type": "code",
952
+ "execution_count": 1,
953
  "id": "5bf23e10-0a93-4b2f-9508-34bb0974d24c",
954
  "metadata": {},
955
  "outputs": [],
 
968
  "# Load test data (in list of dictionaries)\n",
969
  "with open(\"test_data.json\", \"r\") as file:\n",
970
  " packing_data = json.load(file)\n",
 
 
 
971
  "\n",
972
  "# Load packing item data\n",
973
  "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
 
976
  },
977
  {
978
  "cell_type": "code",
979
+ "execution_count": 2,
980
  "id": "61ebbe99-2563-4c99-ba65-d2312c9d5844",
981
  "metadata": {},
982
  "outputs": [
 
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
  ]
991
  },
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
  },
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": [
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
+ "hydration bladder or water bottles",
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 hut 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",
30
+ "cookset + stove",
31
+ "food and snacks",
32
+ "lighter",
33
+ "toiletry bag with biodegradable soap"
34
  ],
35
  "camping trip (campground)": [
36
  "tent",
37
+ "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",
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",
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",
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
+ "downtime entertainment (e.g. book / ebook, games, laptop, journal)"
185
  ],
186
  "swimming": [
187
+ "swimsuit",
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 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 or GPS)"
267
  ],
268
  "hut-to-hut hiking": [
269
+ "lightweight trekking backpack (30–45 liters)",
270
+ "water bottles 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 hut",
278
+ "earplugs",
279
+ "reservation confirmation / cash for hut"
280
  ],
281
  "rock climbing": [
282
+ "climbing shoes",
283
+ "climbing harness",
284
+ "belay device",
285
  "chalk bag",
286
+ "helmet"
287
  ],
288
  "ice climbing": [
289
+ "ice axes",
290
  "crampons",
291
+ "climbing rope",
292
+ "warm insulation layers",
293
+ "climbing harness and helmet"
294
  ],
295
  "snowshoe hiking": [
296
+ "general items for this situation",
297
+ "extra clothing or gear if needed"
298
  ],
299
  "kayaking / canoeing": [
300
+ "kayak or canoe",
301
+ "paddle",
302
+ "life jacket",
303
+ "dry bag",
304
+ "water shoes"
305
  ],
306
  "stand-up paddleboarding (SUP)": [
307
+ "SUP board and paddle",
308
+ "life jacket",
309
+ "dry bag",
310
+ "sunglasses with strap"
311
  ],
312
  "snorkeling": [
313
+ "snorkel and mask",
314
+ "fins",
315
+ "swimwear",
316
+ "waterproof bag"
317
  ],
318
  "scuba diving": [
319
+ "mask and snorkel",
320
  "wetsuit",
321
+ "fins",
322
+ "dive computer",
323
+ "regulator (if own)"
324
  ],
325
  "surfing": [
326
  "surfboard",
327
  "wetsuit",
328
  "wax",
329
  "board leash",
330
+ "poncho or towel"
331
  ],
332
  "paragliding": [
333
  "paraglider",
334
+ "helmet",
335
+ "gloves",
336
+ "hiking boots",
337
+ "wind jacket"
338
  ],
339
  "horseback riding": [
340
+ "riding pants",
341
+ "riding boots or shoes with heel",
342
+ "gloves",
343
+ "helmet",
344
+ "optional own saddle or stirrups"
345
  ],
346
  "photography": [
347
+ "camera + lenses",
348
+ "tripod",
349
+ "memory card(s)",
350
+ "extra batteries",
351
+ "lens cloth"
352
  ],
353
  "fishing": [
354
+ "fishing rod",
355
+ "bait / lures",
356
+ "fishing license",
357
+ "boots or waders",
358
+ "cooler box (optional)"
359
  ],
360
  "rafting": [
361
+ "life jacket",
362
+ "waterproof bag",
363
+ "water shoes",
364
+ "quick‑dry clothing",
365
+ "helmet"
366
  ],
367
  "yoga": [
368
+ "general items for this situation",
369
+ "extra clothing or gear if needed"
370
  ],
371
  "cold destination / winter": [
372
+ "thermal clothing",
373
+ "hat and gloves",
374
+ "warm jacket",
375
+ "waterproof shoes",
376
+ "lip balm"
377
  ],
378
  "warm destination / summer": [
379
+ "lightweight clothing",
380
+ "sunglasses",
381
+ "sunscreen",
382
+ "water bottle",
383
+ "hat or cap"
384
  ],
385
  "variable weather / spring / autumn": [
386
+ "rain jacket",
387
+ "layered clothing",
388
+ "warm sweater",
389
+ "waterproof shoes"
390
  ],
391
  "tropical / humid": [
392
+ "lightweight clothing",
393
+ "insect repellent",
394
+ "sunscreen",
395
+ "rain poncho",
396
+ "quick‑dry towel"
397
  ],
398
  "dry / desert-like": [
399
+ "sunglasses",
400
+ "sunscreen",
401
+ "head protection",
402
+ "light long sleeves",
403
+ "lots of water"
404
  ],
405
  "ultralight": [
406
+ "lightweight backpack (< 1kg)",
407
+ "minimalist shelter (tarp or tent)",
408
+ "lightweight sleeping pad",
409
+ "quilt or down blanket",
410
+ "titanium cookset",
411
+ "limited clothing (layers!)",
412
+ "compact rain jacket",
413
+ "quick‑dry towel",
414
+ "toothbrush (shortened ;))"
415
  ],
416
  "lightweight (but comfortable)": [
417
+ "light tent or tarp",
418
+ "comfortable sleeping pad",
419
+ "lightweight cookset",
420
+ "compact clothing pack",
421
+ "quick‑dry towel"
422
  ],
423
  "luxury (including evening wear)": [
424
+ "dress shoes",
425
+ "dress or shirt",
426
+ "perfume / deodorant",
427
+ "accessories",
428
+ "toiletry bag with essentials"
429
  ],
430
  "minimalist": [
431
+ "1 set of clothing for every situation",
432
+ "compact toothbrush",
433
+ "all‑in‑one soap",
434
+ "lightweight towel",
435
+ "small backpack"
436
  ],
437
  "casual": [
438
+ "jeans or comfortable pants",
439
  "t-shirts",
440
+ "sweater or hoodie",
441
  "sneakers",
442
+ "sunglasses"
443
  ],
444
  "formal (business trip)": [
445
+ "shirt / blouse",
446
+ "smart jacket",
447
+ "dress shoes",
448
+ "laptop and charger",
449
+ "business cards / documents"
450
  ],
451
  "conservative": [
452
+ "covering clothing",
453
+ "scarf or shawl",
454
+ "long pants or skirt",
455
+ "closed shoes"
456
  ],
457
  "outdoor": [
458
+ "rain jacket",
459
+ "waterproof shoes",
460
+ "bivvy bag or tarp",
461
+ "headlamp",
462
+ "navigation"
463
  ],
464
  "indoor": [
465
+ "slippers",
466
+ "comfortable clothing",
467
+ "pajamas",
468
+ "charger",
469
+ "toiletry bag"
470
  ],
471
  "huts with half board": [
472
+ "reservation confirmation",
473
+ "sheet liner (often required)",
474
+ "slippers or indoor shoes for inside",
475
+ "light pajamas or sleepwear",
476
+ "earplugs",
477
+ "water bottle",
478
+ "snacks for along the way",
479
+ "small toiletry bag",
480
+ "cash for payments",
481
+ "light towel",
482
+ "flashlight or headlamp"
483
  ],
484
  "sleeping in a tent": [
485
+ "tent (1 or 2‑person, depending on trip)",
486
+ "groundsheet",
487
+ "sleeping pad",
488
+ "sleeping bag (suitable for temperature)",
489
+ "headlamp or flashlight",
490
+ "quick‑dry towel",
491
+ "pillow or inflatable pillow",
492
+ "earplugs",
493
+ "toiletry bag",
494
+ "power bank",
495
+ "water bottle",
496
+ "book or ereader",
497
+ "first aid kit"
498
  ],
499
  "sleeping in a car": [
500
+ "sleeping pad that fits in car",
501
+ "warm sleeping bag",
502
+ "sunshades or blackout covers",
503
+ "pillow",
504
+ "water bottle within reach",
505
+ "power bank or 12V charger",
506
+ "toiletry bag",
507
+ "snacks for the night",
508
+ "thermal blanket (for cold nights)"
509
  ],
510
  "own vehicle": [
511
+ "driver’s license",
512
+ "car documents",
513
+ "first aid kit",
514
+ "navigation or smartphone",
515
+ "phone holder"
516
  ],
517
  "no own vehicle": [
518
+ "backpack",
519
+ "water bottle",
520
+ "light shoes",
521
+ "public transport app or ticket"
522
  ],
523
  "off-grid / no electricity": [
524
+ "power bank (at least 10,000 mAh)",
525
+ "solar panel or portable charging system",
526
+ "headlamp + extra batteries",
527
+ "rechargeable batteries and charger",
528
+ "backup lighting (e.g. small flashlight)",
529
+ "paper map and compass",
530
+ "notebook + pen",
531
+ "emergency communication (e.g. GPS beacon or satellite messenger)",
532
+ "foldable solar panel (if on longer trips)",
533
+ "navigation device with offline maps",
534
+ "extra charger cables",
535
+ "USB hub (for multiple devices)",
536
+ "packaging to keep electronics dry"
537
  ],
538
  "self-supported (bring your own cooking gear)": [
539
+ "lightweight stove (gas, petrol or alcohol)",
540
+ "fuel (enough for several days)",
541
+ "pan or small pot",
542
+ "spork or spoon",
543
+ "foldable cutting board (optional)",
544
+ "press‑on bowl or mug",
545
+ "lighter + matches (waterproof packed)",
546
+ "dried or freeze‑dried meals",
547
+ "snacks / emergency bars",
548
+ "biodegradable soap + sponge",
549
+ "bags for waste",
550
+ "water filter or pump",
551
+ "chlorine drops or purification tablets",
552
+ "at least 2 liters of water storage per person",
553
+ "food bag or hanging bag (wild-safe)"
554
  ],
555
  "travel with children": [
556
+ "snacks and toys",
557
+ "first aid kit with bandages",
558
+ "extra clothing",
559
+ "child carrier or stroller",
560
+ "sun protection",
561
+ "extra snacks for children",
562
+ "favorite toy or stuffed animal",
563
+ "travel chair or sling",
564
+ "wet wipes",
565
+ "diapers or potty (depending on age)",
566
+ "extra clothing set per day",
567
+ "children’s travel pharmacy",
568
+ "children’s sunscreen",
569
+ "activity book or tablet with films",
570
+ "quick snacks for en route",
571
+ "child sleeping bag or pad",
572
+ "travel crib or mattress (for young children)",
573
+ "diapers or training pants",
574
+ "bottles and food (if applicable)",
575
+ "baby monitor (for staying at location)",
576
+ "pacifier or dummy",
577
+ "kids first aid kit (including thermometer)",
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",
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",
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
+ }
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/.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 = "facebook/bart-large-mnli"),
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/.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/.ipynb_checkpoints/main_model-checkpoint.ipynb CHANGED
The diff for this file is too large to render. See raw diff
 
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 = "facebook/bart-large-mnli"),
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/blog_post/article.md ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Working with Large Language Models
2
+ ## Introduction
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 adept models to your application
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
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
+
24
+ ### Predefine outputs/classes
25
+
26
+ ### Model implementation
27
+
28
+ ### Using gradio app
29
+
30
+ ### Share your model
31
+ * created space
32
+ * created github access token on huffing face and then github actions workflow
33
+ * you need to install the required dependencies in the environment where your Hugging Face Space is running.
34
+ * create requirements.txt file with necessary libraries
35
+
36
+
37
+ ## Performance assessment
38
+ * Test data creation
39
+
40
+ ## Side notes
41
+ * Hugging face API (or mention during implementation)
42
+
43
+ ## Closing
44
+ * Summary
45
+ * Limitations
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
  {
@@ -18,41 +18,32 @@
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
  {
@@ -229,20 +220,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 +250,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 +257,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 +373,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 +394,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 +421,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 +439,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 +591,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 +700,7 @@
808
  },
809
  {
810
  "cell_type": "code",
811
- "execution_count": 6,
812
  "id": "adb491b1-3ac3-4c32-934f-5eb6171f2ec9",
813
  "metadata": {},
814
  "outputs": [
@@ -904,26 +796,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 +861,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
  {
@@ -1013,9 +968,10 @@
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
  {
@@ -1029,15 +985,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>"
@@ -1056,11 +1011,9 @@
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,7 +1024,21 @@
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",
@@ -1080,15 +1047,49 @@
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
  {
 
18
  },
19
  {
20
  "cell_type": "code",
21
+ "execution_count": 2,
22
  "id": "f8c28d2d-8458-49fd-8ebf-5e729d6e861f",
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
  {
 
220
  },
221
  {
222
  "cell_type": "code",
223
+ "execution_count": 3,
224
  "id": "fac51224-9575-4b4b-8567-4ad4e759ecc9",
225
  "metadata": {},
226
  "outputs": [],
227
  "source": [
228
+ "def pred_trip(model_name, trip_descr, trip_type, cut_off = 0.5):\n",
229
+ " \"\"\"\n",
230
+ " Classifies trip\n",
231
+ " \n",
232
+ " Parameters:\n",
233
+ " model_name: name of hugging-face model\n",
234
+ " trip_descr: text describing the trip\n",
235
+ " trip_type: true trip classification\n",
236
+ " cut_off: cut_off for choosing activities\n",
237
  "\n",
238
+ " Returns:\n",
239
+ " pd Dataframe: with class predictions and true values\n",
240
+ " \"\"\"\n",
241
+ " \n",
242
  " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
 
243
  " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
244
  " for i, key in enumerate(keys_list):\n",
245
+ " print(i)\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
  " else:\n",
251
  " result = classifier(trip_descr, candidate_labels[key])\n",
252
  " classes = result[\"labels\"][0]\n",
 
 
 
253
  " df.loc[i] = [key, classes]\n",
254
  " df['true_class'] = trip_type\n",
255
  " return df"
 
257
  },
258
  {
259
  "cell_type": "code",
260
+ "execution_count": 4,
261
  "id": "b36ab806-2f35-4950-ac5a-7c192190cba7",
262
  "metadata": {},
263
  "outputs": [],
264
  "source": [
 
 
265
  "def perf_measure(df):\n",
266
+ " \"\"\"\n",
267
+ " Calculates performance measures:\n",
268
+ " Accuracy of classification excluding activities superclass\n",
269
+ " Percentage of correctly identified activities (#correctly predicted/#true activities)\n",
270
+ " Percentage of wrongly identified activities (#wrongly predicted/#predicted activities)\n",
271
+ "\n",
272
+ " Parameters:\n",
273
+ " df: pd Dataframe returned from pred_trip()\n",
274
+ "\n",
275
+ " Returns:\n",
276
+ " pd Dataframe: containing performance measures\n",
277
+ " \"\"\"\n",
278
+ " \n",
279
  " df['same_value'] = df['pred_class'] == df['true_class']\n",
280
  " correct = sum(df.loc[df.index != 1, 'same_value'])\n",
281
  " total = len(df['same_value'])\n",
 
373
  "model_names = [\n",
374
  " \"facebook/bart-large-mnli\",\n",
375
  " \"MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli\",\n",
376
+ " \"cross-encoder/nli-deberta-v3-base\",\n",
377
  " \"cross-encoder/nli-deberta-v3-large\",\n",
378
  " \"MoritzLaurer/mDeBERTa-v3-base-mnli-xnli\",\n",
379
+ " \"joeddav/bart-large-mnli-yahoo-answers\",\n",
380
  " \"MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli\",\n",
381
  " \"MoritzLaurer/deberta-v3-large-zeroshot-v2.0\",\n",
382
  " \"valhalla/distilbart-mnli-12-1\",\n",
 
394
  " current_trip = trip_descriptions[i]\n",
395
  " current_type = trip_types[i]\n",
396
  " df = pred_trip(model_name, current_trip, current_type, cut_off = 0.5)\n",
 
 
397
  " performance = pd.concat([performance, perf_measure(df)])\n",
 
 
398
  " result_list.append(df)\n",
399
  " end_time = time.time()\n",
400
  " elapsed_time = end_time - start_time\n",
401
+ " \n",
402
+ " # Extract and combine columns identifying correct prediction (for each trip)\n",
403
+ " sv_columns = [df['same_value'] for df in result_list]\n",
404
  " sv_columns.insert(0, result_list[0]['superclass'])\n",
 
405
  " sv_df = pd.concat(sv_columns, axis=1)\n",
406
+ " # Compute accuracy per superclass\n",
 
407
  " row_means = sv_df.iloc[:, 1:].mean(axis=1)\n",
408
  " df_row_means = pd.DataFrame({\n",
409
  " 'superclass': sv_df['superclass'],\n",
410
  " 'accuracy': row_means\n",
411
  " })\n",
 
412
  " # Compute performance measures per trip (mean for each column of performance table)\n",
413
  " column_means = performance.mean()\n",
414
+ " # Save results\n",
 
415
  " model = model_name.replace(\"/\", \"-\")\n",
416
  " model_result = {\n",
417
  " 'model': model,\n",
 
421
  " 'perf_superclass': df_row_means,\n",
422
  " 'elapsed_time': elapsed_time\n",
423
  " }\n",
 
424
  " filename = os.path.join('results', f'{model}_results.pkl')\n",
 
425
  " with open(filename, 'wb') as f:\n",
426
  " pickle.dump(model_result, f)\n",
427
  "\n",
 
439
  },
440
  {
441
  "cell_type": "code",
442
+ "execution_count": 6,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
443
  "id": "37849e0b-864e-4377-b06c-0ac70c3861f9",
444
  "metadata": {
445
  "scrolled": true
 
591
  ],
592
  "source": [
593
  "def get_difficult_trips(model_result, cut_off = 0.6):\n",
594
+ " \"\"\"\n",
595
+ " \"\"\"\n",
596
  " # model_result is a dict with dict_keys(['model', 'predictions', \n",
597
  " # 'performance', 'perf_summary', 'perf_superclass', 'elapsed_time'])\n",
598
  " # get performance dataframe and repair index\n",
 
700
  },
701
  {
702
  "cell_type": "code",
703
+ "execution_count": 9,
704
  "id": "adb491b1-3ac3-4c32-934f-5eb6171f2ec9",
705
  "metadata": {},
706
  "outputs": [
 
796
  },
797
  {
798
  "cell_type": "code",
799
+ "execution_count": 10,
800
  "id": "b020f584-1468-4c84-9dac-7ca7fac6e8ca",
801
+ "metadata": {
802
+ "scrolled": true
803
+ },
804
  "outputs": [
805
  {
806
  "name": "stdout",
807
  "output_type": "stream",
808
  "text": [
809
  "[]\n",
810
+ " accuracy true_ident false_pred \\\n",
811
+ "0 0.444444 0.533333 0.712500 \n",
812
+ "1 0.355556 0.650000 0.553792 \n",
813
+ "2 0.466667 0.566667 0.541667 \n",
814
+ "3 0.611111 0.841667 0.546667 \n",
815
+ "4 0.455556 0.408333 0.481250 \n",
816
+ "5 0.500000 0.325000 0.500000 \n",
817
+ "6 0.466667 0.708333 0.400000 \n",
818
+ "7 0.500000 0.300000 0.533333 \n",
819
+ "8 0.522222 0.841667 0.572381 \n",
 
820
  "\n",
821
  " model \n",
822
  "0 cross-encoder-nli-deberta-v3-base \n",
 
861
  },
862
  {
863
  "cell_type": "code",
864
+ "execution_count": 25,
865
+ "id": "222a70fc-8d3c-4ebb-9954-d5c72baed9e5",
866
+ "metadata": {},
867
+ "outputs": [],
868
+ "source": [
869
+ "# return packing list additionally to classes\n",
870
+ "# Load packing item data\n",
871
+ "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
872
+ " packing_items = json.load(file)\n",
873
+ "\n",
874
+ "# function and gradio app\n",
875
+ "def classify(model_name, trip_descr, cut_off = 0.5):\n",
876
+ " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
877
+ " ## Create and fill dataframe with class predictions\n",
878
+ " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
879
+ " for i, key in enumerate(keys_list):\n",
880
+ " if key == 'activities':\n",
881
+ " result = classifier(trip_descr, candidate_labels[key], multi_label=True)\n",
882
+ " indices = [i for i, score in enumerate(result['scores']) if score > cut_off]\n",
883
+ " classes = [result['labels'][i] for i in indices]\n",
884
+ " else:\n",
885
+ " result = classifier(trip_descr, candidate_labels[key])\n",
886
+ " classes = result[\"labels\"][0]\n",
887
+ " df.loc[i] = [key, classes]\n",
888
+ "\n",
889
+ " ## Look up and return list of items to pack based on class predictions\n",
890
+ " # make list from dataframe column\n",
891
+ " all_classes = [elem for x in df[\"pred_class\"] for elem in (x if isinstance(x, list) else [x])]\n",
892
+ " # look up packing items for each class/key\n",
893
+ " list_of_list_of_items = [packing_items.get(k, []) for k in all_classes]\n",
894
+ " # combine lists and remove doubble entries\n",
895
+ " flat_unique = []\n",
896
+ " for sublist in list_of_list_of_items:\n",
897
+ " for item in sublist:\n",
898
+ " if item not in flat_unique:\n",
899
+ " flat_unique.append(item)\n",
900
+ " # sort alphabetically to notice duplicates\n",
901
+ " sorted_list = sorted(flat_unique) \n",
902
+ " return df, sorted_list"
903
+ ]
904
+ },
905
+ {
906
+ "cell_type": "code",
907
+ "execution_count": 26,
908
  "id": "0f7376bd-a50b-47cc-8055-48a6de5dfee6",
909
  "metadata": {},
910
  "outputs": [
911
+ {
912
+ "name": "stderr",
913
+ "output_type": "stream",
914
+ "text": [
915
+ "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"
916
+ ]
917
+ },
918
  {
919
  "name": "stdout",
920
  "output_type": "stream",
921
  "text": [
922
+ "( superclass pred_class\n",
923
+ "0 activity_type beach vacation\n",
924
+ "1 activities [going to the beach, relaxing, hiking]\n",
925
+ "2 climate_or_season warm destination / summer\n",
926
+ "3 style_or_comfort minimalist\n",
927
+ "4 dress_code casual\n",
928
+ "5 accommodation huts with half board\n",
929
+ "6 transportation no own vehicle\n",
930
+ "7 special_conditions off-grid / no electricity\n",
931
+ "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"
932
  ]
933
  }
934
  ],
935
  "source": [
936
+ "# Access the first trip description\n",
937
+ "first_trip = trip_descriptions[0]\n",
938
+ "tmp = classify(\"facebook/bart-large-mnli\", first_trip )\n",
939
+ "print(tmp)"
940
  ]
941
  },
942
  {
 
968
  "# Load test data (in list of dictionaries)\n",
969
  "with open(\"test_data.json\", \"r\") as file:\n",
970
  " packing_data = json.load(file)\n",
971
+ "\n",
972
+ "# Load packing item data\n",
973
+ "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
974
+ " packing_items = json.load(file)"
975
  ]
976
  },
977
  {
 
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
  ]
991
  },
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>"
 
1011
  ],
1012
  "source": [
1013
  "# function and gradio app\n",
1014
+ "def classify(model_name, trip_descr, cut_off = 0.5):\n",
 
 
1015
  " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
1016
+ " ## Create and fill dataframe with class predictions\n",
1017
  " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
1018
  " for i, key in enumerate(keys_list):\n",
1019
  " if key == 'activities':\n",
 
1024
  " result = classifier(trip_descr, candidate_labels[key])\n",
1025
  " classes = result[\"labels\"][0]\n",
1026
  " df.loc[i] = [key, classes]\n",
1027
+ "\n",
1028
+ " ## Look up and return list of items to pack based on class predictions\n",
1029
+ " # make list from dataframe column\n",
1030
+ " all_classes = [elem for x in df[\"pred_class\"] for elem in (x if isinstance(x, list) else [x])]\n",
1031
+ " # look up packing items for each class/key\n",
1032
+ " list_of_list_of_items = [packing_items.get(k, []) for k in all_classes]\n",
1033
+ " # combine lists and remove doubble entries\n",
1034
+ " flat_unique = []\n",
1035
+ " for sublist in list_of_list_of_items:\n",
1036
+ " for item in sublist:\n",
1037
+ " if item not in flat_unique:\n",
1038
+ " flat_unique.append(item)\n",
1039
+ " # sort alphabetically to notice duplicates\n",
1040
+ " sorted_list = sorted(flat_unique) \n",
1041
+ " return df, \"\\n\".join(sorted_list)\n",
1042
  "\n",
1043
  "demo = gr.Interface(\n",
1044
  " fn=classify,\n",
 
1047
  " gr.Textbox(label=\"Trip description\"),\n",
1048
  " gr.Number(label=\"Activity cut-off\", value = 0.5),\n",
1049
  " ],\n",
1050
+ " # outputs=\"dataframe\",\n",
1051
+ " outputs=[gr.Dataframe(label=\"DataFrame\"), gr.Textbox(label=\"List of words\")],\n",
1052
  " title=\"Trip classification\",\n",
1053
  " description=\"Enter a text describing your trip\",\n",
1054
  ")\n",
1055
  "\n",
1056
  "# Launch the Gradio app\n",
1057
  "if __name__ == \"__main__\":\n",
1058
+ " demo.launch()\n"
1059
+ ]
1060
+ },
1061
+ {
1062
+ "cell_type": "code",
1063
+ "execution_count": 32,
1064
+ "id": "1f5df949-a527-4b11-8e5e-23786e1cde12",
1065
+ "metadata": {},
1066
+ "outputs": [
1067
+ {
1068
+ "name": "stdout",
1069
+ "output_type": "stream",
1070
+ "text": [
1071
+ "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"
1072
+ ]
1073
+ },
1074
+ {
1075
+ "name": "stderr",
1076
+ "output_type": "stream",
1077
+ "text": [
1078
+ "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"
1079
+ ]
1080
+ }
1081
+ ],
1082
+ "source": [
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": []
1093
  }
1094
  ],
1095
  "metadata": {
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
+ "hydration bladder or water bottles",
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 hut 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",
30
+ "cookset + stove",
31
+ "food and snacks",
32
+ "lighter",
33
+ "toiletry bag with biodegradable soap"
34
  ],
35
  "camping trip (campground)": [
36
  "tent",
37
+ "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",
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",
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",
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
+ "downtime entertainment (e.g. book / ebook, games, laptop, journal)"
185
  ],
186
  "swimming": [
187
+ "swimsuit",
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 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 or GPS)"
267
  ],
268
  "hut-to-hut hiking": [
269
+ "lightweight trekking backpack (30–45 liters)",
270
+ "water bottles 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 hut",
278
+ "earplugs",
279
+ "reservation confirmation / cash for hut"
280
  ],
281
  "rock climbing": [
282
+ "climbing shoes",
283
+ "climbing harness",
284
+ "belay device",
285
  "chalk bag",
286
+ "helmet"
287
  ],
288
  "ice climbing": [
289
+ "ice axes",
290
  "crampons",
291
+ "climbing rope",
292
+ "warm insulation layers",
293
+ "climbing harness and helmet"
294
  ],
295
  "snowshoe hiking": [
296
+ "general items for this situation",
297
+ "extra clothing or gear if needed"
298
  ],
299
  "kayaking / canoeing": [
300
+ "kayak or canoe",
301
+ "paddle",
302
+ "life jacket",
303
+ "dry bag",
304
+ "water shoes"
305
  ],
306
  "stand-up paddleboarding (SUP)": [
307
+ "SUP board and paddle",
308
+ "life jacket",
309
+ "dry bag",
310
+ "sunglasses with strap"
311
  ],
312
  "snorkeling": [
313
+ "snorkel and mask",
314
+ "fins",
315
+ "swimwear",
316
+ "waterproof bag"
317
  ],
318
  "scuba diving": [
319
+ "mask and snorkel",
320
  "wetsuit",
321
+ "fins",
322
+ "dive computer",
323
+ "regulator (if own)"
324
  ],
325
  "surfing": [
326
  "surfboard",
327
  "wetsuit",
328
  "wax",
329
  "board leash",
330
+ "poncho or towel"
331
  ],
332
  "paragliding": [
333
  "paraglider",
334
+ "helmet",
335
+ "gloves",
336
+ "hiking boots",
337
+ "wind jacket"
338
  ],
339
  "horseback riding": [
340
+ "riding pants",
341
+ "riding boots or shoes with heel",
342
+ "gloves",
343
+ "helmet",
344
+ "optional own saddle or stirrups"
345
  ],
346
  "photography": [
347
+ "camera + lenses",
348
+ "tripod",
349
+ "memory card(s)",
350
+ "extra batteries",
351
+ "lens cloth"
352
  ],
353
  "fishing": [
354
+ "fishing rod",
355
+ "bait / lures",
356
+ "fishing license",
357
+ "boots or waders",
358
+ "cooler box (optional)"
359
  ],
360
  "rafting": [
361
+ "life jacket",
362
+ "waterproof bag",
363
+ "water shoes",
364
+ "quick‑dry clothing",
365
+ "helmet"
366
  ],
367
  "yoga": [
368
+ "general items for this situation",
369
+ "extra clothing or gear if needed"
370
  ],
371
  "cold destination / winter": [
372
+ "thermal clothing",
373
+ "hat and gloves",
374
+ "warm jacket",
375
+ "waterproof shoes",
376
+ "lip balm"
377
  ],
378
  "warm destination / summer": [
379
+ "lightweight clothing",
380
+ "sunglasses",
381
+ "sunscreen",
382
+ "water bottle",
383
+ "hat or cap"
384
  ],
385
  "variable weather / spring / autumn": [
386
+ "rain jacket",
387
+ "layered clothing",
388
+ "warm sweater",
389
+ "waterproof shoes"
390
  ],
391
  "tropical / humid": [
392
+ "lightweight clothing",
393
+ "insect repellent",
394
+ "sunscreen",
395
+ "rain poncho",
396
+ "quick‑dry towel"
397
  ],
398
  "dry / desert-like": [
399
+ "sunglasses",
400
+ "sunscreen",
401
+ "head protection",
402
+ "light long sleeves",
403
+ "lots of water"
404
  ],
405
  "ultralight": [
406
+ "lightweight backpack (< 1kg)",
407
+ "minimalist shelter (tarp or tent)",
408
+ "lightweight sleeping pad",
409
+ "quilt or down blanket",
410
+ "titanium cookset",
411
+ "limited clothing (layers!)",
412
+ "compact rain jacket",
413
+ "quick‑dry towel",
414
+ "toothbrush (shortened ;))"
415
  ],
416
  "lightweight (but comfortable)": [
417
+ "light tent or tarp",
418
+ "comfortable sleeping pad",
419
+ "lightweight cookset",
420
+ "compact clothing pack",
421
+ "quick‑dry towel"
422
  ],
423
  "luxury (including evening wear)": [
424
+ "dress shoes",
425
+ "dress or shirt",
426
+ "perfume / deodorant",
427
+ "accessories",
428
+ "toiletry bag with essentials"
429
  ],
430
  "minimalist": [
431
+ "1 set of clothing for every situation",
432
+ "compact toothbrush",
433
+ "all‑in‑one soap",
434
+ "lightweight towel",
435
+ "small backpack"
436
  ],
437
  "casual": [
438
+ "jeans or comfortable pants",
439
  "t-shirts",
440
+ "sweater or hoodie",
441
  "sneakers",
442
+ "sunglasses"
443
  ],
444
  "formal (business trip)": [
445
+ "shirt / blouse",
446
+ "smart jacket",
447
+ "dress shoes",
448
+ "laptop and charger",
449
+ "business cards / documents"
450
  ],
451
  "conservative": [
452
+ "covering clothing",
453
+ "scarf or shawl",
454
+ "long pants or skirt",
455
+ "closed shoes"
456
  ],
457
  "outdoor": [
458
+ "rain jacket",
459
+ "waterproof shoes",
460
+ "bivvy bag or tarp",
461
+ "headlamp",
462
+ "navigation"
463
  ],
464
  "indoor": [
465
+ "slippers",
466
+ "comfortable clothing",
467
+ "pajamas",
468
+ "charger",
469
+ "toiletry bag"
470
  ],
471
  "huts with half board": [
472
+ "reservation confirmation",
473
+ "sheet liner (often required)",
474
+ "slippers or indoor shoes for inside",
475
+ "light pajamas or sleepwear",
476
+ "earplugs",
477
+ "water bottle",
478
+ "snacks for along the way",
479
+ "small toiletry bag",
480
+ "cash for payments",
481
+ "light towel",
482
+ "flashlight or headlamp"
483
  ],
484
  "sleeping in a tent": [
485
+ "tent (1 or 2‑person, depending on trip)",
486
+ "groundsheet",
487
+ "sleeping pad",
488
+ "sleeping bag (suitable for temperature)",
489
+ "headlamp or flashlight",
490
+ "quick‑dry towel",
491
+ "pillow or inflatable pillow",
492
+ "earplugs",
493
+ "toiletry bag",
494
+ "power bank",
495
+ "water bottle",
496
+ "book or ereader",
497
+ "first aid kit"
498
  ],
499
  "sleeping in a car": [
500
+ "sleeping pad that fits in car",
501
+ "warm sleeping bag",
502
+ "sunshades or blackout covers",
503
+ "pillow",
504
+ "water bottle within reach",
505
+ "power bank or 12V charger",
506
+ "toiletry bag",
507
+ "snacks for the night",
508
+ "thermal blanket (for cold nights)"
509
  ],
510
  "own vehicle": [
511
+ "driver’s license",
512
+ "car documents",
513
+ "first aid kit",
514
+ "navigation or smartphone",
515
+ "phone holder"
516
  ],
517
  "no own vehicle": [
518
+ "backpack",
519
+ "water bottle",
520
+ "light shoes",
521
+ "public transport app or ticket"
522
  ],
523
  "off-grid / no electricity": [
524
+ "power bank (at least 10,000 mAh)",
525
+ "solar panel or portable charging system",
526
+ "headlamp + extra batteries",
527
+ "rechargeable batteries and charger",
528
+ "backup lighting (e.g. small flashlight)",
529
+ "paper map and compass",
530
+ "notebook + pen",
531
+ "emergency communication (e.g. GPS beacon or satellite messenger)",
532
+ "foldable solar panel (if on longer trips)",
533
+ "navigation device with offline maps",
534
+ "extra charger cables",
535
+ "USB hub (for multiple devices)",
536
+ "packaging to keep electronics dry"
537
  ],
538
  "self-supported (bring your own cooking gear)": [
539
+ "lightweight stove (gas, petrol or alcohol)",
540
+ "fuel (enough for several days)",
541
+ "pan or small pot",
542
+ "spork or spoon",
543
+ "foldable cutting board (optional)",
544
+ "press‑on bowl or mug",
545
+ "lighter + matches (waterproof packed)",
546
+ "dried or freeze‑dried meals",
547
+ "snacks / emergency bars",
548
+ "biodegradable soap + sponge",
549
+ "bags for waste",
550
+ "water filter or pump",
551
+ "chlorine drops or purification tablets",
552
+ "at least 2 liters of water storage per person",
553
+ "food bag or hanging bag (wild-safe)"
554
  ],
555
  "travel with children": [
556
+ "snacks and toys",
557
+ "first aid kit with bandages",
558
+ "extra clothing",
559
+ "child carrier or stroller",
560
+ "sun protection",
561
+ "extra snacks for children",
562
+ "favorite toy or stuffed animal",
563
+ "travel chair or sling",
564
+ "wet wipes",
565
+ "diapers or potty (depending on age)",
566
+ "extra clothing set per day",
567
+ "children’s travel pharmacy",
568
+ "children’s sunscreen",
569
+ "activity book or tablet with films",
570
+ "quick snacks for en route",
571
+ "child sleeping bag or pad",
572
+ "travel crib or mattress (for young children)",
573
+ "diapers or training pants",
574
+ "bottles and food (if applicable)",
575
+ "baby monitor (for staying at location)",
576
+ "pacifier or dummy",
577
+ "kids first aid kit (including thermometer)",
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",
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",
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/.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/.ipynb_checkpoints/main_model-checkpoint.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
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/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/results/.DS_Store ADDED
Binary file (6.15 kB). View file
 
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/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/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/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/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/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/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/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/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/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/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/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
space/space/space/space/results/before/valhalla-distilbart-mnli-12-1_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:45d4d12f3880836626c96e5dddad7293aa8124abec5eb187845a0637cdd93df1
3
+ size 9277
space/space/space/space/results/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:ce310367d9c5baec72cef673cf1608ee1b11fc7239c459b38f4ffb86cbe7ddff
3
+ size 9670
space/space/space/space/results/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:2b363db77b85d99ed32e0daa026f31cfdd7d001ab5f4782abecd2f11f2a06281
3
+ size 9602
space/space/space/space/results/facebook-bart-large-mnli_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6e00867ad478907a6e514e97d342ef8915ee2c486912ff7056e6dfc5faa11278
3
+ size 9489
space/space/space/space/results/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:175935f34f69404b1662d4572a543ddd77938bc5ee53751034e2ddb07f6b4d49
3
+ size 9694
space/space/space/space/results/valhalla-distilbart-mnli-12-1_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:779ac1118c668f3c090dafe28608c624b0acac270bff55ddb7babff36ee33f09
3
+ size 9374
space/space/space/space/space/.ipynb_checkpoints/gradio_tryout-checkpoint.ipynb CHANGED
@@ -19,113 +19,15 @@
19
  "id": "3bbee2e4-55c8-4b06-9929-72026edf7932",
20
  "metadata": {},
21
  "source": [
22
- "**Load and try the model**"
23
  ]
24
  },
25
  {
26
  "cell_type": "code",
27
- "execution_count": 36,
28
  "id": "f8c28d2d-8458-49fd-8ebf-5e729d6e861f",
29
  "metadata": {},
30
  "outputs": [
31
- {
32
- "data": {
33
- "application/vnd.jupyter.widget-view+json": {
34
- "model_id": "9ec45d8fb4e247e4b1188972547ebb7f",
35
- "version_major": 2,
36
- "version_minor": 0
37
- },
38
- "text/plain": [
39
- "config.json: 0%| | 0.00/1.09k [00:00<?, ?B/s]"
40
- ]
41
- },
42
- "metadata": {},
43
- "output_type": "display_data"
44
- },
45
- {
46
- "data": {
47
- "application/vnd.jupyter.widget-view+json": {
48
- "model_id": "991968ef7a0448b39ca84316e6d06902",
49
- "version_major": 2,
50
- "version_minor": 0
51
- },
52
- "text/plain": [
53
- "model.safetensors: 0%| | 0.00/369M [00:00<?, ?B/s]"
54
- ]
55
- },
56
- "metadata": {},
57
- "output_type": "display_data"
58
- },
59
- {
60
- "data": {
61
- "application/vnd.jupyter.widget-view+json": {
62
- "model_id": "561c0cdcc88f4cd6b89dd19bcc0599cb",
63
- "version_major": 2,
64
- "version_minor": 0
65
- },
66
- "text/plain": [
67
- "tokenizer_config.json: 0%| | 0.00/1.28k [00:00<?, ?B/s]"
68
- ]
69
- },
70
- "metadata": {},
71
- "output_type": "display_data"
72
- },
73
- {
74
- "data": {
75
- "application/vnd.jupyter.widget-view+json": {
76
- "model_id": "c5e517b2512246018e5cb1fdc8d3e1e1",
77
- "version_major": 2,
78
- "version_minor": 0
79
- },
80
- "text/plain": [
81
- "spm.model: 0%| | 0.00/2.46M [00:00<?, ?B/s]"
82
- ]
83
- },
84
- "metadata": {},
85
- "output_type": "display_data"
86
- },
87
- {
88
- "data": {
89
- "application/vnd.jupyter.widget-view+json": {
90
- "model_id": "03b470dec7174fd29b9b0e4afab759a0",
91
- "version_major": 2,
92
- "version_minor": 0
93
- },
94
- "text/plain": [
95
- "tokenizer.json: 0%| | 0.00/8.66M [00:00<?, ?B/s]"
96
- ]
97
- },
98
- "metadata": {},
99
- "output_type": "display_data"
100
- },
101
- {
102
- "data": {
103
- "application/vnd.jupyter.widget-view+json": {
104
- "model_id": "16d24496b31b4c0fb7744c8ee1222d40",
105
- "version_major": 2,
106
- "version_minor": 0
107
- },
108
- "text/plain": [
109
- "added_tokens.json: 0%| | 0.00/23.0 [00:00<?, ?B/s]"
110
- ]
111
- },
112
- "metadata": {},
113
- "output_type": "display_data"
114
- },
115
- {
116
- "data": {
117
- "application/vnd.jupyter.widget-view+json": {
118
- "model_id": "ef2aefc365734c1884bbbb04d79edf5b",
119
- "version_major": 2,
120
- "version_minor": 0
121
- },
122
- "text/plain": [
123
- "special_tokens_map.json: 0%| | 0.00/286 [00:00<?, ?B/s]"
124
- ]
125
- },
126
- "metadata": {},
127
- "output_type": "display_data"
128
- },
129
  {
130
  "name": "stderr",
131
  "output_type": "stream",
@@ -152,10 +54,14 @@
152
  "import matplotlib.pyplot as plt\n",
153
  "import pickle\n",
154
  "import os\n",
 
155
  "\n",
156
  "# Load the model and create a pipeline for zero-shot classification (1min loading + classifying with 89 labels)\n",
157
- "classifier = pipeline(\"zero-shot-classification\", model=\"MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli\")\n",
 
158
  "# tried:\n",
 
 
159
  "# facebook/bart-large-mnli\n",
160
  "# sileod/deberta-v3-base-tasksource-nli\n",
161
  "\n",
@@ -182,7 +88,7 @@
182
  },
183
  {
184
  "cell_type": "code",
185
- "execution_count": 37,
186
  "id": "3a762755-872d-43a6-b666-874d6133488c",
187
  "metadata": {},
188
  "outputs": [],
@@ -212,7 +118,7 @@
212
  },
213
  {
214
  "cell_type": "code",
215
- "execution_count": 38,
216
  "id": "3b4f3193-3bdd-453c-8664-df84f955600c",
217
  "metadata": {},
218
  "outputs": [],
@@ -249,87 +155,85 @@
249
  },
250
  {
251
  "cell_type": "code",
252
- "execution_count": 39,
253
  "id": "4dd01755-be8d-4904-8494-ac28aba2fee7",
254
  "metadata": {
255
  "scrolled": true
256
  },
257
  "outputs": [
258
- {
259
- "name": "stderr",
260
- "output_type": "stream",
261
- "text": [
262
- "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"
263
- ]
264
- },
265
  {
266
  "name": "stdout",
267
  "output_type": "stream",
268
  "text": [
269
- "{'sequence': '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.', 'labels': ['beach vacation', 'micro-adventure / weekend trip', 'cultural exploration', 'nature escape', 'digital nomad trip', 'camping trip (campground)', 'camping trip (wild camping)', 'long-distance hike / thru-hike', 'ski tour / skitour', 'hut trek (summer)', 'city trip', 'hut trek (winter)', 'road trip (car/camper)', 'festival trip', 'yoga / wellness retreat', 'snowboard / splitboard trip'], 'scores': [0.37198853492736816, 0.31496119499206543, 0.10890532284975052, 0.09102731198072433, 0.0735681876540184, 0.012933704070746899, 0.009422042407095432, 0.0051276967860758305, 0.004056071396917105, 0.0017408831045031548, 0.001503779087215662, 0.0014244643971323967, 0.0013752576196566224, 0.0009292717440985143, 0.0006881792796775699, 0.0003480584127828479]}\n",
270
- "beach vacation\n",
271
  "0\n",
272
- "{'sequence': '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.', 'labels': ['relaxing', 'hiking', 'going to the beach', 'photography', 'sightseeing', 'hut-to-hut hiking', 'snorkeling', 'snowshoe hiking', 'yoga', 'stand-up paddleboarding (SUP)', 'kayaking / canoeing', 'horseback riding', 'swimming', 'paragliding', 'rafting', 'biking', 'rock climbing', 'surfing', 'running', 'ice climbing', 'cross-country skiing', 'fishing', 'ski touring', 'skiing', 'scuba diving'], 'scores': [0.9943736791610718, 0.9631249308586121, 0.9454535841941833, 0.7538902759552002, 0.4525446593761444, 0.1696157604455948, 0.05957728251814842, 0.04234873503446579, 0.01991761103272438, 0.016971556469798088, 0.006959819234907627, 0.00411367928609252, 0.0030609173700213432, 0.00186573073733598, 0.0017515394138172269, 0.00142807571683079, 0.0005748369731009007, 0.00037779140984639525, 0.0003097739245276898, 0.00030914091621525586, 0.0002725012309383601, 0.00027050732751376927, 0.00024376016517635435, 0.00017392759036738425, 0.00014787293912377208]}\n",
273
- "['relaxing', 'hiking', 'going to the beach', 'photography']\n",
274
  "1\n",
275
- "{'sequence': '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.', 'labels': ['tropical / humid', 'warm destination / summer', 'variable weather / spring / autumn', 'cold destination / winter', 'dry / desert-like'], 'scores': [0.4895477890968323, 0.25917261838912964, 0.24829530715942383, 0.0017174285603687167, 0.0012668712297454476]}\n",
276
- "tropical / humid\n",
277
  "2\n",
278
- "{'sequence': '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.', 'labels': ['minimalist', 'luxury (including evening wear)', 'lightweight (but comfortable)', 'ultralight'], 'scores': [0.7574900984764099, 0.09964746236801147, 0.07804173231124878, 0.06482075154781342]}\n",
279
  "minimalist\n",
280
  "3\n",
281
- "{'sequence': '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.', 'labels': ['casual', 'conservative', 'formal (business trip)'], 'scores': [0.8163393139839172, 0.11898067593574524, 0.06467998772859573]}\n",
282
  "casual\n",
283
  "4\n",
284
- "{'sequence': '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.', 'labels': ['indoor', 'huts with half board', 'sleeping in a car', 'sleeping in a tent'], 'scores': [0.6389047503471375, 0.18624886870384216, 0.13902997970581055, 0.03581654652953148]}\n",
285
  "indoor\n",
286
  "5\n",
287
- "{'sequence': '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.', 'labels': ['no own vehicle', 'own vehicle'], 'scores': [0.9990958571434021, 0.0009041387238539755]}\n",
288
  "no own vehicle\n",
289
- "6\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  ]
291
  },
292
  {
293
- "ename": "KeyboardInterrupt",
294
- "evalue": "",
295
  "output_type": "error",
296
  "traceback": [
297
  "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
298
- "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
299
- "Cell \u001b[0;32mIn[39], line 7\u001b[0m\n\u001b[1;32m 5\u001b[0m current_trip \u001b[38;5;241m=\u001b[39m trip_descriptions[i]\n\u001b[1;32m 6\u001b[0m current_type \u001b[38;5;241m=\u001b[39m trip_types[i]\n\u001b[0;32m----> 7\u001b[0m df \u001b[38;5;241m=\u001b[39m \u001b[43mpred_trip\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 8\u001b[0m \u001b[38;5;28mprint\u001b[39m(df)\n\u001b[1;32m 10\u001b[0m \u001b[38;5;66;03m# accuracy, perc true classes identified and perc wrong pred classes\u001b[39;00m\n",
300
- "Cell \u001b[0;32mIn[37], line 14\u001b[0m, in \u001b[0;36mpred_trip\u001b[0;34m(trip_descr, trip_type, cut_off)\u001b[0m\n\u001b[1;32m 12\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 13\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m---> 14\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 15\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 16\u001b[0m \u001b[38;5;28mprint\u001b[39m(result)\n",
301
- "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",
302
- "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",
303
- "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",
304
- "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",
305
- "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",
306
- "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",
307
- "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",
308
- "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",
309
- "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:1297\u001b[0m, in \u001b[0;36mDebertaV2ForSequenceClassification.forward\u001b[0;34m(self, input_ids, attention_mask, token_type_ids, position_ids, inputs_embeds, labels, output_attentions, output_hidden_states, return_dict)\u001b[0m\n\u001b[1;32m 1289\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124mr\u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 1290\u001b[0m \u001b[38;5;124;03mlabels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):\u001b[39;00m\n\u001b[1;32m 1291\u001b[0m \u001b[38;5;124;03m Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,\u001b[39;00m\n\u001b[1;32m 1292\u001b[0m \u001b[38;5;124;03m config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If\u001b[39;00m\n\u001b[1;32m 1293\u001b[0m \u001b[38;5;124;03m `config.num_labels > 1` a classification loss is computed (Cross-Entropy).\u001b[39;00m\n\u001b[1;32m 1294\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 1295\u001b[0m return_dict \u001b[38;5;241m=\u001b[39m return_dict \u001b[38;5;28;01mif\u001b[39;00m return_dict \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;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconfig\u001b[38;5;241m.\u001b[39muse_return_dict\n\u001b[0;32m-> 1297\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[43mdeberta\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1298\u001b[0m \u001b[43m \u001b[49m\u001b[43minput_ids\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1299\u001b[0m \u001b[43m \u001b[49m\u001b[43mtoken_type_ids\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtoken_type_ids\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1300\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 1301\u001b[0m \u001b[43m \u001b[49m\u001b[43mposition_ids\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mposition_ids\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1302\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 1303\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 1304\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 1305\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 1306\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1308\u001b[0m encoder_layer \u001b[38;5;241m=\u001b[39m outputs[\u001b[38;5;241m0\u001b[39m]\n\u001b[1;32m 1309\u001b[0m pooled_output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpooler(encoder_layer)\n",
310
- "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",
311
- "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",
312
- "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:1063\u001b[0m, in \u001b[0;36mDebertaV2Model.forward\u001b[0;34m(self, input_ids, attention_mask, token_type_ids, position_ids, inputs_embeds, output_attentions, output_hidden_states, return_dict)\u001b[0m\n\u001b[1;32m 1053\u001b[0m token_type_ids \u001b[38;5;241m=\u001b[39m torch\u001b[38;5;241m.\u001b[39mzeros(input_shape, dtype\u001b[38;5;241m=\u001b[39mtorch\u001b[38;5;241m.\u001b[39mlong, device\u001b[38;5;241m=\u001b[39mdevice)\n\u001b[1;32m 1055\u001b[0m embedding_output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39membeddings(\n\u001b[1;32m 1056\u001b[0m input_ids\u001b[38;5;241m=\u001b[39minput_ids,\n\u001b[1;32m 1057\u001b[0m token_type_ids\u001b[38;5;241m=\u001b[39mtoken_type_ids,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1060\u001b[0m inputs_embeds\u001b[38;5;241m=\u001b[39minputs_embeds,\n\u001b[1;32m 1061\u001b[0m )\n\u001b[0;32m-> 1063\u001b[0m encoder_outputs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mencoder\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1064\u001b[0m \u001b[43m \u001b[49m\u001b[43membedding_output\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1065\u001b[0m \u001b[43m \u001b[49m\u001b[43mattention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1066\u001b[0m \u001b[43m \u001b[49m\u001b[43moutput_hidden_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 1067\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 1068\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 1069\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1070\u001b[0m encoded_layers \u001b[38;5;241m=\u001b[39m encoder_outputs[\u001b[38;5;241m1\u001b[39m]\n\u001b[1;32m 1072\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mz_steps \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m1\u001b[39m:\n",
313
- "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",
314
- "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",
315
- "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:507\u001b[0m, in \u001b[0;36mDebertaV2Encoder.forward\u001b[0;34m(self, hidden_states, attention_mask, output_hidden_states, output_attentions, query_states, relative_pos, return_dict)\u001b[0m\n\u001b[1;32m 497\u001b[0m output_states \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 498\u001b[0m layer_module\u001b[38;5;241m.\u001b[39m\u001b[38;5;21m__call__\u001b[39m,\n\u001b[1;32m 499\u001b[0m next_kv,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 504\u001b[0m output_attentions,\n\u001b[1;32m 505\u001b[0m )\n\u001b[1;32m 506\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 507\u001b[0m output_states \u001b[38;5;241m=\u001b[39m \u001b[43mlayer_module\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 508\u001b[0m \u001b[43m \u001b[49m\u001b[43mnext_kv\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 509\u001b[0m \u001b[43m \u001b[49m\u001b[43mattention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 510\u001b[0m \u001b[43m \u001b[49m\u001b[43mquery_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mquery_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 511\u001b[0m \u001b[43m \u001b[49m\u001b[43mrelative_pos\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrelative_pos\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 512\u001b[0m \u001b[43m \u001b[49m\u001b[43mrel_embeddings\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrel_embeddings\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 513\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 514\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 516\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m output_attentions:\n\u001b[1;32m 517\u001b[0m output_states, att_m \u001b[38;5;241m=\u001b[39m output_states\n",
316
- "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",
317
- "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",
318
- "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:366\u001b[0m, in \u001b[0;36mDebertaV2Layer.forward\u001b[0;34m(self, hidden_states, attention_mask, query_states, relative_pos, rel_embeddings, output_attentions)\u001b[0m\n\u001b[1;32m 364\u001b[0m attention_output, att_matrix \u001b[38;5;241m=\u001b[39m attention_output\n\u001b[1;32m 365\u001b[0m intermediate_output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mintermediate(attention_output)\n\u001b[0;32m--> 366\u001b[0m layer_output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43moutput\u001b[49m\u001b[43m(\u001b[49m\u001b[43mintermediate_output\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mattention_output\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 367\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m output_attentions:\n\u001b[1;32m 368\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m (layer_output, att_matrix)\n",
319
- "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",
320
- "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",
321
- "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:332\u001b[0m, in \u001b[0;36mDebertaV2Output.forward\u001b[0;34m(self, hidden_states, input_tensor)\u001b[0m\n\u001b[1;32m 331\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mforward\u001b[39m(\u001b[38;5;28mself\u001b[39m, hidden_states, input_tensor):\n\u001b[0;32m--> 332\u001b[0m hidden_states \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdense\u001b[49m\u001b[43m(\u001b[49m\u001b[43mhidden_states\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 333\u001b[0m hidden_states \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdropout(hidden_states)\n\u001b[1;32m 334\u001b[0m hidden_states \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mLayerNorm(hidden_states \u001b[38;5;241m+\u001b[39m input_tensor)\n",
322
- "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",
323
- "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",
324
- "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",
325
- "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
326
  ]
327
  }
328
  ],
329
  "source": [
330
  "result_list = []\n",
331
  "performance = pd.DataFrame(columns=['accuracy', 'true_ident', 'false_pred'])\n",
332
- " \n",
 
 
333
  "for i in range(len(trip_descriptions)):\n",
334
  " current_trip = trip_descriptions[i]\n",
335
  " current_type = trip_types[i]\n",
@@ -340,7 +244,11 @@
340
  " performance = pd.concat([performance, perf_measure(df)])\n",
341
  " print(performance)\n",
342
  " \n",
343
- " result_list.append(df)"
 
 
 
 
344
  ]
345
  },
346
  {
@@ -353,10 +261,22 @@
353
  },
354
  {
355
  "cell_type": "code",
356
- "execution_count": null,
357
  "id": "eb33fd31-94e6-40b5-9c36-a32effe77c01",
358
  "metadata": {},
359
- "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
360
  "source": [
361
  "# Extract \"same_value\" column from each DataFrame\n",
362
  "sv_columns = [df['same_value'] for df in result_list] # 'same' needs to be changed\n",
@@ -370,10 +290,27 @@
370
  },
371
  {
372
  "cell_type": "code",
373
- "execution_count": null,
374
  "id": "bf7546cb-79ce-49ad-8cee-54d02239220c",
375
  "metadata": {},
376
- "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
  "source": [
378
  "# Compute accuracy per superclass (row means of same_value matrix excluding the first column)\n",
379
  "row_means = sv_df.iloc[:, 1:].mean(axis=1)\n",
@@ -413,15 +350,14 @@
413
  "outputs": [],
414
  "source": [
415
  "# save results\n",
416
- "# Example data for one model\n",
417
- "model_name = 'model_MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli'\n",
418
  "# Structure to save\n",
419
  "model_result = {\n",
420
  " 'model': model_name,\n",
421
  " 'predictions': result_list,\n",
422
  " 'performance': performance,\n",
423
  " 'perf_summary': column_means,\n",
424
- " 'perf_superclass': df_row_means\n",
 
425
  "}\n",
426
  "\n",
427
  "# File path with folder\n",
@@ -432,6 +368,16 @@
432
  " pickle.dump(model_result, f)"
433
  ]
434
  },
 
 
 
 
 
 
 
 
 
 
435
  {
436
  "cell_type": "markdown",
437
  "id": "e1cbb54e-abe6-49b6-957e-0683196f3199",
@@ -442,14 +388,23 @@
442
  },
443
  {
444
  "cell_type": "code",
445
- "execution_count": 35,
446
  "id": "62ca82b0-6909-4e6c-9d2c-fed87971e5b6",
447
- "metadata": {},
 
 
448
  "outputs": [
449
  {
450
  "name": "stdout",
451
  "output_type": "stream",
452
  "text": [
 
 
 
 
 
 
 
453
  "Model: model_a_facebook-bart-large-mnli\n",
454
  "Performance Summary:\n",
455
  "accuracy 0.454545\n",
@@ -464,6 +419,19 @@
464
  "false_pred 0.551667\n",
465
  "dtype: float64\n",
466
  "----------------------------------------\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
467
  "Model: model_a_facebook-bart-large-mnli\n",
468
  "Performance Summary:\n",
469
  " superclass accuracy\n",
@@ -511,20 +479,57 @@
511
  " result = pickle.load(f)\n",
512
  " all_results[model_name] = result\n",
513
  "\n",
514
- "# Now you can compare performance across models\n",
515
  "for model, data in all_results.items():\n",
516
  " print(f\"Model: {model}\")\n",
517
  " print(f\"Performance Summary:\\n{data['perf_summary']}\")\n",
518
  " print(\"-\" * 40)\n",
519
  "\n",
520
  "\n",
521
- "# Now you can compare performance across models\n",
522
  "for model, data in all_results.items():\n",
523
  " print(f\"Model: {model}\")\n",
524
  " print(f\"Performance Summary:\\n{data['perf_superclass']}\")\n",
525
  " print(\"-\" * 40)"
526
  ]
527
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528
  {
529
  "cell_type": "markdown",
530
  "id": "17483df4-55c4-41cd-b8a9-61f7a5c7e8a3",
 
19
  "id": "3bbee2e4-55c8-4b06-9929-72026edf7932",
20
  "metadata": {},
21
  "source": [
22
+ "**Load prerequisites**"
23
  ]
24
  },
25
  {
26
  "cell_type": "code",
27
+ "execution_count": 57,
28
  "id": "f8c28d2d-8458-49fd-8ebf-5e729d6e861f",
29
  "metadata": {},
30
  "outputs": [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  {
32
  "name": "stderr",
33
  "output_type": "stream",
 
54
  "import matplotlib.pyplot as plt\n",
55
  "import pickle\n",
56
  "import os\n",
57
+ "import time\n",
58
  "\n",
59
  "# Load the model and create a pipeline for zero-shot classification (1min loading + classifying with 89 labels)\n",
60
+ "classifier = pipeline(\"zero-shot-classification\", model=\"cross-encoder/nli-deberta-v3-base\")\n",
61
+ "model_name = 'model_cross-encoder-nli-deberta-v3-base'\n",
62
  "# tried:\n",
63
+ "# cross-encoder/nli-deberta-v3-large gave error\n",
64
+ "# MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli\n",
65
  "# facebook/bart-large-mnli\n",
66
  "# sileod/deberta-v3-base-tasksource-nli\n",
67
  "\n",
 
88
  },
89
  {
90
  "cell_type": "code",
91
+ "execution_count": 58,
92
  "id": "3a762755-872d-43a6-b666-874d6133488c",
93
  "metadata": {},
94
  "outputs": [],
 
118
  },
119
  {
120
  "cell_type": "code",
121
+ "execution_count": 59,
122
  "id": "3b4f3193-3bdd-453c-8664-df84f955600c",
123
  "metadata": {},
124
  "outputs": [],
 
155
  },
156
  {
157
  "cell_type": "code",
158
+ "execution_count": 60,
159
  "id": "4dd01755-be8d-4904-8494-ac28aba2fee7",
160
  "metadata": {
161
  "scrolled": true
162
  },
163
  "outputs": [
 
 
 
 
 
 
 
164
  {
165
  "name": "stdout",
166
  "output_type": "stream",
167
  "text": [
168
+ "{'sequence': '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.', 'labels': ['micro-adventure / weekend trip', 'digital nomad trip', 'beach vacation', 'festival trip', 'city trip', 'cultural exploration', 'road trip (car/camper)', 'camping trip (wild camping)', 'long-distance hike / thru-hike', 'hut trek (winter)', 'ski tour / skitour', 'snowboard / splitboard trip', 'nature escape', 'yoga / wellness retreat', 'hut trek (summer)', 'camping trip (campground)'], 'scores': [0.9722680449485779, 0.007802918087691069, 0.0075571718625724316, 0.0022959215566515923, 0.0021305829286575317, 0.001222927705384791, 0.0009879637509584427, 0.000805296644102782, 0.0007946204277686775, 0.0007107199053280056, 0.0007009899127297103, 0.0006353880744427443, 0.0005838185315951705, 0.0005424902774393559, 0.0004807499353773892, 0.0004804217896889895]}\n",
169
+ "micro-adventure / weekend trip\n",
170
  "0\n",
171
+ "{'sequence': '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.', 'labels': ['going to the beach', 'sightseeing', 'relaxing', 'hiking', 'hut-to-hut hiking', 'stand-up paddleboarding (SUP)', 'photography', 'biking', 'running', 'ski touring', 'snowshoe hiking', 'yoga', 'kayaking / canoeing', 'horseback riding', 'rafting', 'paragliding', 'cross-country skiing', 'surfing', 'skiing', 'ice climbing', 'fishing', 'snorkeling', 'swimming', 'rock climbing', 'scuba diving'], 'scores': [0.4660525321960449, 0.007281942293047905, 0.003730606520548463, 0.0001860307966126129, 0.00014064949937164783, 0.00011034693307010457, 5.2949126256862655e-05, 3.828677654382773e-05, 3.396756437723525e-05, 1.5346524378401227e-05, 9.348185812996235e-06, 8.182429155567661e-06, 6.5973340497293975e-06, 6.271920938161202e-06, 5.544673058466287e-06, 5.299102667777333e-06, 4.855380211665761e-06, 4.506250661506783e-06, 3.949530764657538e-06, 3.730233856913401e-06, 3.297281637060223e-06, 3.0508665531669976e-06, 2.933618134193239e-06, 2.6379277642263332e-06, 2.2992651338427095e-06]}\n",
172
+ "[]\n",
173
  "1\n",
174
+ "{'sequence': '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.', 'labels': ['variable weather / spring / autumn', 'warm destination / summer', 'cold destination / winter', 'dry / desert-like', 'tropical / humid'], 'scores': [0.5934922695159912, 0.17430798709392548, 0.10943299531936646, 0.07068652659654617, 0.05208020657300949]}\n",
175
+ "variable weather / spring / autumn\n",
176
  "2\n",
177
+ "{'sequence': '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.', 'labels': ['minimalist', 'ultralight', 'luxury (including evening wear)', 'lightweight (but comfortable)'], 'scores': [0.6965053081512451, 0.11270010471343994, 0.10676420480012894, 0.08403033763170242]}\n",
178
  "minimalist\n",
179
  "3\n",
180
+ "{'sequence': '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.', 'labels': ['casual', 'formal (business trip)', 'conservative'], 'scores': [0.6362482309341431, 0.22082458436489105, 0.14292724430561066]}\n",
181
  "casual\n",
182
  "4\n",
183
+ "{'sequence': '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.', 'labels': ['indoor', 'sleeping in a tent', 'huts with half board', 'sleeping in a car'], 'scores': [0.435793399810791, 0.20242486894130707, 0.19281964004039764, 0.16896207630634308]}\n",
184
  "indoor\n",
185
  "5\n",
186
+ "{'sequence': '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.', 'labels': ['no own vehicle', 'own vehicle'], 'scores': [0.9987181425094604, 0.0012818538816645741]}\n",
187
  "no own vehicle\n",
188
+ "6\n",
189
+ "{'sequence': '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.', 'labels': ['self-supported (bring your own food/cooking)', 'no special conditions', 'off-grid / no electricity', 'rainy climate', 'child-friendly', 'snow and ice', 'pet-friendly', 'high alpine terrain', 'avalanche-prone terrain'], 'scores': [0.1984991431236267, 0.1695038080215454, 0.16221018135547638, 0.13200421631336212, 0.12101645022630692, 0.10550825297832489, 0.042406272143125534, 0.03797775134444237, 0.030873913317918777]}\n",
190
+ "self-supported (bring your own food/cooking)\n",
191
+ "7\n",
192
+ "{'sequence': '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.', 'labels': ['7+ days', '2 days', '1 day', '7 days', '5 days', '3 days', '6 days', '4 days'], 'scores': [0.4730822443962097, 0.1168912723660469, 0.10058756172657013, 0.0991850346326828, 0.05424537882208824, 0.053677864372730255, 0.051554784178733826, 0.050775907933712006]}\n",
193
+ "7+ days\n",
194
+ "8\n",
195
+ " superclass pred_class \\\n",
196
+ "0 activity_type micro-adventure / weekend trip \n",
197
+ "1 activities [] \n",
198
+ "2 climate_or_season variable weather / spring / autumn \n",
199
+ "3 style_or_comfort minimalist \n",
200
+ "4 dress_code casual \n",
201
+ "5 accommodation indoor \n",
202
+ "6 transportation no own vehicle \n",
203
+ "7 special_conditions self-supported (bring your own food/cooking) \n",
204
+ "8 trip_length_days 7+ days \n",
205
+ "\n",
206
+ " true_class \n",
207
+ "0 beach vacation \n",
208
+ "1 [swimming, going to the beach, relaxing, hiking] \n",
209
+ "2 warm destination / summer \n",
210
+ "3 lightweight (but comfortable) \n",
211
+ "4 casual \n",
212
+ "5 indoor \n",
213
+ "6 no own vehicle \n",
214
+ "7 no special conditions \n",
215
+ "8 7+ days \n"
216
  ]
217
  },
218
  {
219
+ "ename": "ZeroDivisionError",
220
+ "evalue": "division by zero",
221
  "output_type": "error",
222
  "traceback": [
223
  "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
224
+ "\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)",
225
+ "Cell \u001b[0;32mIn[60], line 13\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[38;5;28mprint\u001b[39m(df)\n\u001b[1;32m 12\u001b[0m \u001b[38;5;66;03m# accuracy, perc true classes identified and perc wrong pred classes\u001b[39;00m\n\u001b[0;32m---> 13\u001b[0m performance \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mconcat([performance, \u001b[43mperf_measure\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdf\u001b[49m\u001b[43m)\u001b[49m])\n\u001b[1;32m 14\u001b[0m \u001b[38;5;28mprint\u001b[39m(performance)\n\u001b[1;32m 16\u001b[0m result_list\u001b[38;5;241m.\u001b[39mappend(df)\n",
226
+ "Cell \u001b[0;32mIn[59], line 14\u001b[0m, in \u001b[0;36mperf_measure\u001b[0;34m(df)\u001b[0m\n\u001b[1;32m 12\u001b[0m correct_perc \u001b[38;5;241m=\u001b[39m num_correct\u001b[38;5;241m/\u001b[39m\u001b[38;5;28mlen\u001b[39m(true_class)\n\u001b[1;32m 13\u001b[0m num_pred \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlen\u001b[39m(pred_class)\n\u001b[0;32m---> 14\u001b[0m wrong_perc \u001b[38;5;241m=\u001b[39m \u001b[43m(\u001b[49m\u001b[43mnum_pred\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mnum_correct\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m/\u001b[39;49m\u001b[43mnum_pred\u001b[49m\n\u001b[1;32m 15\u001b[0m df_perf \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mDataFrame({\n\u001b[1;32m 16\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124maccuracy\u001b[39m\u001b[38;5;124m'\u001b[39m: [accuracy],\n\u001b[1;32m 17\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtrue_ident\u001b[39m\u001b[38;5;124m'\u001b[39m: [correct_perc],\n\u001b[1;32m 18\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mfalse_pred\u001b[39m\u001b[38;5;124m'\u001b[39m: [wrong_perc]\n\u001b[1;32m 19\u001b[0m })\n\u001b[1;32m 20\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m(df_perf)\n",
227
+ "\u001b[0;31mZeroDivisionError\u001b[0m: division by zero"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  ]
229
  }
230
  ],
231
  "source": [
232
  "result_list = []\n",
233
  "performance = pd.DataFrame(columns=['accuracy', 'true_ident', 'false_pred'])\n",
234
+ "\n",
235
+ "start_time = time.time()\n",
236
+ "\n",
237
  "for i in range(len(trip_descriptions)):\n",
238
  " current_trip = trip_descriptions[i]\n",
239
  " current_type = trip_types[i]\n",
 
244
  " performance = pd.concat([performance, perf_measure(df)])\n",
245
  " print(performance)\n",
246
  " \n",
247
+ " result_list.append(df)\n",
248
+ "\n",
249
+ "end_time = time.time()\n",
250
+ "\n",
251
+ "elapsed_time = end_time - start_time"
252
  ]
253
  },
254
  {
 
261
  },
262
  {
263
  "cell_type": "code",
264
+ "execution_count": 61,
265
  "id": "eb33fd31-94e6-40b5-9c36-a32effe77c01",
266
  "metadata": {},
267
+ "outputs": [
268
+ {
269
+ "ename": "IndexError",
270
+ "evalue": "list index out of range",
271
+ "output_type": "error",
272
+ "traceback": [
273
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
274
+ "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)",
275
+ "Cell \u001b[0;32mIn[61], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Extract \"same_value\" column from each DataFrame\u001b[39;00m\n\u001b[1;32m 2\u001b[0m sv_columns \u001b[38;5;241m=\u001b[39m [df[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124msame_value\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;28;01mfor\u001b[39;00m df \u001b[38;5;129;01min\u001b[39;00m result_list] \u001b[38;5;66;03m# 'same' needs to be changed\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m sv_columns\u001b[38;5;241m.\u001b[39minsert(\u001b[38;5;241m0\u001b[39m, \u001b[43mresult_list\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124msuperclass\u001b[39m\u001b[38;5;124m'\u001b[39m])\n\u001b[1;32m 5\u001b[0m \u001b[38;5;66;03m# Combine into a new DataFrame (columns side-by-side)\u001b[39;00m\n\u001b[1;32m 6\u001b[0m sv_df \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mconcat(sv_columns, axis\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m)\n",
276
+ "\u001b[0;31mIndexError\u001b[0m: list index out of range"
277
+ ]
278
+ }
279
+ ],
280
  "source": [
281
  "# Extract \"same_value\" column from each DataFrame\n",
282
  "sv_columns = [df['same_value'] for df in result_list] # 'same' needs to be changed\n",
 
290
  },
291
  {
292
  "cell_type": "code",
293
+ "execution_count": 62,
294
  "id": "bf7546cb-79ce-49ad-8cee-54d02239220c",
295
  "metadata": {},
296
+ "outputs": [
297
+ {
298
+ "name": "stdout",
299
+ "output_type": "stream",
300
+ "text": [
301
+ " superclass accuracy\n",
302
+ "0 activity_type 0.8\n",
303
+ "1 activities 0.0\n",
304
+ "2 climate_or_season 0.5\n",
305
+ "3 style_or_comfort 0.3\n",
306
+ "4 dress_code 0.8\n",
307
+ "5 accommodation 0.8\n",
308
+ "6 transportation 0.7\n",
309
+ "7 special_conditions 0.2\n",
310
+ "8 trip_length_days 0.6\n"
311
+ ]
312
+ }
313
+ ],
314
  "source": [
315
  "# Compute accuracy per superclass (row means of same_value matrix excluding the first column)\n",
316
  "row_means = sv_df.iloc[:, 1:].mean(axis=1)\n",
 
350
  "outputs": [],
351
  "source": [
352
  "# save results\n",
 
 
353
  "# Structure to save\n",
354
  "model_result = {\n",
355
  " 'model': model_name,\n",
356
  " 'predictions': result_list,\n",
357
  " 'performance': performance,\n",
358
  " 'perf_summary': column_means,\n",
359
+ " 'perf_superclass': df_row_means,\n",
360
+ " 'elapsed_time': elapsed_time\n",
361
  "}\n",
362
  "\n",
363
  "# File path with folder\n",
 
368
  " pickle.dump(model_result, f)"
369
  ]
370
  },
371
+ {
372
+ "cell_type": "code",
373
+ "execution_count": null,
374
+ "id": "f38d0924-30b6-43cd-9bfc-fe5b0dc80411",
375
+ "metadata": {},
376
+ "outputs": [],
377
+ "source": [
378
+ "print(elapsed_time/60)"
379
+ ]
380
+ },
381
  {
382
  "cell_type": "markdown",
383
  "id": "e1cbb54e-abe6-49b6-957e-0683196f3199",
 
388
  },
389
  {
390
  "cell_type": "code",
391
+ "execution_count": 54,
392
  "id": "62ca82b0-6909-4e6c-9d2c-fed87971e5b6",
393
+ "metadata": {
394
+ "scrolled": true
395
+ },
396
  "outputs": [
397
  {
398
  "name": "stdout",
399
  "output_type": "stream",
400
  "text": [
401
+ "Model: model_MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli\n",
402
+ "Performance Summary:\n",
403
+ "accuracy 0.522222\n",
404
+ "true_ident 0.841667\n",
405
+ "false_pred 0.572381\n",
406
+ "dtype: float64\n",
407
+ "----------------------------------------\n",
408
  "Model: model_a_facebook-bart-large-mnli\n",
409
  "Performance Summary:\n",
410
  "accuracy 0.454545\n",
 
419
  "false_pred 0.551667\n",
420
  "dtype: float64\n",
421
  "----------------------------------------\n",
422
+ "Model: model_MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli\n",
423
+ "Performance Summary:\n",
424
+ " superclass accuracy\n",
425
+ "0 activity_type 0.8\n",
426
+ "1 activities 0.0\n",
427
+ "2 climate_or_season 0.5\n",
428
+ "3 style_or_comfort 0.3\n",
429
+ "4 dress_code 0.8\n",
430
+ "5 accommodation 0.8\n",
431
+ "6 transportation 0.7\n",
432
+ "7 special_conditions 0.2\n",
433
+ "8 trip_length_days 0.6\n",
434
+ "----------------------------------------\n",
435
  "Model: model_a_facebook-bart-large-mnli\n",
436
  "Performance Summary:\n",
437
  " superclass accuracy\n",
 
479
  " result = pickle.load(f)\n",
480
  " all_results[model_name] = result\n",
481
  "\n",
482
+ "# Compare performance across models\n",
483
  "for model, data in all_results.items():\n",
484
  " print(f\"Model: {model}\")\n",
485
  " print(f\"Performance Summary:\\n{data['perf_summary']}\")\n",
486
  " print(\"-\" * 40)\n",
487
  "\n",
488
  "\n",
489
+ "# Compare performance across models\n",
490
  "for model, data in all_results.items():\n",
491
  " print(f\"Model: {model}\")\n",
492
  " print(f\"Performance Summary:\\n{data['perf_superclass']}\")\n",
493
  " print(\"-\" * 40)"
494
  ]
495
  },
496
+ {
497
+ "cell_type": "code",
498
+ "execution_count": 69,
499
+ "id": "57fd150d-1cda-4be5-806b-ef380469243a",
500
+ "metadata": {},
501
+ "outputs": [
502
+ {
503
+ "name": "stdout",
504
+ "output_type": "stream",
505
+ "text": [
506
+ "Model: model_MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli\n",
507
+ "Time in minutes for 10 trips:\n",
508
+ "83.45150986512502\n",
509
+ "----------------------------------------\n",
510
+ "Model: model_a_facebook-bart-large-mnli\n"
511
+ ]
512
+ },
513
+ {
514
+ "ename": "KeyError",
515
+ "evalue": "'elapsed_time'",
516
+ "output_type": "error",
517
+ "traceback": [
518
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
519
+ "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
520
+ "Cell \u001b[0;32mIn[69], line 4\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m model, data \u001b[38;5;129;01min\u001b[39;00m all_results\u001b[38;5;241m.\u001b[39mitems():\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mModel: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmodel\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m----> 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTime in minutes for 10 trips:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00mdata[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124melapsed_time\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m/\u001b[39m\u001b[38;5;241m60\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m-\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m*\u001b[39m \u001b[38;5;241m40\u001b[39m)\n",
521
+ "\u001b[0;31mKeyError\u001b[0m: 'elapsed_time'"
522
+ ]
523
+ }
524
+ ],
525
+ "source": [
526
+ "# Compare across models\n",
527
+ "for model, data in all_results.items():\n",
528
+ " print(f\"Model: {model}\")\n",
529
+ " print(f\"Time in minutes for 10 trips:\\n{data['elapsed_time']/60}\")\n",
530
+ " print(\"-\" * 40)"
531
+ ]
532
+ },
533
  {
534
  "cell_type": "markdown",
535
  "id": "17483df4-55c4-41cd-b8a9-61f7a5c7e8a3",
space/space/space/space/space/gradio_tryout.ipynb CHANGED
@@ -19,12 +19,12 @@
19
  "id": "3bbee2e4-55c8-4b06-9929-72026edf7932",
20
  "metadata": {},
21
  "source": [
22
- "**Load and try the model**"
23
  ]
24
  },
25
  {
26
  "cell_type": "code",
27
- "execution_count": 40,
28
  "id": "f8c28d2d-8458-49fd-8ebf-5e729d6e861f",
29
  "metadata": {},
30
  "outputs": [
@@ -57,8 +57,11 @@
57
  "import time\n",
58
  "\n",
59
  "# Load the model and create a pipeline for zero-shot classification (1min loading + classifying with 89 labels)\n",
60
- "classifier = pipeline(\"zero-shot-classification\", model=\"MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli\")\n",
 
61
  "# tried:\n",
 
 
62
  "# facebook/bart-large-mnli\n",
63
  "# sileod/deberta-v3-base-tasksource-nli\n",
64
  "\n",
@@ -85,7 +88,7 @@
85
  },
86
  {
87
  "cell_type": "code",
88
- "execution_count": 41,
89
  "id": "3a762755-872d-43a6-b666-874d6133488c",
90
  "metadata": {},
91
  "outputs": [],
@@ -115,7 +118,7 @@
115
  },
116
  {
117
  "cell_type": "code",
118
- "execution_count": 42,
119
  "id": "3b4f3193-3bdd-453c-8664-df84f955600c",
120
  "metadata": {},
121
  "outputs": [],
@@ -152,60 +155,53 @@
152
  },
153
  {
154
  "cell_type": "code",
155
- "execution_count": 43,
156
  "id": "4dd01755-be8d-4904-8494-ac28aba2fee7",
157
  "metadata": {
158
  "scrolled": true
159
  },
160
  "outputs": [
161
- {
162
- "name": "stderr",
163
- "output_type": "stream",
164
- "text": [
165
- "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"
166
- ]
167
- },
168
  {
169
  "name": "stdout",
170
  "output_type": "stream",
171
  "text": [
172
- "{'sequence': '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.', 'labels': ['beach vacation', 'micro-adventure / weekend trip', 'cultural exploration', 'nature escape', 'digital nomad trip', 'camping trip (campground)', 'camping trip (wild camping)', 'long-distance hike / thru-hike', 'ski tour / skitour', 'hut trek (summer)', 'city trip', 'hut trek (winter)', 'road trip (car/camper)', 'festival trip', 'yoga / wellness retreat', 'snowboard / splitboard trip'], 'scores': [0.37198853492736816, 0.31496119499206543, 0.10890532284975052, 0.09102731198072433, 0.0735681876540184, 0.012933704070746899, 0.009422042407095432, 0.0051276967860758305, 0.004056071396917105, 0.0017408831045031548, 0.001503779087215662, 0.0014244643971323967, 0.0013752576196566224, 0.0009292717440985143, 0.0006881792796775699, 0.0003480584127828479]}\n",
173
- "beach vacation\n",
174
  "0\n",
175
- "{'sequence': '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.', 'labels': ['relaxing', 'hiking', 'going to the beach', 'photography', 'sightseeing', 'hut-to-hut hiking', 'snorkeling', 'snowshoe hiking', 'yoga', 'stand-up paddleboarding (SUP)', 'kayaking / canoeing', 'horseback riding', 'swimming', 'paragliding', 'rafting', 'biking', 'rock climbing', 'surfing', 'running', 'ice climbing', 'cross-country skiing', 'fishing', 'ski touring', 'skiing', 'scuba diving'], 'scores': [0.9943736791610718, 0.9631249308586121, 0.9454535841941833, 0.7538902759552002, 0.4525446593761444, 0.1696157604455948, 0.05957728251814842, 0.04234873503446579, 0.01991761103272438, 0.016971556469798088, 0.006959819234907627, 0.00411367928609252, 0.0030609173700213432, 0.00186573073733598, 0.0017515394138172269, 0.00142807571683079, 0.0005748369731009007, 0.00037779140984639525, 0.0003097739245276898, 0.00030914091621525586, 0.0002725012309383601, 0.00027050732751376927, 0.00024376016517635435, 0.00017392759036738425, 0.00014787293912377208]}\n",
176
- "['relaxing', 'hiking', 'going to the beach', 'photography']\n",
177
  "1\n",
178
- "{'sequence': '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.', 'labels': ['tropical / humid', 'warm destination / summer', 'variable weather / spring / autumn', 'cold destination / winter', 'dry / desert-like'], 'scores': [0.4895477890968323, 0.25917261838912964, 0.24829530715942383, 0.0017174285603687167, 0.0012668712297454476]}\n",
179
- "tropical / humid\n",
180
  "2\n",
181
- "{'sequence': '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.', 'labels': ['minimalist', 'luxury (including evening wear)', 'lightweight (but comfortable)', 'ultralight'], 'scores': [0.7574900984764099, 0.09964746236801147, 0.07804173231124878, 0.06482075154781342]}\n",
182
  "minimalist\n",
183
  "3\n",
184
- "{'sequence': '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.', 'labels': ['casual', 'conservative', 'formal (business trip)'], 'scores': [0.8163393139839172, 0.11898067593574524, 0.06467998772859573]}\n",
185
  "casual\n",
186
  "4\n",
187
- "{'sequence': '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.', 'labels': ['indoor', 'huts with half board', 'sleeping in a car', 'sleeping in a tent'], 'scores': [0.6389047503471375, 0.18624886870384216, 0.13902997970581055, 0.03581654652953148]}\n",
188
  "indoor\n",
189
  "5\n",
190
- "{'sequence': '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.', 'labels': ['no own vehicle', 'own vehicle'], 'scores': [0.9990958571434021, 0.0009041387238539755]}\n",
191
  "no own vehicle\n",
192
  "6\n",
193
- "{'sequence': '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.', 'labels': ['off-grid / no electricity', 'self-supported (bring your own food/cooking)', 'child-friendly', 'no special conditions', 'pet-friendly', 'rainy climate', 'avalanche-prone terrain', 'high alpine terrain', 'snow and ice'], 'scores': [0.7414510250091553, 0.07683143764734268, 0.055722303688526154, 0.054133761674165726, 0.04852374270558357, 0.006977608893066645, 0.005693929269909859, 0.005599685944616795, 0.005066512618213892]}\n",
194
- "off-grid / no electricity\n",
195
  "7\n",
196
- "{'sequence': '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.', 'labels': ['7+ days', '2 days', '7 days', '3 days', '4 days', '6 days', '5 days', '1 day'], 'scores': [0.29225289821624756, 0.20232954621315002, 0.1837582290172577, 0.13940994441509247, 0.06562349200248718, 0.04916509613394737, 0.040249694138765335, 0.0272111464291811]}\n",
197
  "7+ days\n",
198
  "8\n",
199
- " superclass pred_class \\\n",
200
- "0 activity_type beach vacation \n",
201
- "1 activities [relaxing, hiking, going to the beach, photogr... \n",
202
- "2 climate_or_season tropical / humid \n",
203
- "3 style_or_comfort minimalist \n",
204
- "4 dress_code casual \n",
205
- "5 accommodation indoor \n",
206
- "6 transportation no own vehicle \n",
207
- "7 special_conditions off-grid / no electricity \n",
208
- "8 trip_length_days 7+ days \n",
209
  "\n",
210
  " true_class \n",
211
  "0 beach vacation \n",
@@ -216,51 +212,19 @@
216
  "5 indoor \n",
217
  "6 no own vehicle \n",
218
  "7 no special conditions \n",
219
- "8 7+ days \n",
220
- " accuracy true_ident false_pred\n",
221
- "0 0.555556 0.75 0.25\n",
222
- "{'sequence': '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.', 'labels': ['city trip', 'cultural exploration', 'micro-adventure / weekend trip', 'ski tour / skitour', 'festival trip', 'digital nomad trip', 'hut trek (winter)', 'camping trip (campground)', 'long-distance hike / thru-hike', 'hut trek (summer)', 'nature escape', 'camping trip (wild camping)', 'yoga / wellness retreat', 'road trip (car/camper)', 'beach vacation', 'snowboard / splitboard trip'], 'scores': [0.517789363861084, 0.297355592250824, 0.1621870994567871, 0.006185388192534447, 0.005294559057801962, 0.002764208009466529, 0.001503965351730585, 0.0014866390265524387, 0.0012240204960107803, 0.0012071850942447782, 0.000757778063416481, 0.0006650012801401317, 0.0005547589971683919, 0.00043604226084426045, 0.00031738984398543835, 0.0002710542466957122]}\n",
223
- "city trip\n",
224
- "0\n"
225
  ]
226
  },
227
  {
228
- "ename": "KeyboardInterrupt",
229
- "evalue": "",
230
  "output_type": "error",
231
  "traceback": [
232
  "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
233
- "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
234
- "Cell \u001b[0;32mIn[43], line 7\u001b[0m\n\u001b[1;32m 5\u001b[0m current_trip \u001b[38;5;241m=\u001b[39m trip_descriptions[i]\n\u001b[1;32m 6\u001b[0m current_type \u001b[38;5;241m=\u001b[39m trip_types[i]\n\u001b[0;32m----> 7\u001b[0m df \u001b[38;5;241m=\u001b[39m \u001b[43mpred_trip\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 8\u001b[0m \u001b[38;5;28mprint\u001b[39m(df)\n\u001b[1;32m 10\u001b[0m \u001b[38;5;66;03m# accuracy, perc true classes identified and perc wrong pred classes\u001b[39;00m\n",
235
- "Cell \u001b[0;32mIn[41], line 10\u001b[0m, in \u001b[0;36mpred_trip\u001b[0;34m(trip_descr, trip_type, cut_off)\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i, key \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(keys_list):\n\u001b[1;32m 9\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m key \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mactivities\u001b[39m\u001b[38;5;124m'\u001b[39m:\n\u001b[0;32m---> 10\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\u001b[43m \u001b[49m\u001b[43mmulti_label\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 11\u001b[0m indices \u001b[38;5;241m=\u001b[39m [i \u001b[38;5;28;01mfor\u001b[39;00m i, score \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(result[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mscores\u001b[39m\u001b[38;5;124m'\u001b[39m]) \u001b[38;5;28;01mif\u001b[39;00m score \u001b[38;5;241m>\u001b[39m cut_off]\n\u001b[1;32m 12\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",
236
- "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",
237
- "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",
238
- "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",
239
- "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",
240
- "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",
241
- "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",
242
- "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",
243
- "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",
244
- "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:1297\u001b[0m, in \u001b[0;36mDebertaV2ForSequenceClassification.forward\u001b[0;34m(self, input_ids, attention_mask, token_type_ids, position_ids, inputs_embeds, labels, output_attentions, output_hidden_states, return_dict)\u001b[0m\n\u001b[1;32m 1289\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124mr\u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 1290\u001b[0m \u001b[38;5;124;03mlabels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):\u001b[39;00m\n\u001b[1;32m 1291\u001b[0m \u001b[38;5;124;03m Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,\u001b[39;00m\n\u001b[1;32m 1292\u001b[0m \u001b[38;5;124;03m config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If\u001b[39;00m\n\u001b[1;32m 1293\u001b[0m \u001b[38;5;124;03m `config.num_labels > 1` a classification loss is computed (Cross-Entropy).\u001b[39;00m\n\u001b[1;32m 1294\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 1295\u001b[0m return_dict \u001b[38;5;241m=\u001b[39m return_dict \u001b[38;5;28;01mif\u001b[39;00m return_dict \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;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconfig\u001b[38;5;241m.\u001b[39muse_return_dict\n\u001b[0;32m-> 1297\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[43mdeberta\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1298\u001b[0m \u001b[43m \u001b[49m\u001b[43minput_ids\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1299\u001b[0m \u001b[43m \u001b[49m\u001b[43mtoken_type_ids\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtoken_type_ids\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1300\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 1301\u001b[0m \u001b[43m \u001b[49m\u001b[43mposition_ids\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mposition_ids\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1302\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 1303\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 1304\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 1305\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 1306\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1308\u001b[0m encoder_layer \u001b[38;5;241m=\u001b[39m outputs[\u001b[38;5;241m0\u001b[39m]\n\u001b[1;32m 1309\u001b[0m pooled_output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpooler(encoder_layer)\n",
245
- "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",
246
- "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",
247
- "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:1063\u001b[0m, in \u001b[0;36mDebertaV2Model.forward\u001b[0;34m(self, input_ids, attention_mask, token_type_ids, position_ids, inputs_embeds, output_attentions, output_hidden_states, return_dict)\u001b[0m\n\u001b[1;32m 1053\u001b[0m token_type_ids \u001b[38;5;241m=\u001b[39m torch\u001b[38;5;241m.\u001b[39mzeros(input_shape, dtype\u001b[38;5;241m=\u001b[39mtorch\u001b[38;5;241m.\u001b[39mlong, device\u001b[38;5;241m=\u001b[39mdevice)\n\u001b[1;32m 1055\u001b[0m embedding_output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39membeddings(\n\u001b[1;32m 1056\u001b[0m input_ids\u001b[38;5;241m=\u001b[39minput_ids,\n\u001b[1;32m 1057\u001b[0m token_type_ids\u001b[38;5;241m=\u001b[39mtoken_type_ids,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1060\u001b[0m inputs_embeds\u001b[38;5;241m=\u001b[39minputs_embeds,\n\u001b[1;32m 1061\u001b[0m )\n\u001b[0;32m-> 1063\u001b[0m encoder_outputs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mencoder\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1064\u001b[0m \u001b[43m \u001b[49m\u001b[43membedding_output\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1065\u001b[0m \u001b[43m \u001b[49m\u001b[43mattention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1066\u001b[0m \u001b[43m \u001b[49m\u001b[43moutput_hidden_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 1067\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 1068\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 1069\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1070\u001b[0m encoded_layers \u001b[38;5;241m=\u001b[39m encoder_outputs[\u001b[38;5;241m1\u001b[39m]\n\u001b[1;32m 1072\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mz_steps \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m1\u001b[39m:\n",
248
- "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",
249
- "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",
250
- "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:507\u001b[0m, in \u001b[0;36mDebertaV2Encoder.forward\u001b[0;34m(self, hidden_states, attention_mask, output_hidden_states, output_attentions, query_states, relative_pos, return_dict)\u001b[0m\n\u001b[1;32m 497\u001b[0m output_states \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 498\u001b[0m layer_module\u001b[38;5;241m.\u001b[39m\u001b[38;5;21m__call__\u001b[39m,\n\u001b[1;32m 499\u001b[0m next_kv,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 504\u001b[0m output_attentions,\n\u001b[1;32m 505\u001b[0m )\n\u001b[1;32m 506\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 507\u001b[0m output_states \u001b[38;5;241m=\u001b[39m \u001b[43mlayer_module\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 508\u001b[0m \u001b[43m \u001b[49m\u001b[43mnext_kv\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 509\u001b[0m \u001b[43m \u001b[49m\u001b[43mattention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 510\u001b[0m \u001b[43m \u001b[49m\u001b[43mquery_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mquery_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 511\u001b[0m \u001b[43m \u001b[49m\u001b[43mrelative_pos\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrelative_pos\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 512\u001b[0m \u001b[43m \u001b[49m\u001b[43mrel_embeddings\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrel_embeddings\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 513\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 514\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 516\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m output_attentions:\n\u001b[1;32m 517\u001b[0m output_states, att_m \u001b[38;5;241m=\u001b[39m output_states\n",
251
- "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",
252
- "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",
253
- "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:355\u001b[0m, in \u001b[0;36mDebertaV2Layer.forward\u001b[0;34m(self, hidden_states, attention_mask, query_states, relative_pos, rel_embeddings, output_attentions)\u001b[0m\n\u001b[1;32m 346\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mforward\u001b[39m(\n\u001b[1;32m 347\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 348\u001b[0m hidden_states,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 353\u001b[0m output_attentions\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[1;32m 354\u001b[0m ):\n\u001b[0;32m--> 355\u001b[0m attention_output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mattention\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 356\u001b[0m \u001b[43m \u001b[49m\u001b[43mhidden_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 357\u001b[0m \u001b[43m \u001b[49m\u001b[43mattention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 358\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 359\u001b[0m \u001b[43m \u001b[49m\u001b[43mquery_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mquery_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 360\u001b[0m \u001b[43m \u001b[49m\u001b[43mrelative_pos\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrelative_pos\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 361\u001b[0m \u001b[43m \u001b[49m\u001b[43mrel_embeddings\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrel_embeddings\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 362\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 363\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m output_attentions:\n\u001b[1;32m 364\u001b[0m attention_output, att_matrix \u001b[38;5;241m=\u001b[39m attention_output\n",
254
- "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",
255
- "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",
256
- "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:286\u001b[0m, in \u001b[0;36mDebertaV2Attention.forward\u001b[0;34m(self, hidden_states, attention_mask, output_attentions, query_states, relative_pos, rel_embeddings)\u001b[0m\n\u001b[1;32m 277\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mforward\u001b[39m(\n\u001b[1;32m 278\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 279\u001b[0m hidden_states,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 284\u001b[0m rel_embeddings\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[1;32m 285\u001b[0m ):\n\u001b[0;32m--> 286\u001b[0m self_output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mself\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 287\u001b[0m \u001b[43m \u001b[49m\u001b[43mhidden_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 288\u001b[0m \u001b[43m \u001b[49m\u001b[43mattention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 289\u001b[0m \u001b[43m \u001b[49m\u001b[43moutput_attentions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 290\u001b[0m \u001b[43m \u001b[49m\u001b[43mquery_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mquery_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 291\u001b[0m \u001b[43m \u001b[49m\u001b[43mrelative_pos\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrelative_pos\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 292\u001b[0m \u001b[43m \u001b[49m\u001b[43mrel_embeddings\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrel_embeddings\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 293\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 294\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m output_attentions:\n\u001b[1;32m 295\u001b[0m self_output, att_matrix \u001b[38;5;241m=\u001b[39m self_output\n",
257
- "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",
258
- "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",
259
- "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:700\u001b[0m, in \u001b[0;36mDisentangledSelfAttention.forward\u001b[0;34m(self, hidden_states, attention_mask, output_attentions, query_states, relative_pos, rel_embeddings)\u001b[0m\n\u001b[1;32m 698\u001b[0m query_states \u001b[38;5;241m=\u001b[39m hidden_states\n\u001b[1;32m 699\u001b[0m query_layer \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtranspose_for_scores(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mquery_proj(query_states), \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnum_attention_heads)\n\u001b[0;32m--> 700\u001b[0m key_layer \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtranspose_for_scores(\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mkey_proj\u001b[49m\u001b[43m(\u001b[49m\u001b[43mhidden_states\u001b[49m\u001b[43m)\u001b[49m, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnum_attention_heads)\n\u001b[1;32m 701\u001b[0m value_layer \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtranspose_for_scores(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mvalue_proj(hidden_states), \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnum_attention_heads)\n\u001b[1;32m 703\u001b[0m rel_att \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n",
260
- "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",
261
- "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",
262
- "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",
263
- "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
264
  ]
265
  }
266
  ],
@@ -269,6 +233,7 @@
269
  "performance = pd.DataFrame(columns=['accuracy', 'true_ident', 'false_pred'])\n",
270
  "\n",
271
  "start_time = time.time()\n",
 
272
  "for i in range(len(trip_descriptions)):\n",
273
  " current_trip = trip_descriptions[i]\n",
274
  " current_type = trip_types[i]\n",
@@ -279,7 +244,11 @@
279
  " performance = pd.concat([performance, perf_measure(df)])\n",
280
  " print(performance)\n",
281
  " \n",
282
- " result_list.append(df)"
 
 
 
 
283
  ]
284
  },
285
  {
@@ -292,10 +261,22 @@
292
  },
293
  {
294
  "cell_type": "code",
295
- "execution_count": null,
296
  "id": "eb33fd31-94e6-40b5-9c36-a32effe77c01",
297
  "metadata": {},
298
- "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
299
  "source": [
300
  "# Extract \"same_value\" column from each DataFrame\n",
301
  "sv_columns = [df['same_value'] for df in result_list] # 'same' needs to be changed\n",
@@ -309,10 +290,27 @@
309
  },
310
  {
311
  "cell_type": "code",
312
- "execution_count": null,
313
  "id": "bf7546cb-79ce-49ad-8cee-54d02239220c",
314
  "metadata": {},
315
- "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  "source": [
317
  "# Compute accuracy per superclass (row means of same_value matrix excluding the first column)\n",
318
  "row_means = sv_df.iloc[:, 1:].mean(axis=1)\n",
@@ -352,15 +350,14 @@
352
  "outputs": [],
353
  "source": [
354
  "# save results\n",
355
- "# Example data for one model\n",
356
- "model_name = 'model_MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli'\n",
357
  "# Structure to save\n",
358
  "model_result = {\n",
359
  " 'model': model_name,\n",
360
  " 'predictions': result_list,\n",
361
  " 'performance': performance,\n",
362
  " 'perf_summary': column_means,\n",
363
- " 'perf_superclass': df_row_means\n",
 
364
  "}\n",
365
  "\n",
366
  "# File path with folder\n",
@@ -371,6 +368,16 @@
371
  " pickle.dump(model_result, f)"
372
  ]
373
  },
 
 
 
 
 
 
 
 
 
 
374
  {
375
  "cell_type": "markdown",
376
  "id": "e1cbb54e-abe6-49b6-957e-0683196f3199",
@@ -381,14 +388,23 @@
381
  },
382
  {
383
  "cell_type": "code",
384
- "execution_count": 35,
385
  "id": "62ca82b0-6909-4e6c-9d2c-fed87971e5b6",
386
- "metadata": {},
 
 
387
  "outputs": [
388
  {
389
  "name": "stdout",
390
  "output_type": "stream",
391
  "text": [
 
 
 
 
 
 
 
392
  "Model: model_a_facebook-bart-large-mnli\n",
393
  "Performance Summary:\n",
394
  "accuracy 0.454545\n",
@@ -403,6 +419,19 @@
403
  "false_pred 0.551667\n",
404
  "dtype: float64\n",
405
  "----------------------------------------\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
406
  "Model: model_a_facebook-bart-large-mnli\n",
407
  "Performance Summary:\n",
408
  " superclass accuracy\n",
@@ -450,20 +479,57 @@
450
  " result = pickle.load(f)\n",
451
  " all_results[model_name] = result\n",
452
  "\n",
453
- "# Now you can compare performance across models\n",
454
  "for model, data in all_results.items():\n",
455
  " print(f\"Model: {model}\")\n",
456
  " print(f\"Performance Summary:\\n{data['perf_summary']}\")\n",
457
  " print(\"-\" * 40)\n",
458
  "\n",
459
  "\n",
460
- "# Now you can compare performance across models\n",
461
  "for model, data in all_results.items():\n",
462
  " print(f\"Model: {model}\")\n",
463
  " print(f\"Performance Summary:\\n{data['perf_superclass']}\")\n",
464
  " print(\"-\" * 40)"
465
  ]
466
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
467
  {
468
  "cell_type": "markdown",
469
  "id": "17483df4-55c4-41cd-b8a9-61f7a5c7e8a3",
 
19
  "id": "3bbee2e4-55c8-4b06-9929-72026edf7932",
20
  "metadata": {},
21
  "source": [
22
+ "**Load prerequisites**"
23
  ]
24
  },
25
  {
26
  "cell_type": "code",
27
+ "execution_count": 57,
28
  "id": "f8c28d2d-8458-49fd-8ebf-5e729d6e861f",
29
  "metadata": {},
30
  "outputs": [
 
57
  "import time\n",
58
  "\n",
59
  "# Load the model and create a pipeline for zero-shot classification (1min loading + classifying with 89 labels)\n",
60
+ "classifier = pipeline(\"zero-shot-classification\", model=\"cross-encoder/nli-deberta-v3-base\")\n",
61
+ "model_name = 'model_cross-encoder-nli-deberta-v3-base'\n",
62
  "# tried:\n",
63
+ "# cross-encoder/nli-deberta-v3-large gave error\n",
64
+ "# MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli\n",
65
  "# facebook/bart-large-mnli\n",
66
  "# sileod/deberta-v3-base-tasksource-nli\n",
67
  "\n",
 
88
  },
89
  {
90
  "cell_type": "code",
91
+ "execution_count": 58,
92
  "id": "3a762755-872d-43a6-b666-874d6133488c",
93
  "metadata": {},
94
  "outputs": [],
 
118
  },
119
  {
120
  "cell_type": "code",
121
+ "execution_count": 59,
122
  "id": "3b4f3193-3bdd-453c-8664-df84f955600c",
123
  "metadata": {},
124
  "outputs": [],
 
155
  },
156
  {
157
  "cell_type": "code",
158
+ "execution_count": 60,
159
  "id": "4dd01755-be8d-4904-8494-ac28aba2fee7",
160
  "metadata": {
161
  "scrolled": true
162
  },
163
  "outputs": [
 
 
 
 
 
 
 
164
  {
165
  "name": "stdout",
166
  "output_type": "stream",
167
  "text": [
168
+ "{'sequence': '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.', 'labels': ['micro-adventure / weekend trip', 'digital nomad trip', 'beach vacation', 'festival trip', 'city trip', 'cultural exploration', 'road trip (car/camper)', 'camping trip (wild camping)', 'long-distance hike / thru-hike', 'hut trek (winter)', 'ski tour / skitour', 'snowboard / splitboard trip', 'nature escape', 'yoga / wellness retreat', 'hut trek (summer)', 'camping trip (campground)'], 'scores': [0.9722680449485779, 0.007802918087691069, 0.0075571718625724316, 0.0022959215566515923, 0.0021305829286575317, 0.001222927705384791, 0.0009879637509584427, 0.000805296644102782, 0.0007946204277686775, 0.0007107199053280056, 0.0007009899127297103, 0.0006353880744427443, 0.0005838185315951705, 0.0005424902774393559, 0.0004807499353773892, 0.0004804217896889895]}\n",
169
+ "micro-adventure / weekend trip\n",
170
  "0\n",
171
+ "{'sequence': '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.', 'labels': ['going to the beach', 'sightseeing', 'relaxing', 'hiking', 'hut-to-hut hiking', 'stand-up paddleboarding (SUP)', 'photography', 'biking', 'running', 'ski touring', 'snowshoe hiking', 'yoga', 'kayaking / canoeing', 'horseback riding', 'rafting', 'paragliding', 'cross-country skiing', 'surfing', 'skiing', 'ice climbing', 'fishing', 'snorkeling', 'swimming', 'rock climbing', 'scuba diving'], 'scores': [0.4660525321960449, 0.007281942293047905, 0.003730606520548463, 0.0001860307966126129, 0.00014064949937164783, 0.00011034693307010457, 5.2949126256862655e-05, 3.828677654382773e-05, 3.396756437723525e-05, 1.5346524378401227e-05, 9.348185812996235e-06, 8.182429155567661e-06, 6.5973340497293975e-06, 6.271920938161202e-06, 5.544673058466287e-06, 5.299102667777333e-06, 4.855380211665761e-06, 4.506250661506783e-06, 3.949530764657538e-06, 3.730233856913401e-06, 3.297281637060223e-06, 3.0508665531669976e-06, 2.933618134193239e-06, 2.6379277642263332e-06, 2.2992651338427095e-06]}\n",
172
+ "[]\n",
173
  "1\n",
174
+ "{'sequence': '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.', 'labels': ['variable weather / spring / autumn', 'warm destination / summer', 'cold destination / winter', 'dry / desert-like', 'tropical / humid'], 'scores': [0.5934922695159912, 0.17430798709392548, 0.10943299531936646, 0.07068652659654617, 0.05208020657300949]}\n",
175
+ "variable weather / spring / autumn\n",
176
  "2\n",
177
+ "{'sequence': '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.', 'labels': ['minimalist', 'ultralight', 'luxury (including evening wear)', 'lightweight (but comfortable)'], 'scores': [0.6965053081512451, 0.11270010471343994, 0.10676420480012894, 0.08403033763170242]}\n",
178
  "minimalist\n",
179
  "3\n",
180
+ "{'sequence': '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.', 'labels': ['casual', 'formal (business trip)', 'conservative'], 'scores': [0.6362482309341431, 0.22082458436489105, 0.14292724430561066]}\n",
181
  "casual\n",
182
  "4\n",
183
+ "{'sequence': '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.', 'labels': ['indoor', 'sleeping in a tent', 'huts with half board', 'sleeping in a car'], 'scores': [0.435793399810791, 0.20242486894130707, 0.19281964004039764, 0.16896207630634308]}\n",
184
  "indoor\n",
185
  "5\n",
186
+ "{'sequence': '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.', 'labels': ['no own vehicle', 'own vehicle'], 'scores': [0.9987181425094604, 0.0012818538816645741]}\n",
187
  "no own vehicle\n",
188
  "6\n",
189
+ "{'sequence': '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.', 'labels': ['self-supported (bring your own food/cooking)', 'no special conditions', 'off-grid / no electricity', 'rainy climate', 'child-friendly', 'snow and ice', 'pet-friendly', 'high alpine terrain', 'avalanche-prone terrain'], 'scores': [0.1984991431236267, 0.1695038080215454, 0.16221018135547638, 0.13200421631336212, 0.12101645022630692, 0.10550825297832489, 0.042406272143125534, 0.03797775134444237, 0.030873913317918777]}\n",
190
+ "self-supported (bring your own food/cooking)\n",
191
  "7\n",
192
+ "{'sequence': '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.', 'labels': ['7+ days', '2 days', '1 day', '7 days', '5 days', '3 days', '6 days', '4 days'], 'scores': [0.4730822443962097, 0.1168912723660469, 0.10058756172657013, 0.0991850346326828, 0.05424537882208824, 0.053677864372730255, 0.051554784178733826, 0.050775907933712006]}\n",
193
  "7+ days\n",
194
  "8\n",
195
+ " superclass pred_class \\\n",
196
+ "0 activity_type micro-adventure / weekend trip \n",
197
+ "1 activities [] \n",
198
+ "2 climate_or_season variable weather / spring / autumn \n",
199
+ "3 style_or_comfort minimalist \n",
200
+ "4 dress_code casual \n",
201
+ "5 accommodation indoor \n",
202
+ "6 transportation no own vehicle \n",
203
+ "7 special_conditions self-supported (bring your own food/cooking) \n",
204
+ "8 trip_length_days 7+ days \n",
205
  "\n",
206
  " true_class \n",
207
  "0 beach vacation \n",
 
212
  "5 indoor \n",
213
  "6 no own vehicle \n",
214
  "7 no special conditions \n",
215
+ "8 7+ days \n"
 
 
 
 
 
216
  ]
217
  },
218
  {
219
+ "ename": "ZeroDivisionError",
220
+ "evalue": "division by zero",
221
  "output_type": "error",
222
  "traceback": [
223
  "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
224
+ "\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)",
225
+ "Cell \u001b[0;32mIn[60], line 13\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[38;5;28mprint\u001b[39m(df)\n\u001b[1;32m 12\u001b[0m \u001b[38;5;66;03m# accuracy, perc true classes identified and perc wrong pred classes\u001b[39;00m\n\u001b[0;32m---> 13\u001b[0m performance \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mconcat([performance, \u001b[43mperf_measure\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdf\u001b[49m\u001b[43m)\u001b[49m])\n\u001b[1;32m 14\u001b[0m \u001b[38;5;28mprint\u001b[39m(performance)\n\u001b[1;32m 16\u001b[0m result_list\u001b[38;5;241m.\u001b[39mappend(df)\n",
226
+ "Cell \u001b[0;32mIn[59], line 14\u001b[0m, in \u001b[0;36mperf_measure\u001b[0;34m(df)\u001b[0m\n\u001b[1;32m 12\u001b[0m correct_perc \u001b[38;5;241m=\u001b[39m num_correct\u001b[38;5;241m/\u001b[39m\u001b[38;5;28mlen\u001b[39m(true_class)\n\u001b[1;32m 13\u001b[0m num_pred \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlen\u001b[39m(pred_class)\n\u001b[0;32m---> 14\u001b[0m wrong_perc \u001b[38;5;241m=\u001b[39m \u001b[43m(\u001b[49m\u001b[43mnum_pred\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mnum_correct\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m/\u001b[39;49m\u001b[43mnum_pred\u001b[49m\n\u001b[1;32m 15\u001b[0m df_perf \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mDataFrame({\n\u001b[1;32m 16\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124maccuracy\u001b[39m\u001b[38;5;124m'\u001b[39m: [accuracy],\n\u001b[1;32m 17\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtrue_ident\u001b[39m\u001b[38;5;124m'\u001b[39m: [correct_perc],\n\u001b[1;32m 18\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mfalse_pred\u001b[39m\u001b[38;5;124m'\u001b[39m: [wrong_perc]\n\u001b[1;32m 19\u001b[0m })\n\u001b[1;32m 20\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m(df_perf)\n",
227
+ "\u001b[0;31mZeroDivisionError\u001b[0m: division by zero"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  ]
229
  }
230
  ],
 
233
  "performance = pd.DataFrame(columns=['accuracy', 'true_ident', 'false_pred'])\n",
234
  "\n",
235
  "start_time = time.time()\n",
236
+ "\n",
237
  "for i in range(len(trip_descriptions)):\n",
238
  " current_trip = trip_descriptions[i]\n",
239
  " current_type = trip_types[i]\n",
 
244
  " performance = pd.concat([performance, perf_measure(df)])\n",
245
  " print(performance)\n",
246
  " \n",
247
+ " result_list.append(df)\n",
248
+ "\n",
249
+ "end_time = time.time()\n",
250
+ "\n",
251
+ "elapsed_time = end_time - start_time"
252
  ]
253
  },
254
  {
 
261
  },
262
  {
263
  "cell_type": "code",
264
+ "execution_count": 61,
265
  "id": "eb33fd31-94e6-40b5-9c36-a32effe77c01",
266
  "metadata": {},
267
+ "outputs": [
268
+ {
269
+ "ename": "IndexError",
270
+ "evalue": "list index out of range",
271
+ "output_type": "error",
272
+ "traceback": [
273
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
274
+ "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)",
275
+ "Cell \u001b[0;32mIn[61], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Extract \"same_value\" column from each DataFrame\u001b[39;00m\n\u001b[1;32m 2\u001b[0m sv_columns \u001b[38;5;241m=\u001b[39m [df[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124msame_value\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;28;01mfor\u001b[39;00m df \u001b[38;5;129;01min\u001b[39;00m result_list] \u001b[38;5;66;03m# 'same' needs to be changed\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m sv_columns\u001b[38;5;241m.\u001b[39minsert(\u001b[38;5;241m0\u001b[39m, \u001b[43mresult_list\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124msuperclass\u001b[39m\u001b[38;5;124m'\u001b[39m])\n\u001b[1;32m 5\u001b[0m \u001b[38;5;66;03m# Combine into a new DataFrame (columns side-by-side)\u001b[39;00m\n\u001b[1;32m 6\u001b[0m sv_df \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mconcat(sv_columns, axis\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m)\n",
276
+ "\u001b[0;31mIndexError\u001b[0m: list index out of range"
277
+ ]
278
+ }
279
+ ],
280
  "source": [
281
  "# Extract \"same_value\" column from each DataFrame\n",
282
  "sv_columns = [df['same_value'] for df in result_list] # 'same' needs to be changed\n",
 
290
  },
291
  {
292
  "cell_type": "code",
293
+ "execution_count": 62,
294
  "id": "bf7546cb-79ce-49ad-8cee-54d02239220c",
295
  "metadata": {},
296
+ "outputs": [
297
+ {
298
+ "name": "stdout",
299
+ "output_type": "stream",
300
+ "text": [
301
+ " superclass accuracy\n",
302
+ "0 activity_type 0.8\n",
303
+ "1 activities 0.0\n",
304
+ "2 climate_or_season 0.5\n",
305
+ "3 style_or_comfort 0.3\n",
306
+ "4 dress_code 0.8\n",
307
+ "5 accommodation 0.8\n",
308
+ "6 transportation 0.7\n",
309
+ "7 special_conditions 0.2\n",
310
+ "8 trip_length_days 0.6\n"
311
+ ]
312
+ }
313
+ ],
314
  "source": [
315
  "# Compute accuracy per superclass (row means of same_value matrix excluding the first column)\n",
316
  "row_means = sv_df.iloc[:, 1:].mean(axis=1)\n",
 
350
  "outputs": [],
351
  "source": [
352
  "# save results\n",
 
 
353
  "# Structure to save\n",
354
  "model_result = {\n",
355
  " 'model': model_name,\n",
356
  " 'predictions': result_list,\n",
357
  " 'performance': performance,\n",
358
  " 'perf_summary': column_means,\n",
359
+ " 'perf_superclass': df_row_means,\n",
360
+ " 'elapsed_time': elapsed_time\n",
361
  "}\n",
362
  "\n",
363
  "# File path with folder\n",
 
368
  " pickle.dump(model_result, f)"
369
  ]
370
  },
371
+ {
372
+ "cell_type": "code",
373
+ "execution_count": null,
374
+ "id": "f38d0924-30b6-43cd-9bfc-fe5b0dc80411",
375
+ "metadata": {},
376
+ "outputs": [],
377
+ "source": [
378
+ "print(elapsed_time/60)"
379
+ ]
380
+ },
381
  {
382
  "cell_type": "markdown",
383
  "id": "e1cbb54e-abe6-49b6-957e-0683196f3199",
 
388
  },
389
  {
390
  "cell_type": "code",
391
+ "execution_count": 54,
392
  "id": "62ca82b0-6909-4e6c-9d2c-fed87971e5b6",
393
+ "metadata": {
394
+ "scrolled": true
395
+ },
396
  "outputs": [
397
  {
398
  "name": "stdout",
399
  "output_type": "stream",
400
  "text": [
401
+ "Model: model_MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli\n",
402
+ "Performance Summary:\n",
403
+ "accuracy 0.522222\n",
404
+ "true_ident 0.841667\n",
405
+ "false_pred 0.572381\n",
406
+ "dtype: float64\n",
407
+ "----------------------------------------\n",
408
  "Model: model_a_facebook-bart-large-mnli\n",
409
  "Performance Summary:\n",
410
  "accuracy 0.454545\n",
 
419
  "false_pred 0.551667\n",
420
  "dtype: float64\n",
421
  "----------------------------------------\n",
422
+ "Model: model_MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli\n",
423
+ "Performance Summary:\n",
424
+ " superclass accuracy\n",
425
+ "0 activity_type 0.8\n",
426
+ "1 activities 0.0\n",
427
+ "2 climate_or_season 0.5\n",
428
+ "3 style_or_comfort 0.3\n",
429
+ "4 dress_code 0.8\n",
430
+ "5 accommodation 0.8\n",
431
+ "6 transportation 0.7\n",
432
+ "7 special_conditions 0.2\n",
433
+ "8 trip_length_days 0.6\n",
434
+ "----------------------------------------\n",
435
  "Model: model_a_facebook-bart-large-mnli\n",
436
  "Performance Summary:\n",
437
  " superclass accuracy\n",
 
479
  " result = pickle.load(f)\n",
480
  " all_results[model_name] = result\n",
481
  "\n",
482
+ "# Compare performance across models\n",
483
  "for model, data in all_results.items():\n",
484
  " print(f\"Model: {model}\")\n",
485
  " print(f\"Performance Summary:\\n{data['perf_summary']}\")\n",
486
  " print(\"-\" * 40)\n",
487
  "\n",
488
  "\n",
489
+ "# Compare performance across models\n",
490
  "for model, data in all_results.items():\n",
491
  " print(f\"Model: {model}\")\n",
492
  " print(f\"Performance Summary:\\n{data['perf_superclass']}\")\n",
493
  " print(\"-\" * 40)"
494
  ]
495
  },
496
+ {
497
+ "cell_type": "code",
498
+ "execution_count": 69,
499
+ "id": "57fd150d-1cda-4be5-806b-ef380469243a",
500
+ "metadata": {},
501
+ "outputs": [
502
+ {
503
+ "name": "stdout",
504
+ "output_type": "stream",
505
+ "text": [
506
+ "Model: model_MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli\n",
507
+ "Time in minutes for 10 trips:\n",
508
+ "83.45150986512502\n",
509
+ "----------------------------------------\n",
510
+ "Model: model_a_facebook-bart-large-mnli\n"
511
+ ]
512
+ },
513
+ {
514
+ "ename": "KeyError",
515
+ "evalue": "'elapsed_time'",
516
+ "output_type": "error",
517
+ "traceback": [
518
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
519
+ "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
520
+ "Cell \u001b[0;32mIn[69], line 4\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m model, data \u001b[38;5;129;01min\u001b[39;00m all_results\u001b[38;5;241m.\u001b[39mitems():\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mModel: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmodel\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m----> 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTime in minutes for 10 trips:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00mdata[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124melapsed_time\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m/\u001b[39m\u001b[38;5;241m60\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m-\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m*\u001b[39m \u001b[38;5;241m40\u001b[39m)\n",
521
+ "\u001b[0;31mKeyError\u001b[0m: 'elapsed_time'"
522
+ ]
523
+ }
524
+ ],
525
+ "source": [
526
+ "# Compare across models\n",
527
+ "for model, data in all_results.items():\n",
528
+ " print(f\"Model: {model}\")\n",
529
+ " print(f\"Time in minutes for 10 trips:\\n{data['elapsed_time']/60}\")\n",
530
+ " print(\"-\" * 40)"
531
+ ]
532
+ },
533
  {
534
  "cell_type": "markdown",
535
  "id": "17483df4-55c4-41cd-b8a9-61f7a5c7e8a3",
space/space/space/space/space/packing_label_structure.json CHANGED
@@ -49,7 +49,8 @@
49
  "warm destination / summer",
50
  "variable weather / spring / autumn",
51
  "tropical / humid",
52
- "dry / desert-like"
 
53
  ],
54
  "style_or_comfort": [
55
  "ultralight",
@@ -74,14 +75,13 @@
74
  ],
75
  "special_conditions": [
76
  "off-grid / no electricity",
77
- "self-supported (bring your own food/cooking)",
78
- "child-friendly",
79
  "pet-friendly",
80
- "rainy climate",
81
  "snow and ice",
82
  "high alpine terrain",
83
- "avalanche-prone terrain",
84
- "no special conditions"
85
  ],
86
  "trip_length_days": [
87
  "1 day",
 
49
  "warm destination / summer",
50
  "variable weather / spring / autumn",
51
  "tropical / humid",
52
+ "dry / desert-like",
53
+ "rainy climate"
54
  ],
55
  "style_or_comfort": [
56
  "ultralight",
 
75
  ],
76
  "special_conditions": [
77
  "off-grid / no electricity",
78
+ "self-supported (bring your own cooking gear)",
79
+ "travel with children",
80
  "pet-friendly",
 
81
  "snow and ice",
82
  "high alpine terrain",
83
+ "snow, ice and avalanche-prone terrain",
84
+ "no special conditions to consider"
85
  ],
86
  "trip_length_days": [
87
  "1 day",
space/space/space/space/space/packing_templates_self_supported_offgrid_expanded.json CHANGED
@@ -535,7 +535,7 @@
535
  "USB-hub (voor meerdere devices)",
536
  "verpakking om elektronica droog te houden"
537
  ],
538
- "self-supported (bring your own food/cooking)": [
539
  "lichtgewicht kooktoestel (gas, benzine of alcohol)",
540
  "brandstof (voldoende voor aantal dagen)",
541
  "pan of keteltje",
@@ -552,7 +552,7 @@
552
  "minstens 2 liter wateropslag per persoon",
553
  "food bag of hangzak voor voedsel (wild-safe)"
554
  ],
555
- "child-friendly": [
556
  "snacks en speelgoed",
557
  "EHBO-set met pleisters",
558
  "extra kleding",
@@ -606,7 +606,7 @@
606
  "extra voeding",
607
  "EHBO-kit"
608
  ],
609
- "avalanche-prone terrain": [
610
  "lawinepieper",
611
  "schep",
612
  "sonde",
 
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",
 
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",
 
606
  "extra voeding",
607
  "EHBO-kit"
608
  ],
609
+ "snow, ice and avalanche-prone terrain": [
610
  "lawinepieper",
611
  "schep",
612
  "sonde",
space/space/space/space/space/results/model_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:dd1d8f5ed1d8b9a0878aa0e99fa144341c27d48bcf71d77390e28951e4936149
3
+ size 9539
space/space/space/space/space/space/results/model_b_sileod-deberta-v3-base-tasksource-nli_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:98f1217c7add9665e814d4ef90a8e1a60e33d53ea81c6c98472bc652aa11ee56
3
+ size 9461
space/space/space/space/space/space/space/.ipynb_checkpoints/gradio_tryout-checkpoint.ipynb CHANGED
The diff for this file is too large to render. See raw diff
 
space/space/space/space/space/space/space/packing_label_hierarchical_mapping.json CHANGED
@@ -247,11 +247,11 @@
247
  "category": "accommodation",
248
  "superclass": "type"
249
  },
250
- "transportation: vehicle": {
251
  "category": "transportation",
252
  "superclass": "mode"
253
  },
254
- "transportation: no vehicle": {
255
  "category": "transportation",
256
  "superclass": "mode"
257
  },
 
247
  "category": "accommodation",
248
  "superclass": "type"
249
  },
250
+ "transportation: own vehicle": {
251
  "category": "transportation",
252
  "superclass": "mode"
253
  },
254
+ "transportation: no own vehicle": {
255
  "category": "transportation",
256
  "superclass": "mode"
257
  },
space/space/space/space/space/space/space/packing_label_structure.json CHANGED
@@ -69,8 +69,8 @@
69
  "sleeping in a car"
70
  ],
71
  "transportation": [
72
- "vehicle",
73
- "no vehicle"
74
  ],
75
  "special_conditions": [
76
  "off-grid / no electricity",
 
69
  "sleeping in a car"
70
  ],
71
  "transportation": [
72
+ "own vehicle",
73
+ "no own vehicle"
74
  ],
75
  "special_conditions": [
76
  "off-grid / no electricity",
space/space/space/space/space/space/space/packing_templates_self_supported_offgrid_expanded.json CHANGED
@@ -507,14 +507,14 @@
507
  "snacks voor de nacht",
508
  "thermische deken (voor koude nachten)"
509
  ],
510
- "vehicle": [
511
  "rijbewijs",
512
  "autopapieren",
513
  "EHBO-set",
514
  "navigatie of smartphone",
515
  "telefoonhouder"
516
  ],
517
- "no vehicle": [
518
  "rugzak",
519
  "waterfles",
520
  "lichte schoenen",
 
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",
space/space/space/space/space/space/space/results/model_a_facebook-bart-large-mnli_results.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6f5c3b28d1fb60f40fa22ebbe9a32e10f6a81b61beaf376c620eabc6912a72e7
3
+ size 9445
space/space/space/space/space/space/space/space/.ipynb_checkpoints/gradio_tryout-checkpoint.ipynb CHANGED
The diff for this file is too large to render. See raw diff
 
space/space/space/space/space/space/space/space/gradio_tryout.ipynb CHANGED
@@ -24,7 +24,7 @@
24
  },
25
  {
26
  "cell_type": "code",
27
- "execution_count": 16,
28
  "id": "f8c28d2d-8458-49fd-8ebf-5e729d6e861f",
29
  "metadata": {},
30
  "outputs": [
@@ -39,9 +39,9 @@
39
  "name": "stdout",
40
  "output_type": "stream",
41
  "text": [
42
- "First trip: 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",
43
  "\n",
44
- "Trip type: ['beach vacation', ['swimming', 'going to the beach', 'relaxing', 'hiking'], 'warm destination / summer', 'lightweight (but comfortable)', 'casual', 'indoor', 'no vehicle', 'no special conditions', '7 days']\n"
45
  ]
46
  }
47
  ],
@@ -51,9 +51,16 @@
51
  "from transformers import pipeline\n",
52
  "import json\n",
53
  "import pandas as pd\n",
 
 
 
 
54
  "\n",
55
  "# Load the model and create a pipeline for zero-shot classification (1min loading + classifying with 89 labels)\n",
56
- "classifier = pipeline(\"zero-shot-classification\", model=\"facebook/bart-large-mnli\")\n",
 
 
 
57
  "\n",
58
  "# get candidate labels\n",
59
  "with open(\"packing_label_structure.json\", \"r\") as file:\n",
@@ -68,9 +75,9 @@
68
  "trip_types = [trip['trip_types'] for trip in packing_data]\n",
69
  "\n",
70
  "# Access the first trip description\n",
71
- "first_trip = trip_descriptions[0]\n",
72
  "# Get the packing list for the secondfirst trip\n",
73
- "first_trip_type = trip_types[0]\n",
74
  "\n",
75
  "print(f\"First trip: {first_trip} \\n\")\n",
76
  "print(f\"Trip type: {first_trip_type}\")"
@@ -78,196 +85,385 @@
78
  },
79
  {
80
  "cell_type": "code",
81
- "execution_count": 37,
82
- "id": "fed1f8bc-5baf-46e7-8763-9d56fb9c536b",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  "metadata": {
84
  "scrolled": true
85
  },
86
  "outputs": [
 
 
 
 
 
 
 
87
  {
88
  "name": "stdout",
89
  "output_type": "stream",
90
  "text": [
91
- "{'sequence': '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.', 'labels': ['beach vacation', 'micro-adventure / weekend trip', 'nature escape', 'digital nomad trip', 'cultural exploration', 'yoga / wellness retreat', 'festival trip', 'long-distance hike / thru-hike', 'hut trek (summer)', 'city trip', 'road trip (car/camper)', 'ski tour / skitour', 'camping trip (campground)', 'snowboard / splitboard trip', 'camping trip (wild camping)', 'hut trek (winter)'], 'scores': [0.37631064653396606, 0.35016775131225586, 0.13397355377674103, 0.031636204570531845, 0.031270742416381836, 0.012846449390053749, 0.012699575163424015, 0.009526746347546577, 0.008148356340825558, 0.007793044205754995, 0.006512156222015619, 0.005669699050486088, 0.0044484627433121204, 0.004113250877708197, 0.002713854657486081, 0.002169555053114891]}\n",
92
  "beach vacation\n",
93
  "0\n",
94
- "{'sequence': '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.', 'labels': ['going to the beach', 'relaxing', 'hiking', 'swimming', 'sightseeing', 'running', 'hut-to-hut hiking', 'biking', 'photography', 'surfing', 'stand-up paddleboarding (SUP)', 'snorkeling', 'yoga', 'kayaking / canoeing', 'rock climbing', 'fishing', 'paragliding', 'rafting', 'horseback riding', 'snowshoe hiking', 'cross-country skiing', 'ice climbing', 'skiing', 'scuba diving', 'ski touring'], 'scores': [0.9914858341217041, 0.9771362543106079, 0.9426282048225403, 0.21901991963386536, 0.17586199939250946, 0.09854521602392197, 0.08370419591665268, 0.03679152950644493, 0.03668990358710289, 0.03099300153553486, 0.025300050154328346, 0.021451234817504883, 0.011070131324231625, 0.0075112744234502316, 0.006306737195700407, 0.0034973458386957645, 0.002655829070135951, 0.00197031581774354, 0.0015599008183926344, 0.001527810120023787, 0.0015017405385151505, 0.0014336870517581701, 0.0011686616344377398, 0.000789369223639369, 0.0004912536824122071]}\n",
95
- "['going to the beach', 'relaxing', 'hiking']\n",
96
  "1\n",
97
- "{'sequence': '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.', 'labels': ['warm destination / summer', 'tropical / humid', 'variable weather / spring / autumn', 'dry / desert-like', 'cold destination / winter'], 'scores': [0.6468702554702759, 0.19999535381793976, 0.09394325315952301, 0.05279730260372162, 0.0063938056118786335]}\n",
98
- "warm destination / summer\n",
99
  "2\n",
100
- "{'sequence': '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.', 'labels': ['minimalist', 'ultralight', 'lightweight (but comfortable)', 'luxury (including evening wear)'], 'scores': [0.4286234974861145, 0.2564568817615509, 0.2147122174501419, 0.10020739585161209]}\n",
101
  "minimalist\n",
102
  "3\n",
103
- "{'sequence': '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.', 'labels': ['casual', 'conservative', 'formal (business trip)'], 'scores': [0.6567223072052002, 0.3034382164478302, 0.039839524775743484]}\n",
104
  "casual\n",
105
  "4\n",
106
- "{'sequence': '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.', 'labels': ['huts with half board', 'indoor', 'sleeping in a car', 'sleeping in a tent'], 'scores': [0.5007699728012085, 0.34074831008911133, 0.10416240990161896, 0.05431929975748062]}\n",
107
- "huts with half board\n",
108
  "5\n",
109
- "{'sequence': '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.', 'labels': ['vehicle', 'no vehicle'], 'scores': [0.7521055936813354, 0.24789436161518097]}\n",
110
- "vehicle\n",
111
  "6\n",
112
- "{'sequence': '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.', 'labels': ['off-grid / no electricity', 'self-supported (bring your own food/cooking)', 'no special conditions', 'pet-friendly', 'rainy climate', 'child-friendly', 'snow and ice', 'high alpine terrain', 'avalanche-prone terrain'], 'scores': [0.46220096945762634, 0.12957870960235596, 0.10651793330907822, 0.09777138382196426, 0.06722460687160492, 0.0632496327161789, 0.04952802509069443, 0.015049820765852928, 0.008878983557224274]}\n",
113
  "off-grid / no electricity\n",
114
  "7\n",
115
- "{'sequence': '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.', 'labels': ['7+ days', '2 days', '1 day', '6 days', '3 days', '4 days', '7 days', '5 days'], 'scores': [0.21139054000377655, 0.18512114882469177, 0.14520084857940674, 0.0976138487458229, 0.094282366335392, 0.09376301616430283, 0.09161651134490967, 0.08101171255111694]}\n",
116
  "7+ days\n",
117
- "8\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  ]
119
  }
120
  ],
121
  "source": [
122
- "# Create an empty DataFrame with specified columns\n",
123
- "df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
124
- "cutoff = 0.5 # used to choose which activities are relevant\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  "\n",
126
- "# fill DataFrame\n",
127
- "for i, key in enumerate(keys_list):\n",
128
- " # Run the classification (ca 30 seconds classifying)\n",
129
- " if key == 'activities':\n",
130
- " result = classifier(first_trip, candidate_labels[key], multi_label=True)\n",
131
- " indices = [i for i, score in enumerate(result['scores']) if score > cutoff]\n",
132
- " classes = [result['labels'][i] for i in indices]\n",
133
- " else:\n",
134
- " result = classifier(first_trip, candidate_labels[key])\n",
135
- " classes = result[\"labels\"][0]\n",
136
- " print(result)\n",
137
- " print(classes)\n",
138
- " print(i)\n",
139
- " df.loc[i] = [key, classes]\n",
140
  "\n",
141
- "df['true_class'] = first_trip_type"
142
  ]
143
  },
144
  {
145
  "cell_type": "code",
146
- "execution_count": 40,
147
- "id": "b3b51280-76a1-4229-a9de-070b925d3463",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  "metadata": {
149
  "scrolled": true
150
  },
151
- "outputs": [
152
- {
153
- "name": "stdout",
154
- "output_type": "stream",
155
- "text": [
156
- " Superclass pred_class true_class\n",
157
- "0 activity_type beach vacation beach vacation\n",
158
- "1 activities [going to the beach, relaxing, hiking] [swimming, going to the beach, relaxing, hiking]\n",
159
- "2 climate_or_season warm destination / summer warm destination / summer\n",
160
- "3 style_or_comfort minimalist lightweight (but comfortable)\n",
161
- "4 dress_code casual casual\n",
162
- "5 accommodation huts with half board indoor\n",
163
- "6 transportation vehicle no vehicle\n",
164
- "7 special_conditions off-grid / no electricity no special conditions\n",
165
- "8 trip_length_days 7+ days 7 days\n"
166
- ]
167
- }
168
- ],
169
  "source": [
170
- "pd.set_option('display.width', 1000) \n",
171
- "pd.set_option('display.max_columns', None)\n",
172
- "print(df)"
 
 
 
 
 
173
  ]
174
  },
175
  {
176
  "cell_type": "code",
177
- "execution_count": 42,
178
- "id": "2ec09e8f-75f5-45b1-b4c0-4fafd685d36b",
179
  "metadata": {},
180
- "outputs": [
181
- {
182
- "name": "stdout",
183
- "output_type": "stream",
184
- "text": [
185
- " Superclass pred_class true_class same\n",
186
- "0 activity_type beach vacation beach vacation True\n",
187
- "1 activities [going to the beach, relaxing, hiking] [swimming, going to the beach, relaxing, hiking] False\n",
188
- "2 climate_or_season warm destination / summer warm destination / summer True\n",
189
- "3 style_or_comfort minimalist lightweight (but comfortable) False\n",
190
- "4 dress_code casual casual True\n",
191
- "5 accommodation huts with half board indoor False\n",
192
- "6 transportation vehicle no vehicle False\n",
193
- "7 special_conditions off-grid / no electricity no special conditions False\n",
194
- "8 trip_length_days 7+ days 7 days False\n"
195
- ]
196
- }
197
- ],
198
  "source": [
199
- "df['same'] = df['pred_class'] == df['true_class']\n",
200
- "print(df)"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  ]
202
  },
203
  {
204
- "cell_type": "code",
205
- "execution_count": 62,
206
- "id": "82ae19c8-8bb7-4f7f-841b-1cb6501a17a7",
207
  "metadata": {},
208
- "outputs": [
209
- {
210
- "name": "stdout",
211
- "output_type": "stream",
212
- "text": [
213
- "Accuracy (excluding activities): 0.3333333333333333\n"
214
- ]
215
- }
216
- ],
217
  "source": [
218
- "# accuracy excluding activities\n",
219
- "correct = sum(df.loc[df.index != 1, 'same'])\n",
220
- "total = len(df['same'])\n",
221
- "accuracy = correct/total\n",
222
- "print(\"Accuracy (excluding activities):\", accuracy)"
223
  ]
224
  },
225
  {
226
  "cell_type": "code",
227
- "execution_count": 64,
228
- "id": "16c0a3ae-34ac-49a4-b59f-411a6f0ce947",
229
  "metadata": {},
230
  "outputs": [
231
  {
232
  "name": "stdout",
233
  "output_type": "stream",
234
  "text": [
235
- "Percentage of true classes that were identified: 0.75\n",
236
- "Percentage of predicted classes that were wrong: 0.0\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  ]
238
  }
239
  ],
240
  "source": [
241
- "pred_class = df.loc[df.index == 1, 'pred_class'].iloc[0]\n",
242
- "true_class = df.loc[df.index == 1, 'true_class'].iloc[0]\n",
243
- "correct = [label for label in pred_class if label in true_class]\n",
244
  "\n",
245
- "num_correct = len(correct)\n",
246
- "correct_perc = num_correct/len(true_class)\n",
247
  "\n",
248
- "num_pred = len(pred_class)\n",
249
- "wrong_perc = (num_pred - num_correct)/num_pred\n",
 
 
 
 
 
 
 
 
250
  "\n",
251
- "print(\"Percentage of true classes that were identified:\", correct_perc)\n",
252
- "print(\"Percentage of predicted classes that were wrong:\", wrong_perc)"
253
- ]
254
- },
255
- {
256
- "cell_type": "markdown",
257
- "id": "62c5c18c-58f4-465c-a188-c57cfa7ffa90",
258
- "metadata": {},
259
- "source": [
260
- "Now do the same for all trips"
 
 
261
  ]
262
  },
263
- {
264
- "cell_type": "code",
265
- "execution_count": null,
266
- "id": "e4192b42-f1bc-4fcb-a238-dbdb3df7d699",
267
- "metadata": {},
268
- "outputs": [],
269
- "source": []
270
- },
271
  {
272
  "cell_type": "markdown",
273
  "id": "17483df4-55c4-41cd-b8a9-61f7a5c7e8a3",
 
24
  },
25
  {
26
  "cell_type": "code",
27
+ "execution_count": 40,
28
  "id": "f8c28d2d-8458-49fd-8ebf-5e729d6e861f",
29
  "metadata": {},
30
  "outputs": [
 
39
  "name": "stdout",
40
  "output_type": "stream",
41
  "text": [
42
+ "First trip: 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",
43
  "\n",
44
+ "Trip type: ['city trip', ['sightseeing'], 'variable weather / spring / autumn', 'luxury (including evening wear)', 'casual', 'indoor', 'no own vehicle', 'no special condition', '3 days']\n"
45
  ]
46
  }
47
  ],
 
51
  "from transformers import pipeline\n",
52
  "import json\n",
53
  "import pandas as pd\n",
54
+ "import matplotlib.pyplot as plt\n",
55
+ "import pickle\n",
56
+ "import os\n",
57
+ "import time\n",
58
  "\n",
59
  "# Load the model and create a pipeline for zero-shot classification (1min loading + classifying with 89 labels)\n",
60
+ "classifier = pipeline(\"zero-shot-classification\", model=\"MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli\")\n",
61
+ "# tried:\n",
62
+ "# facebook/bart-large-mnli\n",
63
+ "# sileod/deberta-v3-base-tasksource-nli\n",
64
  "\n",
65
  "# get candidate labels\n",
66
  "with open(\"packing_label_structure.json\", \"r\") as file:\n",
 
75
  "trip_types = [trip['trip_types'] for trip in packing_data]\n",
76
  "\n",
77
  "# Access the first trip description\n",
78
+ "first_trip = trip_descriptions[1]\n",
79
  "# Get the packing list for the secondfirst trip\n",
80
+ "first_trip_type = trip_types[1]\n",
81
  "\n",
82
  "print(f\"First trip: {first_trip} \\n\")\n",
83
  "print(f\"Trip type: {first_trip_type}\")"
 
85
  },
86
  {
87
  "cell_type": "code",
88
+ "execution_count": 41,
89
+ "id": "3a762755-872d-43a6-b666-874d6133488c",
90
+ "metadata": {},
91
+ "outputs": [],
92
+ "source": [
93
+ "# function that returns pandas data frame with predictions\n",
94
+ "\n",
95
+ "cut_off = 0.5 # used to choose which activities are relevant\n",
96
+ "\n",
97
+ "def pred_trip(trip_descr, trip_type, cut_off):\n",
98
+ " # Create an empty DataFrame with specified columns\n",
99
+ " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
100
+ " for i, key in enumerate(keys_list):\n",
101
+ " if key == 'activities':\n",
102
+ " result = classifier(trip_descr, candidate_labels[key], multi_label=True)\n",
103
+ " indices = [i for i, score in enumerate(result['scores']) if score > cut_off]\n",
104
+ " classes = [result['labels'][i] for i in indices]\n",
105
+ " else:\n",
106
+ " result = classifier(trip_descr, candidate_labels[key])\n",
107
+ " classes = result[\"labels\"][0]\n",
108
+ " print(result)\n",
109
+ " print(classes)\n",
110
+ " print(i)\n",
111
+ " df.loc[i] = [key, classes]\n",
112
+ " df['true_class'] = trip_type\n",
113
+ " return df"
114
+ ]
115
+ },
116
+ {
117
+ "cell_type": "code",
118
+ "execution_count": 42,
119
+ "id": "3b4f3193-3bdd-453c-8664-df84f955600c",
120
+ "metadata": {},
121
+ "outputs": [],
122
+ "source": [
123
+ "# function for accuracy, perc true classes identified and perc wrong pred classes\n",
124
+ "\n",
125
+ "def perf_measure(df):\n",
126
+ " df['same_value'] = df['pred_class'] == df['true_class']\n",
127
+ " correct = sum(df.loc[df.index != 1, 'same_value'])\n",
128
+ " total = len(df['same_value'])\n",
129
+ " accuracy = correct/total\n",
130
+ " pred_class = df.loc[df.index == 1, 'pred_class'].iloc[0]\n",
131
+ " true_class = df.loc[df.index == 1, 'true_class'].iloc[0]\n",
132
+ " correct = [label for label in pred_class if label in true_class]\n",
133
+ " num_correct = len(correct)\n",
134
+ " correct_perc = num_correct/len(true_class)\n",
135
+ " num_pred = len(pred_class)\n",
136
+ " wrong_perc = (num_pred - num_correct)/num_pred\n",
137
+ " df_perf = pd.DataFrame({\n",
138
+ " 'accuracy': [accuracy],\n",
139
+ " 'true_ident': [correct_perc],\n",
140
+ " 'false_pred': [wrong_perc]\n",
141
+ " })\n",
142
+ " return(df_perf)"
143
+ ]
144
+ },
145
+ {
146
+ "cell_type": "markdown",
147
+ "id": "62c5c18c-58f4-465c-a188-c57cfa7ffa90",
148
+ "metadata": {},
149
+ "source": [
150
+ "**Now do the same for all trips**"
151
+ ]
152
+ },
153
+ {
154
+ "cell_type": "code",
155
+ "execution_count": 43,
156
+ "id": "4dd01755-be8d-4904-8494-ac28aba2fee7",
157
  "metadata": {
158
  "scrolled": true
159
  },
160
  "outputs": [
161
+ {
162
+ "name": "stderr",
163
+ "output_type": "stream",
164
+ "text": [
165
+ "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"
166
+ ]
167
+ },
168
  {
169
  "name": "stdout",
170
  "output_type": "stream",
171
  "text": [
172
+ "{'sequence': '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.', 'labels': ['beach vacation', 'micro-adventure / weekend trip', 'cultural exploration', 'nature escape', 'digital nomad trip', 'camping trip (campground)', 'camping trip (wild camping)', 'long-distance hike / thru-hike', 'ski tour / skitour', 'hut trek (summer)', 'city trip', 'hut trek (winter)', 'road trip (car/camper)', 'festival trip', 'yoga / wellness retreat', 'snowboard / splitboard trip'], 'scores': [0.37198853492736816, 0.31496119499206543, 0.10890532284975052, 0.09102731198072433, 0.0735681876540184, 0.012933704070746899, 0.009422042407095432, 0.0051276967860758305, 0.004056071396917105, 0.0017408831045031548, 0.001503779087215662, 0.0014244643971323967, 0.0013752576196566224, 0.0009292717440985143, 0.0006881792796775699, 0.0003480584127828479]}\n",
173
  "beach vacation\n",
174
  "0\n",
175
+ "{'sequence': '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.', 'labels': ['relaxing', 'hiking', 'going to the beach', 'photography', 'sightseeing', 'hut-to-hut hiking', 'snorkeling', 'snowshoe hiking', 'yoga', 'stand-up paddleboarding (SUP)', 'kayaking / canoeing', 'horseback riding', 'swimming', 'paragliding', 'rafting', 'biking', 'rock climbing', 'surfing', 'running', 'ice climbing', 'cross-country skiing', 'fishing', 'ski touring', 'skiing', 'scuba diving'], 'scores': [0.9943736791610718, 0.9631249308586121, 0.9454535841941833, 0.7538902759552002, 0.4525446593761444, 0.1696157604455948, 0.05957728251814842, 0.04234873503446579, 0.01991761103272438, 0.016971556469798088, 0.006959819234907627, 0.00411367928609252, 0.0030609173700213432, 0.00186573073733598, 0.0017515394138172269, 0.00142807571683079, 0.0005748369731009007, 0.00037779140984639525, 0.0003097739245276898, 0.00030914091621525586, 0.0002725012309383601, 0.00027050732751376927, 0.00024376016517635435, 0.00017392759036738425, 0.00014787293912377208]}\n",
176
+ "['relaxing', 'hiking', 'going to the beach', 'photography']\n",
177
  "1\n",
178
+ "{'sequence': '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.', 'labels': ['tropical / humid', 'warm destination / summer', 'variable weather / spring / autumn', 'cold destination / winter', 'dry / desert-like'], 'scores': [0.4895477890968323, 0.25917261838912964, 0.24829530715942383, 0.0017174285603687167, 0.0012668712297454476]}\n",
179
+ "tropical / humid\n",
180
  "2\n",
181
+ "{'sequence': '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.', 'labels': ['minimalist', 'luxury (including evening wear)', 'lightweight (but comfortable)', 'ultralight'], 'scores': [0.7574900984764099, 0.09964746236801147, 0.07804173231124878, 0.06482075154781342]}\n",
182
  "minimalist\n",
183
  "3\n",
184
+ "{'sequence': '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.', 'labels': ['casual', 'conservative', 'formal (business trip)'], 'scores': [0.8163393139839172, 0.11898067593574524, 0.06467998772859573]}\n",
185
  "casual\n",
186
  "4\n",
187
+ "{'sequence': '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.', 'labels': ['indoor', 'huts with half board', 'sleeping in a car', 'sleeping in a tent'], 'scores': [0.6389047503471375, 0.18624886870384216, 0.13902997970581055, 0.03581654652953148]}\n",
188
+ "indoor\n",
189
  "5\n",
190
+ "{'sequence': '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.', 'labels': ['no own vehicle', 'own vehicle'], 'scores': [0.9990958571434021, 0.0009041387238539755]}\n",
191
+ "no own vehicle\n",
192
  "6\n",
193
+ "{'sequence': '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.', 'labels': ['off-grid / no electricity', 'self-supported (bring your own food/cooking)', 'child-friendly', 'no special conditions', 'pet-friendly', 'rainy climate', 'avalanche-prone terrain', 'high alpine terrain', 'snow and ice'], 'scores': [0.7414510250091553, 0.07683143764734268, 0.055722303688526154, 0.054133761674165726, 0.04852374270558357, 0.006977608893066645, 0.005693929269909859, 0.005599685944616795, 0.005066512618213892]}\n",
194
  "off-grid / no electricity\n",
195
  "7\n",
196
+ "{'sequence': '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.', 'labels': ['7+ days', '2 days', '7 days', '3 days', '4 days', '6 days', '5 days', '1 day'], 'scores': [0.29225289821624756, 0.20232954621315002, 0.1837582290172577, 0.13940994441509247, 0.06562349200248718, 0.04916509613394737, 0.040249694138765335, 0.0272111464291811]}\n",
197
  "7+ days\n",
198
+ "8\n",
199
+ " superclass pred_class \\\n",
200
+ "0 activity_type beach vacation \n",
201
+ "1 activities [relaxing, hiking, going to the beach, photogr... \n",
202
+ "2 climate_or_season tropical / humid \n",
203
+ "3 style_or_comfort minimalist \n",
204
+ "4 dress_code casual \n",
205
+ "5 accommodation indoor \n",
206
+ "6 transportation no own vehicle \n",
207
+ "7 special_conditions off-grid / no electricity \n",
208
+ "8 trip_length_days 7+ days \n",
209
+ "\n",
210
+ " true_class \n",
211
+ "0 beach vacation \n",
212
+ "1 [swimming, going to the beach, relaxing, hiking] \n",
213
+ "2 warm destination / summer \n",
214
+ "3 lightweight (but comfortable) \n",
215
+ "4 casual \n",
216
+ "5 indoor \n",
217
+ "6 no own vehicle \n",
218
+ "7 no special conditions \n",
219
+ "8 7+ days \n",
220
+ " accuracy true_ident false_pred\n",
221
+ "0 0.555556 0.75 0.25\n",
222
+ "{'sequence': '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.', 'labels': ['city trip', 'cultural exploration', 'micro-adventure / weekend trip', 'ski tour / skitour', 'festival trip', 'digital nomad trip', 'hut trek (winter)', 'camping trip (campground)', 'long-distance hike / thru-hike', 'hut trek (summer)', 'nature escape', 'camping trip (wild camping)', 'yoga / wellness retreat', 'road trip (car/camper)', 'beach vacation', 'snowboard / splitboard trip'], 'scores': [0.517789363861084, 0.297355592250824, 0.1621870994567871, 0.006185388192534447, 0.005294559057801962, 0.002764208009466529, 0.001503965351730585, 0.0014866390265524387, 0.0012240204960107803, 0.0012071850942447782, 0.000757778063416481, 0.0006650012801401317, 0.0005547589971683919, 0.00043604226084426045, 0.00031738984398543835, 0.0002710542466957122]}\n",
223
+ "city trip\n",
224
+ "0\n"
225
+ ]
226
+ },
227
+ {
228
+ "ename": "KeyboardInterrupt",
229
+ "evalue": "",
230
+ "output_type": "error",
231
+ "traceback": [
232
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
233
+ "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
234
+ "Cell \u001b[0;32mIn[43], line 7\u001b[0m\n\u001b[1;32m 5\u001b[0m current_trip \u001b[38;5;241m=\u001b[39m trip_descriptions[i]\n\u001b[1;32m 6\u001b[0m current_type \u001b[38;5;241m=\u001b[39m trip_types[i]\n\u001b[0;32m----> 7\u001b[0m df \u001b[38;5;241m=\u001b[39m \u001b[43mpred_trip\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 8\u001b[0m \u001b[38;5;28mprint\u001b[39m(df)\n\u001b[1;32m 10\u001b[0m \u001b[38;5;66;03m# accuracy, perc true classes identified and perc wrong pred classes\u001b[39;00m\n",
235
+ "Cell \u001b[0;32mIn[41], line 10\u001b[0m, in \u001b[0;36mpred_trip\u001b[0;34m(trip_descr, trip_type, cut_off)\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i, key \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(keys_list):\n\u001b[1;32m 9\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m key \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mactivities\u001b[39m\u001b[38;5;124m'\u001b[39m:\n\u001b[0;32m---> 10\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\u001b[43m \u001b[49m\u001b[43mmulti_label\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 11\u001b[0m indices \u001b[38;5;241m=\u001b[39m [i \u001b[38;5;28;01mfor\u001b[39;00m i, score \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(result[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mscores\u001b[39m\u001b[38;5;124m'\u001b[39m]) \u001b[38;5;28;01mif\u001b[39;00m score \u001b[38;5;241m>\u001b[39m cut_off]\n\u001b[1;32m 12\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",
236
+ "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",
237
+ "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",
238
+ "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",
239
+ "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",
240
+ "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",
241
+ "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",
242
+ "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",
243
+ "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",
244
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:1297\u001b[0m, in \u001b[0;36mDebertaV2ForSequenceClassification.forward\u001b[0;34m(self, input_ids, attention_mask, token_type_ids, position_ids, inputs_embeds, labels, output_attentions, output_hidden_states, return_dict)\u001b[0m\n\u001b[1;32m 1289\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124mr\u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 1290\u001b[0m \u001b[38;5;124;03mlabels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):\u001b[39;00m\n\u001b[1;32m 1291\u001b[0m \u001b[38;5;124;03m Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,\u001b[39;00m\n\u001b[1;32m 1292\u001b[0m \u001b[38;5;124;03m config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If\u001b[39;00m\n\u001b[1;32m 1293\u001b[0m \u001b[38;5;124;03m `config.num_labels > 1` a classification loss is computed (Cross-Entropy).\u001b[39;00m\n\u001b[1;32m 1294\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 1295\u001b[0m return_dict \u001b[38;5;241m=\u001b[39m return_dict \u001b[38;5;28;01mif\u001b[39;00m return_dict \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;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconfig\u001b[38;5;241m.\u001b[39muse_return_dict\n\u001b[0;32m-> 1297\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[43mdeberta\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1298\u001b[0m \u001b[43m \u001b[49m\u001b[43minput_ids\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1299\u001b[0m \u001b[43m \u001b[49m\u001b[43mtoken_type_ids\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtoken_type_ids\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1300\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 1301\u001b[0m \u001b[43m \u001b[49m\u001b[43mposition_ids\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mposition_ids\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1302\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 1303\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 1304\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 1305\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 1306\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1308\u001b[0m encoder_layer \u001b[38;5;241m=\u001b[39m outputs[\u001b[38;5;241m0\u001b[39m]\n\u001b[1;32m 1309\u001b[0m pooled_output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpooler(encoder_layer)\n",
245
+ "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",
246
+ "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",
247
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:1063\u001b[0m, in \u001b[0;36mDebertaV2Model.forward\u001b[0;34m(self, input_ids, attention_mask, token_type_ids, position_ids, inputs_embeds, output_attentions, output_hidden_states, return_dict)\u001b[0m\n\u001b[1;32m 1053\u001b[0m token_type_ids \u001b[38;5;241m=\u001b[39m torch\u001b[38;5;241m.\u001b[39mzeros(input_shape, dtype\u001b[38;5;241m=\u001b[39mtorch\u001b[38;5;241m.\u001b[39mlong, device\u001b[38;5;241m=\u001b[39mdevice)\n\u001b[1;32m 1055\u001b[0m embedding_output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39membeddings(\n\u001b[1;32m 1056\u001b[0m input_ids\u001b[38;5;241m=\u001b[39minput_ids,\n\u001b[1;32m 1057\u001b[0m token_type_ids\u001b[38;5;241m=\u001b[39mtoken_type_ids,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1060\u001b[0m inputs_embeds\u001b[38;5;241m=\u001b[39minputs_embeds,\n\u001b[1;32m 1061\u001b[0m )\n\u001b[0;32m-> 1063\u001b[0m encoder_outputs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mencoder\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1064\u001b[0m \u001b[43m \u001b[49m\u001b[43membedding_output\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1065\u001b[0m \u001b[43m \u001b[49m\u001b[43mattention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1066\u001b[0m \u001b[43m \u001b[49m\u001b[43moutput_hidden_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 1067\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 1068\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 1069\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1070\u001b[0m encoded_layers \u001b[38;5;241m=\u001b[39m encoder_outputs[\u001b[38;5;241m1\u001b[39m]\n\u001b[1;32m 1072\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mz_steps \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m1\u001b[39m:\n",
248
+ "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",
249
+ "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",
250
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:507\u001b[0m, in \u001b[0;36mDebertaV2Encoder.forward\u001b[0;34m(self, hidden_states, attention_mask, output_hidden_states, output_attentions, query_states, relative_pos, return_dict)\u001b[0m\n\u001b[1;32m 497\u001b[0m output_states \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 498\u001b[0m layer_module\u001b[38;5;241m.\u001b[39m\u001b[38;5;21m__call__\u001b[39m,\n\u001b[1;32m 499\u001b[0m next_kv,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 504\u001b[0m output_attentions,\n\u001b[1;32m 505\u001b[0m )\n\u001b[1;32m 506\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 507\u001b[0m output_states \u001b[38;5;241m=\u001b[39m \u001b[43mlayer_module\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 508\u001b[0m \u001b[43m \u001b[49m\u001b[43mnext_kv\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 509\u001b[0m \u001b[43m \u001b[49m\u001b[43mattention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 510\u001b[0m \u001b[43m \u001b[49m\u001b[43mquery_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mquery_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 511\u001b[0m \u001b[43m \u001b[49m\u001b[43mrelative_pos\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrelative_pos\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 512\u001b[0m \u001b[43m \u001b[49m\u001b[43mrel_embeddings\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrel_embeddings\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 513\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 514\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 516\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m output_attentions:\n\u001b[1;32m 517\u001b[0m output_states, att_m \u001b[38;5;241m=\u001b[39m output_states\n",
251
+ "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",
252
+ "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",
253
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:355\u001b[0m, in \u001b[0;36mDebertaV2Layer.forward\u001b[0;34m(self, hidden_states, attention_mask, query_states, relative_pos, rel_embeddings, output_attentions)\u001b[0m\n\u001b[1;32m 346\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mforward\u001b[39m(\n\u001b[1;32m 347\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 348\u001b[0m hidden_states,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 353\u001b[0m output_attentions\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[1;32m 354\u001b[0m ):\n\u001b[0;32m--> 355\u001b[0m attention_output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mattention\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 356\u001b[0m \u001b[43m \u001b[49m\u001b[43mhidden_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 357\u001b[0m \u001b[43m \u001b[49m\u001b[43mattention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 358\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 359\u001b[0m \u001b[43m \u001b[49m\u001b[43mquery_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mquery_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 360\u001b[0m \u001b[43m \u001b[49m\u001b[43mrelative_pos\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrelative_pos\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 361\u001b[0m \u001b[43m \u001b[49m\u001b[43mrel_embeddings\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrel_embeddings\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 362\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 363\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m output_attentions:\n\u001b[1;32m 364\u001b[0m attention_output, att_matrix \u001b[38;5;241m=\u001b[39m attention_output\n",
254
+ "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",
255
+ "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",
256
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:286\u001b[0m, in \u001b[0;36mDebertaV2Attention.forward\u001b[0;34m(self, hidden_states, attention_mask, output_attentions, query_states, relative_pos, rel_embeddings)\u001b[0m\n\u001b[1;32m 277\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mforward\u001b[39m(\n\u001b[1;32m 278\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 279\u001b[0m hidden_states,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 284\u001b[0m rel_embeddings\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[1;32m 285\u001b[0m ):\n\u001b[0;32m--> 286\u001b[0m self_output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mself\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 287\u001b[0m \u001b[43m \u001b[49m\u001b[43mhidden_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 288\u001b[0m \u001b[43m \u001b[49m\u001b[43mattention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 289\u001b[0m \u001b[43m \u001b[49m\u001b[43moutput_attentions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 290\u001b[0m \u001b[43m \u001b[49m\u001b[43mquery_states\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mquery_states\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 291\u001b[0m \u001b[43m \u001b[49m\u001b[43mrelative_pos\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrelative_pos\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 292\u001b[0m \u001b[43m \u001b[49m\u001b[43mrel_embeddings\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrel_embeddings\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 293\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 294\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m output_attentions:\n\u001b[1;32m 295\u001b[0m self_output, att_matrix \u001b[38;5;241m=\u001b[39m self_output\n",
257
+ "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",
258
+ "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",
259
+ "File \u001b[0;32m~/opt/anaconda3/envs/huggingface_env/lib/python3.8/site-packages/transformers/models/deberta_v2/modeling_deberta_v2.py:700\u001b[0m, in \u001b[0;36mDisentangledSelfAttention.forward\u001b[0;34m(self, hidden_states, attention_mask, output_attentions, query_states, relative_pos, rel_embeddings)\u001b[0m\n\u001b[1;32m 698\u001b[0m query_states \u001b[38;5;241m=\u001b[39m hidden_states\n\u001b[1;32m 699\u001b[0m query_layer \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtranspose_for_scores(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mquery_proj(query_states), \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnum_attention_heads)\n\u001b[0;32m--> 700\u001b[0m key_layer \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtranspose_for_scores(\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mkey_proj\u001b[49m\u001b[43m(\u001b[49m\u001b[43mhidden_states\u001b[49m\u001b[43m)\u001b[49m, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnum_attention_heads)\n\u001b[1;32m 701\u001b[0m value_layer \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtranspose_for_scores(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mvalue_proj(hidden_states), \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnum_attention_heads)\n\u001b[1;32m 703\u001b[0m rel_att \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n",
260
+ "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",
261
+ "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",
262
+ "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",
263
+ "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
264
  ]
265
  }
266
  ],
267
  "source": [
268
+ "result_list = []\n",
269
+ "performance = pd.DataFrame(columns=['accuracy', 'true_ident', 'false_pred'])\n",
270
+ "\n",
271
+ "start_time = time.time()\n",
272
+ "for i in range(len(trip_descriptions)):\n",
273
+ " current_trip = trip_descriptions[i]\n",
274
+ " current_type = trip_types[i]\n",
275
+ " df = pred_trip(current_trip, current_type, cut_off = 0.5)\n",
276
+ " print(df)\n",
277
+ " \n",
278
+ " # accuracy, perc true classes identified and perc wrong pred classes\n",
279
+ " performance = pd.concat([performance, perf_measure(df)])\n",
280
+ " print(performance)\n",
281
+ " \n",
282
+ " result_list.append(df)"
283
+ ]
284
+ },
285
+ {
286
+ "cell_type": "markdown",
287
+ "id": "b5c08703-7166-4d03-9d6b-ee2c12608134",
288
+ "metadata": {},
289
+ "source": [
290
+ "**Compute average performance measures**"
291
+ ]
292
+ },
293
+ {
294
+ "cell_type": "code",
295
+ "execution_count": null,
296
+ "id": "eb33fd31-94e6-40b5-9c36-a32effe77c01",
297
+ "metadata": {},
298
+ "outputs": [],
299
+ "source": [
300
+ "# Extract \"same_value\" column from each DataFrame\n",
301
+ "sv_columns = [df['same_value'] for df in result_list] # 'same' needs to be changed\n",
302
+ "sv_columns.insert(0, result_list[0]['superclass'])\n",
303
  "\n",
304
+ "# Combine into a new DataFrame (columns side-by-side)\n",
305
+ "sv_df = pd.concat(sv_columns, axis=1)\n",
 
 
 
 
 
 
 
 
 
 
 
 
306
  "\n",
307
+ "print(sv_df)"
308
  ]
309
  },
310
  {
311
  "cell_type": "code",
312
+ "execution_count": null,
313
+ "id": "bf7546cb-79ce-49ad-8cee-54d02239220c",
314
+ "metadata": {},
315
+ "outputs": [],
316
+ "source": [
317
+ "# Compute accuracy per superclass (row means of same_value matrix excluding the first column)\n",
318
+ "row_means = sv_df.iloc[:, 1:].mean(axis=1)\n",
319
+ "\n",
320
+ "df_row_means = pd.DataFrame({\n",
321
+ " 'superclass': sv_df['superclass'],\n",
322
+ " 'accuracy': row_means\n",
323
+ "})\n",
324
+ "\n",
325
+ "print(df_row_means)"
326
+ ]
327
+ },
328
+ {
329
+ "cell_type": "code",
330
+ "execution_count": null,
331
+ "id": "fd232953-59e8-4f28-9ce8-11515a2c310b",
332
  "metadata": {
333
  "scrolled": true
334
  },
335
+ "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
336
  "source": [
337
+ "# Compute performance measures per trip (mean for each column of performance table)\n",
338
+ "column_means = performance.mean()\n",
339
+ "print(column_means)\n",
340
+ "\n",
341
+ "# Plot histograms for all numeric columns\n",
342
+ "performance.hist(bins=10, figsize=(10, 6))\n",
343
+ "plt.tight_layout()\n",
344
+ "plt.show()"
345
  ]
346
  },
347
  {
348
  "cell_type": "code",
349
+ "execution_count": null,
350
+ "id": "bd682c84-3eb1-4a8d-9621-b741e98e4537",
351
  "metadata": {},
352
+ "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
  "source": [
354
+ "# save results\n",
355
+ "# Example data for one model\n",
356
+ "model_name = 'model_MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli'\n",
357
+ "# Structure to save\n",
358
+ "model_result = {\n",
359
+ " 'model': model_name,\n",
360
+ " 'predictions': result_list,\n",
361
+ " 'performance': performance,\n",
362
+ " 'perf_summary': column_means,\n",
363
+ " 'perf_superclass': df_row_means\n",
364
+ "}\n",
365
+ "\n",
366
+ "# File path with folder\n",
367
+ "filename = os.path.join('results', f'{model_name}_results.pkl')\n",
368
+ "\n",
369
+ "# Save the object\n",
370
+ "with open(filename, 'wb') as f:\n",
371
+ " pickle.dump(model_result, f)"
372
  ]
373
  },
374
  {
375
+ "cell_type": "markdown",
376
+ "id": "e1cbb54e-abe6-49b6-957e-0683196f3199",
 
377
  "metadata": {},
 
 
 
 
 
 
 
 
 
378
  "source": [
379
+ "**Load and compare results**"
 
 
 
 
380
  ]
381
  },
382
  {
383
  "cell_type": "code",
384
+ "execution_count": 35,
385
+ "id": "62ca82b0-6909-4e6c-9d2c-fed87971e5b6",
386
  "metadata": {},
387
  "outputs": [
388
  {
389
  "name": "stdout",
390
  "output_type": "stream",
391
  "text": [
392
+ "Model: model_a_facebook-bart-large-mnli\n",
393
+ "Performance Summary:\n",
394
+ "accuracy 0.454545\n",
395
+ "true_ident 0.689394\n",
396
+ "false_pred 0.409091\n",
397
+ "dtype: float64\n",
398
+ "----------------------------------------\n",
399
+ "Model: model_b_sileod-deberta-v3-base-tasksource-nli\n",
400
+ "Performance Summary:\n",
401
+ "accuracy 0.500000\n",
402
+ "true_ident 0.666667\n",
403
+ "false_pred 0.551667\n",
404
+ "dtype: float64\n",
405
+ "----------------------------------------\n",
406
+ "Model: model_a_facebook-bart-large-mnli\n",
407
+ "Performance Summary:\n",
408
+ " superclass accuracy\n",
409
+ "0 activity_type 0.8\n",
410
+ "1 activities 0.0\n",
411
+ "2 climate_or_season 0.6\n",
412
+ "3 style_or_comfort 0.4\n",
413
+ "4 dress_code 0.7\n",
414
+ "5 accommodation 0.3\n",
415
+ "6 transportation 0.8\n",
416
+ "7 special_conditions 0.0\n",
417
+ "8 trip_length_days 0.5\n",
418
+ "----------------------------------------\n",
419
+ "Model: model_b_sileod-deberta-v3-base-tasksource-nli\n",
420
+ "Performance Summary:\n",
421
+ " superclass accuracy\n",
422
+ "0 activity_type 0.7\n",
423
+ "1 activities 0.1\n",
424
+ "2 climate_or_season 0.6\n",
425
+ "3 style_or_comfort 0.4\n",
426
+ "4 dress_code 0.6\n",
427
+ "5 accommodation 0.9\n",
428
+ "6 transportation 0.7\n",
429
+ "7 special_conditions 0.1\n",
430
+ "8 trip_length_days 0.5\n",
431
+ "----------------------------------------\n"
432
  ]
433
  }
434
  ],
435
  "source": [
436
+ "# Folder where your .pkl files are saved\n",
437
+ "results_dir = 'results'\n",
 
438
  "\n",
439
+ "# Dictionary to store all loaded results\n",
440
+ "all_results = {}\n",
441
  "\n",
442
+ "# Loop through all .pkl files in the folder\n",
443
+ "for filename in os.listdir(results_dir):\n",
444
+ " if filename.endswith('.pkl'):\n",
445
+ " model_name = filename.replace('_results.pkl', '') # Extract model name\n",
446
+ " file_path = os.path.join(results_dir, filename)\n",
447
+ " \n",
448
+ " # Load the result\n",
449
+ " with open(file_path, 'rb') as f:\n",
450
+ " result = pickle.load(f)\n",
451
+ " all_results[model_name] = result\n",
452
  "\n",
453
+ "# Now you can compare performance across models\n",
454
+ "for model, data in all_results.items():\n",
455
+ " print(f\"Model: {model}\")\n",
456
+ " print(f\"Performance Summary:\\n{data['perf_summary']}\")\n",
457
+ " print(\"-\" * 40)\n",
458
+ "\n",
459
+ "\n",
460
+ "# Now you can compare performance across models\n",
461
+ "for model, data in all_results.items():\n",
462
+ " print(f\"Model: {model}\")\n",
463
+ " print(f\"Performance Summary:\\n{data['perf_superclass']}\")\n",
464
+ " print(\"-\" * 40)"
465
  ]
466
  },
 
 
 
 
 
 
 
 
467
  {
468
  "cell_type": "markdown",
469
  "id": "17483df4-55c4-41cd-b8a9-61f7a5c7e8a3",
space/space/space/space/space/space/space/space/space/space/space/.DS_Store ADDED
Binary file (6.15 kB). View file
 
space/space/space/space/space/space/space/space/space/space/space/Candidate labels in Word en idee.docx ADDED
Binary file (21.1 kB). View file
 
space/space/space/space/space/space/space/space/space/space/space/gradio_tryout.ipynb CHANGED
@@ -8,59 +8,359 @@
8
  "# Try out gradio"
9
  ]
10
  },
 
 
 
 
 
 
11
  {
12
  "cell_type": "markdown",
13
  "id": "3bbee2e4-55c8-4b06-9929-72026edf7932",
14
  "metadata": {},
15
  "source": [
16
- "Try model"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  ]
18
  },
19
  {
20
  "cell_type": "code",
21
- "execution_count": 1,
22
- "id": "fa0d8126-e346-4412-9197-7d51baf868da",
23
  "metadata": {
24
  "scrolled": true
25
  },
26
  "outputs": [
27
  {
28
- "name": "stderr",
29
  "output_type": "stream",
30
  "text": [
31
- "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",
32
- "You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n",
33
- "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",
34
- "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",
35
- "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"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  ]
37
  },
 
 
 
 
 
 
 
 
 
 
 
 
38
  {
39
  "name": "stdout",
40
  "output_type": "stream",
41
  "text": [
42
- "{'sequence': '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.', 'labels': ['Map', 'Compass', 'Laptop', 'Car charger', 'Toys', 'Travel crib', 'Hat', 'Playlist', 'Stroller', 'Currency', 'Travel adapter', 'Hostel lock', 'Pen', 'Charging cables', 'Flip-flops', 'Pacifier', 'Camping stove', 'Multi-tool', 'Passport', 'Poncho', 'Hiking boots', 'Portable charger', 'Power bank', 'Trekking poles', 'Snowboard', 'Base layers', 'Bandana', 'Aloe vera gel', 'Gloves', 'Baby blanket', 'Tent', 'Tent', 'Snorkel gear', 'Water filter', 'Diapers', 'Presentation materials', 'Nursing cover', 'Headphones', 'Sunscreen', 'Beach towel', 'Snacks', 'Ski jacket', 'Earplugs', 'Ski goggles', 'Flashlight', 'Neck wallet', 'Swimsuit', 'Notebook', 'Thermal clothing', 'Blanket', 'Snow boots', 'Sleeping bag', 'Lightweight backpack', 'Refillable water bottle', 'Quick-dry towel', 'Comfortable shoes', 'Reusable shopping bags', 'Travel journal', 'Travel pillow', 'Beach bag', 'Reusable coffee mug', 'Reusable water bottle', 'Festival tickets', 'Waterproof phone case', 'Business attire', 'Sunglasses', 'Sunglasses', 'Cooler', 'Baby clothes', 'Fanny pack', 'Beanie', 'First aid kit', 'Emergency roadside kit', 'Dry bag', 'SIM card', 'Energy bars', 'Baby food', 'Work ID badge', 'Packable rain jacket', 'Hand warmers', 'Visa documents', 'Glow sticks', 'Bug spray', 'Travel-sized toiletries', 'Dress shoes', 'Language phrasebook', 'Baby wipes', 'Lip balm', 'Travel insurance documents'], 'scores': [0.013028442859649658, 0.012909057550132275, 0.0124660674482584, 0.012431488372385502, 0.012379261665046215, 0.012377972714602947, 0.012329353019595146, 0.012096051126718521, 0.012086767703294754, 0.011947661638259888, 0.011939236894249916, 0.011935302056372166, 0.011887168511748314, 0.011814153753221035, 0.011788924224674702, 0.011783207766711712, 0.01177265401929617, 0.011771135963499546, 0.011747810058295727, 0.011738969013094902, 0.01169698778539896, 0.01166312862187624, 0.011658026836812496, 0.011596457101404667, 0.01158847101032734, 0.011561167426407337, 0.011526867747306824, 0.01149983424693346, 0.011472185142338276, 0.011455104686319828, 0.011445573531091213, 0.011445573531091213, 0.011444379575550556, 0.011416648514568806, 0.01136692427098751, 0.011363024823367596, 0.011361461132764816, 0.011328471824526787, 0.011299548670649529, 0.011291779577732086, 0.011282541789114475, 0.01127372495830059, 0.011270811781287193, 0.011263585649430752, 0.011179029010236263, 0.011149592697620392, 0.01113132108002901, 0.011122703552246094, 0.011105425655841827, 0.011101326905190945, 0.011090466752648354, 0.011066330596804619, 0.011058374308049679, 0.011055233888328075, 0.01103114802390337, 0.011022195219993591, 0.011012199334800243, 0.01100123766809702, 0.010985593311488628, 0.010961917228996754, 0.010958753526210785, 0.010938071645796299, 0.010903625749051571, 0.010879918932914734, 0.010863620787858963, 0.010824359022080898, 0.010824359022080898, 0.010805793106555939, 0.010763236321508884, 0.010710005648434162, 0.010690474882721901, 0.010647830553352833, 0.010583569295704365, 0.010571518912911415, 0.010570857673883438, 0.010552200488746166, 0.0105352271348238, 0.010523369535803795, 0.010514546185731888, 0.010479346849024296, 0.010450395755469799, 0.010436479933559895, 0.01043587177991867, 0.010400519706308842, 0.010214710608124733, 0.010052643716335297, 0.010041419416666031, 0.010003888048231602, 0.009946384467184544]}\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  ]
44
  }
45
  ],
46
  "source": [
 
47
  "from transformers import pipeline\n",
48
  "import gradio as gr\n",
49
  "\n",
50
- "# Load the model and create a pipeline for zero-shot classification\n",
51
- "classifier = pipeline(\"zero-shot-classification\", model=\"facebook/bart-base\")\n",
52
- "\n",
53
- "# Load labels from a txt file\n",
54
- "with open(\"labels.txt\", \"r\", encoding=\"utf-8\") as f:\n",
55
- " class_labels = [line.strip() for line in f if line.strip()]\n",
 
 
 
 
 
 
 
56
  "\n",
57
- "# Example text to classify\n",
58
- "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",
59
  "\n",
60
- "# Perform classification\n",
61
- "result = classifier(input_text, class_labels)\n",
 
 
 
 
 
62
  "\n",
63
- "print(result)"
 
 
64
  ]
65
  },
66
  {
@@ -73,7 +373,7 @@
73
  },
74
  {
75
  "cell_type": "code",
76
- "execution_count": 2,
77
  "id": "521d9118-b59d-4cc6-b637-20202eaf8f33",
78
  "metadata": {
79
  "scrolled": true
@@ -83,15 +383,16 @@
83
  "name": "stdout",
84
  "output_type": "stream",
85
  "text": [
86
- "Running on local URL: http://127.0.0.1:7860\n",
 
87
  "\n",
88
- "To create a public link, set `share=True` in `launch()`.\n"
89
  ]
90
  },
91
  {
92
  "data": {
93
  "text/html": [
94
- "<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>"
95
  ],
96
  "text/plain": [
97
  "<IPython.core.display.HTML object>"
@@ -116,50 +417,16 @@
116
  "\n",
117
  "# Launch the Gradio app\n",
118
  "if __name__ == \"__main__\":\n",
119
- " demo.launch()"
120
- ]
121
- },
122
- {
123
- "cell_type": "markdown",
124
- "id": "d6526d18-6ba6-4a66-8310-21337b832d84",
125
- "metadata": {},
126
- "source": [
127
- "Simple app"
128
  ]
129
  },
130
  {
131
  "cell_type": "code",
132
  "execution_count": null,
133
- "id": "5496ded9-7294-4da4-af05-00e5846cdd04",
134
  "metadata": {},
135
  "outputs": [],
136
- "source": [
137
- "import gradio as gr\n",
138
- "from transformers import pipeline\n",
139
- "\n",
140
- "# Initialize the zero-shot classification pipeline\n",
141
- "classifier = pipeline(\"zero-shot-classification\", model=\"facebook/bart-base\")\n",
142
- "\n",
143
- "# Define the classification function\n",
144
- "def classify_text(text, labels):\n",
145
- " labels = labels.split(\",\") # Convert the comma-separated string into a list\n",
146
- " result = classifier(text, candidate_labels=labels)\n",
147
- " return result\n",
148
- "\n",
149
- "# Set up the Gradio interface\n",
150
- "with gr.Blocks() as demo:\n",
151
- " gr.Markdown(\"# Zero-Shot Classification\")\n",
152
- " text_input = gr.Textbox(label=\"Input Text\")\n",
153
- " label_input = gr.Textbox(label=\"Comma-separated Labels\")\n",
154
- " output = gr.JSON(label=\"Result\")\n",
155
- " classify_button = gr.Button(\"Classify\")\n",
156
- "\n",
157
- " # Link the button to the classification function\n",
158
- " classify_button.click(classify_text, inputs=[text_input, label_input], outputs=output)\n",
159
- "\n",
160
- "# Launch the Gradio interface\n",
161
- "demo.launch()"
162
- ]
163
  }
164
  ],
165
  "metadata": {
 
8
  "# Try out gradio"
9
  ]
10
  },
11
+ {
12
+ "cell_type": "markdown",
13
+ "id": "afd23321-1870-44af-82ed-bb241d055dfa",
14
+ "metadata": {},
15
+ "source": []
16
+ },
17
  {
18
  "cell_type": "markdown",
19
  "id": "3bbee2e4-55c8-4b06-9929-72026edf7932",
20
  "metadata": {},
21
  "source": [
22
+ "**Load and try the model**"
23
+ ]
24
+ },
25
+ {
26
+ "cell_type": "code",
27
+ "execution_count": 16,
28
+ "id": "f8c28d2d-8458-49fd-8ebf-5e729d6e861f",
29
+ "metadata": {},
30
+ "outputs": [
31
+ {
32
+ "name": "stderr",
33
+ "output_type": "stream",
34
+ "text": [
35
+ "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"
36
+ ]
37
+ },
38
+ {
39
+ "name": "stdout",
40
+ "output_type": "stream",
41
+ "text": [
42
+ "First trip: 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",
43
+ "\n",
44
+ "Trip type: ['beach vacation', ['swimming', 'going to the beach', 'relaxing', 'hiking'], 'warm destination / summer', 'lightweight (but comfortable)', 'casual', 'indoor', 'no vehicle', 'no special conditions', '7 days']\n"
45
+ ]
46
+ }
47
+ ],
48
+ "source": [
49
+ "# Prerequisites\n",
50
+ "from tabulate import tabulate\n",
51
+ "from transformers import pipeline\n",
52
+ "import json\n",
53
+ "import pandas as pd\n",
54
+ "\n",
55
+ "# Load the model and create a pipeline for zero-shot classification (1min loading + classifying with 89 labels)\n",
56
+ "classifier = pipeline(\"zero-shot-classification\", model=\"facebook/bart-large-mnli\")\n",
57
+ "\n",
58
+ "# get candidate labels\n",
59
+ "with open(\"packing_label_structure.json\", \"r\") as file:\n",
60
+ " candidate_labels = json.load(file)\n",
61
+ "keys_list = list(candidate_labels.keys())\n",
62
+ "\n",
63
+ "# Load test data (in list of dictionaries)\n",
64
+ "with open(\"test_data.json\", \"r\") as file:\n",
65
+ " packing_data = json.load(file)\n",
66
+ "# Extract all trip descriptions and trip_types\n",
67
+ "trip_descriptions = [trip['description'] for trip in packing_data]\n",
68
+ "trip_types = [trip['trip_types'] for trip in packing_data]\n",
69
+ "\n",
70
+ "# Access the first trip description\n",
71
+ "first_trip = trip_descriptions[0]\n",
72
+ "# Get the packing list for the secondfirst trip\n",
73
+ "first_trip_type = trip_types[0]\n",
74
+ "\n",
75
+ "print(f\"First trip: {first_trip} \\n\")\n",
76
+ "print(f\"Trip type: {first_trip_type}\")"
77
  ]
78
  },
79
  {
80
  "cell_type": "code",
81
+ "execution_count": 37,
82
+ "id": "fed1f8bc-5baf-46e7-8763-9d56fb9c536b",
83
  "metadata": {
84
  "scrolled": true
85
  },
86
  "outputs": [
87
  {
88
+ "name": "stdout",
89
  "output_type": "stream",
90
  "text": [
91
+ "{'sequence': '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.', 'labels': ['beach vacation', 'micro-adventure / weekend trip', 'nature escape', 'digital nomad trip', 'cultural exploration', 'yoga / wellness retreat', 'festival trip', 'long-distance hike / thru-hike', 'hut trek (summer)', 'city trip', 'road trip (car/camper)', 'ski tour / skitour', 'camping trip (campground)', 'snowboard / splitboard trip', 'camping trip (wild camping)', 'hut trek (winter)'], 'scores': [0.37631064653396606, 0.35016775131225586, 0.13397355377674103, 0.031636204570531845, 0.031270742416381836, 0.012846449390053749, 0.012699575163424015, 0.009526746347546577, 0.008148356340825558, 0.007793044205754995, 0.006512156222015619, 0.005669699050486088, 0.0044484627433121204, 0.004113250877708197, 0.002713854657486081, 0.002169555053114891]}\n",
92
+ "beach vacation\n",
93
+ "0\n",
94
+ "{'sequence': '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.', 'labels': ['going to the beach', 'relaxing', 'hiking', 'swimming', 'sightseeing', 'running', 'hut-to-hut hiking', 'biking', 'photography', 'surfing', 'stand-up paddleboarding (SUP)', 'snorkeling', 'yoga', 'kayaking / canoeing', 'rock climbing', 'fishing', 'paragliding', 'rafting', 'horseback riding', 'snowshoe hiking', 'cross-country skiing', 'ice climbing', 'skiing', 'scuba diving', 'ski touring'], 'scores': [0.9914858341217041, 0.9771362543106079, 0.9426282048225403, 0.21901991963386536, 0.17586199939250946, 0.09854521602392197, 0.08370419591665268, 0.03679152950644493, 0.03668990358710289, 0.03099300153553486, 0.025300050154328346, 0.021451234817504883, 0.011070131324231625, 0.0075112744234502316, 0.006306737195700407, 0.0034973458386957645, 0.002655829070135951, 0.00197031581774354, 0.0015599008183926344, 0.001527810120023787, 0.0015017405385151505, 0.0014336870517581701, 0.0011686616344377398, 0.000789369223639369, 0.0004912536824122071]}\n",
95
+ "['going to the beach', 'relaxing', 'hiking']\n",
96
+ "1\n",
97
+ "{'sequence': '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.', 'labels': ['warm destination / summer', 'tropical / humid', 'variable weather / spring / autumn', 'dry / desert-like', 'cold destination / winter'], 'scores': [0.6468702554702759, 0.19999535381793976, 0.09394325315952301, 0.05279730260372162, 0.0063938056118786335]}\n",
98
+ "warm destination / summer\n",
99
+ "2\n",
100
+ "{'sequence': '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.', 'labels': ['minimalist', 'ultralight', 'lightweight (but comfortable)', 'luxury (including evening wear)'], 'scores': [0.4286234974861145, 0.2564568817615509, 0.2147122174501419, 0.10020739585161209]}\n",
101
+ "minimalist\n",
102
+ "3\n",
103
+ "{'sequence': '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.', 'labels': ['casual', 'conservative', 'formal (business trip)'], 'scores': [0.6567223072052002, 0.3034382164478302, 0.039839524775743484]}\n",
104
+ "casual\n",
105
+ "4\n",
106
+ "{'sequence': '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.', 'labels': ['huts with half board', 'indoor', 'sleeping in a car', 'sleeping in a tent'], 'scores': [0.5007699728012085, 0.34074831008911133, 0.10416240990161896, 0.05431929975748062]}\n",
107
+ "huts with half board\n",
108
+ "5\n",
109
+ "{'sequence': '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.', 'labels': ['vehicle', 'no vehicle'], 'scores': [0.7521055936813354, 0.24789436161518097]}\n",
110
+ "vehicle\n",
111
+ "6\n",
112
+ "{'sequence': '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.', 'labels': ['off-grid / no electricity', 'self-supported (bring your own food/cooking)', 'no special conditions', 'pet-friendly', 'rainy climate', 'child-friendly', 'snow and ice', 'high alpine terrain', 'avalanche-prone terrain'], 'scores': [0.46220096945762634, 0.12957870960235596, 0.10651793330907822, 0.09777138382196426, 0.06722460687160492, 0.0632496327161789, 0.04952802509069443, 0.015049820765852928, 0.008878983557224274]}\n",
113
+ "off-grid / no electricity\n",
114
+ "7\n",
115
+ "{'sequence': '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.', 'labels': ['7+ days', '2 days', '1 day', '6 days', '3 days', '4 days', '7 days', '5 days'], 'scores': [0.21139054000377655, 0.18512114882469177, 0.14520084857940674, 0.0976138487458229, 0.094282366335392, 0.09376301616430283, 0.09161651134490967, 0.08101171255111694]}\n",
116
+ "7+ days\n",
117
+ "8\n"
118
+ ]
119
+ }
120
+ ],
121
+ "source": [
122
+ "# Create an empty DataFrame with specified columns\n",
123
+ "df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
124
+ "cutoff = 0.5 # used to choose which activities are relevant\n",
125
+ "\n",
126
+ "# fill DataFrame\n",
127
+ "for i, key in enumerate(keys_list):\n",
128
+ " # Run the classification (ca 30 seconds classifying)\n",
129
+ " if key == 'activities':\n",
130
+ " result = classifier(first_trip, candidate_labels[key], multi_label=True)\n",
131
+ " indices = [i for i, score in enumerate(result['scores']) if score > cutoff]\n",
132
+ " classes = [result['labels'][i] for i in indices]\n",
133
+ " else:\n",
134
+ " result = classifier(first_trip, candidate_labels[key])\n",
135
+ " classes = result[\"labels\"][0]\n",
136
+ " print(result)\n",
137
+ " print(classes)\n",
138
+ " print(i)\n",
139
+ " df.loc[i] = [key, classes]\n",
140
+ "\n",
141
+ "df['true_class'] = first_trip_type"
142
+ ]
143
+ },
144
+ {
145
+ "cell_type": "code",
146
+ "execution_count": 40,
147
+ "id": "b3b51280-76a1-4229-a9de-070b925d3463",
148
+ "metadata": {
149
+ "scrolled": true
150
+ },
151
+ "outputs": [
152
+ {
153
+ "name": "stdout",
154
+ "output_type": "stream",
155
+ "text": [
156
+ " Superclass pred_class true_class\n",
157
+ "0 activity_type beach vacation beach vacation\n",
158
+ "1 activities [going to the beach, relaxing, hiking] [swimming, going to the beach, relaxing, hiking]\n",
159
+ "2 climate_or_season warm destination / summer warm destination / summer\n",
160
+ "3 style_or_comfort minimalist lightweight (but comfortable)\n",
161
+ "4 dress_code casual casual\n",
162
+ "5 accommodation huts with half board indoor\n",
163
+ "6 transportation vehicle no vehicle\n",
164
+ "7 special_conditions off-grid / no electricity no special conditions\n",
165
+ "8 trip_length_days 7+ days 7 days\n"
166
+ ]
167
+ }
168
+ ],
169
+ "source": [
170
+ "pd.set_option('display.width', 1000) \n",
171
+ "pd.set_option('display.max_columns', None)\n",
172
+ "print(df)"
173
+ ]
174
+ },
175
+ {
176
+ "cell_type": "code",
177
+ "execution_count": 42,
178
+ "id": "2ec09e8f-75f5-45b1-b4c0-4fafd685d36b",
179
+ "metadata": {},
180
+ "outputs": [
181
+ {
182
+ "name": "stdout",
183
+ "output_type": "stream",
184
+ "text": [
185
+ " Superclass pred_class true_class same\n",
186
+ "0 activity_type beach vacation beach vacation True\n",
187
+ "1 activities [going to the beach, relaxing, hiking] [swimming, going to the beach, relaxing, hiking] False\n",
188
+ "2 climate_or_season warm destination / summer warm destination / summer True\n",
189
+ "3 style_or_comfort minimalist lightweight (but comfortable) False\n",
190
+ "4 dress_code casual casual True\n",
191
+ "5 accommodation huts with half board indoor False\n",
192
+ "6 transportation vehicle no vehicle False\n",
193
+ "7 special_conditions off-grid / no electricity no special conditions False\n",
194
+ "8 trip_length_days 7+ days 7 days False\n"
195
+ ]
196
+ }
197
+ ],
198
+ "source": [
199
+ "df['same'] = df['pred_class'] == df['true_class']\n",
200
+ "print(df)"
201
+ ]
202
+ },
203
+ {
204
+ "cell_type": "code",
205
+ "execution_count": 62,
206
+ "id": "82ae19c8-8bb7-4f7f-841b-1cb6501a17a7",
207
+ "metadata": {},
208
+ "outputs": [
209
+ {
210
+ "name": "stdout",
211
+ "output_type": "stream",
212
+ "text": [
213
+ "Accuracy (excluding activities): 0.3333333333333333\n"
214
+ ]
215
+ }
216
+ ],
217
+ "source": [
218
+ "# accuracy excluding activities\n",
219
+ "correct = sum(df.loc[df.index != 1, 'same'])\n",
220
+ "total = len(df['same'])\n",
221
+ "accuracy = correct/total\n",
222
+ "print(\"Accuracy (excluding activities):\", accuracy)"
223
+ ]
224
+ },
225
+ {
226
+ "cell_type": "code",
227
+ "execution_count": 64,
228
+ "id": "16c0a3ae-34ac-49a4-b59f-411a6f0ce947",
229
+ "metadata": {},
230
+ "outputs": [
231
+ {
232
+ "name": "stdout",
233
+ "output_type": "stream",
234
+ "text": [
235
+ "Percentage of true classes that were identified: 0.75\n",
236
+ "Percentage of predicted classes that were wrong: 0.0\n"
237
+ ]
238
+ }
239
+ ],
240
+ "source": [
241
+ "pred_class = df.loc[df.index == 1, 'pred_class'].iloc[0]\n",
242
+ "true_class = df.loc[df.index == 1, 'true_class'].iloc[0]\n",
243
+ "correct = [label for label in pred_class if label in true_class]\n",
244
+ "\n",
245
+ "num_correct = len(correct)\n",
246
+ "correct_perc = num_correct/len(true_class)\n",
247
+ "\n",
248
+ "num_pred = len(pred_class)\n",
249
+ "wrong_perc = (num_pred - num_correct)/num_pred\n",
250
+ "\n",
251
+ "print(\"Percentage of true classes that were identified:\", correct_perc)\n",
252
+ "print(\"Percentage of predicted classes that were wrong:\", wrong_perc)"
253
+ ]
254
+ },
255
+ {
256
+ "cell_type": "markdown",
257
+ "id": "62c5c18c-58f4-465c-a188-c57cfa7ffa90",
258
+ "metadata": {},
259
+ "source": [
260
+ "Now do the same for all trips"
261
+ ]
262
+ },
263
+ {
264
+ "cell_type": "code",
265
+ "execution_count": null,
266
+ "id": "e4192b42-f1bc-4fcb-a238-dbdb3df7d699",
267
+ "metadata": {},
268
+ "outputs": [],
269
+ "source": []
270
+ },
271
+ {
272
+ "cell_type": "markdown",
273
+ "id": "17483df4-55c4-41cd-b8a9-61f7a5c7e8a3",
274
+ "metadata": {},
275
+ "source": [
276
+ "**Use gradio for user input**"
277
+ ]
278
+ },
279
+ {
280
+ "cell_type": "code",
281
+ "execution_count": 66,
282
+ "id": "cb7fd425-d0d6-458d-97ca-2150dc55f206",
283
+ "metadata": {},
284
+ "outputs": [
285
+ {
286
+ "name": "stdout",
287
+ "output_type": "stream",
288
+ "text": [
289
+ "Running on local URL: http://127.0.0.1:7861\n",
290
+ "Running on public URL: https://aa06d5d85ffadaa92b.gradio.live\n",
291
+ "\n",
292
+ "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"
293
  ]
294
  },
295
+ {
296
+ "data": {
297
+ "text/html": [
298
+ "<div><iframe src=\"https://aa06d5d85ffadaa92b.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
299
+ ],
300
+ "text/plain": [
301
+ "<IPython.core.display.HTML object>"
302
+ ]
303
+ },
304
+ "metadata": {},
305
+ "output_type": "display_data"
306
+ },
307
  {
308
  "name": "stdout",
309
  "output_type": "stream",
310
  "text": [
311
+ "0\n",
312
+ "1\n",
313
+ "2\n",
314
+ "3\n",
315
+ "4\n",
316
+ "5\n",
317
+ "6\n",
318
+ "7\n",
319
+ "8\n",
320
+ "0\n",
321
+ "1\n",
322
+ "2\n",
323
+ "3\n",
324
+ "4\n",
325
+ "5\n",
326
+ "6\n",
327
+ "7\n",
328
+ "8\n"
329
  ]
330
  }
331
  ],
332
  "source": [
333
+ "# use model with gradio\n",
334
  "from transformers import pipeline\n",
335
  "import gradio as gr\n",
336
  "\n",
337
+ "# make a function for what I am doing\n",
338
+ "def classify(text):\n",
339
+ " df = pd.DataFrame(columns=['Superclass', 'class'])\n",
340
+ " for i, key in enumerate(keys_list):\n",
341
+ " # Run the classification (ca 30 seconds classifying)\n",
342
+ " if key == 'activities':\n",
343
+ " result = classifier(text, candidate_labels[key], multi_label=True)\n",
344
+ " classes = [result['labels'][i] for i in indices]\n",
345
+ " else:\n",
346
+ " result = classifier(text, candidate_labels[key])\n",
347
+ " classes = result[\"labels\"][0]\n",
348
+ " print(i)\n",
349
+ " df.loc[i] = [key, classes]\n",
350
  "\n",
351
+ " return df\n",
 
352
  "\n",
353
+ "demo = gr.Interface(\n",
354
+ " fn=classify,\n",
355
+ " inputs=\"text\",\n",
356
+ " outputs=\"dataframe\",\n",
357
+ " title=\"Zero-Shot Classification\",\n",
358
+ " description=\"Enter a text describing your trip\",\n",
359
+ ")\n",
360
  "\n",
361
+ "# Launch the Gradio app\n",
362
+ "if __name__ == \"__main__\":\n",
363
+ " demo.launch(share=True)"
364
  ]
365
  },
366
  {
 
373
  },
374
  {
375
  "cell_type": "code",
376
+ "execution_count": 4,
377
  "id": "521d9118-b59d-4cc6-b637-20202eaf8f33",
378
  "metadata": {
379
  "scrolled": true
 
383
  "name": "stdout",
384
  "output_type": "stream",
385
  "text": [
386
+ "Running on local URL: http://127.0.0.1:7861\n",
387
+ "Running on public URL: https://0f70ba5369d721cf8f.gradio.live\n",
388
  "\n",
389
+ "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"
390
  ]
391
  },
392
  {
393
  "data": {
394
  "text/html": [
395
+ "<div><iframe src=\"https://0f70ba5369d721cf8f.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
396
  ],
397
  "text/plain": [
398
  "<IPython.core.display.HTML object>"
 
417
  "\n",
418
  "# Launch the Gradio app\n",
419
  "if __name__ == \"__main__\":\n",
420
+ " demo.launch(share=True)"
 
 
 
 
 
 
 
 
421
  ]
422
  },
423
  {
424
  "cell_type": "code",
425
  "execution_count": null,
426
+ "id": "c8da1c90-d3a3-4b08-801c-b3afa17b2633",
427
  "metadata": {},
428
  "outputs": [],
429
+ "source": []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
430
  }
431
  ],
432
  "metadata": {
space/space/space/space/space/space/space/space/space/space/space/packing_label_hierarchical_mapping.json ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "ski touring": {
3
+ "category": "activities",
4
+ "superclass": "winter sport"
5
+ },
6
+ "cross-country skiing": {
7
+ "category": "activities",
8
+ "superclass": "winter sport"
9
+ },
10
+ "skiing": {
11
+ "category": "activities",
12
+ "superclass": "winter sport"
13
+ },
14
+ "snowboard / splitboard trip": {
15
+ "category": "activity_type",
16
+ "superclass": "winter sport"
17
+ },
18
+ "snowshoe hiking": {
19
+ "category": "activities",
20
+ "superclass": "winter sport"
21
+ },
22
+ "ice climbing": {
23
+ "category": "activities",
24
+ "superclass": "winter sport"
25
+ },
26
+ "hiking": {
27
+ "category": "activities",
28
+ "superclass": "outdoor land"
29
+ },
30
+ "hut-to-hut hiking": {
31
+ "category": "activities",
32
+ "superclass": "outdoor land"
33
+ },
34
+ "huttentocht (zomer)": {
35
+ "category": "activity_type",
36
+ "superclass": "outdoor land"
37
+ },
38
+ "huttentocht (winter)": {
39
+ "category": "activity_type",
40
+ "superclass": "winter sport"
41
+ },
42
+ "rock climbing": {
43
+ "category": "activities",
44
+ "superclass": "outdoor land"
45
+ },
46
+ "biking": {
47
+ "category": "activities",
48
+ "superclass": "outdoor land"
49
+ },
50
+ "running": {
51
+ "category": "activities",
52
+ "superclass": "fitness"
53
+ },
54
+ "swimming": {
55
+ "category": "activities",
56
+ "superclass": "water sport"
57
+ },
58
+ "kayaking / canoeing": {
59
+ "category": "activities",
60
+ "superclass": "water sport"
61
+ },
62
+ "stand-up paddleboarding (SUP)": {
63
+ "category": "activities",
64
+ "superclass": "water sport"
65
+ },
66
+ "snorkeling": {
67
+ "category": "activities",
68
+ "superclass": "water sport"
69
+ },
70
+ "scuba diving": {
71
+ "category": "activities",
72
+ "superclass": "water sport"
73
+ },
74
+ "surfing": {
75
+ "category": "activities",
76
+ "superclass": "water sport"
77
+ },
78
+ "fishing": {
79
+ "category": "activities",
80
+ "superclass": "water sport"
81
+ },
82
+ "rafting": {
83
+ "category": "activities",
84
+ "superclass": "water sport"
85
+ },
86
+ "paragliding": {
87
+ "category": "activities",
88
+ "superclass": "adventure sport"
89
+ },
90
+ "horseback riding": {
91
+ "category": "activities",
92
+ "superclass": "outdoor land"
93
+ },
94
+ "photography": {
95
+ "category": "activities",
96
+ "superclass": "leisure"
97
+ },
98
+ "relaxing": {
99
+ "category": "activities",
100
+ "superclass": "leisure"
101
+ },
102
+ "sightseeing": {
103
+ "category": "activities",
104
+ "superclass": "cultural"
105
+ },
106
+ "yoga": {
107
+ "category": "activities",
108
+ "superclass": "wellness"
109
+ },
110
+ "festivaltrip": {
111
+ "category": "activity_type",
112
+ "superclass": "urban / event"
113
+ },
114
+ "stedentrip": {
115
+ "category": "activity_type",
116
+ "superclass": "urban / cultural"
117
+ },
118
+ "roadtrip (auto/camper)": {
119
+ "category": "activity_type",
120
+ "superclass": "travel mode"
121
+ },
122
+ "digitale nomade reis": {
123
+ "category": "activity_type",
124
+ "superclass": "remote work"
125
+ },
126
+ "kampeerreis (wildkamperen)": {
127
+ "category": "activity_type",
128
+ "superclass": "outdoor overnight"
129
+ },
130
+ "kampeerreis (camping)": {
131
+ "category": "activity_type",
132
+ "superclass": "outdoor overnight"
133
+ },
134
+ "langeafstandswandeling / thru-hike": {
135
+ "category": "activity_type",
136
+ "superclass": "backpacking"
137
+ },
138
+ "microavontuur / weekendtrip": {
139
+ "category": "activity_type",
140
+ "superclass": "short trip"
141
+ },
142
+ "yoga / wellness retreat": {
143
+ "category": "activity_type",
144
+ "superclass": "wellness"
145
+ },
146
+ "strandvakantie": {
147
+ "category": "activity_type",
148
+ "superclass": "beach / leisure"
149
+ },
150
+ "warme bestemming / zomer": {
151
+ "category": "climate_or_season",
152
+ "superclass": "warm"
153
+ },
154
+ "koude bestemming / winter": {
155
+ "category": "climate_or_season",
156
+ "superclass": "cold"
157
+ },
158
+ "wisselvallig / lente / herfst": {
159
+ "category": "climate_or_season",
160
+ "superclass": "mild"
161
+ },
162
+ "tropisch / vochtig": {
163
+ "category": "climate_or_season",
164
+ "superclass": "humid"
165
+ },
166
+ "droog / woestijnachtig": {
167
+ "category": "climate_or_season",
168
+ "superclass": "dry"
169
+ },
170
+ "ultralight": {
171
+ "category": "style_or_comfort",
172
+ "superclass": "packing style"
173
+ },
174
+ "lichtgewicht (maar comfortabel)": {
175
+ "category": "style_or_comfort",
176
+ "superclass": "packing style"
177
+ },
178
+ "luxe (inclusief avondkleding)": {
179
+ "category": "style_or_comfort",
180
+ "superclass": "comfort / luxury"
181
+ },
182
+ "casual": {
183
+ "category": "dress_code",
184
+ "superclass": "informal"
185
+ },
186
+ "formeel (zakelijke reis)": {
187
+ "category": "dress_code",
188
+ "superclass": "formal"
189
+ },
190
+ "conservative": {
191
+ "category": "dress_code",
192
+ "superclass": "cultural"
193
+ },
194
+ "minimalistisch": {
195
+ "category": "style_or_comfort",
196
+ "superclass": "packing style"
197
+ },
198
+ "off-grid / geen stroom": {
199
+ "category": "special_conditions",
200
+ "superclass": "independent"
201
+ },
202
+ "self-supported (eten/koken zelf meenemen)": {
203
+ "category": "special_conditions",
204
+ "superclass": "independent"
205
+ },
206
+ "regenachtig klimaat": {
207
+ "category": "special_conditions",
208
+ "superclass": "weather"
209
+ },
210
+ "sneeuw en ijs": {
211
+ "category": "special_conditions",
212
+ "superclass": "weather"
213
+ },
214
+ "hoog alpine terrein": {
215
+ "category": "special_conditions",
216
+ "superclass": "terrain"
217
+ },
218
+ "lawinegevoelig terrein": {
219
+ "category": "special_conditions",
220
+ "superclass": "terrain"
221
+ },
222
+ "hutten met halfpension": {
223
+ "category": "accommodation",
224
+ "superclass": "type"
225
+ },
226
+ "slapen in tent": {
227
+ "category": "accommodation",
228
+ "superclass": "type"
229
+ },
230
+ "slapen in auto": {
231
+ "category": "accommodation",
232
+ "superclass": "type"
233
+ },
234
+ "kindvriendelijk": {
235
+ "category": "special_conditions",
236
+ "superclass": "target group"
237
+ },
238
+ "huisdiervriendelijk": {
239
+ "category": "special_conditions",
240
+ "superclass": "target group"
241
+ },
242
+ "accommodation: outdoor": {
243
+ "category": "accommodation",
244
+ "superclass": "type"
245
+ },
246
+ "accommodation: indoor": {
247
+ "category": "accommodation",
248
+ "superclass": "type"
249
+ },
250
+ "transportation: vehicle": {
251
+ "category": "transportation",
252
+ "superclass": "mode"
253
+ },
254
+ "transportation: no vehicle": {
255
+ "category": "transportation",
256
+ "superclass": "mode"
257
+ },
258
+ "1 day": {
259
+ "category": "trip_length_days",
260
+ "superclass": "duration"
261
+ },
262
+ "2 days": {
263
+ "category": "trip_length_days",
264
+ "superclass": "duration"
265
+ },
266
+ "3 days": {
267
+ "category": "trip_length_days",
268
+ "superclass": "duration"
269
+ },
270
+ "4 days": {
271
+ "category": "trip_length_days",
272
+ "superclass": "duration"
273
+ },
274
+ "5 days": {
275
+ "category": "trip_length_days",
276
+ "superclass": "duration"
277
+ },
278
+ "6 days": {
279
+ "category": "trip_length_days",
280
+ "superclass": "duration"
281
+ },
282
+ "7 days": {
283
+ "category": "trip_length_days",
284
+ "superclass": "duration"
285
+ },
286
+ "7+ days": {
287
+ "category": "trip_length_days",
288
+ "superclass": "duration"
289
+ }
290
+ }