Create view_fix.py
Browse files- view_fix.py +34 -0
view_fix.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
from datasets import GeneratorBasedBuilder, DatasetInfo, Features, Value, SplitGenerator, Split
|
| 3 |
+
|
| 4 |
+
class SourceWorksNanoSet(GeneratorBasedBuilder):
|
| 5 |
+
VERSION = "1.0.0"
|
| 6 |
+
|
| 7 |
+
def _info(self):
|
| 8 |
+
return DatasetInfo(
|
| 9 |
+
description="SourceWorks NanoSet Dataset",
|
| 10 |
+
features=Features({
|
| 11 |
+
"prompt": Value("string"),
|
| 12 |
+
"completion": Value("string"),
|
| 13 |
+
}),
|
| 14 |
+
supervised_keys=None,
|
| 15 |
+
homepage="https://srcworks-software.github.io/",
|
| 16 |
+
license="MIT",
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
def _split_generators(self, dl_manager):
|
| 20 |
+
data_files = dl_manager.download_and_extract({
|
| 21 |
+
"train": "https://huggingface.co/datasets/srcworks-software/nanoset/blob/main/nanoset.jsonl"
|
| 22 |
+
})
|
| 23 |
+
return [
|
| 24 |
+
SplitGenerator(
|
| 25 |
+
name=Split.TRAIN,
|
| 26 |
+
gen_kwargs={"filepath": data_files["train"]}
|
| 27 |
+
),
|
| 28 |
+
]
|
| 29 |
+
|
| 30 |
+
def _generate_examples(self, filepath):
|
| 31 |
+
with open(filepath, encoding="utf-8") as f:
|
| 32 |
+
for idx, line in enumerate(f):
|
| 33 |
+
record = json.loads(line)
|
| 34 |
+
yield idx, record
|