File size: 877 Bytes
b0c0df0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
def dtcbench_doc_to_visual(doc):
    return [doc["image"].convert("RGB")]


def dtcbench_doc_to_text(doc):
    question = doc["question"]
    question += f"\nOptions: A: {doc['choice_a']}, B: {doc['choice_b']}, C: {doc['choice_c']}, D: {doc['choice_d']}"
    return f"{question}\n์ฃผ์–ด์ง„ ์„ ํƒ์ง€ ์ค‘ ํ•ด๋‹น ์˜ต์…˜์˜ ๋ฌธ์ž๋กœ ๋ฐ”๋กœ ๋‹ตํ•˜์„ธ์š”."


def dtcbench_process_result(doc, result):
    pred = result[0].strip()
    if len(pred) > 1:
        pred = pred[0]
    answer = doc["answer"]

    return {"dtcbench_acc": {"pred": pred, "answer": answer, "question_id": doc["index"]}}


def dtcbench_aggregation_result(results):
    total_count = 0
    total_correct = 0
    for result in results:
        if result["pred"].lower().strip() == result["answer"].lower().strip():
            total_correct += 1
        total_count += 1
    return total_correct / total_count