MicPie commited on
Commit
14f7415
·
1 Parent(s): bbd636e

update name change

Browse files
Files changed (1) hide show
  1. unpredictable_cram-com.py +96 -0
unpredictable_cram-com.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """This loads the UnpredicTable-cram-com dataset."""
15
+
16
+ import json
17
+ import os
18
+ import pandas as pd
19
+
20
+ import datasets
21
+
22
+ _CITATION = """\
23
+ @misc{https://ethanperez.net/unpredictable,
24
+ author = {Chan, Jun Shern and Pieler, Michael and Jao, Jonathan and Scheurer, Jérémy and Perez, Ethan},
25
+ title = {Exploring Few-Shot Adaptation of Language Models with Tables},
26
+ publisher = {arXiv},
27
+ year = {2022},
28
+ }
29
+ """
30
+
31
+ _DESCRIPTION = """\
32
+ The UnpredicTable dataset consists of web tables formatted as few-shot tasks for fine-tuning language models to improve their few-shot performance. For more details please see the accompanying dataset card.
33
+ """
34
+
35
+ _HOMEPAGE = "https://ethanperez.net/unpredictable"
36
+
37
+ _LICENSE = "Apache 2.0"
38
+
39
+ _URL = "https://huggingface.co/datasets/MicPie/unpredictable_cram-com/resolve/main/data/unpredictable_cram-com.jsonl"
40
+
41
+ logger = datasets.logging.get_logger(__name__)
42
+
43
+
44
+ class UnpredicTable(datasets.GeneratorBasedBuilder):
45
+ """
46
+ The UnpredicTable dataset consists of web tables formatted as few-shot tasks for fine-tuning language models to improve their few-shot performance. For more details please see the accompanying dataset card.
47
+ """
48
+
49
+ VERSION = datasets.Version("1.0.0")
50
+
51
+ def _info(self):
52
+ features = datasets.Features(
53
+ {
54
+ "task": datasets.Value("string"),
55
+ "input": datasets.Value("string"),
56
+ "output": datasets.Value("string"),
57
+ "options": datasets.Sequence([datasets.Value("string")]),
58
+ "pageTitle": datasets.Value("string"),
59
+ "outputColName": datasets.Value("string"),
60
+ "url": datasets.Value("string"),
61
+ "wdcFile": datasets.Value("string")
62
+ }
63
+ )
64
+ return datasets.DatasetInfo(
65
+ description=_DESCRIPTION,
66
+ features=features,
67
+ license=_LICENSE,
68
+ citation=_CITATION,
69
+ )
70
+
71
+ def _split_generators(self, dl_manager):
72
+ """Returns SplitGenerators."""
73
+ data_dir = dl_manager.download_and_extract(_URL)
74
+ return [
75
+ datasets.SplitGenerator(
76
+ name=datasets.Split.TRAIN,
77
+ gen_kwargs={"filepath": data_dir},
78
+ ),
79
+ ]
80
+
81
+ def _generate_examples(self, filepath):
82
+ """Yields examples."""
83
+ with open(filepath, encoding="utf-8") as f:
84
+ for i, row in enumerate(f):
85
+ data = json.loads(row)
86
+ key = f"{data['task']}_{i}"
87
+ yield key, {
88
+ "task": data["task"],
89
+ "input": data["input"],
90
+ "output": data["output"],
91
+ "options": data["options"],
92
+ "pageTitle": data["pageTitle"],
93
+ "outputColName": data["outputColName"],
94
+ "url": data["url"],
95
+ "wdcFile": data["wdcFile"],
96
+ }