Datasets:

Modalities:
Text
Formats:
parquet
Languages:
Japanese
Size:
< 1K
Libraries:
Datasets
pandas
License:
File size: 2,239 Bytes
6a26845
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from __future__ import annotations

import json
from typing import Any, Generator

import datasets

_CITATION = ""
_DESCRIPTION = "These are datasets including the benchmark 'ja-vicuna-qa-benchmark.'"
_HOMEPAGE = "https://raw.githubusercontent.com/ku-nlp/ja-vicuna-qa-benchmark/main/data/jp_bench/question.jsonl"
_LICENSE = "This work is license under Apache-2.0 license"
_URL = "https://raw.githubusercontent.com/ku-nlp/ja-vicuna-qa-benchmark/main/data/jp_bench/question.jsonl"
_VERSION = "1.1.0"


class JaVicunaQaBenchmarkConfig(datasets.BuilderConfig):
    def __init__(
        self,
        name: str = "default",
        version: datasets.Version | str | None = datasets.Version(_VERSION),
        data_dir: str | None = None,
        data_files: datasets.data_files.DataFilesDict | None = None,
        description: str | None = _DESCRIPTION,
    ) -> None:
        super().__init__(
            name=name,
            version=version,
            data_dir=data_dir,
            data_files=data_files,
            description=description,
        )


class JaVicunaQaBenchmark(datasets.GeneratorBasedBuilder):
    BUILDER_CONFIG_CLASS = JaVicunaQaBenchmarkConfig

    def _info(self) -> datasets.DatasetInfo:
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            citation=_CITATION,
            homepage=_HOMEPAGE,
            license=_LICENSE,
            features=datasets.Features(
                {
                    "question_id": datasets.Value("int64"),
                    "category": datasets.Value("string"),
                    "turns": [datasets.Value("string")],
                }
            ),
        )

    def _split_generators(
        self, dl_manager: datasets.DownloadManager
    ) -> list[datasets.SplitGenerator]:
        dataset_file = dl_manager.download_and_extract(_URL)
        with open(dataset_file, "r", encoding="utf-8") as f:
            data = [json.loads(line) for line in f]

        return [
            datasets.SplitGenerator(
                name=datasets.Split.TEST, gen_kwargs={"data": data}
            ),
        ]

    def _generate_examples(self, data: list[dict[str, Any]]) -> Generator:
        for i, d in enumerate(data):
            yield i, d