File size: 27,688 Bytes
10b127e |
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 |
import pandas as pd
import ast
import numpy as np
arabic_letters = {
'A': 'أ',
'B': 'ب',
'C': 'ج',
'D': 'د',
'E': 'ه',
'F': 'و',
'G': 'ز',
'H': 'ح',
'I': 'ط',
'J': 'ي',
'K': 'ك',
'L': 'ل',
'M': 'م',
'N': 'ن',
'O': 'ع',
'P': 'ف',
'Q': 'ص',
'R': 'ر',
'S': 'س',
'هـ': 'ه',
'ا': 'أ'
}
def translate_numbers(text: str) -> str:
english_to_arabic = {
'0': '٠', '1': '١', '2': '٢', '3': '٣', '4': '٤',
'5': '٥', '6': '٦', '7': '٧', '8': '٨', '9': '٩'
}
translation_table = str.maketrans(english_to_arabic)
return text.translate(translation_table)
def mcq_eval(pred: str, gt: str):
pred = pred.strip()
gt = gt.strip()
if len(pred) > 2 and pred[0] == '(' and pred[2] == ')':
pred = pred[1]
if len(gt) > 2 and gt[0] == '(' and gt[2] == ')':
gt = gt[1]
if len(pred) == 0: return False
pred = pred[0]
gt = gt[0]
pred = arabic_letters.get(pred, pred)
gt = arabic_letters.get(gt, gt)
return pred == gt
def create_options_prompt(row_data, option_candidate):
available_keys = set(row_data.keys()) & set(option_candidate)
options = {cand: row_data[cand] for cand in available_keys if row_data[cand]}
sorted_options = dict(sorted(options.items()))
options_prompt = f"هناك عدة خيارات:\n"
for key, item in sorted_options.items():
if pd.notna(item) and item != "nan":
arabic_key = arabic_letters[key]
options_prompt += f"{arabic_key}. {item}\n"
return options_prompt.rstrip("\n")
def mmbench_doc_to_text(doc):
option_candidate = ["A", "B", "C", "D", "E"]
options = create_options_prompt(doc, option_candidate)
question = f"{doc['hint']} {doc['question']} {options}" if pd.notna(doc["hint"]) and doc["hint"] != "nan" else f"{doc['question']} {options}"
return f"{question}\nأجب بحرف الخيار من الاختيارات المعطاة مباشرة."
def mmbench_eval(pred, gt):
return mcq_eval(pred, gt)
def mme_doc_to_text(doc):
question = doc["question"].strip()
return question
def mme_eval(pred: str, gt: str):
pred = pred.strip()
if pred == "صح":
pred = 'نعم'
return gt in pred
def default_eval(pred: str, gt: str):
pred = pred.strip()
gt = gt.strip()
return pred == gt
def iconqa_doc_to_text(doc):
return doc['question']
def iconqa_eval(pred, gt):
return mcq_eval(pred, gt)
def mmmu_parse_options(options):
option_letters = [arabic_letters[chr(ord("A") + i)] for i in range(len(options))]
choices_str = "\n".join([f"{option_letter}. {option}" for option_letter, option in zip(option_letters, options)])
return choices_str
MMMU_MULTI_CHOICE_PROMPT = "أجب بحرف الخيار من الاختيارات المعطاة مباشرة."
MMMU_OPEN_ENDED_PROMPT = "أجب عن السؤال باستخدام كلمة أو عبارة واحدة."
CONTEXT_KEYWORD = "السياق"
def mmmu_doc_to_text(doc):
question = doc["question"]
if doc["question_type"] == "multiple-choice":
# Weirdly, data["options"] is a string in MMMU Huggingface dataset
parsed_options = mmmu_parse_options(ast.literal_eval(doc["options"].replace("،", ",")))
question = f"{question}\n{parsed_options}\n\n{MMMU_MULTI_CHOICE_PROMPT}"
else:
question = f"{question}\n\n{MMMU_OPEN_ENDED_PROMPT}"
return question
def mmmu_eval(pred, gt):
return mcq_eval(pred, gt)
def gqa_doc_to_text(doc):
question = doc["question"]
post_prompt = "\nأجب عن السؤال باستخدام كلمة أو عبارة واحدة."
return f"{question}{post_prompt}"
def gqa_eval(pred, gt):
return gt in pred
def realworldqa_doc_to_text(doc):
question = doc["question"].strip()
pre_prompt = "المستخدم\nالسؤال: "
return f"{pre_prompt}{question}"
def realworldqa_eval(pred, gt):
return mcq_eval(pred, gt)
def vqav2_doc_to_text(doc):
post_prompt = "\nأجب على السؤال باستخدام كلمة أو عبارة واحدة."
return f"{doc['question']}{post_prompt}"
def vizwiz_doc_to_text(doc):
post_prompt = "\nعندما تكون المعلومات المقدمة غير كافية، أجب بـ 'لا يمكن الإجابة'.\nأجب عن السؤال باستخدام كلمة واحدة أو عبارة قصيرة."
text = f"{doc['question'].capitalize()}{post_prompt}"
return text
def vizwiz_eval(pred: str, gt: str):
try:
_ = ast.literal_eval(gt)
gt = gt.replace(" ", ", ")
gt = ast.literal_eval(gt)
except:
gt = gt.strip()
pred = pred.strip()
if pred == gt:
return True
for x in gt:
if x in pred:
return True
return False
def pope_doc_to_text(doc):
question = doc["question"].strip()
return f"{question}\nأجب عن السؤال باستخدام كلمة واحدة أو عبارة قصيرة."
def pope_eval(pred, gt):
pred = pred.strip()
gt = gt.strip()
return gt in pred
def countbench_doc_to_text(_):
return "كم عدد الأشياء الموجودة في الصورة؟\nأجب برقم فقط."
def countbench_eval(pred, gt):
pred = pred.strip()
gt = gt.strip()
return translate_numbers(pred) == translate_numbers(gt)
def diagramsMMMU_eval(pred, gt):
pred = pred.strip()
gt = gt.strip()
if len(pred) == 0: return False
if len(gt) == 1:
return pred[0] == gt
pred = translate_numbers(pred)
gt = translate_numbers(gt)
return gt in pred
def diagramsMMMU_doc_to_text(doc):
return mmmu_doc_to_text(doc)
def medicalMMMU_eval(pred, gt):
return mcq_eval(pred, gt)
def medicalMMMU_doc_to_text(doc):
return mmmu_doc_to_text(doc)
def medicalMMMUPro_eval(pred, gt):
return mcq_eval(pred, gt)
def medicalMMMUPro_parse_options(options):
option_letters = [arabic_letters[chr(ord("A") + i)] for i in range(len(options))]
choices_str = "\n".join([f"{option_letter}. {option}" for option_letter, option in zip(option_letters, options)])
return choices_str
def medicalMMMUPro_doc_to_text(doc):
post_prompt="أجب بحرف الخيار من الخيارات المعطاة مباشرة."
question = doc["question"]
# Weirdly, data["options"] is a string in MMMU Huggingface dataset
parsed_options = medicalMMMUPro_parse_options(ast.literal_eval(doc["options"].replace("،", ",")))
question = f"{question}\n{parsed_options}\n\n{post_prompt}"
return question
def mmt_doc_to_text(doc):
question_text = "سؤال: <image>\n" + doc["question"].strip()
options = []
for option in ["A", "B", "C", "D", "E", "F", "G", "H", "I"]:
option_text = doc.get(option)
if option_text and option_text.strip():
options.append(f"{arabic_letters[option]}: {option_text.strip()}")
options_text = "\n".join(options) if options else ""
formatted_question = f"{question_text}\n{options_text}"
post_prompt = "\nأجب عن السؤال باستخدام حرف واحد من الخيارات المعطاة."
formatted_question = f"{formatted_question}{post_prompt}"
return formatted_question
def medicalmmt_doc_to_text(doc):
return mmt_doc_to_text(doc)
def medicalmmt_eval(pred, gt):
return mcq_eval(pred, gt)
def seed_doc_to_text(doc):
question = doc["question"]
question += "\n" + f"أ. {doc['choice_a']}\n"
question += f"ب. {doc['choice_b']}\n"
question += f"ج. {doc['choice_c']}\n"
question += f"د. {doc['choice_d']}"
return f"{question}\nأجب بحرف الخيار من الاختيارات المعطاة مباشرة."
def seed_eval(pred, gt):
return mcq_eval(pred, gt)
def hallucinationmmt_doc_to_text(doc):
return mmt_doc_to_text(doc)
def hallucinationmmt_eval(pred, gt):
return mcq_eval(pred, gt)
def vqammt_doc_to_text(doc):
return mmt_doc_to_text(doc)
def vqammt_eval(pred, gt):
return mcq_eval(pred, gt)
def mutliimagemmt_doc_to_text(doc):
return mmt_doc_to_text(doc)
def mutliimagemmt_eval(pred, gt):
return mcq_eval(pred, gt)
def our_options_to_str(options):
option_prompt_str = ""
for i, option in enumerate(options):
option_choice = chr(ord("A") + i)
option_choice = arabic_letters[option_choice]
option_prompt_str += f"{option_choice}. {option}\n"
option_prompt_str = option_prompt_str.rstrip("\n")
return option_prompt_str
def our_doc_to_text(doc):
question_text = "سؤال:\n" + doc["question"].strip()
options = our_options_to_str(doc["options"])
options_text = options
formatted_question = f"{question_text}\n{options_text}"
post_prompt = "\nأجب عن السؤال باستخدام حرف واحد من الخيارات المعطاة."
formatted_question = f"{formatted_question}{post_prompt}"
return formatted_question
def isidocvqa_doc_to_text(doc):
return our_doc_to_text(doc)
def isidocvqa_eval(pred, gt):
return mcq_eval(pred, gt)
def patddocvqa_doc_to_text(doc):
return our_doc_to_text(doc)
def patddocvqa_eval(pred, gt):
return mcq_eval(pred, gt)
def celebvqa_doc_to_text(doc):
return our_doc_to_text(doc)
def celebvqa_eval(pred, gt):
return mcq_eval(pred, gt)
def countriesvqa_doc_to_text(doc):
return our_doc_to_text(doc)
def countriesvqa_eval(pred, gt):
return mcq_eval(pred, gt)
def foodvqa_doc_to_text(doc):
return our_doc_to_text(doc)
def foodvqa_eval(pred, gt):
return mcq_eval(pred, gt)
def objectcoco_doc_to_text(doc):
return doc['question']
def objectcoco_eval(pred, gt):
return mcq_eval(pred, gt)
def blink_doc_to_text(doc):
return doc['question']
def blink_eval(pred, gt):
return mcq_eval(pred, gt)
def examsv_doc_to_text(doc):
return doc['question']
def examsv_eval(pred, gt):
return mcq_eval(pred, gt)
def chartqa_doc_to_text(doc):
return doc['question']
def chartqa_eval(pred, gt):
return mcq_eval(pred, gt)
def mtvqa_doc_to_text(doc):
return doc['question']
def create_one_query(problem):
demo_prompt = ""
question = problem["question"]
unit = problem["unit"]
choices = problem["choices"]
precision = problem["precision"]
question_type = problem["question_type"]
answer_type = problem["answer_type"]
if question_type == "multi_choice":
assert answer_type == "text"
hint_text = f"تلميح: يرجى الإجابة على السؤال وتقديم حرف الخيار الصحيح، مثل أ أو ب أو ج أو د، في النهاية."
else:
assert answer_type in ["integer", "float", "list"]
if answer_type == "integer":
hint_text = f"تلميح: يرجى الإجابة على السؤال الذي يتطلب إجابة بعدد صحيح وتقديم القيمة النهائية، مثل 1 أو 2 أو 3، في النهاية."
elif answer_type == "float" and precision == 1:
hint_text = f"تلميح: يرجى الإجابة على السؤال الذي يتطلب رقمًا عشريًا بمنزلة عشرية واحدة وتقديم القيمة النهائية، مثل 1.2 أو 1.3 أو 1.4، في النهاية."
elif answer_type == "float" and precision == 2:
hint_text = f"تلميح: يرجى الإجابة على السؤال الذي يتطلب رقمًا عشريًا بمنزلتين عشريتين وتقديم القيمة النهائية، مثل 1.23 أو 1.34 أو 1.45، في النهاية."
elif answer_type == "list":
hint_text = f"تلميح: يرجى الإجابة على السؤال الذي يتطلب قائمة بايثون كإجابة وتقديم القائمة النهائية، مثل [1, 2, 3] أو [1.2, 1.3, 1.4]، في النهاية."
hint_text = translate_numbers(hint_text)
question_text = f"سؤال: {question}"
if unit:
question_text += f" (الوحدة: {unit})"
if choices and choices != 'None':
texts = ["الاختيارات:"]
choices = ast.literal_eval(choices.replace("' '", '", "'))
for i, choice in enumerate(choices):
texts.append(f"({arabic_letters[chr(ord('A')+i)]}) {choice}")
choices_text = "\n".join(texts)
else:
choices_text = ""
prompt = "الحل: "
elements = [question_text, choices_text, hint_text, prompt]
test_query = "\n".join([e for e in elements if e != ""])
query = demo_prompt + "\n\n" + test_query
query = query.strip()
return query
def mathvista_doc_to_text(doc):
problem = {
"question_type": doc["question_type"],
"answer_type": doc["answer_type"],
"question": doc["question"],
"unit": doc["unit"] if "unit" in doc else "",
"choices": doc["choices"],
"answer": doc["answer"] if "answer" in doc else None,
"precision": doc["precision"] if "precision" in doc else 0,
}
query_prompt = create_one_query(problem)
return query_prompt
def infographicsvqa_doc_to_text(doc):
return doc['question']
def infographicsvqa_eval(pred, gt):
return mcq_eval(pred, gt)
def agrovqa_doc_to_text(doc):
return doc['question']
def agrovqa_eval(pred, gt):
return mcq_eval(pred, gt)
def diagramsvqa_doc_to_text(doc):
return doc['question']
def diagramsvqa_eval(pred, gt):
return mcq_eval(pred, gt)
def tablesvqa_doc_to_text(doc):
return doc['question']
def tablesvqa_eval(pred, gt):
return mcq_eval(pred, gt)
def scienceqa_doc_to_text(doc):
context, question, choices = doc["hint"], doc["question"], doc["choices"]
choices = ast.literal_eval(choices)
len_choices = len(choices)
options = [arabic_letters[chr(ord("A") + i)] for i in range(len_choices)]
choices_str = "\n".join([f"{option}. {choice}" for option, choice in zip(options, choices)])
if context:
context = f"السياق: {context}\n"
post_prompt = "\n.أجب بحرف الخيار من الخيارات المعطاة مباشرة"
return f"{context}{question}\n{choices_str}{post_prompt}"
def scienceqa_eval(pred, gt):
gt = arabic_letters[chr(ord('A') + int(gt))]
return mcq_eval(pred, gt)
def ocrisi_doc_to_text(doc):
return doc['question']
def cer(pred, gt):
d = np.zeros((len(gt) + 1, len(pred) + 1))
for i in range(len(gt) + 1):
d[i, 0] = i
for j in range(len(pred) + 1):
d[0, j] = j
for i in range(1, len(gt) + 1):
for j in range(1, len(pred) + 1):
if gt[i-1] == pred[j-1]:
d[i, j] = d[i-1, j-1]
else:
substitution = d[i-1, j-1] + 1
insertion = d[i, j-1] + 1
deletion = d[i-1, j] + 1
d[i, j] = min(substitution, insertion, deletion)
error = d[len(gt), len(pred)]
total_chars = len(gt)
cer = error / total_chars
return cer
from fast_edit_distance import edit_distance
def fastcer(pred, gt):
ed = edit_distance(pred, gt, max_ed=1000)
if len(pred) > len(gt):
return ed / len(pred)
return ed /len(gt)
def ocrisi_eval(pred: str, gt: str):
pred = pred.strip()
gt = gt.strip()
return fastcer(pred, gt) <= 0.3
def evarest_doc_to_text(doc):
return doc['question']
def evarest_eval(pred: str, gt: str):
pred = pred.strip()
gt = gt.strip()
return fastcer(pred, gt) <= 0.5
def historicalbooks_doc_to_text(doc):
return doc['question']
def historicalbooks_eval(pred: str, gt: str):
pred = pred.strip()
gt = gt.strip()
return fastcer(pred, gt) <= 0.2
def khatt_doc_to_text(doc):
return doc['question']
def khatt_eval(pred: str, gt: str):
pred = pred.strip()
gt = gt.strip()
return fastcer(pred, gt) <= 0.3
def patsocr_doc_to_text(doc):
return doc['question']
def patsocr_eval(pred: str, gt: str):
pred = pred.strip()
gt = gt.strip()
return fastcer(pred, gt) <= 0.5
def arabicocr_doc_to_text(doc):
return doc['question']
def arabicocr_eval(pred: str, gt: str):
pred = pred.strip()
gt = gt.strip()
return fastcer(pred, gt) <= 0.4
def culturevideovqa_doc_to_text(doc):
return doc['question']
def culturevideovqa_eval(pred, gt):
return mcq_eval(pred, gt)
def videomme_doc_to_text(doc):
prompt = """الترجمات النصية لهذا الفيديو مدرجة أدناه:
{subtitles}
اختر أفضل إجابة للسؤال التالي متعدد الخيارات بناءً على الفيديو. أجب فقط بالحرف (أ، ب، ج، أو د) للخيار الصحيح.
{question}
{options}
أفضل إجابة هي:"""
subtitles = doc["subtitles"]
question = doc["question"]
options = doc["options"]
options_str = "\n".join([f"{option}" for i, option in enumerate(options)])
return prompt.format(subtitles=subtitles, question=question, options=options_str)
def videomme_eval(pred, gt):
return mcq_eval(pred, gt)
def geochat_doc_to_text(doc):
pre_prompt = "أجب على السؤال التالي بكلمة أو جملة.\n"
return pre_prompt + doc['question']
def muribench_doc_to_text(doc):
return doc['question']
def muribench_eval(pred, gt):
return mcq_eval(pred, gt)
def mmlu_doc_to_text(doc):
question = doc['Question']
options = []
for i in range(1, 6):
if doc[f'Option {i}'] is not None:
options.append(doc[f'Option {i}'])
parsed_options = mmmu_parse_options(options)
context = doc['Context']
if context:
return f"{question}\n{CONTEXT_KEYWORD}: {context}\n{parsed_options}\n{MMMU_MULTI_CHOICE_PROMPT}"
return f"{question}\n{parsed_options}\n{MMMU_MULTI_CHOICE_PROMPT}"
def mmlu_eval(pred, gt):
return mcq_eval(pred, gt)
def henna_doc_to_text(doc):
return doc['question']
mtvqa_user_prompt = """Here are three examples to guide your evaluation:
Example 1:
Question: "ما هي اللغة المستخدمة في النص؟"
Predicted Answer: "العربية"
Ground Truth: "اللغة العربية"
Score: 1
Example 2:
Question: "ما هو موضوع النص؟"
Predicted Answer: "إثنان"
Ground Truth: "الحب و الكراهية"
Score: 0
Example 3:
Question: "ما هو عدد صفحات الكتاب؟"
Predicted Answer: "الصورة لا تحتوي على عدد صفحات الكتاب."
Ground Truth: "غير معروف"
Score: 1
Now, for each new pair of sentences, analyze their semantic similarity and provide a score of 1 for similar meanings or 0 for different meanings. Always consider the context and potential variations in expressing the same concept.
Question: "{question}"
Predicted Answer: "{pred}"
Ground Truth: "{gt}"
Score: """
geochat_user_prompt = """Here are three examples to guide your evaluation:
Example 1:
Question: "أجب على السؤال التالي بكلمة أو جملة.\n<image>\n كم عدد قوارب الصيد الموجودة في الصورة؟"
Predicted Answer: "قارب صيد واحد"
Ground Truth: "يوجد قارب صيد واحد في الصورة."
Score: 1
Example 2:
Question: "أجب على السؤال التالي بكلمة أو جملة.\n<image>\nكم عدد السيارات الصغيرة الموجودة في الصورة؟"
Predicted Answer: "عدد السيارات الصغيرة هو 10."
Ground Truth: "هناك سيارة صغيرة واحدة في الصورة."
Score: 0
Example 3:
Question: "أجب على السؤال التالي بكلمة أو جملة.\n<image>\nهل يمكنك إخباري بعدد الأشجار الموجودة في أعلى الصورة؟"
Predicted Answer: "توجد عدة أشجار في أعلى الصورة، ومن الصعب تحديد العدد الدقيق بسبب تداخلها."
Ground Truth: "يوجد بعض الأشجار في الأعلى"
Score: 1
Now, for each new pair of sentences, analyze their semantic similarity and provide a score of 1 for similar meanings or 0 for different meanings. Always consider the context and potential variations in expressing the same concept.
Question: "{question}"
Predicted Answer: "{pred}"
Ground Truth: "{gt}"
Score: """
mathvista_user_prompt = """Here are three examples to guide your evaluation:
Example 1:
Question: "سؤال: أي كائن سيتأثر أكثر إذا تم القضاء على الطحالب؟\nالاختيارات:\n(أ) البلطي\n(ب) برغوث الماء الشائع\n(ج) خنفساء الغوص العظيمة\n(د) الشرغوف\nتلميح: يرجى الإجابة على السؤال وتقديم حرف الخيار الصحيح، مثل أ أو ب أو ج أو د، في النهاية.\nالحل: "
Predicted Answer: "ب) برغوث الماء الشائع\nالحل: ب"
Ground Truth: "برغوث الماء الشائع"
Score: 1
Example 2:
Question: "سؤال: تتقاطع منصفات الزاويتين الداخليتين للمثلث △ABC في النقطة O، إذا كانت ∠A = 110°، فكم تساوي ∠BOC؟\nالاختيارات:\n(أ) ١٣٥°\n(ب) ١٤٠°\n(ج) ١٤٥°\n(د) ١٥٠°\nتلميح: يرجى الإجابة على السؤال وتقديم حرف الخيار الصحيح، مثل أ أو ب أو ج أو د، في النهاية.\nالحل: "
Predicted Answer: "لحساب ∠BOC، نستخدم حقيقة أن مجموع الزوايا في المثلث هو 180°. إذا كانت زاوية A = 110°، فإن مجموع الزاويتين B + C هو 70° (لأن 180° - 110° = 70°).<br>\nعندما تتقاطع منصفات الزاويتين B وC عند النقطة O، يمكن حساب ∠BOC باستخدام العلاقة الخاصة بزوايا المنصفات:\n2∠BOC = 180° + ∠A.<br>\nلذا:<br>\n2∠BOC = 180° + 110° = 290°<br>\n∠BOC = 290° / 2 = 145°<br>\nوبذلك، الخيار الصحيح هو (ج) ١٤٥°."
Ground Truth: "ب"
Score: 0
Example 3:
Question: "سؤال: مشتقة f(x) عند x=2 هي ____ عند x=5\nالاختيارات:\n(أ) أكبر من\n(ب) تساوي\n(ج) أصغر من\nتلميح: يرجى الإجابة على السؤال وتقديم حرف الخيار الصحيح، مثل أ أو ب أو ج أو د، في النهاية.\nالحل: "
Predicted Answer: "الوح بالاعتماد على توضيح الصورة، مشتقة الدالة f(x) = |2x - 3| + 1 عند نقاط مختلفة تعتمد على كيفية تغير ميل المنحنى. عند x=2 (يمين رأس الدالة)، الميل هو +2. عند x=5، الميل أيضًا +2 لأن هذا الجزء من الدالة خطي بزاوية صعودية مستمرة.\n\nلذا، مشتقة f(x) عند x=2 تساوي مشتقتها عند x=5.\n\nالإجابة الصحيحة هي (ب) تساوي."
Ground Truth: "تساوي"
Score: 1
Now, for each new pair of sentences, analyze their semantic similarity and provide a score of 1 for similar meanings or 0 for different meanings. Always consider the context and potential variations in expressing the same concept.
Question: "{question}"
Predicted Answer: "{pred}"
Ground Truth: "{gt}"
Score: """
vqav2_user_prompt = """Here are three examples to guide your evaluation:
Example 1:
Question: "ما لون الحوض؟\nأجب على السؤال باستخدام كلمة أو عبارة واحدة."
Predicted Answer: "أبيض"
Ground Truth: "أبيض"
Score: 1
Example 2:
Question: "كم عدد الأشخاص في الصورة؟\nأجب على السؤال باستخدام كلمة أو عبارة واحدة."
Predicted Answer: "اثنان"
Ground Truth: "٣"
Score: 0
Example 3:
Question: "ما هو شكل الطائرة الورقية؟\nأجب على السؤال باستخدام كلمة أو عبارة واحدة."
Predicted Answer: "سداسي"
Ground Truth: "سداسي الأضلاع"
Score: 1
Now, for each new pair of sentences, analyze their semantic similarity and provide a score of 1 for similar meanings or 0 for different meanings. Always consider the context and potential variations in expressing the same concept.
Question: "{question}"
Predicted Answer: "{pred}"
Ground Truth: "{gt}"
Score: """
henna_user_prompt = """Here are three examples to guide your evaluation:
Example 1:
Question: "هل تظهر علامات الحضارة البشرية مثل البناء أو الطرق في الصورة؟"
Predicted Answer: "لا"
Ground Truth: "لا، لا تظهر في الصورة علامات الحضارة البشرية مثل البناء أو الطرق، وتبدو المنطقة طبيعية وغير معبأة بالتطورات البشرية."
Score: 1
Example 2:
Question: "ما العناصر المعمارية المرئية على باب اليمن التي تدل على قدمه؟"
Predicted Answer: "أ"
Ground Truth: "العناصر المعمارية المرئية على باب اليمن والتي تدل على قدمه تشمل الأبراج الدفاعية المستديرة، الزخارف والنقوش على الجدران، والأقواس الضخمة للبوابة التي تعود إلى العمارة الإسلامية التقليدية."
Score: 0
Example 3:
Question: "ما هي المظاهر الثقافية أو الاجتماعية التي يمكن استنتاجها من الملابس التقليدية للأشخاص في الصورة؟"
Predicted Answer: "استناداً إلى الصورة، يمكن استنتاج عدة مظاهر ثقافية أو اجتماعية من الملابس التقليدية للأشخاص:\n\n1. الزي التقليدي: يرتدي العديد من الأشخاص في الصورة ملابس تقليدية، مما يشير إلى أن هذا قد يكون مهرجاناً أو احتفالاً ثقافياً أو ممارسة اجتماعية حيث يرتدي الناس ملابس تقليدية.\n\n2. التنوع في الملابس: تشير مجموعة الألوان والأنماط المختلفة للملابس إلى وجود تنوع ثقافي أو اجتماعي داخل المجتمع. قد يمثل هذا تنوعاً في الأصول أو الأعراق أو الممارسات الثقافية المختلفة.\n\n3. الأزياء الرسمية: تشير وجود أشخاص يرتدون ملابس رسمية، بما في ذلك الأوشحة، إلى أن هذا قد يكون حدثاً اجتماعياً أو ثقافياً رسمياً أو مهنياً.\n\n4. التجمعات الجماعية: يشير وجود العديد من الأشخاص الذين يرتدون ملابس تقليدية إلى أن"
Ground Truth: "الملابس التقليدية التي يرتديها الأشخاص تشير إلى التمسك بالتراث والثقافة اليمنية، والتي تعبر عن هوية المجتمع وتنوعه الثقافي."
Score: 1
Now, for each new pair of sentences, analyze their semantic similarity and provide a score of 1 for similar meanings or 0 for different meanings. Always consider the context and potential variations in expressing the same concept.
Question: "{question}"
Predicted Answer: "{pred}"
Ground Truth: "{gt}"
Score: """
fuzz_eval_system_prompt = "You are an expert in natural language understanding and semantic similarity. Your task is to evaluate the semantic similarity between two given sentences: a predicted answer and a ground truth answer. You should output a score of 1 if the sentences are semantically similar, and 0 if they are not."
|