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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 38,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"from datasets import load_dataset"
|
10 |
+
]
|
11 |
+
},
|
12 |
+
{
|
13 |
+
"cell_type": "code",
|
14 |
+
"execution_count": 39,
|
15 |
+
"metadata": {},
|
16 |
+
"outputs": [
|
17 |
+
{
|
18 |
+
"data": {
|
19 |
+
"application/vnd.jupyter.widget-view+json": {
|
20 |
+
"model_id": "3a8b3dffa1b948aaa0733e2ab086920d",
|
21 |
+
"version_major": 2,
|
22 |
+
"version_minor": 0
|
23 |
+
},
|
24 |
+
"text/plain": [
|
25 |
+
"Downloading data files: 0%| | 0/1 [00:00<?, ?it/s]"
|
26 |
+
]
|
27 |
+
},
|
28 |
+
"metadata": {},
|
29 |
+
"output_type": "display_data"
|
30 |
+
},
|
31 |
+
{
|
32 |
+
"data": {
|
33 |
+
"application/vnd.jupyter.widget-view+json": {
|
34 |
+
"model_id": "1f11b1625c5d488a87faa0159fa7dcb4",
|
35 |
+
"version_major": 2,
|
36 |
+
"version_minor": 0
|
37 |
+
},
|
38 |
+
"text/plain": [
|
39 |
+
"Extracting data files: 0%| | 0/1 [00:00<?, ?it/s]"
|
40 |
+
]
|
41 |
+
},
|
42 |
+
"metadata": {},
|
43 |
+
"output_type": "display_data"
|
44 |
+
},
|
45 |
+
{
|
46 |
+
"data": {
|
47 |
+
"application/vnd.jupyter.widget-view+json": {
|
48 |
+
"model_id": "e9c7863b49734ed2b44438e8312d7d5c",
|
49 |
+
"version_major": 2,
|
50 |
+
"version_minor": 0
|
51 |
+
},
|
52 |
+
"text/plain": [
|
53 |
+
"Generating 2024_math split: 0 examples [00:00, ? examples/s]"
|
54 |
+
]
|
55 |
+
},
|
56 |
+
"metadata": {},
|
57 |
+
"output_type": "display_data"
|
58 |
+
}
|
59 |
+
],
|
60 |
+
"source": [
|
61 |
+
"dataset=load_dataset(\"json\",data_files={\"2024_math\":\"./data/json/2024/math.json\"})"
|
62 |
+
]
|
63 |
+
},
|
64 |
+
{
|
65 |
+
"cell_type": "code",
|
66 |
+
"execution_count": 40,
|
67 |
+
"metadata": {},
|
68 |
+
"outputs": [
|
69 |
+
{
|
70 |
+
"data": {
|
71 |
+
"text/plain": [
|
72 |
+
"DatasetDict({\n",
|
73 |
+
" 2024_math: Dataset({\n",
|
74 |
+
" features: ['id', 'name', 'problem', 'answer', 'score'],\n",
|
75 |
+
" num_rows: 46\n",
|
76 |
+
" })\n",
|
77 |
+
"})"
|
78 |
+
]
|
79 |
+
},
|
80 |
+
"execution_count": 40,
|
81 |
+
"metadata": {},
|
82 |
+
"output_type": "execute_result"
|
83 |
+
}
|
84 |
+
],
|
85 |
+
"source": [
|
86 |
+
"dataset"
|
87 |
+
]
|
88 |
+
},
|
89 |
+
{
|
90 |
+
"cell_type": "code",
|
91 |
+
"execution_count": 44,
|
92 |
+
"metadata": {},
|
93 |
+
"outputs": [
|
94 |
+
{
|
95 |
+
"data": {
|
96 |
+
"application/vnd.jupyter.widget-view+json": {
|
97 |
+
"model_id": "d7597eced7414d229ecff3c3d1bd2739",
|
98 |
+
"version_major": 2,
|
99 |
+
"version_minor": 0
|
100 |
+
},
|
101 |
+
"text/plain": [
|
102 |
+
"Pushing dataset shards to the dataset hub: 0%| | 0/1 [00:00<?, ?it/s]"
|
103 |
+
]
|
104 |
+
},
|
105 |
+
"metadata": {},
|
106 |
+
"output_type": "display_data"
|
107 |
+
},
|
108 |
+
{
|
109 |
+
"data": {
|
110 |
+
"application/vnd.jupyter.widget-view+json": {
|
111 |
+
"model_id": "751cbdf0381b4fea91ff4dc1f0697bd0",
|
112 |
+
"version_major": 2,
|
113 |
+
"version_minor": 0
|
114 |
+
},
|
115 |
+
"text/plain": [
|
116 |
+
"Creating parquet from Arrow format: 0%| | 0/1 [00:00<?, ?ba/s]"
|
117 |
+
]
|
118 |
+
},
|
119 |
+
"metadata": {},
|
120 |
+
"output_type": "display_data"
|
121 |
+
},
|
122 |
+
{
|
123 |
+
"data": {
|
124 |
+
"application/vnd.jupyter.widget-view+json": {
|
125 |
+
"model_id": "f9e6119ff58243b28480d9659a390037",
|
126 |
+
"version_major": 2,
|
127 |
+
"version_minor": 0
|
128 |
+
},
|
129 |
+
"text/plain": [
|
130 |
+
"Downloading metadata: 0%| | 0.00/1.05k [00:00<?, ?B/s]"
|
131 |
+
]
|
132 |
+
},
|
133 |
+
"metadata": {},
|
134 |
+
"output_type": "display_data"
|
135 |
+
}
|
136 |
+
],
|
137 |
+
"source": [
|
138 |
+
"#save as parquet\n",
|
139 |
+
"dataset.push_to_hub(\"cfpark00/KoreanSAT\")"
|
140 |
+
]
|
141 |
+
},
|
142 |
+
{
|
143 |
+
"cell_type": "code",
|
144 |
+
"execution_count": null,
|
145 |
+
"metadata": {},
|
146 |
+
"outputs": [],
|
147 |
+
"source": []
|
148 |
+
},
|
149 |
+
{
|
150 |
+
"cell_type": "code",
|
151 |
+
"execution_count": null,
|
152 |
+
"metadata": {},
|
153 |
+
"outputs": [],
|
154 |
+
"source": []
|
155 |
+
},
|
156 |
+
{
|
157 |
+
"cell_type": "code",
|
158 |
+
"execution_count": 45,
|
159 |
+
"metadata": {},
|
160 |
+
"outputs": [
|
161 |
+
{
|
162 |
+
"data": {
|
163 |
+
"application/vnd.jupyter.widget-view+json": {
|
164 |
+
"model_id": "4008ff6d9bd347d9898bb7bde7df1ae3",
|
165 |
+
"version_major": 2,
|
166 |
+
"version_minor": 0
|
167 |
+
},
|
168 |
+
"text/plain": [
|
169 |
+
"Downloading readme: 0%| | 0.00/1.06k [00:00<?, ?B/s]"
|
170 |
+
]
|
171 |
+
},
|
172 |
+
"metadata": {},
|
173 |
+
"output_type": "display_data"
|
174 |
+
},
|
175 |
+
{
|
176 |
+
"data": {
|
177 |
+
"application/vnd.jupyter.widget-view+json": {
|
178 |
+
"model_id": "c1404a18c0734c62abcbe89245a967dd",
|
179 |
+
"version_major": 2,
|
180 |
+
"version_minor": 0
|
181 |
+
},
|
182 |
+
"text/plain": [
|
183 |
+
"Downloading data files: 0%| | 0/1 [00:00<?, ?it/s]"
|
184 |
+
]
|
185 |
+
},
|
186 |
+
"metadata": {},
|
187 |
+
"output_type": "display_data"
|
188 |
+
},
|
189 |
+
{
|
190 |
+
"data": {
|
191 |
+
"application/vnd.jupyter.widget-view+json": {
|
192 |
+
"model_id": "c7022d40bfab4776a76b000df1179300",
|
193 |
+
"version_major": 2,
|
194 |
+
"version_minor": 0
|
195 |
+
},
|
196 |
+
"text/plain": [
|
197 |
+
"Downloading data: 0%| | 0.00/15.2k [00:00<?, ?B/s]"
|
198 |
+
]
|
199 |
+
},
|
200 |
+
"metadata": {},
|
201 |
+
"output_type": "display_data"
|
202 |
+
},
|
203 |
+
{
|
204 |
+
"data": {
|
205 |
+
"application/vnd.jupyter.widget-view+json": {
|
206 |
+
"model_id": "ed08141788444f01994fff9580596bc5",
|
207 |
+
"version_major": 2,
|
208 |
+
"version_minor": 0
|
209 |
+
},
|
210 |
+
"text/plain": [
|
211 |
+
"Extracting data files: 0%| | 0/1 [00:00<?, ?it/s]"
|
212 |
+
]
|
213 |
+
},
|
214 |
+
"metadata": {},
|
215 |
+
"output_type": "display_data"
|
216 |
+
},
|
217 |
+
{
|
218 |
+
"data": {
|
219 |
+
"application/vnd.jupyter.widget-view+json": {
|
220 |
+
"model_id": "abbcfec95f544869bbce8682a7108610",
|
221 |
+
"version_major": 2,
|
222 |
+
"version_minor": 0
|
223 |
+
},
|
224 |
+
"text/plain": [
|
225 |
+
"Generating 2024_math split: 0%| | 0/46 [00:00<?, ? examples/s]"
|
226 |
+
]
|
227 |
+
},
|
228 |
+
"metadata": {},
|
229 |
+
"output_type": "display_data"
|
230 |
+
}
|
231 |
+
],
|
232 |
+
"source": [
|
233 |
+
"from datasets import load_dataset\n",
|
234 |
+
"\n",
|
235 |
+
"ds = load_dataset(\"cfpark00/KoreanSAT\")"
|
236 |
+
]
|
237 |
+
},
|
238 |
+
{
|
239 |
+
"cell_type": "code",
|
240 |
+
"execution_count": 46,
|
241 |
+
"metadata": {},
|
242 |
+
"outputs": [
|
243 |
+
{
|
244 |
+
"data": {
|
245 |
+
"text/plain": [
|
246 |
+
"DatasetDict({\n",
|
247 |
+
" 2024_math: Dataset({\n",
|
248 |
+
" features: ['id', 'name', 'problem', 'answer', 'score'],\n",
|
249 |
+
" num_rows: 46\n",
|
250 |
+
" })\n",
|
251 |
+
"})"
|
252 |
+
]
|
253 |
+
},
|
254 |
+
"execution_count": 46,
|
255 |
+
"metadata": {},
|
256 |
+
"output_type": "execute_result"
|
257 |
+
}
|
258 |
+
],
|
259 |
+
"source": [
|
260 |
+
"ds"
|
261 |
+
]
|
262 |
+
},
|
263 |
+
{
|
264 |
+
"cell_type": "code",
|
265 |
+
"execution_count": null,
|
266 |
+
"metadata": {},
|
267 |
+
"outputs": [],
|
268 |
+
"source": []
|
269 |
+
},
|
270 |
+
{
|
271 |
+
"cell_type": "code",
|
272 |
+
"execution_count": 37,
|
273 |
+
"metadata": {},
|
274 |
+
"outputs": [
|
275 |
+
{
|
276 |
+
"data": {
|
277 |
+
"application/vnd.jupyter.widget-view+json": {
|
278 |
+
"model_id": "56b0357800c24f42af02e56bcd9f9133",
|
279 |
+
"version_major": 2,
|
280 |
+
"version_minor": 0
|
281 |
+
},
|
282 |
+
"text/plain": [
|
283 |
+
"Creating json from Arrow format: 0%| | 0/1 [00:00<?, ?ba/s]"
|
284 |
+
]
|
285 |
+
},
|
286 |
+
"metadata": {},
|
287 |
+
"output_type": "display_data"
|
288 |
+
},
|
289 |
+
{
|
290 |
+
"data": {
|
291 |
+
"text/plain": [
|
292 |
+
"33057"
|
293 |
+
]
|
294 |
+
},
|
295 |
+
"execution_count": 37,
|
296 |
+
"metadata": {},
|
297 |
+
"output_type": "execute_result"
|
298 |
+
}
|
299 |
+
],
|
300 |
+
"source": [
|
301 |
+
"dataset[\"2024_math\"].to_json(\"./data/json/2024/math.json\")"
|
302 |
+
]
|
303 |
+
},
|
304 |
+
{
|
305 |
+
"cell_type": "code",
|
306 |
+
"execution_count": 29,
|
307 |
+
"metadata": {},
|
308 |
+
"outputs": [],
|
309 |
+
"source": [
|
310 |
+
"import json\n",
|
311 |
+
"jsons=[]\n",
|
312 |
+
"for line in open(\"./data/json/2024/math.json\"):\n",
|
313 |
+
" jsons.append(json.loads(line))"
|
314 |
+
]
|
315 |
+
},
|
316 |
+
{
|
317 |
+
"cell_type": "code",
|
318 |
+
"execution_count": 31,
|
319 |
+
"metadata": {},
|
320 |
+
"outputs": [
|
321 |
+
{
|
322 |
+
"name": "stdout",
|
323 |
+
"output_type": "stream",
|
324 |
+
"text": [
|
325 |
+
"16. λ°©μ μ\n",
|
326 |
+
"\\[\n",
|
327 |
+
"\\log_2{(3x+2)} = 2 + \\log_2{(x-2)}\n",
|
328 |
+
"\\]\n",
|
329 |
+
"\\text{λ₯Ό λ§μ‘±μν€λ μ€μ } \\( x \\) \\text{μ κ°μ ꡬνμμ€. [3μ ]}\n",
|
330 |
+
"\n"
|
331 |
+
]
|
332 |
+
}
|
333 |
+
],
|
334 |
+
"source": [
|
335 |
+
"print(jsons[15][\"problem\"])"
|
336 |
+
]
|
337 |
+
},
|
338 |
+
{
|
339 |
+
"cell_type": "code",
|
340 |
+
"execution_count": 30,
|
341 |
+
"metadata": {},
|
342 |
+
"outputs": [
|
343 |
+
{
|
344 |
+
"data": {
|
345 |
+
"text/plain": [
|
346 |
+
"{'id': 16,\n",
|
347 |
+
" 'name': '16',\n",
|
348 |
+
" 'problem': '16. λ°©μ μ\\n\\\\[\\n\\\\log_2{(3x+2)} = 2 + \\\\log_2{(x-2)}\\n\\\\]\\n\\\\text{λ₯Ό λ§μ‘±μν€λ μ€μ } \\\\( x \\\\) \\\\text{μ κ°μ ꡬνμμ€. [3μ ]}\\n',\n",
|
349 |
+
" 'answer': '2',\n",
|
350 |
+
" 'score': 3}"
|
351 |
+
]
|
352 |
+
},
|
353 |
+
"execution_count": 30,
|
354 |
+
"metadata": {},
|
355 |
+
"output_type": "execute_result"
|
356 |
+
}
|
357 |
+
],
|
358 |
+
"source": [
|
359 |
+
"jsons[15]"
|
360 |
+
]
|
361 |
+
},
|
362 |
+
{
|
363 |
+
"cell_type": "code",
|
364 |
+
"execution_count": null,
|
365 |
+
"metadata": {},
|
366 |
+
"outputs": [],
|
367 |
+
"source": []
|
368 |
+
},
|
369 |
+
{
|
370 |
+
"cell_type": "code",
|
371 |
+
"execution_count": null,
|
372 |
+
"metadata": {},
|
373 |
+
"outputs": [],
|
374 |
+
"source": []
|
375 |
+
},
|
376 |
+
{
|
377 |
+
"cell_type": "code",
|
378 |
+
"execution_count": null,
|
379 |
+
"metadata": {},
|
380 |
+
"outputs": [],
|
381 |
+
"source": []
|
382 |
+
}
|
383 |
+
],
|
384 |
+
"metadata": {
|
385 |
+
"kernelspec": {
|
386 |
+
"display_name": "venv1",
|
387 |
+
"language": "python",
|
388 |
+
"name": "python3"
|
389 |
+
},
|
390 |
+
"language_info": {
|
391 |
+
"codemirror_mode": {
|
392 |
+
"name": "ipython",
|
393 |
+
"version": 3
|
394 |
+
},
|
395 |
+
"file_extension": ".py",
|
396 |
+
"mimetype": "text/x-python",
|
397 |
+
"name": "python",
|
398 |
+
"nbconvert_exporter": "python",
|
399 |
+
"pygments_lexer": "ipython3",
|
400 |
+
"version": "3.10.9"
|
401 |
+
}
|
402 |
+
},
|
403 |
+
"nbformat": 4,
|
404 |
+
"nbformat_minor": 2
|
405 |
+
}
|