File size: 77,018 Bytes
6e82d28
 
 
 
 
 
 
04cc170
6e82d28
 
 
 
 
 
 
 
 
 
 
 
dca931a
6e82d28
 
 
 
04cc170
6e82d28
 
 
 
04cc170
 
 
 
6e82d28
04cc170
6e82d28
 
 
 
04cc170
6e82d28
 
04cc170
6e82d28
04cc170
6e82d28
 
 
 
 
 
 
 
 
 
 
 
7be2c11
6e82d28
 
7be2c11
6e82d28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7be2c11
6e82d28
 
7be2c11
 
6e82d28
7be2c11
6e82d28
 
 
 
 
 
dca931a
6e82d28
 
 
 
 
 
dca931a
6e82d28
 
 
 
 
 
 
 
dca931a
6e82d28
 
dca931a
6e82d28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
04cc170
6e82d28
 
 
 
04cc170
 
 
 
 
 
 
 
 
6e82d28
04cc170
 
 
 
6e82d28
 
 
04cc170
6e82d28
 
 
 
 
 
 
 
 
 
 
 
 
 
04cc170
6e82d28
 
 
 
 
04cc170
 
 
 
 
 
 
 
 
 
 
 
 
6e82d28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7be2c11
 
 
 
 
 
 
 
 
 
 
 
a8586cd
7be2c11
 
 
 
 
6e82d28
 
 
 
 
a8586cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e82d28
 
 
 
 
 
 
 
 
 
a8586cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e82d28
 
 
 
 
7bc1042
 
6e82d28
 
 
04cc170
6e82d28
 
04cc170
6e82d28
 
 
 
 
7bc1042
 
 
 
 
 
a8586cd
 
7bc1042
a8586cd
7bc1042
 
 
 
 
 
 
6e82d28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
04cc170
 
 
6e82d28
 
04cc170
6e82d28
 
 
 
 
 
 
04cc170
6e82d28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7bc1042
7be2c11
 
 
 
 
 
 
 
 
6e82d28
 
7be2c11
 
 
 
6e82d28
 
 
7be2c11
 
 
 
6e82d28
 
 
7be2c11
 
 
 
6e82d28
 
 
7be2c11
 
 
 
6e82d28
 
 
7be2c11
 
 
 
6e82d28
 
 
7be2c11
 
 
 
6e82d28
a8586cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e82d28
 
7be2c11
 
 
 
6e82d28
 
 
7be2c11
 
 
 
6e82d28
 
 
7be2c11
 
 
 
6e82d28
 
 
 
 
 
7be2c11
6e82d28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7be2c11
6e82d28
 
a8586cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e82d28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a8586cd
6e82d28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7be2c11
6e82d28
 
 
7be2c11
6e82d28
a8586cd
 
 
 
 
 
6e82d28
 
 
 
 
 
 
 
 
 
 
04cc170
 
6e82d28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a8586cd
6e82d28
7be2c11
 
 
6e82d28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7be2c11
 
 
 
 
 
 
 
 
 
 
 
6e82d28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a8586cd
6e82d28
 
 
 
 
 
 
 
 
 
 
 
 
7be2c11
6e82d28
 
 
 
 
a8586cd
 
 
 
 
 
6e82d28
 
7be2c11
6e82d28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a8586cd
6e82d28
 
 
 
 
 
 
7bc1042
6e82d28
 
 
 
 
 
 
 
 
 
 
a8586cd
6e82d28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7bc1042
6e82d28
04cc170
 
 
6e82d28
 
 
 
 
a8586cd
 
 
 
 
 
 
 
 
 
 
 
 
6e82d28
 
 
 
a8586cd
 
 
7be2c11
a8586cd
6e82d28
7be2c11
 
7bc1042
 
7be2c11
 
 
a8586cd
 
 
6e82d28
a8586cd
7be2c11
 
6e82d28
a8586cd
6e82d28
 
7be2c11
 
04cc170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7be2c11
 
 
04cc170
 
 
 
 
 
 
7be2c11
 
 
 
04cc170
 
 
 
 
 
 
 
 
 
7be2c11
 
 
 
04cc170
 
 
 
7be2c11
 
6e82d28
 
 
 
 
 
 
 
 
 
8b6417b
7be2c11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
04cc170
 
 
 
7be2c11
 
 
 
8b6417b
7be2c11
6e82d28
 
 
 
 
 
8b6417b
6e82d28
04712b6
6e82d28
 
 
 
 
8b6417b
6e82d28
 
 
 
 
 
 
4c6440f
 
 
 
 
 
 
6e82d28
 
 
7be2c11
04cc170
7be2c11
04cc170
7be2c11
6e82d28
 
7be2c11
 
6e82d28
 
7be2c11
6e82d28
 
04cc170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e82d28
 
 
7be2c11
8b6417b
7be2c11
 
 
04cc170
 
7be2c11
6e82d28
 
 
 
 
04cc170
6e82d28
04cc170
 
 
 
 
dca931a
 
 
04cc170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dca931a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
04cc170
 
 
94e04ae
04cc170
 
 
6e82d28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e25090fa-f990-4f1a-84f3-b12159eedae8",
   "metadata": {},
   "source": [
    "# Working with a Large Language Model (LLM)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3bbee2e4-55c8-4b06-9929-72026edf7932",
   "metadata": {},
   "source": [
    "## Prerequisites"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f8c28d2d-8458-49fd-8ebf-5e729d6e861f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import math\n",
    "import json\n",
    "import pickle\n",
    "import os\n",
    "import time\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "from tabulate import tabulate\n",
    "from transformers import pipeline\n",
    "\n",
    "# Get candidate labels\n",
    "with open(\"packing_label_structure.json\", \"r\") as file:\n",
    "    candidate_labels = json.load(file)\n",
    "keys_list = list(candidate_labels.keys())\n",
    "\n",
    "# Load test data (list of dictionaries)\n",
    "with open(\"test_data.json\", \"r\") as file:\n",
    "    packing_data = json.load(file)\n",
    "# Extract trip descriptions and classification (trip_types)\n",
    "trip_descriptions = [trip['description'] for trip in packing_data]\n",
    "trip_types = [trip['trip_types'] for trip in packing_data]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5cf4f76f-0035-44e8-93af-52eafaec686e",
   "metadata": {},
   "source": [
    "**All trip descriptions**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "89d42ca7-e871-4eda-b428-69e9bd965428",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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",
      "\n",
      "beach vacation\n",
      "['swimming', 'going to the beach', 'relaxing', 'hiking']\n",
      "warm destination / summer\n",
      "lightweight (but comfortable)\n",
      "casual\n",
      "indoor\n",
      "no own vehicle\n",
      "no special conditions to consider\n",
      "7+ days\n",
      "\n",
      "\n",
      "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",
      "\n",
      "city trip\n",
      "['sightseeing']\n",
      "variable weather / spring / autumn\n",
      "luxury (including evening wear)\n",
      "casual\n",
      "indoor\n",
      "no own vehicle\n",
      "no special conditions to consider\n",
      "3 days\n",
      "\n",
      "\n",
      "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",
      "\n",
      "city trip\n",
      "['relaxing']\n",
      "cold destination / winter\n",
      "lightweight (but comfortable)\n",
      "casual\n",
      "indoor\n",
      "no own vehicle\n",
      "no special conditions to consider\n",
      "7+ days\n",
      "\n",
      "\n",
      "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",
      "\n",
      "cultural exploration\n",
      "['sightseeing', 'hiking', 'rafting']\n",
      "variable weather / spring / autumn\n",
      "lightweight (but comfortable)\n",
      "casual\n",
      "indoor\n",
      "no own vehicle\n",
      "rainy climate\n",
      "7+ days\n",
      "\n",
      "\n",
      "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",
      "\n",
      "nature escape\n",
      "['swimming', 'relaxing', 'hiking']\n",
      "warm destination / summer\n",
      "lightweight (but comfortable)\n",
      "casual\n",
      "indoor\n",
      "no own vehicle\n",
      "no special conditions to consider\n",
      "7+ days\n",
      "\n",
      "\n",
      "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",
      "\n",
      "long-distance hike / thru-hike\n",
      "['going to the beach']\n",
      "tropical / humid\n",
      "minimalist\n",
      "casual\n",
      "huts with half board\n",
      "own vehicle\n",
      "off-grid / no electricity\n",
      "6 days\n",
      "\n",
      "\n",
      "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",
      "\n",
      "beach vacation\n",
      "['stand-up paddleboarding (SUP)', 'surfing']\n",
      "cold destination / winter\n",
      "ultralight\n",
      "casual\n",
      "sleeping in a tent\n",
      "own vehicle\n",
      "off-grid / no electricity\n",
      "6 days\n",
      "\n",
      "\n",
      "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",
      "\n",
      "yoga / wellness retreat\n",
      "['hiking', 'yoga']\n",
      "cold destination / winter\n",
      "lightweight (but comfortable)\n",
      "casual\n",
      "indoor\n",
      "no own vehicle\n",
      "snow and ice\n",
      "7 days\n",
      "\n",
      "\n",
      "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",
      "\n",
      "ski tour / skitour\n",
      "['ski touring', 'photography']\n",
      "cold destination / winter\n",
      "minimalist\n",
      "conservative\n",
      "indoor\n",
      "no own vehicle\n",
      "avalanche-prone terrain\n",
      "7+ days\n",
      "\n",
      "\n",
      "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",
      "\n",
      "camping trip (wild camping)\n",
      "['scuba diving', 'kayaking / canoeing']\n",
      "tropical / humid\n",
      "lightweight (but comfortable)\n",
      "casual\n",
      "sleeping in a tent\n",
      "own vehicle\n",
      "self-supported (bring your own cooking gear)\n",
      "3 days\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for i, item in enumerate(trip_descriptions):\n",
    "    print(i, \".\", item, \"\\n\")\n",
    "    for elem in trip_types[i]:\n",
    "        print(elem)\n",
    "    print(\"\\n\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0f60c54b-affc-4d9a-acf1-da70f68c5578",
   "metadata": {},
   "source": [
    "**Functions**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "fac51224-9575-4b4b-8567-4ad4e759ecc9",
   "metadata": {},
   "outputs": [],
   "source": [
    "def pred_trip(model_name, trip_descr, trip_type, cut_off = 0.5):\n",
    "    \"\"\"\n",
    "    Classifies trip\n",
    "    \n",
    "    Parameters:\n",
    "    model_name: name of hugging-face model\n",
    "    trip_descr: text describing the trip\n",
    "    trip_type: true trip classification\n",
    "    cut_off: cut_off for choosing activities\n",
    "\n",
    "    Returns:\n",
    "    pd Dataframe: with class predictions and true values\n",
    "    \"\"\"\n",
    "    \n",
    "    classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
    "    df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
    "    for i, key in enumerate(keys_list):\n",
    "        print(i)\n",
    "        if key == 'activities':\n",
    "            result = classifier(trip_descr, candidate_labels[key], multi_label=True)\n",
    "            indices = [i for i, score in enumerate(result['scores']) if score > cut_off]\n",
    "            classes = [result['labels'][i] for i in indices]\n",
    "        else:\n",
    "            result = classifier(trip_descr, candidate_labels[key])\n",
    "            classes = result[\"labels\"][0]\n",
    "        df.loc[i] = [key, classes]\n",
    "    df['true_class'] = trip_type\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "b36ab806-2f35-4950-ac5a-7c192190cba7",
   "metadata": {},
   "outputs": [],
   "source": [
    "def perf_measure(df):\n",
    "    \"\"\"\n",
    "    Calculates performance measures:\n",
    "    Accuracy of classification excluding activities superclass\n",
    "    Percentage of correctly identified activities (#correctly predicted/#true activities)\n",
    "    Percentage of wrongly identified activities (#wrongly predicted/#predicted activities)\n",
    "\n",
    "    Parameters:\n",
    "    df: pd Dataframe returned from pred_trip()\n",
    "\n",
    "    Returns:\n",
    "    pd Dataframe: containing performance measures\n",
    "    \"\"\"\n",
    "    \n",
    "    df['same_value'] = df['pred_class'] == df['true_class']\n",
    "    correct = sum(df.loc[df.index != 1, 'same_value'])\n",
    "    total = len(df['same_value'])\n",
    "    accuracy = correct/total\n",
    "    pred_class = df.loc[df.index == 1, 'pred_class'].iloc[0]\n",
    "    true_class = df.loc[df.index == 1, 'true_class'].iloc[0]\n",
    "    correct = [label for label in pred_class if label in true_class]\n",
    "    num_correct = len(correct)\n",
    "    correct_perc = num_correct/len(true_class)\n",
    "    num_pred = len(pred_class)\n",
    "    if num_pred == 0:\n",
    "        wrong_perc = math.nan\n",
    "    else:\n",
    "        wrong_perc = (num_pred - num_correct)/num_pred\n",
    "    df_perf = pd.DataFrame({\n",
    "    'accuracy': [accuracy],\n",
    "    'true_ident': [correct_perc],\n",
    "    'false_pred': [wrong_perc]\n",
    "    })\n",
    "    return(df_perf)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c10aa57d-d7ed-45c7-bdf5-29af193c7fd5",
   "metadata": {},
   "source": [
    "## Make predictions for many models and trip descriptions\n",
    "\n",
    "Provide a list of candidate models and apply them to the test data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "dd7869a8-b436-40de-9ea0-28eb4b7d3248",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Using model: pongjin/roberta_with_kornli\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "a44415d353264dda885031d6570e21a7",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "config.json:   0%|          | 0.00/985 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "d31b49452fe64db39745a833a832a340",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "pytorch_model.bin:   0%|          | 0.00/443M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "a4c31853bc854b8d91dca8689b7cdc18",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "tokenizer_config.json:   0%|          | 0.00/415 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "048df7d028224b5bb36b5b8042c8579b",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "vocab.txt: 0.00B [00:00, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "b9a39be1b8024e27aee465f0253c8274",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "tokenizer.json: 0.00B [00:00, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "c4170138359149728e468730ee237f8e",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "special_tokens_map.json:   0%|          | 0.00/173 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "\n",
      "Using model: MoritzLaurer/mDeBERTa-v3-base-xnli-multilingual-nli-2mil7\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "c1b011a630894a23b58f4a88e97a849d",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "config.json: 0.00B [00:00, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "5fa889524f9c439d9bbd79426e2eefa6",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "model.safetensors:   0%|          | 0.00/558M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Error while downloading from https://cas-bridge.xethub.hf.co/xet-bridge-us/6303b5f71dd5d3c62482f3e9/11250a388e769f8d819bc3d9b55590ab43bde78b2d4f37df57bc5603c5dea0b0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cas%2F20251104%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20251104T105145Z&X-Amz-Expires=3600&X-Amz-Signature=603bdf8dd3ba17470e9f30bd3b31141b09a02d57e6cf00b63996b798d985c323&X-Amz-SignedHeaders=host&X-Xet-Cas-Uid=public&response-content-disposition=inline%3B+filename*%3DUTF-8%27%27model.safetensors%3B+filename%3D%22model.safetensors%22%3B&x-id=GetObject&Expires=1762257105&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTc2MjI1NzEwNX19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2FzLWJyaWRnZS54ZXRodWIuaGYuY28veGV0LWJyaWRnZS11cy82MzAzYjVmNzFkZDVkM2M2MjQ4MmYzZTkvMTEyNTBhMzg4ZTc2OWY4ZDgxOWJjM2Q5YjU1NTkwYWI0M2JkZTc4YjJkNGYzN2RmNTdiYzU2MDNjNWRlYTBiMCoifV19&Signature=s7MbLznU9vhypkS2WueXkH%7E41QifR0qWT8YHXKdMNPheh483kMtmwoaCCqvVlcukJygS0K2zvyynfo8zpNM%7EqiH8ZI1k3E7B2f6UH97HlJA48Th3pabY4zi1WYI2IeZDnBdPlreb3qTCkCZw1l11fyt9ri2QOaxuRrT6jcxPOquIFzz5lZ0sZNjngA0rg8gtCGi89qsWATMV3Oh45cRpO%7E6DrmmHfP8LEk8sZOiu9Zi-33x-ZoO4oayJSvzxOw8y8TWs%7E5q3cD9geNVIToO-PJPHQJ6qk9FybNeN75zhWtBtERN77Ie2mf9mGEcnZVqBd%7EH4kyAyYsWUcwviGjJSxA__&Key-Pair-Id=K2L8F4GPSG1IFC: HTTPSConnectionPool(host='cas-bridge.xethub.hf.co', port=443): Read timed out.\n",
      "Trying to resume download...\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "137e0628b2464c4ba34304ff81db5cc3",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "model.safetensors:  26%|##6       | 147M/558M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Error while downloading from https://cas-bridge.xethub.hf.co/xet-bridge-us/6303b5f71dd5d3c62482f3e9/11250a388e769f8d819bc3d9b55590ab43bde78b2d4f37df57bc5603c5dea0b0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cas%2F20251104%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20251104T105145Z&X-Amz-Expires=3600&X-Amz-Signature=603bdf8dd3ba17470e9f30bd3b31141b09a02d57e6cf00b63996b798d985c323&X-Amz-SignedHeaders=host&X-Xet-Cas-Uid=public&response-content-disposition=inline%3B+filename*%3DUTF-8%27%27model.safetensors%3B+filename%3D%22model.safetensors%22%3B&x-id=GetObject&Expires=1762257105&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTc2MjI1NzEwNX19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2FzLWJyaWRnZS54ZXRodWIuaGYuY28veGV0LWJyaWRnZS11cy82MzAzYjVmNzFkZDVkM2M2MjQ4MmYzZTkvMTEyNTBhMzg4ZTc2OWY4ZDgxOWJjM2Q5YjU1NTkwYWI0M2JkZTc4YjJkNGYzN2RmNTdiYzU2MDNjNWRlYTBiMCoifV19&Signature=s7MbLznU9vhypkS2WueXkH%7E41QifR0qWT8YHXKdMNPheh483kMtmwoaCCqvVlcukJygS0K2zvyynfo8zpNM%7EqiH8ZI1k3E7B2f6UH97HlJA48Th3pabY4zi1WYI2IeZDnBdPlreb3qTCkCZw1l11fyt9ri2QOaxuRrT6jcxPOquIFzz5lZ0sZNjngA0rg8gtCGi89qsWATMV3Oh45cRpO%7E6DrmmHfP8LEk8sZOiu9Zi-33x-ZoO4oayJSvzxOw8y8TWs%7E5q3cD9geNVIToO-PJPHQJ6qk9FybNeN75zhWtBtERN77Ie2mf9mGEcnZVqBd%7EH4kyAyYsWUcwviGjJSxA__&Key-Pair-Id=K2L8F4GPSG1IFC: HTTPSConnectionPool(host='cas-bridge.xethub.hf.co', port=443): Read timed out.\n",
      "Trying to resume download...\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "9a7e7a8614d14b789f54c4e61b526bf8",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "model.safetensors:  26%|##6       | 147M/558M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Error while downloading from https://cas-bridge.xethub.hf.co/xet-bridge-us/6303b5f71dd5d3c62482f3e9/11250a388e769f8d819bc3d9b55590ab43bde78b2d4f37df57bc5603c5dea0b0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cas%2F20251104%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20251104T105145Z&X-Amz-Expires=3600&X-Amz-Signature=603bdf8dd3ba17470e9f30bd3b31141b09a02d57e6cf00b63996b798d985c323&X-Amz-SignedHeaders=host&X-Xet-Cas-Uid=public&response-content-disposition=inline%3B+filename*%3DUTF-8%27%27model.safetensors%3B+filename%3D%22model.safetensors%22%3B&x-id=GetObject&Expires=1762257105&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTc2MjI1NzEwNX19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2FzLWJyaWRnZS54ZXRodWIuaGYuY28veGV0LWJyaWRnZS11cy82MzAzYjVmNzFkZDVkM2M2MjQ4MmYzZTkvMTEyNTBhMzg4ZTc2OWY4ZDgxOWJjM2Q5YjU1NTkwYWI0M2JkZTc4YjJkNGYzN2RmNTdiYzU2MDNjNWRlYTBiMCoifV19&Signature=s7MbLznU9vhypkS2WueXkH%7E41QifR0qWT8YHXKdMNPheh483kMtmwoaCCqvVlcukJygS0K2zvyynfo8zpNM%7EqiH8ZI1k3E7B2f6UH97HlJA48Th3pabY4zi1WYI2IeZDnBdPlreb3qTCkCZw1l11fyt9ri2QOaxuRrT6jcxPOquIFzz5lZ0sZNjngA0rg8gtCGi89qsWATMV3Oh45cRpO%7E6DrmmHfP8LEk8sZOiu9Zi-33x-ZoO4oayJSvzxOw8y8TWs%7E5q3cD9geNVIToO-PJPHQJ6qk9FybNeN75zhWtBtERN77Ie2mf9mGEcnZVqBd%7EH4kyAyYsWUcwviGjJSxA__&Key-Pair-Id=K2L8F4GPSG1IFC: HTTPSConnectionPool(host='cas-bridge.xethub.hf.co', port=443): Read timed out.\n",
      "Trying to resume download...\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "517575609add45b3a2494deae2cdacc3",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "model.safetensors:  26%|##6       | 147M/558M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Error while downloading from https://cas-bridge.xethub.hf.co/xet-bridge-us/6303b5f71dd5d3c62482f3e9/11250a388e769f8d819bc3d9b55590ab43bde78b2d4f37df57bc5603c5dea0b0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cas%2F20251104%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20251104T105145Z&X-Amz-Expires=3600&X-Amz-Signature=603bdf8dd3ba17470e9f30bd3b31141b09a02d57e6cf00b63996b798d985c323&X-Amz-SignedHeaders=host&X-Xet-Cas-Uid=public&response-content-disposition=inline%3B+filename*%3DUTF-8%27%27model.safetensors%3B+filename%3D%22model.safetensors%22%3B&x-id=GetObject&Expires=1762257105&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTc2MjI1NzEwNX19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2FzLWJyaWRnZS54ZXRodWIuaGYuY28veGV0LWJyaWRnZS11cy82MzAzYjVmNzFkZDVkM2M2MjQ4MmYzZTkvMTEyNTBhMzg4ZTc2OWY4ZDgxOWJjM2Q5YjU1NTkwYWI0M2JkZTc4YjJkNGYzN2RmNTdiYzU2MDNjNWRlYTBiMCoifV19&Signature=s7MbLznU9vhypkS2WueXkH%7E41QifR0qWT8YHXKdMNPheh483kMtmwoaCCqvVlcukJygS0K2zvyynfo8zpNM%7EqiH8ZI1k3E7B2f6UH97HlJA48Th3pabY4zi1WYI2IeZDnBdPlreb3qTCkCZw1l11fyt9ri2QOaxuRrT6jcxPOquIFzz5lZ0sZNjngA0rg8gtCGi89qsWATMV3Oh45cRpO%7E6DrmmHfP8LEk8sZOiu9Zi-33x-ZoO4oayJSvzxOw8y8TWs%7E5q3cD9geNVIToO-PJPHQJ6qk9FybNeN75zhWtBtERN77Ie2mf9mGEcnZVqBd%7EH4kyAyYsWUcwviGjJSxA__&Key-Pair-Id=K2L8F4GPSG1IFC: HTTPSConnectionPool(host='cas-bridge.xethub.hf.co', port=443): Read timed out.\n",
      "Trying to resume download...\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "91efbf29652b4f77be230c371d1a515b",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "model.safetensors:  26%|##6       | 147M/558M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "b57255653a394073ad9f6a10ae142d31",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "tokenizer_config.json:   0%|          | 0.00/467 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "4269962d819c4a06a6fd38069293eef2",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "spm.model:   0%|          | 0.00/4.31M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "d209ea62c4bb421ebe01856271b32bf5",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "tokenizer.json:   0%|          | 0.00/16.3M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "574f0405e8c2410d9659b60b263dab81",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "added_tokens.json:   0%|          | 0.00/23.0 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "09d43e8d85214c0096ff7836934d23ac",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "special_tokens_map.json:   0%|          | 0.00/173 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n"
     ]
    }
   ],
   "source": [
    "# List of Hugging Face model names\n",
    "# trending...\n",
    "\"\"\"\n",
    "model_names = [\n",
    "    \"facebook/bart-large-mnli\",\n",
    "    \"MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli\",\n",
    "    \"cross-encoder/nli-deberta-v3-base\",\n",
    "    \"cross-encoder/nli-deberta-v3-large\",\n",
    "    \"MoritzLaurer/mDeBERTa-v3-base-mnli-xnli\",\n",
    "    \"joeddav/bart-large-mnli-yahoo-answers\",\n",
    "    \"MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli\",\n",
    "    \"MoritzLaurer/deberta-v3-large-zeroshot-v2.0\",\n",
    "    \"valhalla/distilbart-mnli-12-1\",\n",
    "    #\"joeddav/xlm-roberta-large-xnli\" # keeps giving errors\n",
    "]\n",
    "\"\"\"\n",
    "\n",
    "# most downloads\n",
    "model_names = [\n",
    "    #\"facebook/bart-large-mnli\",\n",
    "    #\"MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli\",\n",
    "    #\"sileod/deberta-v3-base-tasksource-nli\",\n",
    "    #\"vicgalle/xlm-roberta-large-xnli-anli\", # gives errors\n",
    "    #\"joeddav/xlm-roberta-large-xnli\",# errors\n",
    "    #\"chuhac/BiomedCLIP-vit-bert-hf\",# errors\n",
    "    \"pongjin/roberta_with_kornli\",\n",
    "    #\"joeddav/bart-large-mnli-yahoo-answers\",\n",
    "    #\"MoritzLaurer/mDeBERTa-v3-base-mnli-xnli\",\n",
    "    #\"valhalla/distilbart-mnli-12-1\",\n",
    "    \"MoritzLaurer/mDeBERTa-v3-base-xnli-multilingual-nli-2mil7\"\n",
    "]\n",
    "\n",
    "\n",
    "# Apply each model to the test data\n",
    "for model_name in model_names:\n",
    "    print(f\"\\nUsing model: {model_name}\")\n",
    "    result_list = []\n",
    "    performance = pd.DataFrame(columns=['accuracy', 'true_ident', 'false_pred'])\n",
    "    \n",
    "    start_time = time.time()\n",
    "    for i in range(len(trip_descriptions)):\n",
    "        current_trip = trip_descriptions[i]\n",
    "        current_type = trip_types[i]\n",
    "        df = pred_trip(model_name, current_trip, current_type, cut_off = 0.5)\n",
    "        performance = pd.concat([performance, perf_measure(df)])\n",
    "        result_list.append(df)\n",
    "    end_time = time.time()\n",
    "    elapsed_time = end_time - start_time\n",
    "    \n",
    "    # Extract and combine columns identifying correct prediction (for each trip)\n",
    "    sv_columns = [df['same_value'] for df in result_list]\n",
    "    sv_columns.insert(0, result_list[0]['superclass'])\n",
    "    sv_df = pd.concat(sv_columns, axis=1)\n",
    "    # Compute accuracy per superclass\n",
    "    row_means = sv_df.iloc[:, 1:].mean(axis=1)\n",
    "    df_row_means = pd.DataFrame({\n",
    "        'superclass': sv_df['superclass'],\n",
    "        'accuracy': row_means\n",
    "    })\n",
    "    # Compute performance measures per trip (mean for each column of performance table)\n",
    "    column_means = performance.mean()\n",
    "    # Save results\n",
    "    model = model_name.replace(\"/\", \"-\")\n",
    "    model_result = {\n",
    "        'model': model,\n",
    "        'predictions': result_list,\n",
    "        'performance': performance,\n",
    "        'perf_summary': column_means,\n",
    "        'perf_superclass': df_row_means,\n",
    "        'elapsed_time': elapsed_time\n",
    "    }\n",
    "    filename = os.path.join('results', f'{model}_results.pkl')\n",
    "    with open(filename, 'wb') as f:\n",
    "        pickle.dump(model_result, f)\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e1cbb54e-abe6-49b6-957e-0683196f3199",
   "metadata": {},
   "source": [
    "## Load and compare results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "37849e0b-864e-4377-b06c-0ac70c3861f9",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Model: cross-encoder-nli-deberta-v3-base\n",
      "Performance Summary:\n",
      "accuracy      0.444444\n",
      "true_ident    0.533333\n",
      "false_pred    0.712500\n",
      "dtype: float64\n",
      "----------------------------------------\n",
      "Model: joeddav-bart-large-mnli-yahoo-answers\n",
      "Performance Summary:\n",
      "accuracy      0.355556\n",
      "true_ident    0.650000\n",
      "false_pred    0.553792\n",
      "dtype: float64\n",
      "----------------------------------------\n",
      "Model: cross-encoder-nli-deberta-v3-large\n",
      "Performance Summary:\n",
      "accuracy      0.466667\n",
      "true_ident    0.566667\n",
      "false_pred    0.541667\n",
      "dtype: float64\n",
      "----------------------------------------\n",
      "Model: MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli\n",
      "Performance Summary:\n",
      "accuracy      0.611111\n",
      "true_ident    0.841667\n",
      "false_pred    0.546667\n",
      "dtype: float64\n",
      "----------------------------------------\n",
      "Model: MoritzLaurer-mDeBERTa-v3-base-mnli-xnli\n",
      "Performance Summary:\n",
      "accuracy      0.455556\n",
      "true_ident    0.408333\n",
      "false_pred    0.481250\n",
      "dtype: float64\n",
      "----------------------------------------\n",
      "Model: MoritzLaurer-deberta-v3-large-zeroshot-v2.0\n",
      "Performance Summary:\n",
      "accuracy      0.500\n",
      "true_ident    0.325\n",
      "false_pred    0.500\n",
      "dtype: float64\n",
      "----------------------------------------\n",
      "Model: pongjin-roberta_with_kornli\n",
      "Performance Summary:\n",
      "accuracy      0.233333\n",
      "true_ident    0.666667\n",
      "false_pred    0.452857\n",
      "dtype: float64\n",
      "----------------------------------------\n",
      "Model: sileod-deberta-v3-base-tasksource-nli\n",
      "Performance Summary:\n",
      "accuracy      0.566667\n",
      "true_ident    0.700000\n",
      "false_pred    0.551667\n",
      "dtype: float64\n",
      "----------------------------------------\n",
      "Model: MoritzLaurer-mDeBERTa-v3-base-xnli-multilingual-nli-2mil7\n",
      "Performance Summary:\n",
      "accuracy      0.488889\n",
      "true_ident    0.833333\n",
      "false_pred    0.688373\n",
      "dtype: float64\n",
      "----------------------------------------\n",
      "Model: facebook-bart-large-mnli\n",
      "Performance Summary:\n",
      "accuracy      0.466667\n",
      "true_ident    0.708333\n",
      "false_pred    0.400000\n",
      "dtype: float64\n",
      "----------------------------------------\n",
      "Model: valhalla-distilbart-mnli-12-1\n",
      "Performance Summary:\n",
      "accuracy      0.500000\n",
      "true_ident    0.300000\n",
      "false_pred    0.533333\n",
      "dtype: float64\n",
      "----------------------------------------\n",
      "Model: MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli\n",
      "Performance Summary:\n",
      "accuracy      0.522222\n",
      "true_ident    0.841667\n",
      "false_pred    0.572381\n",
      "dtype: float64\n",
      "----------------------------------------\n"
     ]
    }
   ],
   "source": [
    "# Folder where .pkl files are saved\n",
    "results_dir = 'results'\n",
    "\n",
    "# Dictionary to store all loaded results\n",
    "all_results = {}\n",
    "\n",
    "# Loop through all .pkl files in the folder\n",
    "for filename in os.listdir(results_dir):\n",
    "    if filename.endswith('.pkl'):\n",
    "        model_name = filename.replace('_results.pkl', '')  # Extract model name\n",
    "        file_path = os.path.join(results_dir, filename)\n",
    "        \n",
    "        # Load the result\n",
    "        with open(file_path, 'rb') as f:\n",
    "            result = pickle.load(f)\n",
    "            all_results[model_name] = result\n",
    "\n",
    "# Compare performance across models\n",
    "for model, data in all_results.items():\n",
    "    print(f\"Model: {model}\")\n",
    "    print(f\"Performance Summary:\\n{data['perf_summary']}\")\n",
    "    print(\"-\" * 40)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "3f1951b1-884d-49ab-985d-ab1779c6f71d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12\n"
     ]
    }
   ],
   "source": [
    "print(len(all_results))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2f65e5b1-bc32-42c2-bbe9-9e3a6ffc72c1",
   "metadata": {},
   "source": [
    "**Identify trips that are difficult to predict**"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "040055c9-5df4-49b0-921a-5bf98ff01a69",
   "metadata": {},
   "source": [
    "Per model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "57fd150d-1cda-4be5-806b-ef380469243a",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cross-encoder-nli-deberta-v3-base: Index([0, 2, 3, 4, 5, 6, 7, 8, 9], dtype='int64')\n",
      "\n",
      "joeddav-bart-large-mnli-yahoo-answers: RangeIndex(start=0, stop=10, step=1)\n",
      "\n",
      "cross-encoder-nli-deberta-v3-large: Index([0, 1, 2, 3, 4, 6, 7, 8, 9], dtype='int64')\n",
      "\n",
      "MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli: Index([2, 3, 5, 6, 7, 8, 9], dtype='int64')\n",
      "\n",
      "MoritzLaurer-mDeBERTa-v3-base-mnli-xnli: RangeIndex(start=0, stop=10, step=1)\n",
      "\n",
      "MoritzLaurer-deberta-v3-large-zeroshot-v2.0: Index([1, 2, 3, 5, 6, 7, 9], dtype='int64')\n",
      "\n",
      "pongjin-roberta_with_kornli: RangeIndex(start=0, stop=10, step=1)\n",
      "\n",
      "sileod-deberta-v3-base-tasksource-nli: Index([0, 2, 3, 5, 6], dtype='int64')\n",
      "\n",
      "MoritzLaurer-mDeBERTa-v3-base-xnli-multilingual-nli-2mil7: Index([0, 2, 3, 4, 5, 6, 7, 8, 9], dtype='int64')\n",
      "\n",
      "facebook-bart-large-mnli: RangeIndex(start=0, stop=10, step=1)\n",
      "\n",
      "valhalla-distilbart-mnli-12-1: Index([0, 1, 2, 3, 4, 7, 9], dtype='int64')\n",
      "\n",
      "MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli: Index([0, 2, 3, 4, 6, 7], dtype='int64')\n",
      "\n"
     ]
    }
   ],
   "source": [
    "def get_difficult_trips(model_result, cut_off = 0.6):\n",
    "    \"\"\"\n",
    "    \"\"\"\n",
    "    # model_result is a dict with dict_keys(['model', 'predictions', \n",
    "    # 'performance', 'perf_summary', 'perf_superclass', 'elapsed_time'])\n",
    "    # get performance dataframe and repair index\n",
    "    df = model_result['performance'].reset_index(drop=True)\n",
    "    # find index of trips whose accuracy is below cut_off\n",
    "    index_result = df[df['accuracy'] < cut_off].index\n",
    "    return(index_result)\n",
    "\n",
    "# dictionary of trips that have accuracy below cut_off default\n",
    "difficult_trips_dict = {}\n",
    "for model, data in all_results.items():\n",
    "    difficult_trips_dict[data[\"model\"]] = get_difficult_trips(data)\n",
    "\n",
    "for key, value in difficult_trips_dict.items():\n",
    "    print(f\"{key}: {value}\\n\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d91fb932-c5aa-472a-9b8d-a0cfc83a87f8",
   "metadata": {},
   "source": [
    "For all models"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a2754cb7-59b9-4f1d-ab74-1bf711b3eba2",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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",
      "\n",
      "city trip\n",
      "['relaxing']\n",
      "cold destination / winter\n",
      "lightweight (but comfortable)\n",
      "casual\n",
      "indoor\n",
      "no own vehicle\n",
      "no special conditions to consider\n",
      "7+ days\n",
      "\n",
      "\n",
      "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",
      "\n",
      "cultural exploration\n",
      "['sightseeing', 'hiking', 'rafting']\n",
      "variable weather / spring / autumn\n",
      "lightweight (but comfortable)\n",
      "casual\n",
      "indoor\n",
      "no own vehicle\n",
      "rainy climate\n",
      "7+ days\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# Which trips are difficult for all models\n",
    "common = set.intersection(*(set(v) for v in difficult_trips_dict.values()))\n",
    "for index in common:\n",
    "    print(index, \".\", trip_descriptions[index], \"\\n\")\n",
    "    for item in trip_types[index]:\n",
    "        print(item)\n",
    "    print(\"\\n\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "be58d66f-a491-4f47-98df-2c0aa4af38e7",
   "metadata": {},
   "source": [
    "**Identify superclasses that are difficult to predict**"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7e833c2d-9356-4d40-9b20-0a1eb6628a30",
   "metadata": {},
   "source": [
    "Per model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "adb491b1-3ac3-4c32-934f-5eb6171f2ec9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cross-encoder-nli-deberta-v3-base: ['activities', 'climate_or_season', 'style_or_comfort', 'special_conditions']\n",
      "\n",
      "joeddav-bart-large-mnli-yahoo-answers: ['activities', 'climate_or_season', 'style_or_comfort', 'dress_code', 'accommodation', 'transportation', 'special_conditions']\n",
      "\n",
      "cross-encoder-nli-deberta-v3-large: ['activities', 'climate_or_season', 'style_or_comfort', 'transportation', 'special_conditions']\n",
      "\n",
      "MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli: ['activities', 'style_or_comfort']\n",
      "\n",
      "MoritzLaurer-mDeBERTa-v3-base-mnli-xnli: ['activities', 'style_or_comfort', 'accommodation', 'special_conditions', 'trip_length_days']\n",
      "\n",
      "MoritzLaurer-deberta-v3-large-zeroshot-v2.0: ['activities', 'climate_or_season', 'style_or_comfort', 'accommodation', 'special_conditions']\n",
      "\n",
      "pongjin-roberta_with_kornli: ['activity_type', 'activities', 'climate_or_season', 'style_or_comfort', 'dress_code', 'accommodation', 'transportation', 'special_conditions', 'trip_length_days']\n",
      "\n",
      "sileod-deberta-v3-base-tasksource-nli: ['activities', 'style_or_comfort', 'special_conditions']\n",
      "\n",
      "MoritzLaurer-mDeBERTa-v3-base-xnli-multilingual-nli-2mil7: ['activity_type', 'activities', 'style_or_comfort', 'special_conditions']\n",
      "\n",
      "facebook-bart-large-mnli: ['activities', 'style_or_comfort', 'accommodation', 'special_conditions']\n",
      "\n",
      "valhalla-distilbart-mnli-12-1: ['activities', 'climate_or_season', 'style_or_comfort', 'accommodation', 'special_conditions']\n",
      "\n",
      "MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli: ['activities', 'climate_or_season', 'style_or_comfort', 'special_conditions']\n",
      "\n"
     ]
    }
   ],
   "source": [
    "def get_difficult_superclasses(model_result, cut_off = 0.6):\n",
    "    # model_result is a dict with dict_keys(['model', 'predictions', \n",
    "    # 'performance', 'perf_summary', 'perf_superclass', 'elapsed_time'])\n",
    "    df = model_result[\"perf_superclass\"]\n",
    "    # find superclass whose accuracy is below cut_off\n",
    "    diff_spc = list(df[df['accuracy'] < cut_off][\"superclass\"])\n",
    "    return(diff_spc)\n",
    "\n",
    "# make dictionary of superclasses that have accuracy below cut_off default\n",
    "difficult_superclass_dict = {}\n",
    "for model, data in all_results.items():\n",
    "    difficult_superclass_dict[data[\"model\"]] = get_difficult_superclasses(data)\n",
    "\n",
    "for key, value in difficult_superclass_dict.items():\n",
    "    print(f\"{key}: {value}\\n\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fbcebdf8-0975-45cb-96f5-15b4645aa7f6",
   "metadata": {},
   "source": [
    "For all models"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "4e51c11b-9a0a-4f9d-b20c-a6feda2d5a3b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'activities', 'style_or_comfort'}\n"
     ]
    }
   ],
   "source": [
    "# Which trips are difficult for all models\n",
    "common = set.intersection(*(set(v) for v in difficult_superclass_dict.values()))\n",
    "print(common)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "f0e31e2c-e87d-4776-b781-991919492430",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Look at particular predicitons in detail\n",
    "# print(all_results[\"joeddav-bart-large-mnli-yahoo-answers\"])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "01e24355-4aac-4ad6-b50c-96f75585ce45",
   "metadata": {},
   "source": [
    "**Comparing models**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "b020f584-1468-4c84-9dac-7ca7fac6e8ca",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                                                        model  accuracy  true_ident  false_pred\n",
      "0    MoritzLaurer-DeBERTa-v3-large-mnli-fever-anli-ling-wanli  0.611111    0.841667    0.546667\n",
      "1                       sileod-deberta-v3-base-tasksource-nli  0.566667    0.700000    0.551667\n",
      "2                MoritzLaurer-DeBERTa-v3-base-mnli-fever-anli  0.522222    0.841667    0.572381\n",
      "3                 MoritzLaurer-deberta-v3-large-zeroshot-v2.0  0.500000    0.325000    0.500000\n",
      "4                               valhalla-distilbart-mnli-12-1  0.500000    0.300000    0.533333\n",
      "5   MoritzLaurer-mDeBERTa-v3-base-xnli-multilingual-nli-2mil7  0.488889    0.833333    0.688373\n",
      "6                          cross-encoder-nli-deberta-v3-large  0.466667    0.566667    0.541667\n",
      "7                                    facebook-bart-large-mnli  0.466667    0.708333    0.400000\n",
      "8                     MoritzLaurer-mDeBERTa-v3-base-mnli-xnli  0.455556    0.408333    0.481250\n",
      "9                           cross-encoder-nli-deberta-v3-base  0.444444    0.533333    0.712500\n",
      "10                      joeddav-bart-large-mnli-yahoo-answers  0.355556    0.650000    0.553792\n",
      "11                                pongjin-roberta_with_kornli  0.233333    0.666667    0.452857\n"
     ]
    }
   ],
   "source": [
    "pd.set_option('display.max_columns', None)       # show all columns\n",
    "pd.set_option('display.max_colwidth', None)     # do not truncate cell contents\n",
    "pd.set_option('display.width', 200)  \n",
    "\n",
    "perf_table = []\n",
    "# fill in for loop with perf_summary per model\n",
    "for model, result in all_results.items():\n",
    "    row = pd.DataFrame(result[\"perf_summary\"]).T\n",
    "    # row[\"model\"] = model\n",
    "    row.insert(0, \"model\", model)  # insert as first column\n",
    "    perf_table.append(row)\n",
    "# Concatenate all into one table\n",
    "df_all = pd.concat(perf_table, ignore_index=True)\n",
    "df = df_all.sort_values(by=\"accuracy\", ascending=False).reset_index(drop=True)\n",
    "\n",
    "\n",
    "\n",
    "print(df)\n",
    "#print(type(df_all))\n",
    "    \n",
    "\n",
    "# rank by accuracy\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "222a70fc-8d3c-4ebb-9954-d5c72baed9e5",
   "metadata": {},
   "outputs": [],
   "source": [
    "# return packing list additionally to classes\n",
    "# Load packing item data\n",
    "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
    "    packing_items = json.load(file)\n",
    "\n",
    "# function and gradio app\n",
    "def classify(model_name, trip_descr, cut_off = 0.5):\n",
    "    classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
    "    ## Create and fill dataframe with class predictions\n",
    "    df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
    "    for i, key in enumerate(keys_list):\n",
    "        if key == 'activities':\n",
    "            result = classifier(trip_descr, candidate_labels[key], multi_label=True)\n",
    "            indices = [i for i, score in enumerate(result['scores']) if score > cut_off]\n",
    "            classes = [result['labels'][i] for i in indices]\n",
    "        else:\n",
    "            result = classifier(trip_descr, candidate_labels[key])\n",
    "            classes = result[\"labels\"][0]\n",
    "        df.loc[i] = [key, classes]\n",
    "\n",
    "    ## Look up and return list of items to pack based on class predictions\n",
    "    # make list from dataframe column\n",
    "    all_classes = [elem for x in df[\"pred_class\"] for elem in (x if isinstance(x, list) else [x])]\n",
    "    # look up packing items for each class/key\n",
    "    list_of_list_of_items = [packing_items.get(k, []) for k in all_classes]\n",
    "    # combine lists and remove doubble entries\n",
    "    flat_unique = []\n",
    "    for sublist in list_of_list_of_items:\n",
    "        for item in sublist:\n",
    "            if item not in flat_unique:\n",
    "                flat_unique.append(item)\n",
    "    # sort alphabetically to notice duplicates\n",
    "    sorted_list = sorted(flat_unique)  \n",
    "    return df, sorted_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "0f7376bd-a50b-47cc-8055-48a6de5dfee6",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(           superclass                              pred_class\n",
      "0       activity_type                          beach vacation\n",
      "1          activities  [going to the beach, relaxing, hiking]\n",
      "2   climate_or_season               warm destination / summer\n",
      "3    style_or_comfort                              minimalist\n",
      "4          dress_code                                  casual\n",
      "5       accommodation                    huts with half board\n",
      "6      transportation                          no own vehicle\n",
      "7  special_conditions               off-grid / no electricity\n",
      "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"
     ]
    }
   ],
   "source": [
    "# Access the first trip description\n",
    "first_trip = trip_descriptions[0]\n",
    "tmp = classify(\"facebook/bart-large-mnli\", first_trip )\n",
    "print(tmp)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "17483df4-55c4-41cd-b8a9-61f7a5c7e8a3",
   "metadata": {},
   "source": [
    "# Use gradio for user input"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5bf23e10-0a93-4b2f-9508-34bb0974d24c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Prerequisites\n",
    "from transformers import pipeline\n",
    "import json\n",
    "import pandas as pd\n",
    "import gradio as gr\n",
    "\n",
    "# get candidate labels\n",
    "with open(\"packing_label_structure.json\", \"r\") as file:\n",
    "    candidate_labels = json.load(file)\n",
    "keys_list = list(candidate_labels.keys())\n",
    "\n",
    "# Load test data (in list of dictionaries)\n",
    "with open(\"test_data.json\", \"r\") as file:\n",
    "    packing_data = json.load(file)\n",
    "\n",
    "# Load packing item data\n",
    "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
    "    packing_items = json.load(file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "61ebbe99-2563-4c99-ba65-d2312c9d5844",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Running on local URL:  http://127.0.0.1:7862\n",
      "\n",
      "To create a public link, set `share=True` in `launch()`.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div><iframe src=\"http://127.0.0.1:7862/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    }
   ],
   "source": [
    "# function and gradio app\n",
    "def classify(model_name, trip_descr, cut_off = 0.5):\n",
    "    classifier = pipeline(\"zero-shot-classification\", model=model_name)\n",
    "    ## Create and fill dataframe with class predictions\n",
    "    df = pd.DataFrame(columns=['superclass', 'pred_class'])\n",
    "    for i, key in enumerate(keys_list):\n",
    "        if key == 'activities':\n",
    "            result = classifier(trip_descr, candidate_labels[key], multi_label=True)\n",
    "            indices = [i for i, score in enumerate(result['scores']) if score > cut_off]\n",
    "            classes = [result['labels'][i] for i in indices]\n",
    "        else:\n",
    "            result = classifier(trip_descr, candidate_labels[key])\n",
    "            classes = result[\"labels\"][0]\n",
    "        df.loc[i] = [key, classes]\n",
    "\n",
    "    ## Look up and return list of items to pack based on class predictions\n",
    "    # make list from dataframe column\n",
    "    all_classes = [elem for x in df[\"pred_class\"] for elem in (x if isinstance(x, list) else [x])]\n",
    "    # look up packing items for each class/key\n",
    "    list_of_list_of_items = [packing_items.get(k, []) for k in all_classes]\n",
    "    # combine lists and remove doubble entries\n",
    "    flat_unique = []\n",
    "    for sublist in list_of_list_of_items:\n",
    "        for item in sublist:\n",
    "            if item not in flat_unique:\n",
    "                flat_unique.append(item)\n",
    "    # sort alphabetically to notice duplicates\n",
    "    sorted_list = sorted(flat_unique)  \n",
    "    return df, \"\\n\".join(sorted_list)\n",
    "\n",
    "demo = gr.Interface(\n",
    "    fn=classify,\n",
    "    inputs=[\n",
    "        gr.Textbox(label=\"Model name\", value = \"MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli\"),\n",
    "        gr.Textbox(label=\"Trip description\"),\n",
    "        gr.Number(label=\"Activity cut-off\", value = 0.5),\n",
    "    ],\n",
    "    # outputs=\"dataframe\",\n",
    "    outputs=[gr.Dataframe(label=\"DataFrame\"), gr.Textbox(label=\"List of words\")],\n",
    "    title=\"Trip classification\",\n",
    "    description=\"Enter a text describing your trip\",\n",
    ")\n",
    "\n",
    "# Launch the Gradio app\n",
    "if __name__ == \"__main__\":\n",
    "    demo.launch()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "1f5df949-a527-4b11-8e5e-23786e1cde12",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "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"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "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"
     ]
    }
   ],
   "source": [
    "print(first_trip)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4ba29d94-88e4-4fb9-b42b-4e013ec2faa0",
   "metadata": {},
   "source": [
    "**Check for duplicate entries, which to combine?**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "66311e68-c7ab-47a0-8d42-02991bc048f2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "print(type(packing_items))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "9b2a01e7-55ac-405a-bb34-2b759c1f2d8e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 set of clothing for every situation\n",
      "GPS or offline maps\n",
      "Gore‑Tex clothing\n",
      "Gore‑Tex jacket and pants\n",
      "MiFi router or portable WiFi hotspot\n",
      "SUP board and paddle\n",
      "USB hub (for multiple devices)\n",
      "WiFi hotspot or local SIM card\n",
      "accessories\n",
      "activity book or tablet with films\n",
      "airbag backpack (if available)\n",
      "all‑in‑one soap\n",
      "at least 2 liters of water storage per person\n",
      "avalanche beacon (transceiver)\n",
      "baby monitor (for staying at location)\n",
      "backpack\n",
      "backup lighting (e.g. small flashlight)\n",
      "bags for waste\n",
      "bait / lures\n",
      "bank card / cash\n",
      "beach bag\n",
      "beach chair\n",
      "beach towel\n",
      "belay device\n",
      "bike light and lock\n",
      "bike or rental bike\n",
      "biodegradable soap + sponge\n",
      "bivvy bag or tarp\n",
      "blister plasters or tape\n",
      "board leash\n",
      "book / meditation material\n",
      "book or e‑reader\n",
      "boots or waders\n",
      "bottles and food (if applicable)\n",
      "breathable thermal clothing\n",
      "buff or neck warmer\n",
      "business cards / documents\n",
      "camera + lenses\n",
      "camera or smartphone\n",
      "camping gear (if staying overnight)\n",
      "camping table (optional)\n",
      "cap or hat\n",
      "car documents\n",
      "cash / card\n",
      "cash for hut\n",
      "cash for payments\n",
      "chair\n",
      "chair and table\n",
      "chalk bag\n",
      "charger\n",
      "child carrier or stroller\n",
      "child sleeping bag or pad\n",
      "children’s sunscreen\n",
      "children’s travel pharmacy\n",
      "chlorine drops or purification tablets\n",
      "city map / offline maps\n",
      "climbing harness\n",
      "climbing rope\n",
      "climbing shoes\n",
      "climbing skins\n",
      "closed shoes\n",
      "comfortable backpack or trolley\n",
      "comfortable clothing\n",
      "comfortable shoes\n",
      "comfortable sleeping pad\n",
      "compact clothing pack\n",
      "compact rain jacket\n",
      "compact sleeping gear (if overnighting)\n",
      "compact toothbrush\n",
      "cookset + stove\n",
      "cooler\n",
      "cooler box\n",
      "cooler box (optional)\n",
      "covering clothing\n",
      "crampons\n",
      "cross-country ski boots\n",
      "cross-country skis and poles\n",
      "daypack\n",
      "diapers or potty (depending on age)\n",
      "dishes & cutlery\n",
      "dive computer\n",
      "dog leash or harness\n",
      "down jacket or warm insulation layer\n",
      "dress or shirt\n",
      "dress shoes\n",
      "dried or freeze‑dried meals\n",
      "driver’s license\n",
      "dry bag\n",
      "earplugs\n",
      "emergency communication (e.g. GPS beacon or satellite messenger)\n",
      "energy bars or sports nutrition\n",
      "entertainment (book, music, games)\n",
      "essential oils (optional)\n",
      "extension cord (for powered campsites)\n",
      "extra batteries\n",
      "extra charger cables\n",
      "extra clothing\n",
      "extra clothing layer\n",
      "extra clothing or gear if needed\n",
      "extra clothing set per day\n",
      "extra food\n",
      "extra snacks for children\n",
      "favorite toy or stuffed animal\n",
      "fins\n",
      "first aid kit\n",
      "fishing license\n",
      "fishing rod\n",
      "flashlight or headlamp\n",
      "flip flops\n",
      "foldable cutting board (optional)\n",
      "foldable solar panel (if on longer trips)\n",
      "food and snacks\n",
      "food and water bowl\n",
      "food bag or hanging bag (wild-safe)\n",
      "food supply\n",
      "friend meetups\n",
      "fuel (enough for several days)\n",
      "gaiters (in deep snow)\n",
      "general items for this situation\n",
      "glitter / outfit\n",
      "gloves\n",
      "gloves (2 pairs)\n",
      "groceries\n",
      "groundsheet\n",
      "guidebook or highlights list\n",
      "hat and gloves\n",
      "hat or cap\n",
      "hat or headband\n",
      "head cover\n",
      "head protection\n",
      "headband or cap\n",
      "headlamp\n",
      "headlamp + extra batteries\n",
      "headlamp or flashlight\n",
      "helmet\n",
      "hiking boots\n",
      "hiking boots or trail runners\n",
      "hiking poles\n",
      "hiking socks (anti-blister)\n",
      "hut slippers / Crocs\n",
      "hydrating cream (for sensitive skin)\n",
      "ice axes\n",
      "identity document or passport\n",
      "indoor hut clothing (thermo / fleece)\n",
      "insect repellent\n",
      "insurance card / travel insurance info\n",
      "jeans or comfortable pants\n",
      "journal / pen\n",
      "kayak or canoe\n",
      "kids first aid kit (including thermometer and bandages)\n",
      "knife or multitool\n",
      "knowledge of avalanche safety / course\n",
      "lamp or lantern\n",
      "laptop and charger\n",
      "layered clothing\n",
      "layers for temperature control\n",
      "layers of clothing\n",
      "lens cloth\n",
      "life jacket\n",
      "light backpack with water and snacks\n",
      "light clothing\n",
      "light down jacket or warm layer\n",
      "light gloves for climbing\n",
      "light jacket or raincoat\n",
      "light long sleeves\n",
      "light pajamas or sleepwear\n",
      "light shoes\n",
      "light tent or tarp\n",
      "light towel\n",
      "lighter\n",
      "lighter + matches (waterproof packed)\n",
      "lightweight backpack\n",
      "lightweight backpack (< 1kg)\n",
      "lightweight clothing\n",
      "lightweight cookset\n",
      "lightweight sleeping pad\n",
      "lightweight stove (gas, petrol or alcohol)\n",
      "lightweight towel\n",
      "lightweight trekking backpack (30–45 liters)\n",
      "limited clothing (layers!)\n",
      "lip balm\n",
      "long pants or skirt\n",
      "lots of water\n",
      "map and compass\n",
      "map and compass / GPS\n",
      "map or GPS\n",
      "map or offline maps\n",
      "mask and snorkel\n",
      "memory card(s)\n",
      "minimalist shelter (tarp or tent)\n",
      "music / headphones\n",
      "navigation\n",
      "navigation (map/compass/GPS)\n",
      "navigation device with offline maps\n",
      "navigation or smartphone\n",
      "noise‑cancelling headphones\n",
      "notebook + pen\n",
      "number of meals/snacks matched to duration\n",
      "optional own saddle or stirrups\n",
      "pacifier or dummy\n",
      "packaging to keep electronics dry\n",
      "pad and sleeping bag\n",
      "paddle\n",
      "pajamas\n",
      "pan or small pot\n",
      "paper map and compass\n",
      "paraglider\n",
      "partner check before departure\n",
      "payment methods (debit card / cash)\n",
      "perfume / deodorant\n",
      "phone + charger\n",
      "phone charger\n",
      "phone holder\n",
      "phone holder / navigation\n",
      "pillow or inflatable pillow\n",
      "poncho or rain jacket\n",
      "poncho or towel\n",
      "poop bags\n",
      "power bank\n",
      "power bank (at least 10,000 mAh)\n",
      "power bank or 12V charger\n",
      "press‑on bowl or mug\n",
      "probe\n",
      "probe and shovel\n",
      "public transport app or ticket\n",
      "quick snacks for en route\n",
      "quick‑dry base layers\n",
      "quick‑dry clothing\n",
      "quick‑dry towel\n",
      "quilt or down blanket\n",
      "rain cover for stroller or carrier\n",
      "rain jacket\n",
      "rain jacket or poncho\n",
      "rain jacket or windbreaker\n",
      "rain poncho\n",
      "rain protection\n",
      "rechargeable batteries and charger\n",
      "regulator (if own)\n",
      "repair kit\n",
      "reservation confirmation\n",
      "reusable bag\n",
      "reusable cup\n",
      "riding boots or shoes with heel\n",
      "riding pants\n",
      "rubber shoes\n",
      "running shoes\n",
      "sandals\n",
      "scarf or shawl\n",
      "seat cushion or beach mat\n",
      "sheet liner\n",
      "sheet liner (often required)\n",
      "shirt / blouse\n",
      "shovel\n",
      "ski boots\n",
      "ski goggles\n",
      "ski or sunglasses\n",
      "ski pass\n",
      "skis and poles\n",
      "sleep mask\n",
      "sleeping bag\n",
      "sleeping bag (light, warm variant)\n",
      "sleeping bag (suitable for temperature)\n",
      "sleeping pad\n",
      "sleeping pad that fits in car\n",
      "slippers\n",
      "slippers or indoor shoes for inside\n",
      "small backpack\n",
      "small toiletry bag\n",
      "smart jacket\n",
      "snacks\n",
      "snacks / emergency bars\n",
      "snacks / energy bars\n",
      "snacks and drinks\n",
      "snacks and toys\n",
      "snacks for along the way\n",
      "snacks for the night\n",
      "sneakers\n",
      "snorkel and mask\n",
      "snow goggles\n",
      "socks\n",
      "socks per day\n",
      "solar panel or portable charging system\n",
      "splitboard or snowboard\n",
      "spork or spoon\n",
      "sports clothing\n",
      "sports watch (optional)\n",
      "sun hat\n",
      "sun hat or cap\n",
      "sun protection\n",
      "sunglasses\n",
      "sunglasses or sport glasses\n",
      "sunglasses with strap\n",
      "sunscreen\n",
      "sunscreen and sunglasses\n",
      "sunshades or blackout covers\n",
      "surfboard\n",
      "sweater or hoodie\n",
      "swimming goggles\n",
      "swimwear\n",
      "t-shirts\n",
      "tent\n",
      "tent (1‑ or 2‑person, depending on trip)\n",
      "tent or tarp\n",
      "thermal blanket (for cold nights)\n",
      "thermal clothing\n",
      "thermos bottle\n",
      "thick gloves\n",
      "thin gloves\n",
      "tissues or toilet paper\n",
      "titanium cookset\n",
      "toiletry bag\n",
      "toiletry bag (toothpaste, brush, deodorant, soap)\n",
      "toiletry bag with biodegradable soap\n",
      "toiletry bag with essentials\n",
      "toothbrush (shortened ;))\n",
      "tour bindings (for splitboard)\n",
      "touring backpack with ski attachment\n",
      "touring skis or splitboard\n",
      "towel\n",
      "traction soles / spikes\n",
      "trail runners or lightweight hiking shoes\n",
      "travel chair or sling\n",
      "travel crib or mattress (for young children)\n",
      "travel guide or maps\n",
      "travel mat or blanket\n",
      "trekking poles\n",
      "tripod\n",
      "underwear per day\n",
      "vaccination booklet\n",
      "warm boots\n",
      "warm insulation layers\n",
      "warm jacket\n",
      "warm layer\n",
      "warm sleeping bag\n",
      "warm sweater\n",
      "warm sweater or scarf\n",
      "washing up supplies\n",
      "water bottle\n",
      "water bottle or belt\n",
      "water bottle within reach\n",
      "water bottle(s) or hydration bladder\n",
      "water filter or pump\n",
      "water shoes\n",
      "waterproof backpack cover\n",
      "waterproof bag\n",
      "waterproof shoes\n",
      "wax\n",
      "wet wipes\n",
      "wetsuit\n",
      "wind jacket\n",
      "windproof and water-repellent outer layer\n",
      "wind‑ and waterproof jacket\n",
      "world adapter plug\n",
      "yoga mat or yoga towel\n"
     ]
    }
   ],
   "source": [
    "# Load packing item data\n",
    "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n",
    "    packing_items = json.load(file)\n",
    "\n",
    "unique_sorted = sorted({item for values in packing_items.values() for item in values})\n",
    "\n",
    "for item in unique_sorted:\n",
    "    print(item)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e300e3f3-93e0-457b-b2f0-e05cc5c2cafb",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python (huggingface_env)",
   "language": "python",
   "name": "huggingface_env"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.20"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}