loubnabnl HF staff commited on
Commit
5675406
1 Parent(s): 6016a7a

add daatset script and readme

Browse files
Files changed (2) hide show
  1. README.md +60 -1
  2. humaneval_infilling.py +80 -0
README.md CHANGED
@@ -1,3 +1,62 @@
1
  ---
2
- license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ annotations_creators:
3
+ - expert-generated
4
+ language_creators:
5
+ - expert-generated
6
+ language:
7
+ - en
8
+ license:
9
+ - mit
10
+ multilinguality:
11
+ - monolingual
12
+ pretty_name: OpenAI HumanEval-Infilling
13
+ source_datasets:
14
+ - original
15
+ task_categories:
16
+ - text2text-generation
17
+ task_ids:
18
+ - text2text-generation-other-code-generation
19
  ---
20
+
21
+ # HumanEval-Infilling
22
+
23
+
24
+ ## Dataset Description
25
+
26
+ - **Homepage:** https://github.com/openai/human-eval-infilling
27
+ - **Repository:** https://github.com/openai/human-eval-infilling
28
+ - **Paper:** https://arxiv.org/pdf/2207.14255
29
+
30
+ ## Dataset Summary
31
+
32
+ [HumanEval-Infilling](https://github.com/openai/human-eval-infilling) is a benchmark for infilling tasks, derived from [HumanEval]() benchmark for the evaluation of code generation models.
33
+
34
+ ## Dataset Structure
35
+ To load the dataset you need to specify a subset among the 5 exiting languages `[python, cpp, go, java, js]`. By default `python` is loaded.
36
+
37
+ ```python
38
+ from datasets import load_dataset
39
+ ds = load_dataset("humaneval_infilling", "HumanEval-RandomSpanInfilling")
40
+
41
+ DatasetDict({
42
+ test: Dataset({
43
+ features: ['task_id', 'entry_point', 'prompt', 'suffix', 'canonical_solution', 'test'],
44
+ num_rows: 1640
45
+ })
46
+ })
47
+ ```
48
+ By default `HumanEval-SingleLineInfilling` subset is loaded.
49
+ ## Subsets
50
+
51
+ This dataset has 4 subsets: HumanEval-MultiLineInfilling, HumanEval-SingleLineInfilling, HumanEval-RandomSpanInfilling, HumanEval-RandomSpanInfillingLight.
52
+ The single-line, multi-line, random span infilling and its light version have 1033, 5815, 1640 and 164 tasks, respectively.
53
+
54
+ ## Citation
55
+
56
+ ```@article{bavarian2022efficient,
57
+ title={Efficient Training of Language Models to Fill in the Middle},
58
+ author={Bavarian, Mohammad and Jun, Heewoo and Tezak, Nikolas and Schulman, John and McLeavey, Christine and Tworek, Jerry and Chen, Mark},
59
+ journal={arXiv preprint arXiv:2207.14255},
60
+ year={2022}
61
+ }
62
+ ```
humaneval_infilling.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import datasets
3
+
4
+ logger = datasets.logging.get_logger(__name__)
5
+
6
+ _CITATION = """\
7
+ @article{bavarian2022efficient,
8
+ title={Efficient Training of Language Models to Fill in the Middle},
9
+ author={Bavarian, Mohammad and Jun, Heewoo and Tezak, Nikolas and Schulman, John and McLeavey, Christine and Tworek, Jerry and Chen, Mark},
10
+ journal={arXiv preprint arXiv:2207.14255},
11
+ year={2022}
12
+ }
13
+ """
14
+
15
+ _DESCRIPTION = """\
16
+ An evaluation benchamrk for infilling tasks on HumanEval dataset for code generation.
17
+ """
18
+
19
+ _SUBSETS = [ "MultiLineInfilling", "SingleLineInfilling", "RandomSpanInfilling", "RandomSpanInfillingLight" ]
20
+
21
+
22
+ class HumanevalConfig(datasets.BuilderConfig):
23
+ """BuilderConfig for HumanevalConfig."""
24
+
25
+ def __init__(
26
+ self,
27
+ subset,
28
+ **kwargs,
29
+ ):
30
+ self.subset = subset
31
+ name = f"HumanEval-{subset}"
32
+ kwargs["name"] = name
33
+ super(HumanevalConfig, self).__init__(**kwargs)
34
+
35
+
36
+ class MultiPLE(datasets.GeneratorBasedBuilder):
37
+ BUILDER_CONFIG_CLASS = HumanevalConfig
38
+
39
+ BUILDER_CONFIGS = [
40
+ HumanevalConfig(
41
+ subset=subset,
42
+ version=datasets.Version("1.0.0"))
43
+ for subset in _SUBSETS
44
+ ]
45
+
46
+ DEFAULT_CONFIG_NAME = "HumanEval-SingleLineInfilling"
47
+
48
+ def _info(self):
49
+ return datasets.DatasetInfo(
50
+ description=_DESCRIPTION,
51
+ license="MIT",
52
+ features = datasets.Features({'task_id': datasets.Value(dtype='string'),
53
+ 'entry_point': datasets.Value(dtype='string'),
54
+ 'prompt': datasets.Value(dtype='string'),
55
+ 'suffix': datasets.Value(dtype='string'),
56
+ 'canonical_solution': datasets.Value(dtype='string'),
57
+ 'test': datasets.Value(dtype='string')}),
58
+ supervised_keys=None,
59
+ homepage="https://github.com/openai/human-eval-infilling",
60
+ citation=_CITATION
61
+ )
62
+
63
+ def _split_generators(self, dl_manager: datasets.DownloadManager):
64
+ files = dl_manager.download(
65
+ f"data/{self.config.name}.jsonl"
66
+ )
67
+ return [
68
+ datasets.SplitGenerator(
69
+ name=datasets.Split.TEST,
70
+ gen_kwargs={
71
+ "filepath": files,
72
+ }
73
+ )
74
+ ]
75
+
76
+ def _generate_examples(self, filepath):
77
+ with open(filepath) as f:
78
+ for id, line in enumerate(f):
79
+ row = json.loads(line)
80
+ yield id, row