Datasets:
Tasks:
Text Generation
Sub-tasks:
language-modeling
Languages:
code
Size:
10K<n<100K
ArXiv:
Tags:
code
License:
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,201 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
annotations_creators: []
|
3 |
+
language_creators:
|
4 |
+
- crowdsourced
|
5 |
+
- expert-generated
|
6 |
+
language: ["code"]
|
7 |
+
license:
|
8 |
+
- mit
|
9 |
+
multilinguality:
|
10 |
+
- monolingual
|
11 |
+
pretty_name: TACO
|
12 |
+
size_categories:
|
13 |
+
- unknown
|
14 |
+
source_datasets: []
|
15 |
+
task_categories:
|
16 |
+
- text-generation
|
17 |
+
task_ids:
|
18 |
+
- language-modeling
|
19 |
---
|
20 |
+
|
21 |
+
# TACO Dataset
|
22 |
+
|
23 |
+
## Dataset Description
|
24 |
+
[TACO] is a benchmark for code generation with 26443 problems. It can be used to evaluate the ability of language models to generate code from natural language specifications.
|
25 |
+
|
26 |
+
## Languages
|
27 |
+
|
28 |
+
The dataset contains questions in English and code solutions in Python.
|
29 |
+
|
30 |
+
## Dataset Structure
|
31 |
+
|
32 |
+
```python
|
33 |
+
from datasets import load_dataset
|
34 |
+
load_dataset("BAAI/TACO")
|
35 |
+
|
36 |
+
DatasetDict({
|
37 |
+
train: Dataset({
|
38 |
+
features: ['question', 'solutions', 'starter_code', 'input_output', 'difficulty', 'raw_tags', 'name', 'source', 'tags', 'skill_types', 'url', 'Expected Auxiliary Space', 'time_limit', 'date', 'picture_num', 'memory_limit', 'Expected Time Complexity'],
|
39 |
+
num_rows: 25443
|
40 |
+
})
|
41 |
+
test: Dataset({
|
42 |
+
features: ['question', 'solutions', 'starter_code', 'input_output', 'difficulty', 'raw_tags', 'name', 'source', 'tags', 'skill_types', 'url', 'Expected Auxiliary Space', 'time_limit', 'date', 'picture_num', 'memory_limit', 'Expected Time Complexity'],
|
43 |
+
num_rows: 1000
|
44 |
+
})
|
45 |
+
})
|
46 |
+
```
|
47 |
+
|
48 |
+
### How to use it
|
49 |
+
|
50 |
+
You can load and iterate through the dataset with the following two lines of code for the train split:
|
51 |
+
|
52 |
+
```python
|
53 |
+
from datasets import load_dataset
|
54 |
+
import json
|
55 |
+
|
56 |
+
ds = load_dataset("BAAI/TACO", split="train")
|
57 |
+
sample = next(iter(ds))
|
58 |
+
# non-empty solutions and input_output features can be parsed from text format this way:
|
59 |
+
sample["solutions"] = json.loads(sample["solutions"])
|
60 |
+
sample["input_output"] = json.loads(sample["input_output"])
|
61 |
+
sample["raw_tags"] = eval(sample["raw_tags"])
|
62 |
+
sample["tags"] = eval(sample["tags"])
|
63 |
+
sample["skill_types"] = eval(sample["skill_types"])
|
64 |
+
print(sample)
|
65 |
+
|
66 |
+
#OUTPUT:
|
67 |
+
{
|
68 |
+
"question": "You have a deck of $n$ cards, and you'd like to reorder it to a new one.\n\nEach card has a value between $1$ and $n$ equal to $p_i$. ...",
|
69 |
+
"solutions": [
|
70 |
+
"import heapq\nfrom math import sqrt\nimport operator\nimport sys\ninf_var = 0\nif inf_var == 1:\n\tinf = open('input.txt', 'r')\nelse:\n\tinf = sys.stdin\n ...",
|
71 |
+
"t = int(input())\nfor _ in range(t):\n\tn = int(input())\n\tp = list(map(int, input().split()))\n\tans = []\n\tp1 = [-1] * (n + 1)\n\tfor i in range(n):\n\t\tp1[p[i]] = i\n\ti = n\n\twhile i:\n\t\twhile i > 0 and p1[i] == -1:\n\t\t\ti -= 1\n\t\telse:\n\t\t\tif i:\n\t\t\t\tk = 0\n\t\t\t\tfor j in range(p1[i], n):\n\t\t\t\t\tans.append(p[j])\n\t\t\t\t\tp1[p[j]] = -1\n\t\t\t\t\tk += 1\n\t\t\t\tn -= k\n\t\t\t\ti -= 1\n\t\t\telse:\n\t\t\t\tbreak\n\tprint(*ans)\n",
|
72 |
+
"import sys\n\ndef get_ints():\n\treturn map(int, sys.stdin.readline().strip().split())\n\ndef get_list():\n\treturn list(map(int, sys.stdin.readline().strip().split()))\n\ndef get_list_string():\n\treturn list(map(str, sys.stdin.readline().strip().split()))\n\ndef get_string():\n\treturn sys.stdin.readline().strip()\n\ndef get_int():\n\treturn int(sys.stdin.readline().strip())\n\ndef get_print_int(x):\n\tsys.stdout.write(str(x) + '\\n')\n\ndef get_print(x):\n\tsys.stdout.write(x + '\\n')\n\ndef get_print_int_same(x):\n\tsys.stdout.write(str(x) + ' ')\n\ndef get_print_same(x):\n\tsys.stdout.write(x + ' ')\nfrom sys import maxsize\n\ndef solve():\n\tfor _ in range(get_int()):\n\t\tn = get_int()\n\t\tarr = get_list()\n\t\ti = n - 1\n\t\tj = n - 1\n\t\ttemp = sorted(arr)\n\t\tvis = [False] * n\n\t\tans = []\n\t\twhile j >= 0:\n\t\t\tt = j\n\t\t\ttt = []\n\t\t\twhile t >= 0 and arr[t] != temp[i]:\n\t\t\t\tvis[arr[t] - 1] = True\n\t\t\t\ttt.append(arr[t])\n\t\t\t\tt -= 1\n\t\t\tvis[arr[t] - 1] = True\n\t\t\ttt.append(arr[t])\n\t\t\ttt = tt[::-1]\n\t\t\tfor k in tt:\n\t\t\t\tans.append(k)\n\t\t\tj = t - 1\n\t\t\twhile i >= 0 and vis[i]:\n\t\t\t\ti -= 1\n\t\tget_print(' '.join(map(str, ans)))\nsolve()\n",
|
73 |
+
...
|
74 |
+
],
|
75 |
+
"starter_code": "",
|
76 |
+
"input_output": {
|
77 |
+
"inputs": [
|
78 |
+
"4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1\n",
|
79 |
+
"4\n4\n2 1 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1\n",
|
80 |
+
"4\n4\n2 1 3 4\n5\n1 5 2 4 3\n6\n2 4 5 3 6 1\n1\n1\n",
|
81 |
+
"4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1\n"
|
82 |
+
],
|
83 |
+
"outputs": [
|
84 |
+
"4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1\n",
|
85 |
+
"4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1\n",
|
86 |
+
"4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1\n",
|
87 |
+
"\n4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1\n"
|
88 |
+
]
|
89 |
+
},
|
90 |
+
"difficulty": "EASY",
|
91 |
+
"raw_tags": [
|
92 |
+
"data structures",
|
93 |
+
"greedy",
|
94 |
+
"math"
|
95 |
+
],
|
96 |
+
"name": null,
|
97 |
+
"source": "codeforces",
|
98 |
+
"tags": [
|
99 |
+
"Data structures",
|
100 |
+
"Mathematics",
|
101 |
+
"Greedy algorithms"
|
102 |
+
],
|
103 |
+
"skill_types": [
|
104 |
+
"Data structures",
|
105 |
+
"Greedy algorithms"
|
106 |
+
],
|
107 |
+
"url": "https://codeforces.com/problemset/problem/1492/B",
|
108 |
+
"Expected Auxiliary Space": null,
|
109 |
+
"time_limit": "1 second",
|
110 |
+
"date": "2021-02-23",
|
111 |
+
"picture_num": "0",
|
112 |
+
"memory_limit": "512 megabytes",
|
113 |
+
"Expected Time Complexity": null
|
114 |
+
}
|
115 |
+
```
|
116 |
+
Each sample consists of a programming problem formulation in English, some ground truth Python solutions, test cases that are defined by their inputs and outputs and function name if provided, as well as some metadata regarding the difficulty level (difficulty), topics of task (raw tags), algorithms (tags) as well as required programming skill types (skill_types) of the problem and its source.
|
117 |
+
|
118 |
+
If a sample has non empty `input_output` feature, you can read it as a dictionary with keys `inputs` and `outputs` and `fn_name` if it exists, and similarily you can parse the solutions into a list of solutions as shown in the code above.
|
119 |
+
|
120 |
+
You can also filter the dataset for the difficulty level: EASY, MEDIUM, MEDIUM_HARD, HARD and VERY_HARD, or filter the programming skill types: Amortized analysis, Bit manipulation, Complete search, Data structures, Dynamic programming, Greedy algorithms, Range queries, Sorting. Just pass the list of difficulties or skills as a list. E.g. if you want the most challenging problems, you need to select the VERY_HARD level:
|
121 |
+
|
122 |
+
```python
|
123 |
+
ds = load_dataset("BAAI/TACO", split="train", difficulties=["VERY_HARD"])
|
124 |
+
print(next(iter(ds))["question"])
|
125 |
+
|
126 |
+
#OUTPUT:
|
127 |
+
"""Let S(n) denote the number that represents the digits of n in sorted order. For example, S(1) = 1, S(5) = 5, S(50394) = 3459, S(353535) = 333555.
|
128 |
+
Given a number X, compute <image> modulo 109 + 7.
|
129 |
+
|
130 |
+
Input
|
131 |
+
The first line of input will contain the integer X (1 ≤ X ≤ 10700).
|
132 |
+
|
133 |
+
Output
|
134 |
+
Print a single integer, the answer to the question.
|
135 |
+
|
136 |
+
Examples
|
137 |
+
|
138 |
+
Input
|
139 |
+
21
|
140 |
+
|
141 |
+
Output
|
142 |
+
195
|
143 |
+
|
144 |
+
Input
|
145 |
+
345342
|
146 |
+
|
147 |
+
Output
|
148 |
+
390548434
|
149 |
+
|
150 |
+
Note
|
151 |
+
|
152 |
+
The first few values of S are 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 12. The sum of these values is 195.
|
153 |
+
```
|
154 |
+
Or if you want the problems invovled with Range queries and Sorting, you need to select the skills Range queries and Sorting:
|
155 |
+
```python
|
156 |
+
ds = load_dataset("BAAI/TACO", split="train", skills=["Range queries", "Sorting"])
|
157 |
+
```
|
158 |
+
|
159 |
+
### Data Fields
|
160 |
+
|
161 |
+
|Field|Type|Description|
|
162 |
+
|---|---|---|
|
163 |
+
|question|string|problem description|
|
164 |
+
|solutions|string|some python solutions|
|
165 |
+
|input_output|string|Json string with "inputs" and "outputs" of the test cases, might also include "fn_name" the name of the function|
|
166 |
+
|difficulty|string|difficulty level of the problem|
|
167 |
+
|picture_num|string|the number of pictures in the problem|
|
168 |
+
|source|string|the source of the problem|
|
169 |
+
|url|string|url of the source of the problem|
|
170 |
+
|date|string|the date of the problem|
|
171 |
+
|starter_code|string|starter code to include in prompts|
|
172 |
+
|time_limit|string|the time consumption limit to solve the problem|
|
173 |
+
|memory_limit|string|the memory consumption limit to solve the problem|
|
174 |
+
|Expected Auxiliary Space|string|the extra auxiliary space expected to solve the problem|
|
175 |
+
|Expected Time Complexity|string|the time complexity expected to solve the problem|
|
176 |
+
|raw_tags|string|the topics of the programming task|
|
177 |
+
|tags|string|the manually annoatated algorithms needed to solve the problem|
|
178 |
+
|skill_types|string|the mapped programming skill types to solve the problem|
|
179 |
+
|
180 |
+
|
181 |
+
|
182 |
+
### Data Splits
|
183 |
+
|
184 |
+
The dataset contains a train with 25443 samples and test splits with 1000 samples.
|
185 |
+
|
186 |
+
### Dataset Statistics
|
187 |
+
* 26443 coding problems
|
188 |
+
* 1.55M verified solutions
|
189 |
+
* for tests split, the average number of test cases is 202.3
|
190 |
+
* all files have ground-truth solutions in the test split
|
191 |
+
|
192 |
+
## Dataset Creation
|
193 |
+
|
194 |
+
To create the TACO dataset, the authors manually curated problems from open-access sites where programmers share problems with each other, including Aizu
|
195 |
+
AtCoder, CodeChef, Codeforces, CodeWars, GeeksforGeeks, HackerEarth, HackerRank, Katti and LeetCode. For more details please refer to the original paper.
|
196 |
+
|
197 |
+
|
198 |
+
## Citation Information
|
199 |
+
|
200 |
+
```
|
201 |
+
```
|