Datasets:

Languages:
English
ArXiv:
License:
skgouda commited on
Commit
7db51ab
1 Parent(s): e3e3cb4

Create mathqa-x.py

Browse files
Files changed (1) hide show
  1. mathqa-x.py +143 -0
mathqa-x.py ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+ import requests
4
+ import datasets
5
+
6
+ import os
7
+ from collections import defaultdict
8
+
9
+ _CITATION = """\
10
+ @inproceedings{
11
+ athiwaratkun2023multilingual,
12
+ title={Multi-lingual Evaluation of Code Generation Models},
13
+ author={Ben Athiwaratkun and Sanjay Krishna Gouda and Zijian Wang and Xiaopeng Li and Yuchen Tian and Ming Tan and Wasi Uddin Ahmad and Shiqi Wang and Qing Sun and Mingyue Shang and Sujan Kumar Gonugondla and Hantian Ding and Varun Kumar and Nathan Fulton and Arash Farahani and Siddhartha Jain and Robert Giaquinto and Haifeng Qian and Murali Krishna Ramanathan and Ramesh Nallapati and Baishakhi Ray and Parminder Bhatia and Sudipta Sengupta and Dan Roth and Bing Xiang},
14
+ booktitle={The Eleventh International Conference on Learning Representations },
15
+ year={2023},
16
+ url={https://openreview.net/forum?id=Bo7eeXm6An8}
17
+ }"""
18
+
19
+ VERSION=f"1.1.0"
20
+
21
+ _HOMEPAGE = "https://github.com/amazon-science/mbxp-exec-eval"
22
+
23
+ _LICENSE = "Apache License 2.0"
24
+
25
+ _DESCRIPTION = """\
26
+ A collection of execution-based multi-lingual benchmark for code generation.
27
+ """
28
+
29
+ _LICENSES = defaultdict(lambda: _LICENSE)
30
+
31
+ _CITATIONS = defaultdict(lambda: _CITATION)
32
+ _CITATIONS["python"] = """\
33
+ @inproceedings{amini-etal-2019-mathqa,
34
+ title={MathQA: Towards Interpretable Math Word Problem Solving with Operation-Based Formalisms},
35
+ author={Amini, Aida and
36
+ Gabriel, Saadia and
37
+ Lin, Shanchuan and
38
+ Koncel-Kedziorski, Rik and
39
+ Choi, Yejin and
40
+ Hajishirzi, Hannaneh},
41
+ booktitle={Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers)},
42
+ month={jun},
43
+ year= {2019},
44
+ address = {Minneapolis, Minnesota},
45
+ publisher = {Association for Computational Linguistics},
46
+ url={https://aclanthology.org/N19-1245}
47
+ doi={10.18653/v1/N19-1245},
48
+ pages={2357--2367},
49
+ }
50
+ @inproceedings{
51
+ athiwaratkun2023multilingual,
52
+ title={Multi-lingual Evaluation of Code Generation Models},
53
+ author={Ben Athiwaratkun and Sanjay Krishna Gouda and Zijian Wang and Xiaopeng Li and Yuchen Tian and Ming Tan and Wasi Uddin Ahmad and Shiqi Wang and Qing Sun and Mingyue Shang and Sujan Kumar Gonugondla and Hantian Ding and Varun Kumar and Nathan Fulton and Arash Farahani and Siddhartha Jain and Robert Giaquinto and Haifeng Qian and Murali Krishna Ramanathan and Ramesh Nallapati and Baishakhi Ray and Parminder Bhatia and Sudipta Sengupta and Dan Roth and Bing Xiang},
54
+ booktitle={The Eleventh International Conference on Learning Representations },
55
+ year={2023},
56
+ url={https://openreview.net/forum?id=Bo7eeXm6An8}
57
+ }"""
58
+
59
+ _GITHUB_ROOT = "https://raw.githubusercontent.com/amazon-science/mbxp-exec-eval/verify_files/data/multilingual_mathqa/"
60
+
61
+ metadata_dict_path = requests.get(os.path.join(_GITHUB_ROOT, "metadata.json"))
62
+ metadata = json.loads(metadata_dict_path.text)
63
+
64
+ class MathQAXConfig(datasets.BuilderConfig):
65
+ """BuilderConfig for MathQA-X."""
66
+
67
+ def __init__(
68
+ self,
69
+ language,
70
+ data_url,
71
+ citation,
72
+ version,
73
+ **kwargs,
74
+ ):
75
+ super(MathQAXConfig, self).__init__(version=datasets.Version(f"{version}", ""), **kwargs)
76
+ self.name = language
77
+ self.data_url = data_url
78
+ self.citation = citation
79
+
80
+
81
+ class MathQAX(datasets.GeneratorBasedBuilder):
82
+ """MathQA-X: An execution-based MathQA-X benchmark for code generation."""
83
+
84
+ BUILDER_CONFIGS = [
85
+ MathQAXConfig(
86
+ name=f"{language}",
87
+ language=f"{language}",
88
+ version=VERSION,
89
+ citation=_CITATIONS[f"{language}"],
90
+ description=f"MathQA-X benchmark in {language}",
91
+ data_url=os.path.join(_GITHUB_ROOT, language_path)
92
+ ) for language, language_path in metadata.items()
93
+ ]
94
+
95
+ def _info(self):
96
+ self.build_name = self.name
97
+ features = datasets.Features(
98
+ {
99
+ "task_id": datasets.Value("string"),
100
+ "language": datasets.Value("string"),
101
+ "prompt": datasets.Value("string"),
102
+ "test": datasets.Value("string"),
103
+ "entry_point": datasets.Value("string"),
104
+ "canonical_solution": datasets.Value("string"),
105
+ # "description": datasets.Value("string"),
106
+ }
107
+ )
108
+ return datasets.DatasetInfo(
109
+ description=_DESCRIPTION,
110
+ features=features,
111
+ supervised_keys=None,
112
+ homepage=_HOMEPAGE,
113
+ license=_LICENSES[self.config.name],
114
+ citation=_CITATIONS[self.config.name],
115
+ )
116
+
117
+
118
+ def _split_generators(
119
+ self, dl_manager
120
+ ):
121
+ """Returns SplitGenerators."""
122
+ data_file = dl_manager.download_and_extract(url_or_urls=self.config.data_url)
123
+ return [
124
+ datasets.SplitGenerator(
125
+ name=datasets.Split.TEST,
126
+ gen_kwargs={
127
+ "filepath": data_file,
128
+ },
129
+ )
130
+ ]
131
+
132
+
133
+ def _generate_examples(self, filepath):
134
+ """Yields examples."""
135
+ with open(filepath) as file:
136
+ data = []
137
+ for line in file:
138
+ jd = json.loads(line)
139
+ data.append(jd)
140
+ id_ = 0
141
+ for sample in data:
142
+ yield id_, sample
143
+ id_ += 1