Update test_repo.py
Browse files- test_repo.py +88 -18
test_repo.py
CHANGED
|
@@ -3,17 +3,8 @@ import os
|
|
| 3 |
import datasets
|
| 4 |
import ast
|
| 5 |
|
| 6 |
-
# Metadata and descriptions for the dataset
|
| 7 |
-
_CITATION = """\
|
| 8 |
-
@InProceedings{huggingface:dataset,
|
| 9 |
-
title = {Test Repo Dataset},
|
| 10 |
-
author={huggingface, Inc.},
|
| 11 |
-
year={2020}
|
| 12 |
-
}
|
| 13 |
-
"""
|
| 14 |
-
|
| 15 |
_DESCRIPTION = """\
|
| 16 |
-
The
|
| 17 |
"""
|
| 18 |
|
| 19 |
_HOMEPAGE = "https://huggingface.co/datasets/anand-s/test_repo"
|
|
@@ -25,6 +16,12 @@ _URLS = {
|
|
| 25 |
"train_normal_mcqa": "https://huggingface.co/datasets/anand-s/test_repo/resolve/main/train_normal_mcqa.zip",
|
| 26 |
"val_normal_mcqa": "https://huggingface.co/datasets/anand-s/test_repo/resolve/main/val_normal_mcqa.zip",
|
| 27 |
"test_normal_mcqa": "https://huggingface.co/datasets/anand-s/test_repo/resolve/main/test_normal_mcqa.zip",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
}
|
| 30 |
|
|
@@ -37,6 +34,12 @@ class TestRepo(datasets.GeneratorBasedBuilder):
|
|
| 37 |
datasets.BuilderConfig(name="train_normal_mcqa", version=VERSION, description="This configuration covers multiple choice questions."),
|
| 38 |
datasets.BuilderConfig(name="val_normal_mcqa", version=VERSION, description="This configuration covers multiple choice questions."),
|
| 39 |
datasets.BuilderConfig(name="test_normal_mcqa", version=VERSION, description="This configuration covers multiple choice questions."),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
]
|
| 41 |
|
| 42 |
# DEFAULT_CONFIG_NAME = "mcq_domain"
|
|
@@ -79,6 +82,46 @@ class TestRepo(datasets.GeneratorBasedBuilder):
|
|
| 79 |
"answer": datasets.Value("string"),
|
| 80 |
"options": datasets.Sequence(datasets.Value("string")),
|
| 81 |
})),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
})
|
| 83 |
}
|
| 84 |
|
|
@@ -112,23 +155,23 @@ class TestRepo(datasets.GeneratorBasedBuilder):
|
|
| 112 |
data = json.loads(row)
|
| 113 |
if split == "train_normal_mcqa":
|
| 114 |
yield key_idx, {
|
| 115 |
-
"prompt": data
|
| 116 |
"question": data["question"],
|
| 117 |
"options": data["options"],
|
| 118 |
-
"answer": data
|
| 119 |
-
"num_options": data
|
| 120 |
-
"question_type": data
|
| 121 |
"dataset_name": os.path.split(filepath)[-1].replace(".jsonl","")
|
| 122 |
}
|
| 123 |
key_idx +=1
|
| 124 |
elif split in ["val_normal_mcqa", "test_normal_mcqa"]:
|
| 125 |
yield key_idx, {
|
| 126 |
-
"prompt": data
|
| 127 |
"question": data["question"],
|
| 128 |
"options": data["options"],
|
| 129 |
-
"answer": data
|
| 130 |
-
"num_options": data
|
| 131 |
-
"question_type": data
|
| 132 |
"dataset_name": os.path.split(filepath)[-1].replace(".jsonl",""),
|
| 133 |
"few_shot_prompt": [{
|
| 134 |
"question": item["question"],
|
|
@@ -136,5 +179,32 @@ class TestRepo(datasets.GeneratorBasedBuilder):
|
|
| 136 |
"options": item["options"],
|
| 137 |
} for item in data["few_shot_prompt"]]
|
| 138 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
key_idx +=1
|
|
|
|
| 3 |
import datasets
|
| 4 |
import ast
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
_DESCRIPTION = """\
|
| 7 |
+
The M-QALM Dataset Repository contains Multiple-Choice and Abstractive Questions for evaluating the performance of LLMs in the clinical and biomedical domain.
|
| 8 |
"""
|
| 9 |
|
| 10 |
_HOMEPAGE = "https://huggingface.co/datasets/anand-s/test_repo"
|
|
|
|
| 16 |
"train_normal_mcqa": "https://huggingface.co/datasets/anand-s/test_repo/resolve/main/train_normal_mcqa.zip",
|
| 17 |
"val_normal_mcqa": "https://huggingface.co/datasets/anand-s/test_repo/resolve/main/val_normal_mcqa.zip",
|
| 18 |
"test_normal_mcqa": "https://huggingface.co/datasets/anand-s/test_repo/resolve/main/test_normal_mcqa.zip",
|
| 19 |
+
"train_context_mcqa": "https://huggingface.co/datasets/anand-s/test_repo/resolve/main/train_context_mcqa.zip",
|
| 20 |
+
"val_context_mcqa": "https://huggingface.co/datasets/anand-s/test_repo/resolve/main/val_context_mcqa.zip",
|
| 21 |
+
"test_context_mcqa": "https://huggingface.co/datasets/anand-s/test_repo/resolve/main/test_context_mcqa.zip",
|
| 22 |
+
"train_aqa": "https://huggingface.co/datasets/anand-s/test_repo/resolve/main/train_aqa.zip",
|
| 23 |
+
"val_aqa": "https://huggingface.co/datasets/anand-s/test_repo/resolve/main/val_aqa.zip",
|
| 24 |
+
"test_aqa": "https://huggingface.co/datasets/anand-s/test_repo/resolve/main/test_aqa.zip",
|
| 25 |
|
| 26 |
}
|
| 27 |
|
|
|
|
| 34 |
datasets.BuilderConfig(name="train_normal_mcqa", version=VERSION, description="This configuration covers multiple choice questions."),
|
| 35 |
datasets.BuilderConfig(name="val_normal_mcqa", version=VERSION, description="This configuration covers multiple choice questions."),
|
| 36 |
datasets.BuilderConfig(name="test_normal_mcqa", version=VERSION, description="This configuration covers multiple choice questions."),
|
| 37 |
+
datasets.BuilderConfig(name="train_context_mcqa", version=VERSION, description="This configuration covers multiple choice questions."),
|
| 38 |
+
datasets.BuilderConfig(name="val_context_mcqa", version=VERSION, description="This configuration covers multiple choice questions."),
|
| 39 |
+
datasets.BuilderConfig(name="test_context_mcqa", version=VERSION, description="This configuration covers multiple choice questions."),
|
| 40 |
+
datasets.BuilderConfig(name="train_aqa", version=VERSION, description="This configuration covers multiple choice questions."),
|
| 41 |
+
datasets.BuilderConfig(name="val_aqa", version=VERSION, description="This configuration covers multiple choice questions."),
|
| 42 |
+
datasets.BuilderConfig(name="test_aqa", version=VERSION, description="This configuration covers multiple choice questions."),
|
| 43 |
]
|
| 44 |
|
| 45 |
# DEFAULT_CONFIG_NAME = "mcq_domain"
|
|
|
|
| 82 |
"answer": datasets.Value("string"),
|
| 83 |
"options": datasets.Sequence(datasets.Value("string")),
|
| 84 |
})),
|
| 85 |
+
}),
|
| 86 |
+
"train_context_mcqa": datasets.Features({
|
| 87 |
+
"prompt": datasets.Value("string"),
|
| 88 |
+
"question": datasets.Value("string"),
|
| 89 |
+
"options": datasets.Sequence(datasets.Value("string")),
|
| 90 |
+
"answer": datasets.Value("string"),
|
| 91 |
+
"num_options": datasets.Value("string"),
|
| 92 |
+
"question_type": datasets.Value("string"),
|
| 93 |
+
"dataset_name": datasets.Value("string"),
|
| 94 |
+
"context": datasets.Value("string")
|
| 95 |
+
}),
|
| 96 |
+
"val_context_mcqa": datasets.Features({
|
| 97 |
+
"prompt": datasets.Value("string"),
|
| 98 |
+
"question": datasets.Value("string"),
|
| 99 |
+
"options": datasets.Sequence(datasets.Value("string")),
|
| 100 |
+
"answer": datasets.Value("string"),
|
| 101 |
+
"num_options": datasets.Value("string"),
|
| 102 |
+
"question_type": datasets.Value("string"),
|
| 103 |
+
"dataset_name": datasets.Value("string"),
|
| 104 |
+
"context": datasets.Value("string"),
|
| 105 |
+
"few_shot_prompt": datasets.Sequence(datasets.Features({
|
| 106 |
+
"question": datasets.Value("string"),
|
| 107 |
+
"answer": datasets.Value("string"),
|
| 108 |
+
"options": datasets.Sequence(datasets.Value("string")),
|
| 109 |
+
})),
|
| 110 |
+
}),
|
| 111 |
+
"test_context_mcqa": datasets.Features({
|
| 112 |
+
"prompt": datasets.Value("string"),
|
| 113 |
+
"question": datasets.Value("string"),
|
| 114 |
+
"options": datasets.Sequence(datasets.Value("string")),
|
| 115 |
+
"answer": datasets.Value("string"),
|
| 116 |
+
"num_options": datasets.Value("string"),
|
| 117 |
+
"question_type": datasets.Value("string"),
|
| 118 |
+
"dataset_name": datasets.Value("string"),
|
| 119 |
+
"context": datasets.Value("string"),
|
| 120 |
+
"few_shot_prompt": datasets.Sequence(datasets.Features({
|
| 121 |
+
"question": datasets.Value("string"),
|
| 122 |
+
"answer": datasets.Value("string"),
|
| 123 |
+
"options": datasets.Sequence(datasets.Value("string")),
|
| 124 |
+
})),
|
| 125 |
})
|
| 126 |
}
|
| 127 |
|
|
|
|
| 155 |
data = json.loads(row)
|
| 156 |
if split == "train_normal_mcqa":
|
| 157 |
yield key_idx, {
|
| 158 |
+
"prompt": data["prompt"],
|
| 159 |
"question": data["question"],
|
| 160 |
"options": data["options"],
|
| 161 |
+
"answer": data["answer"],
|
| 162 |
+
"num_options": data["num_options"],
|
| 163 |
+
"question_type": data["question_type"],
|
| 164 |
"dataset_name": os.path.split(filepath)[-1].replace(".jsonl","")
|
| 165 |
}
|
| 166 |
key_idx +=1
|
| 167 |
elif split in ["val_normal_mcqa", "test_normal_mcqa"]:
|
| 168 |
yield key_idx, {
|
| 169 |
+
"prompt": data["prompt"],
|
| 170 |
"question": data["question"],
|
| 171 |
"options": data["options"],
|
| 172 |
+
"answer": data["answer"],
|
| 173 |
+
"num_options": data["num_options"],
|
| 174 |
+
"question_type": data["question_type"],
|
| 175 |
"dataset_name": os.path.split(filepath)[-1].replace(".jsonl",""),
|
| 176 |
"few_shot_prompt": [{
|
| 177 |
"question": item["question"],
|
|
|
|
| 179 |
"options": item["options"],
|
| 180 |
} for item in data["few_shot_prompt"]]
|
| 181 |
}
|
| 182 |
+
elif split == "train_context_mcqa":
|
| 183 |
+
yield key_idx, {
|
| 184 |
+
"prompt": data["prompt"],
|
| 185 |
+
"question": data["question"],
|
| 186 |
+
"options": data["options"],
|
| 187 |
+
"answer": data.["answer"]
|
| 188 |
+
"num_options": data["num_options"],
|
| 189 |
+
"context": data["context"],
|
| 190 |
+
"question_type": data["question_type"],
|
| 191 |
+
"dataset_name": os.path.split(filepath)[-1].replace(".jsonl","")
|
| 192 |
+
}
|
| 193 |
+
key_idx +=1
|
| 194 |
+
elif split in ["val_normal_mcqa", "test_normal_mcqa"]:
|
| 195 |
+
yield key_idx, {
|
| 196 |
+
"prompt": data["prompt"],
|
| 197 |
+
"question": data["question"],
|
| 198 |
+
"options": data["options"],
|
| 199 |
+
"answer": data["answer"],
|
| 200 |
+
"num_options": data["num_options"],
|
| 201 |
+
"question_type": data["question_type"],
|
| 202 |
+
"dataset_name": os.path.split(filepath)[-1].replace(".jsonl",""),
|
| 203 |
+
"few_shot_prompt": [{
|
| 204 |
+
"question": item["question"],
|
| 205 |
+
"answer": item["answer"],
|
| 206 |
+
"options": item["options"],
|
| 207 |
+
} for item in data["few_shot_prompt"]]
|
| 208 |
+
}
|
| 209 |
|
| 210 |
key_idx +=1
|