File size: 46,309 Bytes
4d7573b 2fb2dc0 4d7573b 2fb2dc0 4d7573b 2fb2dc0 4d7573b 2fb2dc0 4d7573b 2fb2dc0 4d7573b 2fb2dc0 4d7573b 2fb2dc0 4d7573b 2fb2dc0 4d7573b 2fb2dc0 4d7573b 2fb2dc0 4d7573b 2fb2dc0 4d7573b 2fb2dc0 4d7573b 2fb2dc0 4d7573b |
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 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os; os.chdir('..');"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/ubuntu/SentenceStructureComparision/venv/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from .autonotebook import tqdm as notebook_tqdm\n"
]
}
],
"source": [
"from datasets import Dataset, load_dataset"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Downloading readme: 100%|██████████| 2.45k/2.45k [00:00<00:00, 14.5MB/s]\n",
"Downloading data: 100%|██████████| 2.56M/2.56M [00:00<00:00, 4.77MB/s]\n",
"Downloading data files: 100%|██████████| 1/1 [00:00<00:00, 1.84it/s]\n",
"Extracting data files: 100%|██████████| 1/1 [00:00<00:00, 603.06it/s]\n",
"Generating evaluation split: 100%|██████████| 238/238 [00:00<00:00, 4242.81 examples/s]\n"
]
}
],
"source": [
"# dataset_name= \"aadityaubhat/GPT-wiki-intro\"\n",
"dataset_name= \"potsawee/wiki_bio_gpt3_hallucination\"\n",
"\n",
"\n",
"\n",
"dataset= load_dataset(dataset_name)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"DatasetDict({\n",
" evaluation: Dataset({\n",
" features: ['gpt3_text', 'wiki_bio_text', 'gpt3_sentences', 'annotation', 'wiki_bio_test_idx', 'gpt3_text_samples'],\n",
" num_rows: 238\n",
" })\n",
"})"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dataset"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Creating CSV from Arrow format: 100%|██████████| 1/1 [00:00<00:00, 5.62ba/s]\n"
]
},
{
"data": {
"text/plain": [
"5060493"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dataset['evaluation'].to_csv(\"data/original_data_gpt3.csv\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>id</th>\n",
" <th>url</th>\n",
" <th>title</th>\n",
" <th>wiki_intro</th>\n",
" <th>generated_intro</th>\n",
" <th>title_len</th>\n",
" <th>wiki_intro_len</th>\n",
" <th>generated_intro_len</th>\n",
" <th>prompt</th>\n",
" <th>generated_text</th>\n",
" <th>prompt_tokens</th>\n",
" <th>generated_text_tokens</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>63064638</td>\n",
" <td>https://en.wikipedia.org/wiki/Sexhow%20railway...</td>\n",
" <td>Sexhow railway station</td>\n",
" <td>Sexhow railway station was a railway station b...</td>\n",
" <td>Sexhow railway station was a railway station l...</td>\n",
" <td>3</td>\n",
" <td>174</td>\n",
" <td>78</td>\n",
" <td>200 word wikipedia style introduction on 'Sexh...</td>\n",
" <td>located in the town of Sexhow, on the Cumbria...</td>\n",
" <td>25</td>\n",
" <td>88</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>279621</td>\n",
" <td>https://en.wikipedia.org/wiki/Eti%C3%A4inen</td>\n",
" <td>Etiäinen</td>\n",
" <td>In Finnish folklore, all places and things, an...</td>\n",
" <td>In Finnish folklore, all places and things, an...</td>\n",
" <td>1</td>\n",
" <td>187</td>\n",
" <td>80</td>\n",
" <td>200 word wikipedia style introduction on 'Etiä...</td>\n",
" <td>animate or inanimate, have a spirit or \"etiäi...</td>\n",
" <td>26</td>\n",
" <td>101</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>287229</td>\n",
" <td>https://en.wikipedia.org/wiki/Inverse%20functi...</td>\n",
" <td>Inverse function theorem</td>\n",
" <td>In mathematics, specifically differential calc...</td>\n",
" <td>In mathematics, specifically differential calc...</td>\n",
" <td>3</td>\n",
" <td>170</td>\n",
" <td>59</td>\n",
" <td>200 word wikipedia style introduction on 'Inve...</td>\n",
" <td>function theorem states that for every real-v...</td>\n",
" <td>26</td>\n",
" <td>65</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>26712375</td>\n",
" <td>https://en.wikipedia.org/wiki/Stepping%20on%20...</td>\n",
" <td>Stepping on Roses</td>\n",
" <td>is a Japanese shōjo manga series written and i...</td>\n",
" <td>is a Japanese shōjo manga series written and i...</td>\n",
" <td>3</td>\n",
" <td>335</td>\n",
" <td>121</td>\n",
" <td>200 word wikipedia style introduction on 'Step...</td>\n",
" <td>and illustrated by Maki Fujii. The series fol...</td>\n",
" <td>26</td>\n",
" <td>150</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>38894426</td>\n",
" <td>https://en.wikipedia.org/wiki/Rob%20Bradley</td>\n",
" <td>Rob Bradley</td>\n",
" <td>Robert Milner \"Rob\" Bradley, Jr. (born August ...</td>\n",
" <td>Robert Milner \"Rob\" Bradley, Jr. (born August ...</td>\n",
" <td>2</td>\n",
" <td>170</td>\n",
" <td>136</td>\n",
" <td>200 word wikipedia style introduction on 'Rob ...</td>\n",
" <td>29, 1973) is an American former professional ...</td>\n",
" <td>28</td>\n",
" <td>162</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" id url \\\n",
"0 63064638 https://en.wikipedia.org/wiki/Sexhow%20railway... \n",
"1 279621 https://en.wikipedia.org/wiki/Eti%C3%A4inen \n",
"2 287229 https://en.wikipedia.org/wiki/Inverse%20functi... \n",
"3 26712375 https://en.wikipedia.org/wiki/Stepping%20on%20... \n",
"4 38894426 https://en.wikipedia.org/wiki/Rob%20Bradley \n",
"\n",
" title \\\n",
"0 Sexhow railway station \n",
"1 Etiäinen \n",
"2 Inverse function theorem \n",
"3 Stepping on Roses \n",
"4 Rob Bradley \n",
"\n",
" wiki_intro \\\n",
"0 Sexhow railway station was a railway station b... \n",
"1 In Finnish folklore, all places and things, an... \n",
"2 In mathematics, specifically differential calc... \n",
"3 is a Japanese shōjo manga series written and i... \n",
"4 Robert Milner \"Rob\" Bradley, Jr. (born August ... \n",
"\n",
" generated_intro title_len \\\n",
"0 Sexhow railway station was a railway station l... 3 \n",
"1 In Finnish folklore, all places and things, an... 1 \n",
"2 In mathematics, specifically differential calc... 3 \n",
"3 is a Japanese shōjo manga series written and i... 3 \n",
"4 Robert Milner \"Rob\" Bradley, Jr. (born August ... 2 \n",
"\n",
" wiki_intro_len generated_intro_len \\\n",
"0 174 78 \n",
"1 187 80 \n",
"2 170 59 \n",
"3 335 121 \n",
"4 170 136 \n",
"\n",
" prompt \\\n",
"0 200 word wikipedia style introduction on 'Sexh... \n",
"1 200 word wikipedia style introduction on 'Etiä... \n",
"2 200 word wikipedia style introduction on 'Inve... \n",
"3 200 word wikipedia style introduction on 'Step... \n",
"4 200 word wikipedia style introduction on 'Rob ... \n",
"\n",
" generated_text prompt_tokens \\\n",
"0 located in the town of Sexhow, on the Cumbria... 25 \n",
"1 animate or inanimate, have a spirit or \"etiäi... 26 \n",
"2 function theorem states that for every real-v... 26 \n",
"3 and illustrated by Maki Fujii. The series fol... 26 \n",
"4 29, 1973) is an American former professional ... 28 \n",
"\n",
" generated_text_tokens \n",
"0 88 \n",
"1 101 \n",
"2 65 \n",
"3 150 \n",
"4 162 "
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"\n",
"df= pd.read_csv(\"data/original_data.csv\")\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>id</th>\n",
" <th>url</th>\n",
" <th>title</th>\n",
" <th>wiki_intro</th>\n",
" <th>generated_intro</th>\n",
" <th>title_len</th>\n",
" <th>wiki_intro_len</th>\n",
" <th>generated_intro_len</th>\n",
" <th>prompt</th>\n",
" <th>generated_text</th>\n",
" <th>prompt_tokens</th>\n",
" <th>generated_text_tokens</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>26709147</td>\n",
" <td>https://en.wikipedia.org/wiki/Moluccans</td>\n",
" <td>Moluccans</td>\n",
" <td>Moluccans are the Austronesian-speaking and Pa...</td>\n",
" <td>Moluccans are the Austronesian-speaking and Pa...</td>\n",
" <td>1</td>\n",
" <td>253</td>\n",
" <td>164</td>\n",
" <td>200 word wikipedia style introduction on 'Molu...</td>\n",
" <td>groups inhabiting the Maluku Islands. The ter...</td>\n",
" <td>33</td>\n",
" <td>238</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" id url title \\\n",
"5 26709147 https://en.wikipedia.org/wiki/Moluccans Moluccans \n",
"\n",
" wiki_intro \\\n",
"5 Moluccans are the Austronesian-speaking and Pa... \n",
"\n",
" generated_intro title_len \\\n",
"5 Moluccans are the Austronesian-speaking and Pa... 1 \n",
"\n",
" wiki_intro_len generated_intro_len \\\n",
"5 253 164 \n",
"\n",
" prompt \\\n",
"5 200 word wikipedia style introduction on 'Molu... \n",
"\n",
" generated_text prompt_tokens \\\n",
"5 groups inhabiting the Maluku Islands. The ter... 33 \n",
"\n",
" generated_text_tokens \n",
"5 238 "
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# df_0= df.head(1)\n",
"# df_0= df.iloc[1] # series result \n",
"df_0= df.iloc[[5]] # dataframe result\n",
"\n",
"df_0"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"title= ['Moluccans']\n",
"\n",
"wiki_intro= ['Moluccans are the Austronesian-speaking and Papuan-speaking ethnic groups indigenous to the Maluku Islands, also called the Moluccas and historically known as the Spice Islands, which as a region has been annexed by Indonesia since the end of 1950. As such, \"Moluccans\" is used as a blanket term for the various ethnic and linguistic groups native to the islands.\\n\\t\\nThe original inhabitants of the Maluku Islands were Austronesian and Melanesian in origin. Austronesian peoples partially assimilated the native Melanesian population in terms of linguistics and other areas, around 2000\\xa0BCE due to extensive trade, making Malayo-Polynesian creole languages the lingua franca in most of the region. Later added to this were several Dutch, Chinese, Portuguese, Spanish, Arabian and English influences due to colonization, marriage with foreign traders during the Silk-route era and Middle ages, and even with European soldiers during the World Wars. A small number of German descendants was added to Moluccan population, especially in Ambon, along with arrival of Protestant Missionaries since 16th century. Moluccans are predominantly Christian like many other Melanesians, but Muslim villages are also present. Despite religious differences, all groups share strong cultural bonds and a sense of common identity, such as through Adat, Pela and Bongso traditions. Music is also a binding factor, playing an important role in the cultural identity. Moluccans historically tend to be a musically gifted people, excelling in creative areas such as singing and sports. In recognition, the Moluccan capital city of Ambon was awarded the official status of City of Music by UNESCO in 2019.']\n",
"\n",
"generated_intro= ['Moluccans are the Austronesian-speaking and Papuan-speaking ethnic groups inhabiting the Maluku Islands. The term \"Moluccan\" is an umbrella term that covers the various Austronesian and Papuan languages spoken on the islands. The largest group of Moluccans are the Tolo-speaking people.\\n\\nThe Maluku Islands are a group of volcanic islands in eastern Indonesia, located about 1,000 kilometres east of Java and 2,000 kilometres south of New Guinea. The islands comprise over 700 islands, with a total land area of approximately 245,000 square kilometres. They have a population of around 1 million people, most of whom are Muslim. The largest island group is the Tolo-speaking region, which comprises over 60% of the population.\\n\\nThe Moluccas were first explored by Europeans in 1512. Portuguese explorer João da Nova discovered Ternate and Tidore, while Dutch explorer Jacob Roggeveen discovered Halmahera and Bougainville. The Moluccas were later visited by Spanish explorer Ferdinand Magellan in 1521. British explorer James Cook visited Ternate, Tidore, Halmahera, and Bougainville during his first voyage in 1770–71.']\n",
"\n",
"prompt= [\"200 word wikipedia style introduction on 'Moluccans'\\n Moluccans are the Austronesian-speaking and Papuan-speaking ethnic\"]\n",
"\n",
"generated_text= [' groups inhabiting the Maluku Islands. The term \"Moluccan\" is an umbrella term that covers the various Austronesian and Papuan languages spoken on the islands. The largest group of Moluccans are the Tolo-speaking people.\\n\\nThe Maluku Islands are a group of volcanic islands in eastern Indonesia, located about 1,000 kilometres east of Java and 2,000 kilometres south of New Guinea. The islands comprise over 700 islands, with a total land area of approximately 245,000 square kilometres. They have a population of around 1 million people, most of whom are Muslim. The largest island group is the Tolo-speaking region, which comprises over 60% of the population.\\n\\nThe Moluccas were first explored by Europeans in 1512. Portuguese explorer João da Nova discovered Ternate and Tidore, while Dutch explorer Jacob Roggeveen discovered Halmahera and Bougainville. The Moluccas were later visited by Spanish explorer Ferdinand Magellan in 1521. British explorer James Cook visited Ternate, Tidore, Halmahera, and Bougainville during his first voyage in 1770–71.']\n"
]
}
],
"source": [
"print(f\"title= {df_0.title.values}\")\n",
"print()\n",
"print(f\"wiki_intro= {df_0.wiki_intro.values}\")\n",
"print()\n",
"print(f\"generated_intro= {df_0.generated_intro.values}\") # prompt {7 tokens} + generated_text\n",
"print()\n",
"print(f\"prompt= {df_0.prompt.values}\")\n",
"print()\n",
"print(f\"generated_text= {df_0.generated_text.values}\")\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Paragraph</th>\n",
" <th>AI_generated</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Sexhow railway station was a railway station b...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>In Finnish folklore, all places and things, an...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>In mathematics, specifically differential calc...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>is a Japanese shōjo manga series written and i...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Robert Milner \"Rob\" Bradley, Jr. (born August ...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149995</th>\n",
" <td>Randy Borum is a Professor and Coordinator of ...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149996</th>\n",
" <td>Sa'och (, also, \"Sauch\") is an endangered, nea...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149997</th>\n",
" <td>Philip C. Hanawalt (born 1931) is an American ...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149998</th>\n",
" <td>Vossius Gymnasium is a public gymnasium in Ams...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149999</th>\n",
" <td>Simone Stratigo (, Symeon Filippos Stratigos; ...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>150000 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" Paragraph AI_generated\n",
"0 Sexhow railway station was a railway station b... 0\n",
"1 In Finnish folklore, all places and things, an... 0\n",
"2 In mathematics, specifically differential calc... 0\n",
"3 is a Japanese shōjo manga series written and i... 0\n",
"4 Robert Milner \"Rob\" Bradley, Jr. (born August ... 0\n",
"... ... ...\n",
"149995 Randy Borum is a Professor and Coordinator of ... 0\n",
"149996 Sa'och (, also, \"Sauch\") is an endangered, nea... 0\n",
"149997 Philip C. Hanawalt (born 1931) is an American ... 0\n",
"149998 Vossius Gymnasium is a public gymnasium in Ams... 0\n",
"149999 Simone Stratigo (, Symeon Filippos Stratigos; ... 0\n",
"\n",
"[150000 rows x 2 columns]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"new_df_human= pd.DataFrame({\n",
" \"Paragraph\": df.wiki_intro, \n",
" \"AI_generated\": pd.Series([0]*len(df))\n",
" \n",
" }\n",
")\n",
"new_df_human"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Paragraph</th>\n",
" <th>AI_generated</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Sexhow railway station was a railway station l...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>In Finnish folklore, all places and things, an...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>In mathematics, specifically differential calc...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>is a Japanese shōjo manga series written and i...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Robert Milner \"Rob\" Bradley, Jr. (born August ...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149995</th>\n",
" <td>Randy Borum is a Professor and Coordinator of ...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149996</th>\n",
" <td>Sa'och (, also, \"Sauch\") is an endangered, nuc...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149997</th>\n",
" <td>Philip C. Hanawalt (born 1931) is an American ...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149998</th>\n",
" <td>Vossius Gymnasium is a public gymnasium in the...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149999</th>\n",
" <td>Simone Stratigo (, Symeon Filippos Stratigos; ...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>150000 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" Paragraph AI_generated\n",
"0 Sexhow railway station was a railway station l... 1\n",
"1 In Finnish folklore, all places and things, an... 1\n",
"2 In mathematics, specifically differential calc... 1\n",
"3 is a Japanese shōjo manga series written and i... 1\n",
"4 Robert Milner \"Rob\" Bradley, Jr. (born August ... 1\n",
"... ... ...\n",
"149995 Randy Borum is a Professor and Coordinator of ... 1\n",
"149996 Sa'och (, also, \"Sauch\") is an endangered, nuc... 1\n",
"149997 Philip C. Hanawalt (born 1931) is an American ... 1\n",
"149998 Vossius Gymnasium is a public gymnasium in the... 1\n",
"149999 Simone Stratigo (, Symeon Filippos Stratigos; ... 1\n",
"\n",
"[150000 rows x 2 columns]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"new_df_ai= pd.DataFrame({\n",
" \"Paragraph\": df.generated_intro, \n",
" \"AI_generated\": pd.Series([1]*len(df))\n",
" \n",
" }\n",
")\n",
"new_df_ai"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([\"In Finnish folklore, all places and things, and also human beings, have a haltija (a genius, guardian spirit) of their own. One such haltija is called etiäinen—an image, doppelgänger, or just an impression that goes ahead of a person, doing things the person in question later does. For example, people waiting at home might hear the door close or even see a shadow or a silhouette, only to realize that no one has yet arrived. Etiäinen can also refer to some kind of a feeling that something is going to happen. Sometimes it could, for example, warn of a bad year coming. In modern Finnish, the term has detached from its shamanistic origins and refers to premonition. Unlike clairvoyance, divination, and similar practices, etiäiset (plural) are spontaneous and can't be induced. Quite the opposite, they may be unwanted and cause anxiety, like ghosts. Etiäiset need not be too dramatic and may concern everyday events, although ones related to e.g. deaths are common. As these phenomena are still reported today, they can be considered a living tradition, as a way to explain the psychological experience of premonition.\"],\n",
" dtype=object)"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"new_df_human.iloc[[1]].Paragraph.values"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array(['In Finnish folklore, all places and things, animate or inanimate, have a spirit or \"etiäinen\" that lives there. Etiäinen can manifest in many forms, but is usually described as a kind, elderly woman with white hair. She is the guardian of natural places and often helps people in need. \\n\\nEtiäinen has been a part of Finnish culture for centuries and is still widely believed in today. Folklorists study etiäinen to understand Finnish traditions and how they have changed over time.'],\n",
" dtype=object)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"new_df_ai.iloc[[1]].Paragraph.values\n"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Paragraph</th>\n",
" <th>AI_generated</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Sexhow railway station was a railway station l...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>In Finnish folklore, all places and things, an...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>In mathematics, specifically differential calc...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>is a Japanese shōjo manga series written and i...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Robert Milner \"Rob\" Bradley, Jr. (born August ...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149995</th>\n",
" <td>Randy Borum is a Professor and Coordinator of ...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149996</th>\n",
" <td>Sa'och (, also, \"Sauch\") is an endangered, nea...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149997</th>\n",
" <td>Philip C. Hanawalt (born 1931) is an American ...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149998</th>\n",
" <td>Vossius Gymnasium is a public gymnasium in Ams...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149999</th>\n",
" <td>Simone Stratigo (, Symeon Filippos Stratigos; ...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>300000 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" Paragraph AI_generated\n",
"0 Sexhow railway station was a railway station l... 1\n",
"1 In Finnish folklore, all places and things, an... 1\n",
"2 In mathematics, specifically differential calc... 1\n",
"3 is a Japanese shōjo manga series written and i... 1\n",
"4 Robert Milner \"Rob\" Bradley, Jr. (born August ... 1\n",
"... ... ...\n",
"149995 Randy Borum is a Professor and Coordinator of ... 0\n",
"149996 Sa'och (, also, \"Sauch\") is an endangered, nea... 0\n",
"149997 Philip C. Hanawalt (born 1931) is an American ... 0\n",
"149998 Vossius Gymnasium is a public gymnasium in Ams... 0\n",
"149999 Simone Stratigo (, Symeon Filippos Stratigos; ... 0\n",
"\n",
"[300000 rows x 2 columns]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"concat_df= pd.concat([new_df_ai, new_df_human])\n",
"concat_df"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Paragraph</th>\n",
" <th>AI_generated</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Sexhow railway station was a railway station l...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Paragraph AI_generated\n",
"0 Sexhow railway station was a railway station l... 1"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"concat_df.iloc[[0000]]\n"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Paragraph</th>\n",
" <th>AI_generated</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Sexhow railway station was a railway station b...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Paragraph AI_generated\n",
"0 Sexhow railway station was a railway station b... 0"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"concat_df.iloc[[150000]]"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"cdf_shffeled= concat_df.sample(frac=1).reset_index(drop=True)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Paragraph</th>\n",
" <th>AI_generated</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Sexhow railway station was a railway station l...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>In Finnish folklore, all places and things, an...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>In mathematics, specifically differential calc...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>is a Japanese shōjo manga series written and i...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Robert Milner \"Rob\" Bradley, Jr. (born August ...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149995</th>\n",
" <td>Randy Borum is a Professor and Coordinator of ...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149996</th>\n",
" <td>Sa'och (, also, \"Sauch\") is an endangered, nea...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149997</th>\n",
" <td>Philip C. Hanawalt (born 1931) is an American ...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149998</th>\n",
" <td>Vossius Gymnasium is a public gymnasium in Ams...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149999</th>\n",
" <td>Simone Stratigo (, Symeon Filippos Stratigos; ...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>300000 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" Paragraph AI_generated\n",
"0 Sexhow railway station was a railway station l... 1\n",
"1 In Finnish folklore, all places and things, an... 1\n",
"2 In mathematics, specifically differential calc... 1\n",
"3 is a Japanese shōjo manga series written and i... 1\n",
"4 Robert Milner \"Rob\" Bradley, Jr. (born August ... 1\n",
"... ... ...\n",
"149995 Randy Borum is a Professor and Coordinator of ... 0\n",
"149996 Sa'och (, also, \"Sauch\") is an endangered, nea... 0\n",
"149997 Philip C. Hanawalt (born 1931) is an American ... 0\n",
"149998 Vossius Gymnasium is a public gymnasium in Ams... 0\n",
"149999 Simone Stratigo (, Symeon Filippos Stratigos; ... 0\n",
"\n",
"[300000 rows x 2 columns]"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"concat_df"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Paragraph</th>\n",
" <th>AI_generated</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Bentivoglio is an Italian surname. Notable peo...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Stephanie McCallum (born Sydney, Australia, 3...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Abdāl lit: substitutes, but which can also be...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>The Gadget is a young adult historical novel w...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>The A-1 lifeboat was a powered lifeboat that w...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>299995</th>\n",
" <td>James Wrighten (b. 1745 - d. 1793) was an Amer...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>299996</th>\n",
" <td>The U-matrix (unified distance matrix) is a sy...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>299997</th>\n",
" <td>Holding Trevor is a 2007 American gay-themed p...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>299998</th>\n",
" <td>Jarvisfield is a heritage-listed former pastor...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>299999</th>\n",
" <td>The Silver Guardian is a Chinese web series c...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>300000 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" Paragraph AI_generated\n",
"0 Bentivoglio is an Italian surname. Notable peo... 0\n",
"1 Stephanie McCallum (born Sydney, Australia, 3... 0\n",
"2 Abdāl lit: substitutes, but which can also be... 1\n",
"3 The Gadget is a young adult historical novel w... 1\n",
"4 The A-1 lifeboat was a powered lifeboat that w... 0\n",
"... ... ...\n",
"299995 James Wrighten (b. 1745 - d. 1793) was an Amer... 1\n",
"299996 The U-matrix (unified distance matrix) is a sy... 1\n",
"299997 Holding Trevor is a 2007 American gay-themed p... 1\n",
"299998 Jarvisfield is a heritage-listed former pastor... 0\n",
"299999 The Silver Guardian is a Chinese web series c... 1\n",
"\n",
"[300000 rows x 2 columns]"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cdf_shffeled"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"cdf_shffeled.to_csv(\"data/AI_checker_remade.csv\", index=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"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.12"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
|