yuting-wei commited on
Commit
316892a
·
verified ·
1 Parent(s): a949f00

Upload 2 files

Browse files
Files changed (2) hide show
  1. aceval.py +116 -0
  2. aceval.zip +3 -0
aceval.py ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import os
16
+ import datasets
17
+ import pandas as pd
18
+
19
+
20
+ _CITATION = """\
21
+ @misc{wei2024aceval,
22
+ title={AC-EVAL: Evaluating Ancient Chinese Language Understanding in Large Language Models},
23
+ author={Yuting Wei and Yuanxing Xu and Xinru Wei and Simin Yang and Yangfu Zhu and Yuqing Li and Di Liu and Bin Wu},
24
+ year={2024},
25
+ eprint={2403.06574},
26
+ archivePrefix={arXiv},
27
+ primaryClass={cs.CL}
28
+ }
29
+ """
30
+
31
+ _DESCRIPTION = """\
32
+ AC-EVAL presents a thorough evaluation suite for Large Language Models (LLMs) focusing on ancient Chinese, covering eras from the Pre-Qin period to the Qing dynasty. This suite includes 3245 multi-choice questions across 3 levels of difficulty and 13 diverse tasks.
33
+ """
34
+
35
+ _HOMEPAGE = "https://github.com/yuting-wei/AC-EVAL"
36
+
37
+ _LICENSE = "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License"
38
+
39
+ _URL = r"https://huggingface.co/datasets/yuting-wei/aceval/resolve/main/aceval.zip"
40
+
41
+ task_list = [
42
+ 'historical_facts',
43
+ 'geography',
44
+ 'social_customs',
45
+ 'art_and_cultural_heritage',
46
+ 'philosophy_and_religion',
47
+ 'lexical_pragmatics_analysis',
48
+ 'allusions_and_idioms',
49
+ 'word_sense_disambiguation',
50
+ 'translation',
51
+ 'event_extraction',
52
+ 'sentence_pauses',
53
+ 'summarization_and_analysis',
54
+ 'poetry_appreciation'
55
+ ]
56
+
57
+
58
+ class ACEVALConfig(datasets.BuilderConfig):
59
+ def __init__(self, **kwargs):
60
+ super().__init__(version=datasets.Version("1.0.0"), **kwargs)
61
+
62
+
63
+ class ACEVAL(datasets.GeneratorBasedBuilder):
64
+ BUILDER_CONFIGS = [
65
+ ACEVALConfig(
66
+ name=task_name
67
+ )
68
+ for task_name in task_list
69
+ ]
70
+
71
+ def _info(self):
72
+ features = datasets.Features(
73
+ {
74
+ "Question": datasets.Value("string"),
75
+ "A": datasets.Value("string"),
76
+ "B": datasets.Value("string"),
77
+ "C": datasets.Value("string"),
78
+ "D": datasets.Value("string"),
79
+ "Answer": datasets.Value("string"),
80
+ "Explanation":datasets.Value("string"),
81
+ }
82
+ )
83
+ return datasets.DatasetInfo(
84
+ description=_DESCRIPTION,
85
+ features=features,
86
+ homepage=_HOMEPAGE,
87
+ license=_LICENSE,
88
+ citation=_CITATION,
89
+ )
90
+
91
+ def _split_generators(self, dl_manager):
92
+ data_dir = dl_manager.download_and_extract(_URL)
93
+ task_name = self.config.name
94
+ return [
95
+ datasets.SplitGenerator(
96
+ name=datasets.Split.TEST,
97
+ gen_kwargs={
98
+ "filepath": os.path.join(data_dir, f"test/{task_name}.xlsx"),
99
+ },
100
+ ),
101
+ datasets.SplitGenerator(
102
+ name=datasets.Split("dev"),
103
+ gen_kwargs={
104
+ "filepath": os.path.join(data_dir, f"dev/{task_name}.xlsx"),
105
+ },
106
+ ),
107
+ ]
108
+
109
+ def _generate_examples(self, filepath):
110
+ df = pd.read_excel(filepath, encoding="utf-8")
111
+ for i, instance in enumerate(df.to_dict(orient="records")):
112
+ if "answer" not in instance.keys():
113
+ instance["answer"]=""
114
+ if "explanation" not in instance.keys():
115
+ instance["explanation"]=""
116
+ yield i, instance
aceval.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a379e089a0708421cf8c625644b00b08d3da2b43c2f61a606e52d69822475a03
3
+ size 1968794