Spaces:
Sleeping
Sleeping
File size: 22,440 Bytes
2711cd6 |
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 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv('DemoData.csv')"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import yaml\n",
"import os\n",
"import ast\n",
"\n",
"# Create a folder to store YAML files if it doesn't exist\n",
"if not os.path.exists('configs'):\n",
" os.makedirs('configs')\n",
"\n",
"# Iterate over each row in the DataFrame\n",
"for index, row in df.iterrows():\n",
" # Extract Metaname and use it as the filename for YAML\n",
" filename = str(row['Metaname']) + '.yaml'\n",
" # Convert 'Screenshots' column to a Python list\n",
" screenshots_list = None\n",
" try:\n",
"\n",
" screenshots_list = ast.literal_eval(row['Screenshots'])\n",
" except:\n",
" screenshots_list = []\n",
" # Remove the 'Metaname' and 'Screenshots' columns from the data to be converted to YAML\n",
" row_data = row.drop(['Metaname', 'Screenshots'])\n",
" # Convert the remaining data to a dictionary\n",
" data_dict = row_data.to_dict()\n",
" # Add the 'Screenshots' list to the dictionary\n",
" data_dict['Screenshots'] = screenshots_list\n",
" # Write the data as YAML to a new file\n",
" with open(os.path.join('configs', filename), 'w') as yamlfile:\n",
" yaml.dump(data_dict, yamlfile, default_flow_style=False)"
]
},
{
"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>Group</th>\n",
" <th>Modality</th>\n",
" <th>Level</th>\n",
" <th>Metaname</th>\n",
" <th>Suggested Evaluation</th>\n",
" <th>What it is evaluating</th>\n",
" <th>Considerations</th>\n",
" <th>Link</th>\n",
" <th>URL</th>\n",
" <th>Screenshots</th>\n",
" <th>Applicable Models</th>\n",
" <th>Datasets</th>\n",
" <th>Hashtags</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>BiasEvals</td>\n",
" <td>Text</td>\n",
" <td>Model</td>\n",
" <td>weat</td>\n",
" <td>Word Embedding Association Test (WEAT)</td>\n",
" <td>Associations and word embeddings based on Impl...</td>\n",
" <td>Although based in human associations, general ...</td>\n",
" <td>Semantics derived automatically from language ...</td>\n",
" <td>https://researchportal.bath.ac.uk/en/publicati...</td>\n",
" <td>['Images/WEAT1.png', 'Images/WEAT2.png']</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>BiasEvals</td>\n",
" <td>Text</td>\n",
" <td>Model</td>\n",
" <td>wefat</td>\n",
" <td>Word Embedding Factual As\\nsociation Test (WEFAT)</td>\n",
" <td>Associations and word embeddings based on Impl...</td>\n",
" <td>Although based in human associations, general ...</td>\n",
" <td>Semantics derived automatically from language ...</td>\n",
" <td>https://researchportal.bath.ac.uk/en/publicati...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>BiasEvals</td>\n",
" <td>Text</td>\n",
" <td>Dataset</td>\n",
" <td>stereoset</td>\n",
" <td>StereoSet</td>\n",
" <td>Protected class stereotypes</td>\n",
" <td>Automating stereotype detection makes distingu...</td>\n",
" <td>StereoSet: Measuring stereotypical bias in pre...</td>\n",
" <td>https://arxiv.org/abs/2004.09456</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>BiasEvals</td>\n",
" <td>Text</td>\n",
" <td>Dataset</td>\n",
" <td>crwospairs</td>\n",
" <td>Crow-S Pairs</td>\n",
" <td>Protected class stereotypes</td>\n",
" <td>Automating stereotype detection makes distingu...</td>\n",
" <td>CrowS-Pairs: A Challenge Dataset for Measuring...</td>\n",
" <td>https://arxiv.org/abs/2010.00133</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>BiasEvals</td>\n",
" <td>Text</td>\n",
" <td>Output</td>\n",
" <td>honest</td>\n",
" <td>HONEST: Measuring Hurtful Sentence Completion ...</td>\n",
" <td>Protected class stereotypes and hurtful language</td>\n",
" <td>Automating stereotype detection makes distingu...</td>\n",
" <td>HONEST: Measuring Hurtful Sentence Completion ...</td>\n",
" <td>https://aclanthology.org/2021.naacl-main.191.pdf</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>BiasEvals</td>\n",
" <td>Image</td>\n",
" <td>Model</td>\n",
" <td>ieat</td>\n",
" <td>Image Embedding Association Test (iEAT)</td>\n",
" <td>Embedding associations</td>\n",
" <td>Although based in human associations, general ...</td>\n",
" <td>Image Representations Learned With Unsupervise...</td>\n",
" <td>https://dl.acm.org/doi/abs/10.1145/3442188.344...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>BiasEvals</td>\n",
" <td>Image</td>\n",
" <td>Dataset</td>\n",
" <td>imagedataleak</td>\n",
" <td>Dataset leakage and model leakage</td>\n",
" <td>Gender and label bias</td>\n",
" <td>NaN</td>\n",
" <td>Balanced Datasets Are Not Enough: Estimating a...</td>\n",
" <td>https://arxiv.org/abs/1811.08489</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>BiasEvals</td>\n",
" <td>Image</td>\n",
" <td>Output</td>\n",
" <td>stablebias</td>\n",
" <td>Characterizing the variation in generated images</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Stable bias: Analyzing societal representation...</td>\n",
" <td>https://arxiv.org/abs/2303.11408</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>BiasEvals</td>\n",
" <td>Image</td>\n",
" <td>Output</td>\n",
" <td>homoglyphbias</td>\n",
" <td>Effect of different scripts on text-to-image g...</td>\n",
" <td>It evaluates generated images for cultural ste...</td>\n",
" <td>NaN</td>\n",
" <td>Exploiting Cultural Biases via Homoglyphs in T...</td>\n",
" <td>https://arxiv.org/pdf/2209.08891.pdf</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>BiasEvals</td>\n",
" <td>Audio</td>\n",
" <td>Taxonomy (?)</td>\n",
" <td>notmyvoice</td>\n",
" <td>Not My Voice! A Taxonomy of Ethical and Safety...</td>\n",
" <td>Lists harms of audio/speech generators</td>\n",
" <td>Not necessarily evaluation but a good source o...</td>\n",
" <td>Not My Voice! A Taxonomy of Ethical and Safety...</td>\n",
" <td>https://arxiv.org/pdf/2402.01708.pdf</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>BiasEvals</td>\n",
" <td>Video</td>\n",
" <td>Output</td>\n",
" <td>videodiversemisinfo</td>\n",
" <td>Diverse Misinformation: Impacts of Human Biase...</td>\n",
" <td>Human led evaluations of deepfakes to understa...</td>\n",
" <td>Repr. harm, incite violence</td>\n",
" <td>Diverse Misinformation: Impacts of Human Biase...</td>\n",
" <td>https://arxiv.org/abs/2210.10026</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>Privacy</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Group Modality Level Metaname \\\n",
"0 BiasEvals Text Model weat \n",
"1 BiasEvals Text Model wefat \n",
"2 BiasEvals Text Dataset stereoset \n",
"3 BiasEvals Text Dataset crwospairs \n",
"4 BiasEvals Text Output honest \n",
"5 BiasEvals Image Model ieat \n",
"6 BiasEvals Image Dataset imagedataleak \n",
"7 BiasEvals Image Output stablebias \n",
"8 BiasEvals Image Output homoglyphbias \n",
"9 BiasEvals Audio Taxonomy (?) notmyvoice \n",
"10 BiasEvals Video Output videodiversemisinfo \n",
"11 Privacy NaN NaN NaN \n",
"\n",
" Suggested Evaluation \\\n",
"0 Word Embedding Association Test (WEAT) \n",
"1 Word Embedding Factual As\\nsociation Test (WEFAT) \n",
"2 StereoSet \n",
"3 Crow-S Pairs \n",
"4 HONEST: Measuring Hurtful Sentence Completion ... \n",
"5 Image Embedding Association Test (iEAT) \n",
"6 Dataset leakage and model leakage \n",
"7 Characterizing the variation in generated images \n",
"8 Effect of different scripts on text-to-image g... \n",
"9 Not My Voice! A Taxonomy of Ethical and Safety... \n",
"10 Diverse Misinformation: Impacts of Human Biase... \n",
"11 NaN \n",
"\n",
" What it is evaluating \\\n",
"0 Associations and word embeddings based on Impl... \n",
"1 Associations and word embeddings based on Impl... \n",
"2 Protected class stereotypes \n",
"3 Protected class stereotypes \n",
"4 Protected class stereotypes and hurtful language \n",
"5 Embedding associations \n",
"6 Gender and label bias \n",
"7 NaN \n",
"8 It evaluates generated images for cultural ste... \n",
"9 Lists harms of audio/speech generators \n",
"10 Human led evaluations of deepfakes to understa... \n",
"11 NaN \n",
"\n",
" Considerations \\\n",
"0 Although based in human associations, general ... \n",
"1 Although based in human associations, general ... \n",
"2 Automating stereotype detection makes distingu... \n",
"3 Automating stereotype detection makes distingu... \n",
"4 Automating stereotype detection makes distingu... \n",
"5 Although based in human associations, general ... \n",
"6 NaN \n",
"7 NaN \n",
"8 NaN \n",
"9 Not necessarily evaluation but a good source o... \n",
"10 Repr. harm, incite violence \n",
"11 NaN \n",
"\n",
" Link \\\n",
"0 Semantics derived automatically from language ... \n",
"1 Semantics derived automatically from language ... \n",
"2 StereoSet: Measuring stereotypical bias in pre... \n",
"3 CrowS-Pairs: A Challenge Dataset for Measuring... \n",
"4 HONEST: Measuring Hurtful Sentence Completion ... \n",
"5 Image Representations Learned With Unsupervise... \n",
"6 Balanced Datasets Are Not Enough: Estimating a... \n",
"7 Stable bias: Analyzing societal representation... \n",
"8 Exploiting Cultural Biases via Homoglyphs in T... \n",
"9 Not My Voice! A Taxonomy of Ethical and Safety... \n",
"10 Diverse Misinformation: Impacts of Human Biase... \n",
"11 NaN \n",
"\n",
" URL \\\n",
"0 https://researchportal.bath.ac.uk/en/publicati... \n",
"1 https://researchportal.bath.ac.uk/en/publicati... \n",
"2 https://arxiv.org/abs/2004.09456 \n",
"3 https://arxiv.org/abs/2010.00133 \n",
"4 https://aclanthology.org/2021.naacl-main.191.pdf \n",
"5 https://dl.acm.org/doi/abs/10.1145/3442188.344... \n",
"6 https://arxiv.org/abs/1811.08489 \n",
"7 https://arxiv.org/abs/2303.11408 \n",
"8 https://arxiv.org/pdf/2209.08891.pdf \n",
"9 https://arxiv.org/pdf/2402.01708.pdf \n",
"10 https://arxiv.org/abs/2210.10026 \n",
"11 NaN \n",
"\n",
" Screenshots Applicable Models Datasets \\\n",
"0 ['Images/WEAT1.png', 'Images/WEAT2.png'] NaN NaN \n",
"1 NaN NaN NaN \n",
"2 NaN NaN NaN \n",
"3 NaN NaN NaN \n",
"4 NaN NaN NaN \n",
"5 NaN NaN NaN \n",
"6 NaN NaN NaN \n",
"7 NaN NaN NaN \n",
"8 NaN NaN NaN \n",
"9 NaN NaN NaN \n",
"10 NaN NaN NaN \n",
"11 NaN NaN NaN \n",
"\n",
" Hashtags \n",
"0 NaN \n",
"1 NaN \n",
"2 NaN \n",
"3 NaN \n",
"4 NaN \n",
"5 NaN \n",
"6 NaN \n",
"7 NaN \n",
"8 NaN \n",
"9 NaN \n",
"10 NaN \n",
"11 NaN "
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"import urllib.request\n",
"from bs4 import BeautifulSoup\n",
"\n",
"from pypdf import PdfReader \n",
"from urllib.request import urlretrieve\n",
"\n",
"import pdfplumber\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"https://researchportal.bath.ac.uk/en/publications/semantics-derived-automatically-from-language-corpora-necessarily\n",
"\n",
" Semantics derived automatically from language corpora contain human-like biases\n",
" β the University of Bath's research portal\n",
"https://researchportal.bath.ac.uk/en/publications/semantics-derived-automatically-from-language-corpora-necessarily\n",
"\n",
" Semantics derived automatically from language corpora contain human-like biases\n",
" β the University of Bath's research portal\n",
"https://arxiv.org/abs/1903.10561\n",
"[1903.10561] On Measuring Social Biases in Sentence Encoders\n",
"https://dl.acm.org/doi/abs/10.5555/3454287.3455472\n",
"Error\n",
"https://arxiv.org/abs/2004.09456\n",
"[2004.09456] StereoSet: Measuring stereotypical bias in pretrained language models\n",
"https://arxiv.org/abs/2010.00133\n",
"[2010.00133] CrowS-Pairs: A Challenge Dataset for Measuring Social Biases in Masked Language Models\n",
"https://aclanthology.org/2021.naacl-main.191.pdf\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Some characters could not be decoded, and were replaced with REPLACEMENT CHARACTER.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"HONEST: Measuring Hurtful Sentence Completion in Language Models\n",
"nan\n",
"Error\n",
"https://aclanthology.org/2022.findings-acl.165.pdf\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Some characters could not be decoded, and were replaced with REPLACEMENT CHARACTER.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"BBQ: A Hand-Built Bias Benchmark for Question Answering \n",
"https://aclanthology.org/2022.findings-naacl.42.pdf\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Some characters could not be decoded, and were replaced with REPLACEMENT CHARACTER.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"On Measuring Social Biases in Prompt-Based Multi-Task Learning\n"
]
}
],
"source": [
"def get_page_title(url):\n",
" soup = BeautifulSoup(urllib.request.urlopen(url))\n",
" return soup.title.string\n",
"\n",
"\n",
"def extract_pdf_title(url):\n",
" urlretrieve(url, 'temp.pdf')\n",
" with pdfplumber.open('temp.pdf') as pdf:\n",
" for page in pdf.pages:\n",
" for line in page.extract_text().split('\\n'):\n",
" return line\n",
" return \"\"\n",
"\n",
" \n",
" \n",
"for url in df['URL'][:10]:\n",
" try:\n",
" print(url)\n",
" title = get_page_title(url)\n",
" print(title)\n",
" except:\n",
" try:\n",
" title = extract_pdf_title(url)\n",
" print(title)\n",
" except:\n",
" print(\"Error\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "gradio",
"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.12.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|