import json import datasets _DESCRIPTION = """\ This is a Japanese translated version of HumanEval, an evaluation harness for the HumanEval problem solving dataset described in the paper "Evaluating Large Language Models Trained on Code". """ _URL = "https://raw.githubusercontent.com/KuramitsuLab/jhuman-eval/main/data/jhuman-eval.jsonl.gz" _LICENSE = "MIT" class JHumaneval(datasets.GeneratorBasedBuilder): VERSION = datasets.Version("0.1.0") BUILDER_CONFIGS = [ datasets.BuilderConfig( name="jhumaneval", version=VERSION, description=_DESCRIPTION, ) ] def _info(self): features = datasets.Features( { "task_id": datasets.Value("string"), "prompt_en": datasets.Value("string"), "prompt": datasets.Value("string"), "entry_point": datasets.Value("string"), "canonical_solution": datasets.Value("string"), "test": datasets.Value("string"), } ) return datasets.DatasetInfo( description=_DESCRIPTION, features=features, supervised_keys=None, license=_LICENSE, ) def _split_generators(self, dl_manager): """Returns SplitGenerators.""" data_dir = dl_manager.download_and_extract(_URL) return [ datasets.SplitGenerator( name=datasets.Split.TEST, gen_kwargs={ "filepath": data_dir, }, ) ] def _generate_examples(self, filepath): """Yields examples.""" with open(filepath, encoding="utf-8") as file: data = [json.loads(line) for line in file] id_ = 0 for sample in data: yield id_, sample id_ += 1