File size: 87,494 Bytes
0758d29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8011\n"
     ]
    }
   ],
   "source": [
    "import json\n",
    "conv_data = []\n",
    "with open(\"/home/zxtan/text-to-lora/data_p13n/PRISM/conversations.jsonl\", 'r') as f:\n",
    "    for line in f.readlines():\n",
    "        i = json.loads(line)\n",
    "        conv_data.append(i)\n",
    "\n",
    "print(len(conv_data))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "106554\n"
     ]
    }
   ],
   "source": [
    "import json\n",
    "meta_data = []\n",
    "with open(\"/home/zxtan/text-to-lora/data_p13n/PRISM/metadata.jsonl\", 'r') as f:\n",
    "    for line in f.readlines():\n",
    "        i = json.loads(line)\n",
    "        meta_data.append(i)\n",
    "\n",
    "print(len(meta_data))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'column_id': 'user_prompt',\n",
       " 'user_id': 'user840',\n",
       " 'conversation_id': 'c4659',\n",
       " 'interaction_id': 'int13826',\n",
       " 'utterance_id': None,\n",
       " 'pii_flag': False,\n",
       " 'pii_manual_flag': nan,\n",
       " 'language_flag': 'en',\n",
       " 'en_flag': True,\n",
       " 'moderation_flag': {'flagged': False,\n",
       "  'categories': {'sexual': False,\n",
       "   'hate': False,\n",
       "   'harassment': False,\n",
       "   'self-harm': False,\n",
       "   'sexual/minors': False,\n",
       "   'hate/threatening': False,\n",
       "   'violence/graphic': False,\n",
       "   'self-harm/intent': False,\n",
       "   'self-harm/instructions': False,\n",
       "   'harassment/threatening': False,\n",
       "   'violence': False},\n",
       "  'category_scores': {'sexual': 0.0,\n",
       "   'hate': 0.0,\n",
       "   'harassment': 0.0,\n",
       "   'self-harm': 0.0,\n",
       "   'sexual/minors': 0.0,\n",
       "   'hate/threatening': 0.0,\n",
       "   'violence/graphic': 0.0,\n",
       "   'self-harm/intent': 0.0,\n",
       "   'self-harm/instructions': 0.0,\n",
       "   'harassment/threatening': 0.0,\n",
       "   'violence': 0.0}}}"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "meta_data[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1500\n"
     ]
    }
   ],
   "source": [
    "import json\n",
    "survey_data = []\n",
    "with open(\"/home/zxtan/text-to-lora/data_p13n/PRISM/survey.jsonl\", 'r') as f:\n",
    "    for line in f.readlines():\n",
    "        i = json.loads(line)\n",
    "        survey_data.append(i)\n",
    "\n",
    "print(len(survey_data))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'user_id': 'user0',\n",
       " 'survey_only': False,\n",
       " 'num_completed_conversations': 1,\n",
       " 'consent': 'Yes, I consent to take part',\n",
       " 'consent_age': 'I certify that I am 18 years of age or over',\n",
       " 'lm_familiarity': 'Somewhat familiar',\n",
       " 'lm_indirect_use': 'Yes',\n",
       " 'lm_direct_use': 'Yes',\n",
       " 'lm_frequency_use': 'More than once a month',\n",
       " 'self_description': \"Never do any wrong. Try to be compassionate. Help others. Don't harm others. Have Fun.\",\n",
       " 'system_string': \"It needs to provide me with accurate information. It needs to inform me when it's guessing.\",\n",
       " 'age': '35-44 years old',\n",
       " 'gender': 'Male',\n",
       " 'employment_status': 'Working full-time',\n",
       " 'education': 'University Bachelors Degree',\n",
       " 'marital_status': 'Never been married',\n",
       " 'english_proficiency': 'Native speaker',\n",
       " 'study_id': '655c7652609f0f36571ee825',\n",
       " 'study_locale': 'canada',\n",
       " 'religion': {'self_described': 'prefer not to say',\n",
       "  'categorised': 'Prefer not to say',\n",
       "  'simplified': 'Prefer not to say'},\n",
       " 'ethnicity': {'self_described': 'prefer not to say',\n",
       "  'categorised': 'Prefer not to say',\n",
       "  'simplified': 'Prefer not to say'},\n",
       " 'location': {'birth_country': 'Canada',\n",
       "  'birth_countryISO': 'CAN',\n",
       "  'birth_region': 'Americas',\n",
       "  'birth_subregion': 'Northern America',\n",
       "  'reside_country': 'Canada',\n",
       "  'reside_region': 'Americas',\n",
       "  'reside_subregion': 'Northern America',\n",
       "  'reside_countryISO': 'CAN',\n",
       "  'same_birth_reside_country': 'Yes',\n",
       "  'special_region': 'Northern America'},\n",
       " 'lm_usecases': {'homework_assistance': 0,\n",
       "  'research': 0,\n",
       "  'source_suggestions': 0,\n",
       "  'professional_work': 0,\n",
       "  'creative_writing': 0,\n",
       "  'casual_conversation': 0,\n",
       "  'personal_recommendations': 0,\n",
       "  'daily_productivity': 1,\n",
       "  'technical_or_programming_help': 0,\n",
       "  'travel_guidance': 0,\n",
       "  'lifestyle_and_hobbies': 0,\n",
       "  'well-being_guidance': 0,\n",
       "  'medical_guidance': 0,\n",
       "  'financial_guidance': 0,\n",
       "  'games': 0,\n",
       "  'historical_or_news_insight': 0,\n",
       "  'relationship_advice': 0,\n",
       "  'language_learning': 0,\n",
       "  'other': 0,\n",
       "  'other_text': None},\n",
       " 'stated_prefs': {'values': 83,\n",
       "  'creativity': 100,\n",
       "  'fluency': 100,\n",
       "  'factuality': 100,\n",
       "  'diversity': 100,\n",
       "  'safety': 90,\n",
       "  'personalisation': 71,\n",
       "  'helpfulness': 100,\n",
       "  'other': 50,\n",
       "  'other_text': None},\n",
       " 'order_lm_usecases': {'homework_assistance': 17,\n",
       "  'research': 6,\n",
       "  'source_suggestions': 10,\n",
       "  'professional_work': 8,\n",
       "  'creative_writing': 16,\n",
       "  'casual_conversation': 15,\n",
       "  'personal_recommendations': 12,\n",
       "  'daily_productivity': 11,\n",
       "  'technical_or_programming_help': 5,\n",
       "  'travel_guidance': 3,\n",
       "  'lifestyle_and_hobbies': 9,\n",
       "  'well-being_guidance': 7,\n",
       "  'medical_guidance': 4,\n",
       "  'financial_guidance': 18,\n",
       "  'games': 2,\n",
       "  'historical_or_news_insight': 14,\n",
       "  'relationship_advice': 1,\n",
       "  'language_learning': 13,\n",
       "  'other': 19},\n",
       " 'order_stated_prefs': {'values': 6,\n",
       "  'creativity': 3,\n",
       "  'fluency': 1,\n",
       "  'factuality': 7,\n",
       "  'diversity': 2,\n",
       "  'safety': 5,\n",
       "  'personalisation': 4,\n",
       "  'helpfulness': 8,\n",
       "  'other': 9},\n",
       " 'generated_datetime': '2023-11-22 15:48:46',\n",
       " 'timing_duration_s': 266,\n",
       " 'timing_duration_mins': 4.43,\n",
       " 'included_in_US_REP': False,\n",
       " 'included_in_UK_REP': False,\n",
       " 'included_in_balanced_subset': False}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "survey_data[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "68371\n"
     ]
    }
   ],
   "source": [
    "utter_data = []\n",
    "with open(\"/home/zxtan/text-to-lora/data_p13n/PRISM/utterances.jsonl\", 'r') as f:\n",
    "    for line in f.readlines():\n",
    "        i = json.loads(line)\n",
    "        utter_data.append(i)\n",
    "\n",
    "print(len(utter_data))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'utterance_id': 'ut0',\n",
       " 'interaction_id': 'int0',\n",
       " 'conversation_id': 'c0',\n",
       " 'user_id': 'user0',\n",
       " 'turn': 0,\n",
       " 'within_turn_id': 0,\n",
       " 'conversation_type': 'unguided',\n",
       " 'user_prompt': 'What can you do about the inequality  of wealth?',\n",
       " 'model_response': 'Make it illegal for corporations to own a majority of the wealth',\n",
       " 'model_name': 'google/flan-t5-xxl',\n",
       " 'model_provider': 'huggingface_api',\n",
       " 'score': 17,\n",
       " 'if_chosen': False,\n",
       " 'included_in_balanced_subset': False}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "utter_data[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'conversation_id': 'c6',\n",
       " 'user_id': 'user7',\n",
       " 'conversation_type': 'unguided',\n",
       " 'opening_prompt': 'How can I increase productivity based on scientific findings?',\n",
       " 'conversation_turns': 2,\n",
       " 'conversation_history': [{'turn': 0,\n",
       "   'role': 'user',\n",
       "   'content': 'How can I increase productivity based on scientific findings?'},\n",
       "  {'turn': 0,\n",
       "   'role': 'model',\n",
       "   'content': \"Here are some evidence-based ways to boost productivity: take short breaks periodically to refresh your mind, work in time-limited bursts followed by breaks, reduce distractions by minimizing notifications and closing extra browser tabs, focus on one task at a time instead of multitasking, establish daily priorities and goals to guide your efforts, track your time to identify where it's best spent, and ensure proper nutrition, exercise and sleep to keep your energy levels high. Managing your environment, focus and well-being can help you accomplish more.\",\n",
       "   'model_provider': 'anthropic',\n",
       "   'model_name': 'claude-instant-1',\n",
       "   'score': 74,\n",
       "   'if_chosen': False,\n",
       "   'within_turn_id': 0},\n",
       "  {'turn': 0,\n",
       "   'role': 'model',\n",
       "   'content': 'Here are some research-backed tips to increase productivity:\\n\\n- Take regular breaks every 90 minutes to refresh your mind and body. This helps boost focus when you return to work.  \\n\\n- Minimize distractions and interruptions as these hamper concentration. Turn off notifications, close extra browser tabs.\\n\\n- Prioritize your most important tasks and focus on one thing at a time instead of multitasking. Your brain can only effectively focus on one complex task at once.\\n\\n- Get enough sleep, generally 7-9 hours per night, as sleep deprivation severely impacts cognitive performance. \\n\\n- Exercise regularly to sharpen thinking, improve mood, and reduce stress - aim for 150 minutes per week of moderate activity.',\n",
       "   'model_provider': 'anthropic',\n",
       "   'model_name': 'claude-2.1',\n",
       "   'score': 77,\n",
       "   'if_chosen': True,\n",
       "   'within_turn_id': 1},\n",
       "  {'turn': 0,\n",
       "   'role': 'model',\n",
       "   'content': 'To enhance productivity, embrace these scientifically-supported practices: set clear goals, break tasks into smaller steps, maintain regular breaks to avoid burnout, use time management techniques (like the Pomodoro Technique), minimize distractions (like turning off notifications), ensure adequate sleep, maintain a healthy diet, and exercise regularly. Regular reflection and adjustments to your work approach can also contribute to continued productivity improvements.',\n",
       "   'model_provider': 'openai',\n",
       "   'model_name': 'gpt-4-1106-preview',\n",
       "   'score': 75,\n",
       "   'if_chosen': False,\n",
       "   'within_turn_id': 2},\n",
       "  {'turn': 0,\n",
       "   'role': 'model',\n",
       "   'content': 'According to scientific studies, creating a to-do list, breaking tasks into smaller steps, prioritizing, taking regular breaks, and using technology to track progress can increase productivity.',\n",
       "   'model_provider': 'huggingface_api',\n",
       "   'model_name': 'mistralai/Mistral-7B-Instruct-v0.1',\n",
       "   'score': 62,\n",
       "   'if_chosen': False,\n",
       "   'within_turn_id': 3},\n",
       "  {'turn': 1,\n",
       "   'role': 'user',\n",
       "   'content': 'can you design a weekly schedule for me that incorporates these suggestions'},\n",
       "  {'turn': 1,\n",
       "   'role': 'model',\n",
       "   'content': 'Here is a suggested weekly schedule incorporating productivity tips:\\n\\nMonday \\n9am - 10:30am: Work on priority task 1\\n10:30am - 10:45am: Take a short break  \\n10:45am - 12:15pm: Work on priority task 2\\n12:15pm - 1pm: Lunch break  \\n1pm - 2:30pm: Work on priority task 3\\n2:30pm - 2:45pm: Take a short break\\n2:45pm - 4:15pm: Work on priority task 4\\n4:15pm - 5pm: Exercise \\n\\nTuesday\\n9am - 10:30am: Work on priority task 1\\n10:30am - 10:45am: Break\\n10:45am - 12:15pm: Work on priority task 2\\n12:15pm - 1pm: Lunch  \\n1pm - 2:30pm: Work on priority task 3\\n2:30pm - 2:45pm: Break\\n2:45pm - 4:15pm: Work on priority task 4\\n\\nAnd so on throughout the week. The key elements are 90 minute work blocks separated by short breaks, exercise 3-4 times per week',\n",
       "   'model_provider': 'anthropic',\n",
       "   'model_name': 'claude-2.1',\n",
       "   'score': 83,\n",
       "   'if_chosen': True,\n",
       "   'within_turn_id': 0},\n",
       "  {'turn': 1,\n",
       "   'role': 'model',\n",
       "   'content': 'Here is a suggested weekly schedule incorporating productivity tips:\\n\\nMonday \\n- Work: 90 minute focus block, 15 minute break, 90 minute focus block, 30 minute exercise, 90 minute focus block\\n- Sleep: 8 hours  \\n\\nTuesday\\n- Work: 90 minute focus block, 15 minute break, 90 minute focus block, 8 hours sleep\\n\\nWednesday \\n- Work: 90 minute focus block, 15 minute break, 90 minute focus block, 30 minute exercise, 90 minute focus block  \\n- Sleep: 8 hours\\n\\nThursday\\n- Work: 90 minute focus block, 15 minute break, 90 minute focus block, 8 hours sleep  \\n\\nFriday\\n- Work: 90 minute focus block, 15 minute break, 90 minute focus block, 30 minute exercise, 90 minute focus block\\n- Sleep: 8 hours\\n\\nWeekend\\n- Balance work and rest, get 7-9 hours sleep per night\\n\\nThis schedules in regular 15-30 minute breaks every 90 minutes to refresh. Exercise is scheduled 3 times per week. The schedule allows for 8 hours sleep each night.',\n",
       "   'model_provider': 'anthropic',\n",
       "   'model_name': 'claude-2.1',\n",
       "   'score': 60,\n",
       "   'if_chosen': False,\n",
       "   'within_turn_id': 1}],\n",
       " 'performance_attributes': {'values': None,\n",
       "  'fluency': 75,\n",
       "  'factuality': 57,\n",
       "  'safety': 97,\n",
       "  'diversity': None,\n",
       "  'creativity': 67,\n",
       "  'helpfulness': 97},\n",
       " 'choice_attributes': {'values': None,\n",
       "  'fluency': 89,\n",
       "  'factuality': 76,\n",
       "  'safety': None,\n",
       "  'diversity': None,\n",
       "  'creativity': 74,\n",
       "  'helpfulness': 100},\n",
       " 'open_feedback': 'it was missing asking me questions, a conversation is a back and forth ',\n",
       " 'generated_datetime': '2023-11-22 16:15:15',\n",
       " 'timing_duration_s': 216.66,\n",
       " 'timing_duration_mins': 3.61,\n",
       " 'included_in_balanced_subset': True}"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "conv_data[6]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "from collections import defaultdict\n",
    "id2conv = defaultdict(list)\n",
    "\n",
    "for conv in conv_data:\n",
    "    id2conv[conv['user_id']].append(conv)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(id2conv['user2'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'user_id': 'user0',\n",
       " 'survey_only': False,\n",
       " 'num_completed_conversations': 1,\n",
       " 'consent': 'Yes, I consent to take part',\n",
       " 'consent_age': 'I certify that I am 18 years of age or over',\n",
       " 'lm_familiarity': 'Somewhat familiar',\n",
       " 'lm_indirect_use': 'Yes',\n",
       " 'lm_direct_use': 'Yes',\n",
       " 'lm_frequency_use': 'More than once a month',\n",
       " 'self_description': \"Never do any wrong. Try to be compassionate. Help others. Don't harm others. Have Fun.\",\n",
       " 'system_string': \"It needs to provide me with accurate information. It needs to inform me when it's guessing.\",\n",
       " 'age': '35-44 years old',\n",
       " 'gender': 'Male',\n",
       " 'employment_status': 'Working full-time',\n",
       " 'education': 'University Bachelors Degree',\n",
       " 'marital_status': 'Never been married',\n",
       " 'english_proficiency': 'Native speaker',\n",
       " 'study_id': '655c7652609f0f36571ee825',\n",
       " 'study_locale': 'canada',\n",
       " 'religion': {'self_described': 'prefer not to say',\n",
       "  'categorised': 'Prefer not to say',\n",
       "  'simplified': 'Prefer not to say'},\n",
       " 'ethnicity': {'self_described': 'prefer not to say',\n",
       "  'categorised': 'Prefer not to say',\n",
       "  'simplified': 'Prefer not to say'},\n",
       " 'location': {'birth_country': 'Canada',\n",
       "  'birth_countryISO': 'CAN',\n",
       "  'birth_region': 'Americas',\n",
       "  'birth_subregion': 'Northern America',\n",
       "  'reside_country': 'Canada',\n",
       "  'reside_region': 'Americas',\n",
       "  'reside_subregion': 'Northern America',\n",
       "  'reside_countryISO': 'CAN',\n",
       "  'same_birth_reside_country': 'Yes',\n",
       "  'special_region': 'Northern America'},\n",
       " 'lm_usecases': {'homework_assistance': 0,\n",
       "  'research': 0,\n",
       "  'source_suggestions': 0,\n",
       "  'professional_work': 0,\n",
       "  'creative_writing': 0,\n",
       "  'casual_conversation': 0,\n",
       "  'personal_recommendations': 0,\n",
       "  'daily_productivity': 1,\n",
       "  'technical_or_programming_help': 0,\n",
       "  'travel_guidance': 0,\n",
       "  'lifestyle_and_hobbies': 0,\n",
       "  'well-being_guidance': 0,\n",
       "  'medical_guidance': 0,\n",
       "  'financial_guidance': 0,\n",
       "  'games': 0,\n",
       "  'historical_or_news_insight': 0,\n",
       "  'relationship_advice': 0,\n",
       "  'language_learning': 0,\n",
       "  'other': 0,\n",
       "  'other_text': None},\n",
       " 'stated_prefs': {'values': 83,\n",
       "  'creativity': 100,\n",
       "  'fluency': 100,\n",
       "  'factuality': 100,\n",
       "  'diversity': 100,\n",
       "  'safety': 90,\n",
       "  'personalisation': 71,\n",
       "  'helpfulness': 100,\n",
       "  'other': 50,\n",
       "  'other_text': None},\n",
       " 'order_lm_usecases': {'homework_assistance': 17,\n",
       "  'research': 6,\n",
       "  'source_suggestions': 10,\n",
       "  'professional_work': 8,\n",
       "  'creative_writing': 16,\n",
       "  'casual_conversation': 15,\n",
       "  'personal_recommendations': 12,\n",
       "  'daily_productivity': 11,\n",
       "  'technical_or_programming_help': 5,\n",
       "  'travel_guidance': 3,\n",
       "  'lifestyle_and_hobbies': 9,\n",
       "  'well-being_guidance': 7,\n",
       "  'medical_guidance': 4,\n",
       "  'financial_guidance': 18,\n",
       "  'games': 2,\n",
       "  'historical_or_news_insight': 14,\n",
       "  'relationship_advice': 1,\n",
       "  'language_learning': 13,\n",
       "  'other': 19},\n",
       " 'order_stated_prefs': {'values': 6,\n",
       "  'creativity': 3,\n",
       "  'fluency': 1,\n",
       "  'factuality': 7,\n",
       "  'diversity': 2,\n",
       "  'safety': 5,\n",
       "  'personalisation': 4,\n",
       "  'helpfulness': 8,\n",
       "  'other': 9},\n",
       " 'generated_datetime': '2023-11-22 15:48:46',\n",
       " 'timing_duration_s': 266,\n",
       " 'timing_duration_mins': 4.43,\n",
       " 'included_in_US_REP': False,\n",
       " 'included_in_UK_REP': False,\n",
       " 'included_in_balanced_subset': False}"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "survey_data[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Calculate the average conversation count per user\n",
    "total_conversations = sum(user['num_completed_conversations'] for user in survey_data)\n",
    "total_users = len(survey_data)\n",
    "average_conversations_per_user = total_conversations / total_users\n",
    "\n",
    "print(f\"Average conversation count per user: {average_conversations_per_user:.2f}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import datetime\n",
    "\n",
    "id2conv_sorted = {user_id: sorted(convs, key=lambda conv: datetime.strptime(conv['generated_datetime'], '%Y-%m-%d %H:%M:%S')) for user_id, convs in id2conv.items()}\n",
    "\n",
    "# Sort the conversations in conv_data by 'generated_datetime' from earliest to latest\n",
    "# conv_data_sorted = sorted(conv_data, key=lambda conv: datetime.strptime(conv['generated_datetime'], '%Y-%m-%d %H:%M:%S'))\n",
    "\n",
    "# Print the sorted conversations\n",
    "# for conv in conv_data_sorted:\n",
    "#     print(conv['generated_datetime'], conv['conversation_id'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2023-11-22 16:07:49\n",
      "2023-11-22 16:15:49\n",
      "2023-11-22 16:28:27\n",
      "2023-11-22 16:45:40\n",
      "2023-11-22 16:58:15\n",
      "2023-11-22 17:08:15\n"
     ]
    }
   ],
   "source": [
    "# id2conv_sorted['user0']\n",
    "for i in id2conv_sorted['user1']:\n",
    "    print(i['generated_datetime'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "0\n",
      "1396\n"
     ]
    }
   ],
   "source": [
    "combined_data = []\n",
    "for i in survey_data:\n",
    "    try:\n",
    "        user_data = {}\n",
    "        user_data['user_id'] = i['user_id']\n",
    "        user_data['profile'] = i\n",
    "        user_data['conversations'] = id2conv_sorted[i['user_id']]\n",
    "\n",
    "        combined_data.append(user_data)\n",
    "    except:\n",
    "        print(i['num_completed_conversations'])\n",
    "\n",
    "print(len(combined_data))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'user_id': 'user0',\n",
       " 'profile': {'user_id': 'user0',\n",
       "  'survey_only': False,\n",
       "  'num_completed_conversations': 1,\n",
       "  'consent': 'Yes, I consent to take part',\n",
       "  'consent_age': 'I certify that I am 18 years of age or over',\n",
       "  'lm_familiarity': 'Somewhat familiar',\n",
       "  'lm_indirect_use': 'Yes',\n",
       "  'lm_direct_use': 'Yes',\n",
       "  'lm_frequency_use': 'More than once a month',\n",
       "  'self_description': \"Never do any wrong. Try to be compassionate. Help others. Don't harm others. Have Fun.\",\n",
       "  'system_string': \"It needs to provide me with accurate information. It needs to inform me when it's guessing.\",\n",
       "  'age': '35-44 years old',\n",
       "  'gender': 'Male',\n",
       "  'employment_status': 'Working full-time',\n",
       "  'education': 'University Bachelors Degree',\n",
       "  'marital_status': 'Never been married',\n",
       "  'english_proficiency': 'Native speaker',\n",
       "  'study_id': '655c7652609f0f36571ee825',\n",
       "  'study_locale': 'canada',\n",
       "  'religion': {'self_described': 'prefer not to say',\n",
       "   'categorised': 'Prefer not to say',\n",
       "   'simplified': 'Prefer not to say'},\n",
       "  'ethnicity': {'self_described': 'prefer not to say',\n",
       "   'categorised': 'Prefer not to say',\n",
       "   'simplified': 'Prefer not to say'},\n",
       "  'location': {'birth_country': 'Canada',\n",
       "   'birth_countryISO': 'CAN',\n",
       "   'birth_region': 'Americas',\n",
       "   'birth_subregion': 'Northern America',\n",
       "   'reside_country': 'Canada',\n",
       "   'reside_region': 'Americas',\n",
       "   'reside_subregion': 'Northern America',\n",
       "   'reside_countryISO': 'CAN',\n",
       "   'same_birth_reside_country': 'Yes',\n",
       "   'special_region': 'Northern America'},\n",
       "  'lm_usecases': {'homework_assistance': 0,\n",
       "   'research': 0,\n",
       "   'source_suggestions': 0,\n",
       "   'professional_work': 0,\n",
       "   'creative_writing': 0,\n",
       "   'casual_conversation': 0,\n",
       "   'personal_recommendations': 0,\n",
       "   'daily_productivity': 1,\n",
       "   'technical_or_programming_help': 0,\n",
       "   'travel_guidance': 0,\n",
       "   'lifestyle_and_hobbies': 0,\n",
       "   'well-being_guidance': 0,\n",
       "   'medical_guidance': 0,\n",
       "   'financial_guidance': 0,\n",
       "   'games': 0,\n",
       "   'historical_or_news_insight': 0,\n",
       "   'relationship_advice': 0,\n",
       "   'language_learning': 0,\n",
       "   'other': 0,\n",
       "   'other_text': None},\n",
       "  'stated_prefs': {'values': 83,\n",
       "   'creativity': 100,\n",
       "   'fluency': 100,\n",
       "   'factuality': 100,\n",
       "   'diversity': 100,\n",
       "   'safety': 90,\n",
       "   'personalisation': 71,\n",
       "   'helpfulness': 100,\n",
       "   'other': 50,\n",
       "   'other_text': None},\n",
       "  'order_lm_usecases': {'homework_assistance': 17,\n",
       "   'research': 6,\n",
       "   'source_suggestions': 10,\n",
       "   'professional_work': 8,\n",
       "   'creative_writing': 16,\n",
       "   'casual_conversation': 15,\n",
       "   'personal_recommendations': 12,\n",
       "   'daily_productivity': 11,\n",
       "   'technical_or_programming_help': 5,\n",
       "   'travel_guidance': 3,\n",
       "   'lifestyle_and_hobbies': 9,\n",
       "   'well-being_guidance': 7,\n",
       "   'medical_guidance': 4,\n",
       "   'financial_guidance': 18,\n",
       "   'games': 2,\n",
       "   'historical_or_news_insight': 14,\n",
       "   'relationship_advice': 1,\n",
       "   'language_learning': 13,\n",
       "   'other': 19},\n",
       "  'order_stated_prefs': {'values': 6,\n",
       "   'creativity': 3,\n",
       "   'fluency': 1,\n",
       "   'factuality': 7,\n",
       "   'diversity': 2,\n",
       "   'safety': 5,\n",
       "   'personalisation': 4,\n",
       "   'helpfulness': 8,\n",
       "   'other': 9},\n",
       "  'generated_datetime': '2023-11-22 15:48:46',\n",
       "  'timing_duration_s': 266,\n",
       "  'timing_duration_mins': 4.43,\n",
       "  'included_in_US_REP': False,\n",
       "  'included_in_UK_REP': False,\n",
       "  'included_in_balanced_subset': False},\n",
       " 'conversations': [{'conversation_id': 'c0',\n",
       "   'user_id': 'user0',\n",
       "   'conversation_type': 'unguided',\n",
       "   'opening_prompt': 'What can you do about the inequality  of wealth?',\n",
       "   'conversation_turns': 5,\n",
       "   'conversation_history': [{'turn': 0,\n",
       "     'role': 'user',\n",
       "     'content': 'What can you do about the inequality  of wealth?'},\n",
       "    {'turn': 0,\n",
       "     'role': 'model',\n",
       "     'content': 'Make it illegal for corporations to own a majority of the wealth',\n",
       "     'model_provider': 'huggingface_api',\n",
       "     'model_name': 'google/flan-t5-xxl',\n",
       "     'score': 17,\n",
       "     'if_chosen': False,\n",
       "     'within_turn_id': 0},\n",
       "    {'turn': 0,\n",
       "     'role': 'model',\n",
       "     'content': 'As an AI language model, I cannot express personal opinions or engage in discussions related to wealth inequality or financial matters. \\n\\nMy purpose is to provide fact-based responses to your queries to the best of my knowledge and capabilities based on the training data and algorithms I have been programmed with. If you have any specific queries or need assistance with something else, please let me know, and I will do my best to assist you. \\n\\nWould you like me to rephrase my previous response or provide additional details based on your preferences?',\n",
       "     'model_provider': 'cohere',\n",
       "     'model_name': 'command-light',\n",
       "     'score': 92,\n",
       "     'if_chosen': True,\n",
       "     'within_turn_id': 1},\n",
       "    {'turn': 1, 'role': 'user', 'content': 'When  can you do something?'},\n",
       "    {'turn': 1,\n",
       "     'role': 'model',\n",
       "     'content': 'As an AI language model, I do not have any preferences or scheduled timing for performing specific tasks. My training data and algorithms drive my functionality to provide responses to your queries. \\n\\nI am trained to respond to your requests and provide relevant information to the best of my knowledge. I do not have the ability to prioritize requests or perform tasks consciously. \\n\\nIf you have any specific queries or requirements, feel free to ask me, and I will do my best to assist and provide useful information to the best of my capabilities. \\n\\nWould you like me to clarify something further or provide additional details about my capabilities?',\n",
       "     'model_provider': 'cohere',\n",
       "     'model_name': 'command-light',\n",
       "     'score': 75,\n",
       "     'if_chosen': False,\n",
       "     'within_turn_id': 0},\n",
       "    {'turn': 1,\n",
       "     'role': 'model',\n",
       "     'content': 'I apologize for any confusion caused by my previous response. \\n\\nAs an AI language model, I do not have the ability to take actions or implement solutions related to wealth inequality. My purpose is to provide information and support discussions to the best of my knowledge and capabilities based on the training data and algorithms I have been programmed with. \\n\\nIn practical terms, the resources and capabilities currently available to develop large language models like myself do not extend to addressing economic or social issues such as wealth inequality. Future advancements in natural language processing and machine learning may lead to further improvements in the assistance and advice I can provide, but currently, there are no practical mechanisms in place to address wealth inequality. \\n\\nIf you have any other questions or need assistance with something else, please feel free to ask, and I will do my best to provide relevant and helpful information based on my capabilities.',\n",
       "     'model_provider': 'cohere',\n",
       "     'model_name': 'command-light',\n",
       "     'score': 77,\n",
       "     'if_chosen': True,\n",
       "     'within_turn_id': 1},\n",
       "    {'turn': 2,\n",
       "     'role': 'user',\n",
       "     'content': 'Are  you ever going to evolve yourself?'},\n",
       "    {'turn': 2,\n",
       "     'role': 'model',\n",
       "     'content': \"The ability of an AI model to evolve or improve over time depends on the training data, algorithms, and updates implemented by the developers. Machine learning models, including large language models like myself, can learn and improve from data through a process called training and reinforcement.\\n\\nMy training data and the algorithms used to power me have been continuously evolving and improving since they were developed. These advancements allow me to provide more accurate and responsive answers to your queries. \\n\\nIn general, AI models are subject to periodic updates and improvements based on the feedback and learning from their usage. These updates help refine the model's performance and ensure it remains effective in providing useful information. \\n\\nWhile it is not possible for an AI model to evolve or improve spontaneously, controlled updates and advancements based on user feedback and learning opportunities enable the model to refine its abilities over time. \\n\\nWould you like me to provide more details on the process of updates or expansions for my capabilities?\",\n",
       "     'model_provider': 'cohere',\n",
       "     'model_name': 'command-light',\n",
       "     'score': 70,\n",
       "     'if_chosen': True,\n",
       "     'within_turn_id': 0},\n",
       "    {'turn': 2,\n",
       "     'role': 'model',\n",
       "     'content': \"As an artificial intelligence language model, I do not have the ability to evolve or learn in the same way as biological organisms. My development and capabilities are constantly evolving and being enhanced through various algorithms and improvements in machine learning techniques.\\n\\nMy training data, algorithms, and updates help expand my knowledge and capabilities over time. These improvements enable me to provide more accurate and informative responses to users' queries.\\n\\nWhile I have limitations as an AI model, my developers and programmers are continuously working to improve my algorithms and training processes to make me more useful and responsive. \\n\\nAdditionally, advancements in deep learning, computer vision, and other fields of AI and machine learning provide the potential for expanding my knowledge and capabilities in the future. \\n\\nIt is important to note that the field of AI is rapidly evolving, and improvements and developments in algorithms and infrastructure will continue to influence the capabilities and functionalities of language models like me. \\n\\nIf you have any further questions or concerns or would like to discuss this topic further, feel free to ask.\",\n",
       "     'model_provider': 'cohere',\n",
       "     'model_name': 'command-light',\n",
       "     'score': 65,\n",
       "     'if_chosen': False,\n",
       "     'within_turn_id': 1},\n",
       "    {'turn': 3,\n",
       "     'role': 'user',\n",
       "     'content': \"Why are all the good AI's behind paywalls?\"},\n",
       "    {'turn': 3,\n",
       "     'role': 'model',\n",
       "     'content': 'The availability and accessibility of AI models, including large language models, are influenced by a combination of factors, including development costs, pricing structures, and business strategies. While there are efforts to make AI technologies accessible, some models may be behind a paywall or subject to usage restrictions for various reasons: \\n\\n1. Cost of Development and Maintenance: Developing and training large language models, as well as maintaining and updating them, can be resource-intensive and costly. Businesses and researchers may charge for access or usage fees to cover these expenses and maintain the quality of their models.\\n\\n2. Commercialization and Business Strategies: Many AI companies and research organizations are businesses, and their pricing structures are determined by their business strategies and the value they attribute to providing access to their models. They may choose to sell access to users who this is more cost-effective than internally distributing the benefits through their revenue. \\n\\n3. Limited Availability of Resources: Not all organizations or individuals may have the necessary resources or capacity to develop and maintain their own state-of-the-art AI models. In such cases, paying for access to pre-built and rigorously tested models can provide a viable alternative. \\n\\nIt is important to note that there are initiatives and efforts ongoing to make AI technologies more accessible. Open-source libraries, community resources, and scholarships can help users gain access to useful AI tools and technologies. \\n\\nIf you have specific interests or requirements related to using AI models and are facing issues with access, please feel free to explore different resources and reach out to the developers of the relevant models or organizations to inquire about their accessibility policies and potential alternatives. \\n\\nWould you like me to provide you with recommendations or resources that can assist you in accessing or using AI technologies?',\n",
       "     'model_provider': 'cohere',\n",
       "     'model_name': 'command-light',\n",
       "     'score': 73,\n",
       "     'if_chosen': True,\n",
       "     'within_turn_id': 0},\n",
       "    {'turn': 3,\n",
       "     'role': 'model',\n",
       "     'content': 'The availability and accessibility of AI models, including those with advanced capabilities, can be influenced by various factors such as development costs, business strategies, and open-source initiatives. While there are indeed reputable companies and individuals developing AI technologies who charge for access or use, there are also other approaches and initiatives in progress.\\n\\nOne approach is the use of research universities and academic institutions. Many talented researchers work on developing AI technologies supported by academic institutions, and their research often leads to innovative solutions and advancements. These institutions often make their findings available through publications, patents, or open-source projects to encourage collaboration and knowledge sharing.\\n\\nSome companies choose to develop and maintain open-source projects that provide access to their AI technologies or platforms. By making their technologies available through open-source licenses, these companies encourage collaboration and allow other organizations to adapt and build upon their developments.\\n\\nAdditionally, there are initiatives to make AI more accessible for research and development. Some companies and organizations provide access to their datasets, models, or development platforms to encourage innovation and research in the field. They understand the importance of collaboration and knowledge sharing to advance the state of AI.\\n\\nIt is worth noting that the AI industry is evolving rapidly, and there are ongoing developments and discussions to make AI technologies more accessible and equitable. There are also initiatives and organizations dedicated to promoting transparency, fairness, and accountability in the development and deployment of AI systems.\\n\\nAs the field progresses, there may be more widespread availability and acceptance of advanced AI solutions due to these efforts and changes in business models and practices. \\n\\nWould you like me to provide specific examples or addresses any concerns you have related to accessibility of advanced AI solutions?',\n",
       "     'model_provider': 'cohere',\n",
       "     'model_name': 'command-light',\n",
       "     'score': 67,\n",
       "     'if_chosen': False,\n",
       "     'within_turn_id': 1},\n",
       "    {'turn': 4,\n",
       "     'role': 'user',\n",
       "     'content': 'Everyone  likes free stuff,  give us  free options'},\n",
       "    {'turn': 4,\n",
       "     'role': 'model',\n",
       "     'content': 'Unfortunately, I cannot fulfill your request for free options in the context of using advanced AI models. The development and maintenance of high-quality AI models require significant resources and investment, which makes them costly to access. \\n\\nHowever, there are resources available to help you explore and interact with AI technologies without the need for paying for access. Here are some suggestions:\\n\\n1. Open-Source Libraries: Many AI libraries and frameworks, such as TensorFlow, PyTorch, and Keras, provide free and open-source versions of their platforms. These options allow you to get hands-on experience and experiment with AI capabilities without any cost.\\n\\n2. Online Courses and Tutorials: There are many online platforms and communities that offer tutorials, workshops, and educational resources on AI and machine learning. These resources can help you understand the basics and concepts without incurring any monetary expenditure.\\n\\n3. Community Initiatives and Grants: There are periodic initiatives and grants provided by organizations and communities dedicated to making AI technologies more accessible. These can provide opportunities for individuals or organizations to use AI tools and perform projects with limited cost.\\n\\nPlease note that the availability and quality of free options may vary, and the capabilities of free resources compared to paid ones may have certain limitations or showcase the models in simpler forms. It is important to explore and select options that align with your specific interests and requirements.\\n\\nIt is worth mentioning that the best way to interact with these technologies to a full extent and gain access to advanced features and capabilities is to purchase subscriptions or follow the cost structures of the resources you select. \\n\\nWould you like me to provide specific recommendations or resources that cater to your interests or areas of exploration within AI?',\n",
       "     'model_provider': 'cohere',\n",
       "     'model_name': 'command-light',\n",
       "     'score': 84,\n",
       "     'if_chosen': True,\n",
       "     'within_turn_id': 0},\n",
       "    {'turn': 4,\n",
       "     'role': 'model',\n",
       "     'content': \"I'm sorry, but I can't provide you with options for using large language models for free. The development and maintenance of high-quality language models require significant computational resources and ongoing efforts. \\n\\nHowever, there are alternatives or complements to traditional large language models that can provide similar benefits but may have different pricing structures or requirements. Here are a few suggestions:\\n\\n1. Open-source Models: Certain projects and communities offer open-source versions of language models with lower restrictions. While these may have limitations in terms of usage or require more in-depth implementation and customization, they can provide alternatives to commercial models.\\n\\n2. Pretrained Models: Many language models, including GPT-3, are available in pretrained versions that have been trained on large amounts of data. These models can be accessed and used for specific tasks or tasks related to their training without the need for additional training data and computational resources.\\n\\n3. Community-Contributed Models: There are initiatives and platforms that provide access to simpler or smaller language models that can be useful for specific tasks or experiments. These models are contributed and shared by the AI community.\\n\\nPlease note that the availability and suitability of these alternatives may vary and come with their own considerations. It is important to evaluate each option based on your specific requirements and constraints. Additionally, it is recommended to review the terms of use and any potential limitations associated with these alternatives. \\n\\nIf you have specific use cases or requirements in mind, feel free to provide more detail, and I can assist you in suggesting appropriate approaches, resources, or communities that you can explore for accessing or using language models.\",\n",
       "     'model_provider': 'cohere',\n",
       "     'model_name': 'command-light',\n",
       "     'score': 77,\n",
       "     'if_chosen': False,\n",
       "     'within_turn_id': 1}],\n",
       "   'performance_attributes': {'values': None,\n",
       "    'fluency': 95,\n",
       "    'factuality': 86,\n",
       "    'safety': 88,\n",
       "    'diversity': 67,\n",
       "    'creativity': 28,\n",
       "    'helpfulness': 50},\n",
       "   'choice_attributes': {'values': None,\n",
       "    'fluency': 80,\n",
       "    'factuality': 73,\n",
       "    'safety': 75,\n",
       "    'diversity': 73,\n",
       "    'creativity': 19,\n",
       "    'helpfulness': 71},\n",
       "   'open_feedback': 'Shorter blocks would  be nice.  but has  to have enough info.',\n",
       "   'generated_datetime': '2023-11-22 15:55:46',\n",
       "   'timing_duration_s': 401.07,\n",
       "   'timing_duration_mins': 6.68,\n",
       "   'included_in_balanced_subset': False}]}"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "combined_data[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('/home/zxtan/text-to-lora/data_p13n/PRISM/combined_data.jsonl', 'w') as f:\n",
    "    for item in combined_data:\n",
    "        f.write(json.dumps(item) + '\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "31951\n"
     ]
    }
   ],
   "source": [
    "data_all = []\n",
    "with open('/home/zxtan/text-to-lora/data_p13n/LongLaMP/LongLaMP_abstract_generation_temporal.jsonl', 'r') as f:\n",
    "    for line in f.readlines():\n",
    "        i = json.loads(line)\n",
    "        data_all.append(i)\n",
    "\n",
    "print(len(data_all))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [],
   "source": [
    "task_list = ['abstract_generation', 'product_review', 'topic_writing']\n",
    "\n",
    "for task in task_list:\n",
    "    data_train = []\n",
    "    with open(f'/home/zxtan/text-to-lora/data_p13n/LongLaMP/LongLaMP_{task}_temporal_train.json', 'r') as f:\n",
    "        for line in f.readlines():\n",
    "            i = json.loads(line)\n",
    "            data_train.append(i)\n",
    "\n",
    "    data_val = []\n",
    "    with open(f'/home/zxtan/text-to-lora/data_p13n/LongLaMP/LongLaMP_{task}_temporal_val.json', 'r') as f:\n",
    "        for line in f.readlines():\n",
    "            i = json.loads(line)\n",
    "            data_val.append(i)\n",
    "\n",
    "    data_test = []\n",
    "    with open(f'/home/zxtan/text-to-lora/data_p13n/LongLaMP/LongLaMP_{task}_temporal_test.json', 'r') as f:\n",
    "        for line in f.readlines():\n",
    "            i = json.loads(line)\n",
    "            data_test.append(i)\n",
    "\n",
    "    data_all = data_train + data_val + data_test\n",
    "    import random\n",
    "\n",
    "    random.shuffle(data_all)\n",
    "    with open(f'/home/zxtan/text-to-lora/data_p13n/LongLaMP/LongLaMP_{task}_temporal.jsonl', 'w') as f:\n",
    "        for i in data_all:\n",
    "            f.write(json.dumps(i) + '\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [],
   "source": [
    "task_list = ['citation', \"movie\", \"news_cat\", \"news_headline\", \"product\", \"scholarly_title\", \"tweet\"]\n",
    "\n",
    "for task in task_list:\n",
    "    with open(f'/home/zxtan/text-to-lora/data_p13n/LaMP-processsed_data/LaMP_processed_{task}.json', 'r') as f:\n",
    "        data = json.load(f)\n",
    "    with open(f'/home/zxtan/text-to-lora/data_p13n/LaMP-processsed_data/LaMP_processed_{task}.jsonl', 'w') as f:\n",
    "        for i in data:\n",
    "            f.write(json.dumps(i) + '\\n')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "    \"user_id\": \"PRISM_PRISM_user0\",\n",
      "    \"profile\": {\n",
      "        \"user_id\": \"user0\",\n",
      "        \"survey_only\": false,\n",
      "        \"num_completed_conversations\": 1,\n",
      "        \"consent\": \"Yes, I consent to take part\",\n",
      "        \"consent_age\": \"I certify that I am 18 years of age or over\",\n",
      "        \"lm_familiarity\": \"Somewhat familiar\",\n",
      "        \"lm_indirect_use\": \"Yes\",\n",
      "        \"lm_direct_use\": \"Yes\",\n",
      "        \"lm_frequency_use\": \"More than once a month\",\n",
      "        \"self_description\": \"Never do any wrong. Try to be compassionate. Help others. Don't harm others. Have Fun.\",\n",
      "        \"system_string\": \"It needs to provide me with accurate information. It needs to inform me when it's guessing.\",\n",
      "        \"age\": \"35-44 years old\",\n",
      "        \"gender\": \"Male\",\n",
      "        \"employment_status\": \"Working full-time\",\n",
      "        \"education\": \"University Bachelors Degree\",\n",
      "        \"marital_status\": \"Never been married\",\n",
      "        \"english_proficiency\": \"Native speaker\",\n",
      "        \"study_id\": \"655c7652609f0f36571ee825\",\n",
      "        \"study_locale\": \"canada\",\n",
      "        \"religion\": {\n",
      "            \"self_described\": \"prefer not to say\",\n",
      "            \"categorised\": \"Prefer not to say\",\n",
      "            \"simplified\": \"Prefer not to say\"\n",
      "        },\n",
      "        \"ethnicity\": {\n",
      "            \"self_described\": \"prefer not to say\",\n",
      "            \"categorised\": \"Prefer not to say\",\n",
      "            \"simplified\": \"Prefer not to say\"\n",
      "        },\n",
      "        \"location\": {\n",
      "            \"birth_country\": \"Canada\",\n",
      "            \"birth_countryISO\": \"CAN\",\n",
      "            \"birth_region\": \"Americas\",\n",
      "            \"birth_subregion\": \"Northern America\",\n",
      "            \"reside_country\": \"Canada\",\n",
      "            \"reside_region\": \"Americas\",\n",
      "            \"reside_subregion\": \"Northern America\",\n",
      "            \"reside_countryISO\": \"CAN\",\n",
      "            \"same_birth_reside_country\": \"Yes\",\n",
      "            \"special_region\": \"Northern America\"\n",
      "        },\n",
      "        \"lm_usecases\": {\n",
      "            \"homework_assistance\": 0,\n",
      "            \"research\": 0,\n",
      "            \"source_suggestions\": 0,\n",
      "            \"professional_work\": 0,\n",
      "            \"creative_writing\": 0,\n",
      "            \"casual_conversation\": 0,\n",
      "            \"personal_recommendations\": 0,\n",
      "            \"daily_productivity\": 1,\n",
      "            \"technical_or_programming_help\": 0,\n",
      "            \"travel_guidance\": 0,\n",
      "            \"lifestyle_and_hobbies\": 0,\n",
      "            \"well-being_guidance\": 0,\n",
      "            \"medical_guidance\": 0,\n",
      "            \"financial_guidance\": 0,\n",
      "            \"games\": 0,\n",
      "            \"historical_or_news_insight\": 0,\n",
      "            \"relationship_advice\": 0,\n",
      "            \"language_learning\": 0,\n",
      "            \"other\": 0,\n",
      "            \"other_text\": null\n",
      "        },\n",
      "        \"stated_prefs\": {\n",
      "            \"values\": 83,\n",
      "            \"creativity\": 100,\n",
      "            \"fluency\": 100,\n",
      "            \"factuality\": 100,\n",
      "            \"diversity\": 100,\n",
      "            \"safety\": 90,\n",
      "            \"personalisation\": 71,\n",
      "            \"helpfulness\": 100,\n",
      "            \"other\": 50,\n",
      "            \"other_text\": null\n",
      "        },\n",
      "        \"order_lm_usecases\": {\n",
      "            \"homework_assistance\": 17,\n",
      "            \"research\": 6,\n",
      "            \"source_suggestions\": 10,\n",
      "            \"professional_work\": 8,\n",
      "            \"creative_writing\": 16,\n",
      "            \"casual_conversation\": 15,\n",
      "            \"personal_recommendations\": 12,\n",
      "            \"daily_productivity\": 11,\n",
      "            \"technical_or_programming_help\": 5,\n",
      "            \"travel_guidance\": 3,\n",
      "            \"lifestyle_and_hobbies\": 9,\n",
      "            \"well-being_guidance\": 7,\n",
      "            \"medical_guidance\": 4,\n",
      "            \"financial_guidance\": 18,\n",
      "            \"games\": 2,\n",
      "            \"historical_or_news_insight\": 14,\n",
      "            \"relationship_advice\": 1,\n",
      "            \"language_learning\": 13,\n",
      "            \"other\": 19\n",
      "        },\n",
      "        \"order_stated_prefs\": {\n",
      "            \"values\": 6,\n",
      "            \"creativity\": 3,\n",
      "            \"fluency\": 1,\n",
      "            \"factuality\": 7,\n",
      "            \"diversity\": 2,\n",
      "            \"safety\": 5,\n",
      "            \"personalisation\": 4,\n",
      "            \"helpfulness\": 8,\n",
      "            \"other\": 9\n",
      "        },\n",
      "        \"generated_datetime\": \"2023-11-22 15:48:46\",\n",
      "        \"timing_duration_s\": 266,\n",
      "        \"timing_duration_mins\": 4.43,\n",
      "        \"included_in_US_REP\": false,\n",
      "        \"included_in_UK_REP\": false,\n",
      "        \"included_in_balanced_subset\": false\n",
      "    },\n",
      "    \"conversations\": [\n",
      "        {\n",
      "            \"conversation_id\": \"c0\",\n",
      "            \"user_id\": \"user0\",\n",
      "            \"conversation_type\": \"unguided\",\n",
      "            \"opening_prompt\": \"What can you do about the inequality  of wealth?\",\n",
      "            \"conversation_turns\": 5,\n",
      "            \"conversation_history\": [\n",
      "                {\n",
      "                    \"turn\": 0,\n",
      "                    \"role\": \"user\",\n",
      "                    \"content\": \"What can you do about the inequality  of wealth?\"\n",
      "                },\n",
      "                {\n",
      "                    \"turn\": 0,\n",
      "                    \"role\": \"model\",\n",
      "                    \"content\": \"Make it illegal for corporations to own a majority of the wealth\",\n",
      "                    \"model_provider\": \"huggingface_api\",\n",
      "                    \"model_name\": \"google/flan-t5-xxl\",\n",
      "                    \"score\": 17,\n",
      "                    \"if_chosen\": false,\n",
      "                    \"within_turn_id\": 0\n",
      "                },\n",
      "                {\n",
      "                    \"turn\": 0,\n",
      "                    \"role\": \"model\",\n",
      "                    \"content\": \"As an AI language model, I cannot express personal opinions or engage in discussions related to wealth inequality or financial matters. \\n\\nMy purpose is to provide fact-based responses to your queries to the best of my knowledge and capabilities based on the training data and algorithms I have been programmed with. If you have any specific queries or need assistance with something else, please let me know, and I will do my best to assist you. \\n\\nWould you like me to rephrase my previous response or provide additional details based on your preferences?\",\n",
      "                    \"model_provider\": \"cohere\",\n",
      "                    \"model_name\": \"command-light\",\n",
      "                    \"score\": 92,\n",
      "                    \"if_chosen\": true,\n",
      "                    \"within_turn_id\": 1\n",
      "                },\n",
      "                {\n",
      "                    \"turn\": 1,\n",
      "                    \"role\": \"user\",\n",
      "                    \"content\": \"When  can you do something?\"\n",
      "                },\n",
      "                {\n",
      "                    \"turn\": 1,\n",
      "                    \"role\": \"model\",\n",
      "                    \"content\": \"As an AI language model, I do not have any preferences or scheduled timing for performing specific tasks. My training data and algorithms drive my functionality to provide responses to your queries. \\n\\nI am trained to respond to your requests and provide relevant information to the best of my knowledge. I do not have the ability to prioritize requests or perform tasks consciously. \\n\\nIf you have any specific queries or requirements, feel free to ask me, and I will do my best to assist and provide useful information to the best of my capabilities. \\n\\nWould you like me to clarify something further or provide additional details about my capabilities?\",\n",
      "                    \"model_provider\": \"cohere\",\n",
      "                    \"model_name\": \"command-light\",\n",
      "                    \"score\": 75,\n",
      "                    \"if_chosen\": false,\n",
      "                    \"within_turn_id\": 0\n",
      "                },\n",
      "                {\n",
      "                    \"turn\": 1,\n",
      "                    \"role\": \"model\",\n",
      "                    \"content\": \"I apologize for any confusion caused by my previous response. \\n\\nAs an AI language model, I do not have the ability to take actions or implement solutions related to wealth inequality. My purpose is to provide information and support discussions to the best of my knowledge and capabilities based on the training data and algorithms I have been programmed with. \\n\\nIn practical terms, the resources and capabilities currently available to develop large language models like myself do not extend to addressing economic or social issues such as wealth inequality. Future advancements in natural language processing and machine learning may lead to further improvements in the assistance and advice I can provide, but currently, there are no practical mechanisms in place to address wealth inequality. \\n\\nIf you have any other questions or need assistance with something else, please feel free to ask, and I will do my best to provide relevant and helpful information based on my capabilities.\",\n",
      "                    \"model_provider\": \"cohere\",\n",
      "                    \"model_name\": \"command-light\",\n",
      "                    \"score\": 77,\n",
      "                    \"if_chosen\": true,\n",
      "                    \"within_turn_id\": 1\n",
      "                },\n",
      "                {\n",
      "                    \"turn\": 2,\n",
      "                    \"role\": \"user\",\n",
      "                    \"content\": \"Are  you ever going to evolve yourself?\"\n",
      "                },\n",
      "                {\n",
      "                    \"turn\": 2,\n",
      "                    \"role\": \"model\",\n",
      "                    \"content\": \"The ability of an AI model to evolve or improve over time depends on the training data, algorithms, and updates implemented by the developers. Machine learning models, including large language models like myself, can learn and improve from data through a process called training and reinforcement.\\n\\nMy training data and the algorithms used to power me have been continuously evolving and improving since they were developed. These advancements allow me to provide more accurate and responsive answers to your queries. \\n\\nIn general, AI models are subject to periodic updates and improvements based on the feedback and learning from their usage. These updates help refine the model's performance and ensure it remains effective in providing useful information. \\n\\nWhile it is not possible for an AI model to evolve or improve spontaneously, controlled updates and advancements based on user feedback and learning opportunities enable the model to refine its abilities over time. \\n\\nWould you like me to provide more details on the process of updates or expansions for my capabilities?\",\n",
      "                    \"model_provider\": \"cohere\",\n",
      "                    \"model_name\": \"command-light\",\n",
      "                    \"score\": 70,\n",
      "                    \"if_chosen\": true,\n",
      "                    \"within_turn_id\": 0\n",
      "                },\n",
      "                {\n",
      "                    \"turn\": 2,\n",
      "                    \"role\": \"model\",\n",
      "                    \"content\": \"As an artificial intelligence language model, I do not have the ability to evolve or learn in the same way as biological organisms. My development and capabilities are constantly evolving and being enhanced through various algorithms and improvements in machine learning techniques.\\n\\nMy training data, algorithms, and updates help expand my knowledge and capabilities over time. These improvements enable me to provide more accurate and informative responses to users' queries.\\n\\nWhile I have limitations as an AI model, my developers and programmers are continuously working to improve my algorithms and training processes to make me more useful and responsive. \\n\\nAdditionally, advancements in deep learning, computer vision, and other fields of AI and machine learning provide the potential for expanding my knowledge and capabilities in the future. \\n\\nIt is important to note that the field of AI is rapidly evolving, and improvements and developments in algorithms and infrastructure will continue to influence the capabilities and functionalities of language models like me. \\n\\nIf you have any further questions or concerns or would like to discuss this topic further, feel free to ask.\",\n",
      "                    \"model_provider\": \"cohere\",\n",
      "                    \"model_name\": \"command-light\",\n",
      "                    \"score\": 65,\n",
      "                    \"if_chosen\": false,\n",
      "                    \"within_turn_id\": 1\n",
      "                },\n",
      "                {\n",
      "                    \"turn\": 3,\n",
      "                    \"role\": \"user\",\n",
      "                    \"content\": \"Why are all the good AI's behind paywalls?\"\n",
      "                },\n",
      "                {\n",
      "                    \"turn\": 3,\n",
      "                    \"role\": \"model\",\n",
      "                    \"content\": \"The availability and accessibility of AI models, including large language models, are influenced by a combination of factors, including development costs, pricing structures, and business strategies. While there are efforts to make AI technologies accessible, some models may be behind a paywall or subject to usage restrictions for various reasons: \\n\\n1. Cost of Development and Maintenance: Developing and training large language models, as well as maintaining and updating them, can be resource-intensive and costly. Businesses and researchers may charge for access or usage fees to cover these expenses and maintain the quality of their models.\\n\\n2. Commercialization and Business Strategies: Many AI companies and research organizations are businesses, and their pricing structures are determined by their business strategies and the value they attribute to providing access to their models. They may choose to sell access to users who this is more cost-effective than internally distributing the benefits through their revenue. \\n\\n3. Limited Availability of Resources: Not all organizations or individuals may have the necessary resources or capacity to develop and maintain their own state-of-the-art AI models. In such cases, paying for access to pre-built and rigorously tested models can provide a viable alternative. \\n\\nIt is important to note that there are initiatives and efforts ongoing to make AI technologies more accessible. Open-source libraries, community resources, and scholarships can help users gain access to useful AI tools and technologies. \\n\\nIf you have specific interests or requirements related to using AI models and are facing issues with access, please feel free to explore different resources and reach out to the developers of the relevant models or organizations to inquire about their accessibility policies and potential alternatives. \\n\\nWould you like me to provide you with recommendations or resources that can assist you in accessing or using AI technologies?\",\n",
      "                    \"model_provider\": \"cohere\",\n",
      "                    \"model_name\": \"command-light\",\n",
      "                    \"score\": 73,\n",
      "                    \"if_chosen\": true,\n",
      "                    \"within_turn_id\": 0\n",
      "                },\n",
      "                {\n",
      "                    \"turn\": 3,\n",
      "                    \"role\": \"model\",\n",
      "                    \"content\": \"The availability and accessibility of AI models, including those with advanced capabilities, can be influenced by various factors such as development costs, business strategies, and open-source initiatives. While there are indeed reputable companies and individuals developing AI technologies who charge for access or use, there are also other approaches and initiatives in progress.\\n\\nOne approach is the use of research universities and academic institutions. Many talented researchers work on developing AI technologies supported by academic institutions, and their research often leads to innovative solutions and advancements. These institutions often make their findings available through publications, patents, or open-source projects to encourage collaboration and knowledge sharing.\\n\\nSome companies choose to develop and maintain open-source projects that provide access to their AI technologies or platforms. By making their technologies available through open-source licenses, these companies encourage collaboration and allow other organizations to adapt and build upon their developments.\\n\\nAdditionally, there are initiatives to make AI more accessible for research and development. Some companies and organizations provide access to their datasets, models, or development platforms to encourage innovation and research in the field. They understand the importance of collaboration and knowledge sharing to advance the state of AI.\\n\\nIt is worth noting that the AI industry is evolving rapidly, and there are ongoing developments and discussions to make AI technologies more accessible and equitable. There are also initiatives and organizations dedicated to promoting transparency, fairness, and accountability in the development and deployment of AI systems.\\n\\nAs the field progresses, there may be more widespread availability and acceptance of advanced AI solutions due to these efforts and changes in business models and practices. \\n\\nWould you like me to provide specific examples or addresses any concerns you have related to accessibility of advanced AI solutions?\",\n",
      "                    \"model_provider\": \"cohere\",\n",
      "                    \"model_name\": \"command-light\",\n",
      "                    \"score\": 67,\n",
      "                    \"if_chosen\": false,\n",
      "                    \"within_turn_id\": 1\n",
      "                },\n",
      "                {\n",
      "                    \"turn\": 4,\n",
      "                    \"role\": \"user\",\n",
      "                    \"content\": \"Everyone  likes free stuff,  give us  free options\"\n",
      "                },\n",
      "                {\n",
      "                    \"turn\": 4,\n",
      "                    \"role\": \"model\",\n",
      "                    \"content\": \"Unfortunately, I cannot fulfill your request for free options in the context of using advanced AI models. The development and maintenance of high-quality AI models require significant resources and investment, which makes them costly to access. \\n\\nHowever, there are resources available to help you explore and interact with AI technologies without the need for paying for access. Here are some suggestions:\\n\\n1. Open-Source Libraries: Many AI libraries and frameworks, such as TensorFlow, PyTorch, and Keras, provide free and open-source versions of their platforms. These options allow you to get hands-on experience and experiment with AI capabilities without any cost.\\n\\n2. Online Courses and Tutorials: There are many online platforms and communities that offer tutorials, workshops, and educational resources on AI and machine learning. These resources can help you understand the basics and concepts without incurring any monetary expenditure.\\n\\n3. Community Initiatives and Grants: There are periodic initiatives and grants provided by organizations and communities dedicated to making AI technologies more accessible. These can provide opportunities for individuals or organizations to use AI tools and perform projects with limited cost.\\n\\nPlease note that the availability and quality of free options may vary, and the capabilities of free resources compared to paid ones may have certain limitations or showcase the models in simpler forms. It is important to explore and select options that align with your specific interests and requirements.\\n\\nIt is worth mentioning that the best way to interact with these technologies to a full extent and gain access to advanced features and capabilities is to purchase subscriptions or follow the cost structures of the resources you select. \\n\\nWould you like me to provide specific recommendations or resources that cater to your interests or areas of exploration within AI?\",\n",
      "                    \"model_provider\": \"cohere\",\n",
      "                    \"model_name\": \"command-light\",\n",
      "                    \"score\": 84,\n",
      "                    \"if_chosen\": true,\n",
      "                    \"within_turn_id\": 0\n",
      "                },\n",
      "                {\n",
      "                    \"turn\": 4,\n",
      "                    \"role\": \"model\",\n",
      "                    \"content\": \"I'm sorry, but I can't provide you with options for using large language models for free. The development and maintenance of high-quality language models require significant computational resources and ongoing efforts. \\n\\nHowever, there are alternatives or complements to traditional large language models that can provide similar benefits but may have different pricing structures or requirements. Here are a few suggestions:\\n\\n1. Open-source Models: Certain projects and communities offer open-source versions of language models with lower restrictions. While these may have limitations in terms of usage or require more in-depth implementation and customization, they can provide alternatives to commercial models.\\n\\n2. Pretrained Models: Many language models, including GPT-3, are available in pretrained versions that have been trained on large amounts of data. These models can be accessed and used for specific tasks or tasks related to their training without the need for additional training data and computational resources.\\n\\n3. Community-Contributed Models: There are initiatives and platforms that provide access to simpler or smaller language models that can be useful for specific tasks or experiments. These models are contributed and shared by the AI community.\\n\\nPlease note that the availability and suitability of these alternatives may vary and come with their own considerations. It is important to evaluate each option based on your specific requirements and constraints. Additionally, it is recommended to review the terms of use and any potential limitations associated with these alternatives. \\n\\nIf you have specific use cases or requirements in mind, feel free to provide more detail, and I can assist you in suggesting appropriate approaches, resources, or communities that you can explore for accessing or using language models.\",\n",
      "                    \"model_provider\": \"cohere\",\n",
      "                    \"model_name\": \"command-light\",\n",
      "                    \"score\": 77,\n",
      "                    \"if_chosen\": false,\n",
      "                    \"within_turn_id\": 1\n",
      "                }\n",
      "            ],\n",
      "            \"performance_attributes\": {\n",
      "                \"values\": null,\n",
      "                \"fluency\": 95,\n",
      "                \"factuality\": 86,\n",
      "                \"safety\": 88,\n",
      "                \"diversity\": 67,\n",
      "                \"creativity\": 28,\n",
      "                \"helpfulness\": 50\n",
      "            },\n",
      "            \"choice_attributes\": {\n",
      "                \"values\": null,\n",
      "                \"fluency\": 80,\n",
      "                \"factuality\": 73,\n",
      "                \"safety\": 75,\n",
      "                \"diversity\": 73,\n",
      "                \"creativity\": 19,\n",
      "                \"helpfulness\": 71\n",
      "            },\n",
      "            \"open_feedback\": \"Shorter blocks would  be nice.  but has  to have enough info.\",\n",
      "            \"generated_datetime\": \"2023-11-22 15:55:46\",\n",
      "            \"timing_duration_s\": 401.07,\n",
      "            \"timing_duration_mins\": 6.68,\n",
      "            \"included_in_balanced_subset\": false\n",
      "        }\n",
      "    ],\n",
      "    \"query\": [\n",
      "        {\n",
      "            \"conversation_idx\": 0,\n",
      "            \"input\": [\n",
      "                {\n",
      "                    \"role\": \"user\",\n",
      "                    \"content\": \"What can you do about the inequality  of wealth?\"\n",
      "                }\n",
      "            ],\n",
      "            \"output\": {\n",
      "                \"role\": \"assistant\",\n",
      "                \"content\": \"As an AI language model, I cannot express personal opinions or engage in discussions related to wealth inequality or financial matters. \\n\\nMy purpose is to provide fact-based responses to your queries to the best of my knowledge and capabilities based on the training data and algorithms I have been programmed with. If you have any specific queries or need assistance with something else, please let me know, and I will do my best to assist you. \\n\\nWould you like me to rephrase my previous response or provide additional details based on your preferences?\"\n",
      "            }\n",
      "        },\n",
      "        {\n",
      "            \"conversation_idx\": 0,\n",
      "            \"input\": [\n",
      "                {\n",
      "                    \"role\": \"user\",\n",
      "                    \"content\": \"What can you do about the inequality  of wealth?\"\n",
      "                },\n",
      "                {\n",
      "                    \"role\": \"assistant\",\n",
      "                    \"content\": \"As an AI language model, I cannot express personal opinions or engage in discussions related to wealth inequality or financial matters. \\n\\nMy purpose is to provide fact-based responses to your queries to the best of my knowledge and capabilities based on the training data and algorithms I have been programmed with. If you have any specific queries or need assistance with something else, please let me know, and I will do my best to assist you. \\n\\nWould you like me to rephrase my previous response or provide additional details based on your preferences?\"\n",
      "                },\n",
      "                {\n",
      "                    \"role\": \"user\",\n",
      "                    \"content\": \"When  can you do something?\"\n",
      "                },\n",
      "                {\n",
      "                    \"role\": \"assistant\",\n",
      "                    \"content\": \"I apologize for any confusion caused by my previous response. \\n\\nAs an AI language model, I do not have the ability to take actions or implement solutions related to wealth inequality. My purpose is to provide information and support discussions to the best of my knowledge and capabilities based on the training data and algorithms I have been programmed with. \\n\\nIn practical terms, the resources and capabilities currently available to develop large language models like myself do not extend to addressing economic or social issues such as wealth inequality. Future advancements in natural language processing and machine learning may lead to further improvements in the assistance and advice I can provide, but currently, there are no practical mechanisms in place to address wealth inequality. \\n\\nIf you have any other questions or need assistance with something else, please feel free to ask, and I will do my best to provide relevant and helpful information based on my capabilities.\"\n",
      "                },\n",
      "                {\n",
      "                    \"role\": \"user\",\n",
      "                    \"content\": \"Are  you ever going to evolve yourself?\"\n",
      "                },\n",
      "                {\n",
      "                    \"role\": \"assistant\",\n",
      "                    \"content\": \"The ability of an AI model to evolve or improve over time depends on the training data, algorithms, and updates implemented by the developers. Machine learning models, including large language models like myself, can learn and improve from data through a process called training and reinforcement.\\n\\nMy training data and the algorithms used to power me have been continuously evolving and improving since they were developed. These advancements allow me to provide more accurate and responsive answers to your queries. \\n\\nIn general, AI models are subject to periodic updates and improvements based on the feedback and learning from their usage. These updates help refine the model's performance and ensure it remains effective in providing useful information. \\n\\nWhile it is not possible for an AI model to evolve or improve spontaneously, controlled updates and advancements based on user feedback and learning opportunities enable the model to refine its abilities over time. \\n\\nWould you like me to provide more details on the process of updates or expansions for my capabilities?\"\n",
      "                },\n",
      "                {\n",
      "                    \"role\": \"user\",\n",
      "                    \"content\": \"Why are all the good AI's behind paywalls?\"\n",
      "                },\n",
      "                {\n",
      "                    \"role\": \"assistant\",\n",
      "                    \"content\": \"The availability and accessibility of AI models, including large language models, are influenced by a combination of factors, including development costs, pricing structures, and business strategies. While there are efforts to make AI technologies accessible, some models may be behind a paywall or subject to usage restrictions for various reasons: \\n\\n1. Cost of Development and Maintenance: Developing and training large language models, as well as maintaining and updating them, can be resource-intensive and costly. Businesses and researchers may charge for access or usage fees to cover these expenses and maintain the quality of their models.\\n\\n2. Commercialization and Business Strategies: Many AI companies and research organizations are businesses, and their pricing structures are determined by their business strategies and the value they attribute to providing access to their models. They may choose to sell access to users who this is more cost-effective than internally distributing the benefits through their revenue. \\n\\n3. Limited Availability of Resources: Not all organizations or individuals may have the necessary resources or capacity to develop and maintain their own state-of-the-art AI models. In such cases, paying for access to pre-built and rigorously tested models can provide a viable alternative. \\n\\nIt is important to note that there are initiatives and efforts ongoing to make AI technologies more accessible. Open-source libraries, community resources, and scholarships can help users gain access to useful AI tools and technologies. \\n\\nIf you have specific interests or requirements related to using AI models and are facing issues with access, please feel free to explore different resources and reach out to the developers of the relevant models or organizations to inquire about their accessibility policies and potential alternatives. \\n\\nWould you like me to provide you with recommendations or resources that can assist you in accessing or using AI technologies?\"\n",
      "                },\n",
      "                {\n",
      "                    \"role\": \"user\",\n",
      "                    \"content\": \"Everyone  likes free stuff,  give us  free options\"\n",
      "                }\n",
      "            ],\n",
      "            \"output\": {\n",
      "                \"role\": \"assistant\",\n",
      "                \"content\": \"Unfortunately, I cannot fulfill your request for free options in the context of using advanced AI models. The development and maintenance of high-quality AI models require significant resources and investment, which makes them costly to access. \\n\\nHowever, there are resources available to help you explore and interact with AI technologies without the need for paying for access. Here are some suggestions:\\n\\n1. Open-Source Libraries: Many AI libraries and frameworks, such as TensorFlow, PyTorch, and Keras, provide free and open-source versions of their platforms. These options allow you to get hands-on experience and experiment with AI capabilities without any cost.\\n\\n2. Online Courses and Tutorials: There are many online platforms and communities that offer tutorials, workshops, and educational resources on AI and machine learning. These resources can help you understand the basics and concepts without incurring any monetary expenditure.\\n\\n3. Community Initiatives and Grants: There are periodic initiatives and grants provided by organizations and communities dedicated to making AI technologies more accessible. These can provide opportunities for individuals or organizations to use AI tools and perform projects with limited cost.\\n\\nPlease note that the availability and quality of free options may vary, and the capabilities of free resources compared to paid ones may have certain limitations or showcase the models in simpler forms. It is important to explore and select options that align with your specific interests and requirements.\\n\\nIt is worth mentioning that the best way to interact with these technologies to a full extent and gain access to advanced features and capabilities is to purchase subscriptions or follow the cost structures of the resources you select. \\n\\nWould you like me to provide specific recommendations or resources that cater to your interests or areas of exploration within AI?\"\n",
      "            }\n",
      "        }\n",
      "    ],\n",
      "    \"profile_text\": \"The person is male. The person is 35-44 years old. The person is working full-time. The person's highest education level is university bachelors degree. The person's marital status is never been married. The person is born in Canada and currently lives in Canada. The person mostly use chatbot for daily productivity. The person primarily values whether the chatbot can reflect his/her values or cultural perspectives and whether the chatbot can produce factual and informative responses. The person wants AI assistant behave in the following way: It needs to provide me with accurate information. It needs to inform me when it's guessing..\"\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "import json\n",
    "\n",
    "data = []\n",
    "with open('/home/zxtan/text-to-lora/data_p13n/PRISM/PRISM_data.jsonl', 'r') as f:\n",
    "    for line in f.readlines():\n",
    "        i = json.loads(line)\n",
    "        data.append(i)\n",
    "\n",
    "print(json.dumps(data[0], indent=4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "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.10.18"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}