Update CMB.py
Browse files
CMB.py
CHANGED
@@ -67,10 +67,10 @@ class CMB(datasets.GeneratorBasedBuilder):
|
|
67 |
|
68 |
BUILDER_CONFIGS = [
|
69 |
CMBConfig(
|
70 |
-
name="
|
71 |
description=textwrap.dedent(
|
72 |
"""\
|
73 |
-
|
74 |
),
|
75 |
features=datasets.Features(
|
76 |
{
|
@@ -96,39 +96,10 @@ class CMB(datasets.GeneratorBasedBuilder):
|
|
96 |
url="https://github.com/FreedomIntelligence/CMB",
|
97 |
),
|
98 |
CMBConfig(
|
99 |
-
name="
|
100 |
description=textwrap.dedent(
|
101 |
"""\
|
102 |
-
|
103 |
-
."""
|
104 |
-
),
|
105 |
-
features=datasets.Features(
|
106 |
-
{
|
107 |
-
"id": datasets.Value("string"),
|
108 |
-
"exam_type": datasets.Value("string"),
|
109 |
-
"exam_class": datasets.Value("string"),
|
110 |
-
"exam_subject": datasets.Value("string"),
|
111 |
-
"question": datasets.Value("string"),
|
112 |
-
"question_type": datasets.Value("string"),
|
113 |
-
"option": datasets.Value("string"),
|
114 |
-
"answer": datasets.Value("string")
|
115 |
-
|
116 |
-
}
|
117 |
-
),
|
118 |
-
data_url=_DATASETS_FILE,
|
119 |
-
data_dir="CMB-test-exampaper",
|
120 |
-
citation=textwrap.dedent(
|
121 |
-
"""\
|
122 |
-
|
123 |
-
}"""
|
124 |
-
),
|
125 |
-
url="https://github.com/FreedomIntelligence/CMB",
|
126 |
-
),
|
127 |
-
CMBConfig(
|
128 |
-
name="qa",
|
129 |
-
description=textwrap.dedent(
|
130 |
-
"""\
|
131 |
-
QA 格式的考题
|
132 |
"""
|
133 |
),
|
134 |
features=datasets.Features(
|
@@ -163,7 +134,7 @@ class CMB(datasets.GeneratorBasedBuilder):
|
|
163 |
)
|
164 |
|
165 |
def _split_generators(self, dl_manager):
|
166 |
-
if self.config.name == "
|
167 |
data_file = dl_manager.extract(self.config.data_url)
|
168 |
main_data_dir = os.path.join(data_file, self.config.data_dir)
|
169 |
|
@@ -193,22 +164,7 @@ class CMB(datasets.GeneratorBasedBuilder):
|
|
193 |
)
|
194 |
]
|
195 |
|
196 |
-
if self.config.name == "
|
197 |
-
data_file = dl_manager.extract(self.config.data_url)
|
198 |
-
main_data_dir = os.path.join(data_file, self.config.data_dir)
|
199 |
-
return [
|
200 |
-
|
201 |
-
|
202 |
-
datasets.SplitGenerator(
|
203 |
-
name=datasets.Split.TEST,
|
204 |
-
gen_kwargs={
|
205 |
-
"data_file": os.path.join(main_data_dir, 'CMB-test-exampaper-merge.json'),
|
206 |
-
"split": "test",
|
207 |
-
},
|
208 |
-
)
|
209 |
-
]
|
210 |
-
|
211 |
-
if self.config.name == "qa":
|
212 |
data_file = dl_manager.extract(self.config.data_url)
|
213 |
main_data_dir = os.path.join(data_file, self.config.data_dir)
|
214 |
return [
|
@@ -226,7 +182,7 @@ class CMB(datasets.GeneratorBasedBuilder):
|
|
226 |
|
227 |
def _generate_examples(self, data_file, split, mrpc_files=None):
|
228 |
|
229 |
-
if self.config.name == '
|
230 |
|
231 |
examples = json.loads(io.open(data_file, 'r').read())
|
232 |
|
@@ -237,16 +193,7 @@ class CMB(datasets.GeneratorBasedBuilder):
|
|
237 |
vals['id'] = vals.get('id',idx)
|
238 |
yield idx, vals
|
239 |
|
240 |
-
if self.config.name == '
|
241 |
-
examples = json.loads(io.open(data_file, 'r').read())
|
242 |
-
for idx in range(len(examples)):
|
243 |
-
vals = examples[idx]
|
244 |
-
vals['answer'] = vals.get('answer','')
|
245 |
-
|
246 |
-
vals['id'] = vals.get('id',idx)
|
247 |
-
yield idx, vals
|
248 |
-
|
249 |
-
if self.config.name == 'qa':
|
250 |
examples = json.loads(io.open(data_file, 'r').read())
|
251 |
for idx in range(len(examples)):
|
252 |
vals = examples[idx]
|
@@ -258,7 +205,7 @@ class CMB(datasets.GeneratorBasedBuilder):
|
|
258 |
if __name__ == '__main__':
|
259 |
from datasets import load_dataset
|
260 |
|
261 |
-
dataset = load_dataset('CMB.py', '
|
262 |
-
# dataset = load_dataset('CMB.py', '
|
263 |
|
264 |
print()
|
|
|
67 |
|
68 |
BUILDER_CONFIGS = [
|
69 |
CMBConfig(
|
70 |
+
name="exam",
|
71 |
description=textwrap.dedent(
|
72 |
"""\
|
73 |
+
全方位多层次注入和测评模型医疗知识,包含 train val test 三个组成部分."""
|
74 |
),
|
75 |
features=datasets.Features(
|
76 |
{
|
|
|
96 |
url="https://github.com/FreedomIntelligence/CMB",
|
97 |
),
|
98 |
CMBConfig(
|
99 |
+
name="clin",
|
100 |
description=textwrap.dedent(
|
101 |
"""\
|
102 |
+
测评复杂临床问诊能力
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
"""
|
104 |
),
|
105 |
features=datasets.Features(
|
|
|
134 |
)
|
135 |
|
136 |
def _split_generators(self, dl_manager):
|
137 |
+
if self.config.name == "exam":
|
138 |
data_file = dl_manager.extract(self.config.data_url)
|
139 |
main_data_dir = os.path.join(data_file, self.config.data_dir)
|
140 |
|
|
|
164 |
)
|
165 |
]
|
166 |
|
167 |
+
if self.config.name == "clin":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
data_file = dl_manager.extract(self.config.data_url)
|
169 |
main_data_dir = os.path.join(data_file, self.config.data_dir)
|
170 |
return [
|
|
|
182 |
|
183 |
def _generate_examples(self, data_file, split, mrpc_files=None):
|
184 |
|
185 |
+
if self.config.name == 'exam':
|
186 |
|
187 |
examples = json.loads(io.open(data_file, 'r').read())
|
188 |
|
|
|
193 |
vals['id'] = vals.get('id',idx)
|
194 |
yield idx, vals
|
195 |
|
196 |
+
if self.config.name == 'clin':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
examples = json.loads(io.open(data_file, 'r').read())
|
198 |
for idx in range(len(examples)):
|
199 |
vals = examples[idx]
|
|
|
205 |
if __name__ == '__main__':
|
206 |
from datasets import load_dataset
|
207 |
|
208 |
+
dataset = load_dataset('CMB.py', 'exam')
|
209 |
+
# dataset = load_dataset('CMB.py', 'clin')
|
210 |
|
211 |
print()
|