File size: 2,543 Bytes
168b56f a76b684 168b56f a76b684 168b56f a76b684 168b56f 0da1b17 168b56f f8660c4 168b56f d12b498 168b56f |
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 |
import os
import datasets
import json
import pandas as pd
_CITATION = """\
@article{son2023hae,
title={HAE-RAE Bench: Evaluation of Korean Knowledge in Language Models},
author={Son, Guijin and Lee, Hanwool and Kim, Suwan and Lee, Jaecheol and Yeom, Je Won and Jung, Jihyu and Kim, Jung Woo and Kim, Songseong},
journal={arXiv preprint arXiv:2309.02706},
year={2023}
}
"""
_DESCRIPTION = """\
HAE-RAE Bench
"""
_HOMEPAGE = "https://huggingface.co/HAERAE-HUB"
_LICENSE = "cc-by-nc-nd-4.0"
split_names = ['standard_nomenclature',
'correct_definition_matching',
'date_understanding',
'general_knowledge',
'history',
'loan_word',
'lyrics_denoising',
'proverbs_denoising',
'rare_word',
'reading_comprehension']
class HRBConfig(datasets.BuilderConfig):
def __init__(self, **kwargs):
super().__init__(version=datasets.Version("1.0.1"), **kwargs)
class HRB(datasets.GeneratorBasedBuilder):
BUILDER_CONFIGS = [
HRBConfig(
name=name,
)
for name in split_names
]
def _info(self):
features = datasets.Features(
{
"query": datasets.Value("string"),
"options" : datasets.Value("string"),
"answer": datasets.Value("string"),
"category": datasets.Value("string"),
}
)
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=features,
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
train_path = dl_manager.download_and_extract("./data/hrb.v1.1.jsonl")
return [
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={
"filepath": train_path,
},
),
]
def _generate_examples(self, filepath):
with open(filepath, encoding="utf-8") as f:
buffer = []
for key, row in enumerate(f):
data = json.loads(row)
if data["category"] == self.config.name:
buffer.append({
"query": data["query"],
"options" : data["options"],
"answer": data["answer"],
"category": data["category"]
})
for idx, dat in enumerate(buffer):
yield idx,dat
|