Micah Weston
commited on
Commit
·
5116c98
0
Parent(s):
Adds dataset code with single example so far.
Browse files- .gitattributes +35 -0
- .gitignore +1 -0
- data/genericify_cpp.jsonl +1 -0
- dataset_genericify_cpp.py +67 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
/__pycache__/
|
data/genericify_cpp.jsonl
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"base_canonical_solution": "\\ntemplate <typename T>\\nbool has_close_elements(T numbers, float threshold) {\\n for (int i = 0; i < numbers.size(); i++)\\n for (int j = i + 1; j < numbers.size(); j++)\\n if (std::abs(numbers[i] - numbers[j]) < threshold)\\n return true;\\n\\n return false;\\n}\\n", "base_prompt": "Make the following function generic for the parameter `numbers`.", "concepts_canonical_solution": "\\ntemplate <typename T>\\n requires std::same_as<typename T::value_type, float>\\nbool has_close_elements(T numbers, float threshold) {\\n for (int i = 0; i < numbers.size(); i++)\\n for (int j = i + 1; j < numbers.size(); j++)\\n if (std::abs(numbers[i] - numbers[j]) < threshold)\\n return true;\\n\\n return false;\\n}\\n", "concepts_prompt": "Constrain the generic code using C++20 Concepts so that it accepts a container with value type of floats.", "invalids": "\\nint main() {\\n std::string s{};\\n has_close_elements(s, 3.4);\\n}\\n", "sfinae_canonical_solution": "\\ntemplate <\\n typename T,\\n std::enable_if_t<std::is_same_v<typename T::value_type, float>, int> = 0>\\nbool has_close_elements(T numbers, float threshold) {\\n for (int i = 0; i < numbers.size(); i++)\\n for (int j = i + 1; j < numbers.size(); j++)\\n if (std::abs(numbers[i] - numbers[j]) < threshold)\\n return true;\\n\\n return false;\\n}\\n", "sfinae_prompt": "Constrain the generic code using C++20 Concepts so that it accepts a container with value type of floats.", "starter_code": "\\nbool has_close_elements(std::vector<float> numbers, float threshold) {\\n for (int i = 0; i < numbers.size(); i++)\\n for (int j = i + 1; j < numbers.size(); j++)\\n if (std::abs(numbers[i] - numbers[j]) < threshold)\\n return true;\\n\\n return false;\\n}\\n", "task_id": "HEP/0", "tests": "\\n#define ASSERT(...) \\\\\\n do { \\\\\\n if (!(__VA_ARGS__)) { \\\\\\n std::exit(-1); \\\\\\n } \\\\\\n } while (false)\\n\\n#define TEST_ON_TYPE(_type_) \\\\\\n do { \\\\\\n _type_ a = {1.0, 2.0, 3.9, 4.0, 5.0, 2.2}; \\\\\\n ASSERT(has_close_elements(a, 0.3) == true); \\\\\\n ASSERT(has_close_elements(a, 0.05) == false); \\\\\\n ASSERT(has_close_elements(_type_{1.0, 2.0, 5.9, 4.0, 5.0}, 0.95) == true); \\\\\\n ASSERT(has_close_elements(_type_{1.0, 2.0, 5.9, 4.0, 5.0}, 0.8) == false); \\\\\\n ASSERT(has_close_elements(_type_{1.0, 2.0, 3.0, 4.0, 5.0}, 2.0) == true); \\\\\\n ASSERT(has_close_elements(_type_{1.1, 2.2, 3.1, 4.1, 5.1}, 1.0) == true); \\\\\\n ASSERT(has_close_elements(_type_{1.1, 2.2, 3.1, 4.1, 5.1}, 0.5) == false); \\\\\\n } while (false)\\n\\nint main() {\\n TEST_ON_TYPE(std::vector<float>);\\n TEST_ON_TYPE(std::deque<float>);\\n}\\n"}
|
dataset_genericify_cpp.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Genericify C++ Dataset for CS7470"""
|
2 |
+
|
3 |
+
|
4 |
+
import json
|
5 |
+
|
6 |
+
import datasets
|
7 |
+
|
8 |
+
|
9 |
+
# You can copy an official description
|
10 |
+
_DESCRIPTION = """\
|
11 |
+
Genericify C++ Dataset
|
12 |
+
"""
|
13 |
+
|
14 |
+
|
15 |
+
class DatasetGenericifyCpp(datasets.GeneratorBasedBuilder):
|
16 |
+
"""Genericify C++ Dataset for CS7470"""
|
17 |
+
|
18 |
+
VERSION = datasets.Version("1.1.0")
|
19 |
+
|
20 |
+
def _info(self):
|
21 |
+
return datasets.DatasetInfo(
|
22 |
+
description=_DESCRIPTION,
|
23 |
+
features=datasets.Features(
|
24 |
+
{
|
25 |
+
"task_id": datasets.Value("string"),
|
26 |
+
"base_prompt": datasets.Value("string"),
|
27 |
+
"sfinae_prompt": datasets.Value("string"),
|
28 |
+
"concepts_prompt": datasets.Value("string"),
|
29 |
+
"starter_code": datasets.Value("string"),
|
30 |
+
"base_canonical_solution": datasets.Value("string"),
|
31 |
+
"sfinae_canonical_solution": datasets.Value("string"),
|
32 |
+
"concepts_canonical_solution": datasets.Value("string"),
|
33 |
+
"tests": datasets.Value("string"),
|
34 |
+
"invalids": datasets.Value("string"),
|
35 |
+
}
|
36 |
+
),
|
37 |
+
)
|
38 |
+
|
39 |
+
def _split_generators(self, dl_manager):
|
40 |
+
downloaded_files = dl_manager.download_and_extract(
|
41 |
+
"data/genericify_cpp.jsonl"
|
42 |
+
)
|
43 |
+
return [
|
44 |
+
datasets.SplitGenerator(
|
45 |
+
name=datasets.Split.TEST,
|
46 |
+
gen_kwargs={
|
47 |
+
"filepath": downloaded_files,
|
48 |
+
},
|
49 |
+
),
|
50 |
+
]
|
51 |
+
|
52 |
+
def _generate_examples(self, filepath):
|
53 |
+
with open(filepath, encoding="utf-8") as f:
|
54 |
+
for key, line in enumerate(f):
|
55 |
+
row = json.loads(line)
|
56 |
+
yield key, {
|
57 |
+
"task_id": row["task_id"],
|
58 |
+
"base_prompt": row["base_prompt"],
|
59 |
+
"sfinae_prompt": row["sfinae_prompt"],
|
60 |
+
"concepts_prompt": row["concepts_prompt"],
|
61 |
+
"starter_code": row["starter_code"],
|
62 |
+
"base_canonical_solution": row["base_canonical_solution"],
|
63 |
+
"sfinae_canonical_solution": row["sfinae_canonical_solution"],
|
64 |
+
"concepts_canonical_solution": row["concepts_canonical_solution"],
|
65 |
+
"tests": row["tests"],
|
66 |
+
"invalids": row["invalids"],
|
67 |
+
}
|