Upload folder using huggingface_hub
Browse files- longbench_pro.py +40 -0
longbench_pro.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datasets import Dataset, DatasetDict, GeneratorBasedBuilder, Split, SplitGenerator, Value, Features, load_dataset
|
| 2 |
+
|
| 3 |
+
class LongBenchPro(GeneratorBasedBuilder):
|
| 4 |
+
VERSION = "1.0.0"
|
| 5 |
+
|
| 6 |
+
def _info(self):
|
| 7 |
+
return datasets.DatasetInfo(
|
| 8 |
+
description="LongBench Pro dataset",
|
| 9 |
+
features=Features({
|
| 10 |
+
"id": Value("string"),
|
| 11 |
+
"context": Value("string"),
|
| 12 |
+
"language": Value("string", choices=["English", "Chinese"]),
|
| 13 |
+
"token_length": Value("string", choices=["8k", "16k", "32k", "64k", "128k", "256k"]),
|
| 14 |
+
"primary_task": Value("string"),
|
| 15 |
+
"secondary_task": Value("string"),
|
| 16 |
+
"contextual_requirement": Value("string", choices=["Full", "Partial"]),
|
| 17 |
+
"question_nonthinking": Value("string"),
|
| 18 |
+
"question_thinking": Value("string"),
|
| 19 |
+
"answer": Value("list"),
|
| 20 |
+
"difficulty": Value("string", choices=["Easy", "Moderate", "Hard", "Extreme"]),
|
| 21 |
+
}),
|
| 22 |
+
supervised_keys=None,
|
| 23 |
+
homepage="https://huggingface.co/datasets/caskcsg/LongBench_Pro",
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
def _split_generators(self, dl_manager):
|
| 27 |
+
data_path = dl_manager.download_and_extract("longbench_pro.json")
|
| 28 |
+
return [
|
| 29 |
+
SplitGenerator(
|
| 30 |
+
name=Split.TRAIN,
|
| 31 |
+
gen_kwargs={"filepath": data_path}
|
| 32 |
+
)
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
+
def _generate_examples(self, filepath):
|
| 36 |
+
import json
|
| 37 |
+
with open(filepath, encoding="utf-8") as f:
|
| 38 |
+
data = json.load(f)
|
| 39 |
+
for i, item in enumerate(data):
|
| 40 |
+
yield i, item
|