File size: 23,578 Bytes
91aeaaa 1e711fd 91aeaaa 1e711fd 91aeaaa 1e711fd 91aeaaa 1e711fd 91aeaaa 1e711fd 91aeaaa 1e711fd 91aeaaa 322bda0 91aeaaa 1e711fd 91aeaaa 1e711fd 91aeaaa 1e711fd 91aeaaa 1e711fd 91aeaaa 1e711fd 91aeaaa 1e711fd 91aeaaa 1e711fd 322bda0 1e711fd 91aeaaa 322bda0 91aeaaa 1e711fd 91aeaaa 1e711fd 91aeaaa 1e711fd 91aeaaa 1e711fd 322bda0 1e711fd 91aeaaa 1e711fd 91aeaaa 1e711fd 322bda0 1e711fd 91aeaaa 1e711fd 91aeaaa 1e711fd 91aeaaa 1e711fd 322bda0 1e711fd 91aeaaa 1e711fd 91aeaaa 1e711fd 91aeaaa 322bda0 91aeaaa 1e711fd 91aeaaa 1e711fd 91aeaaa 1e711fd 91aeaaa 322bda0 91aeaaa 1e711fd 91aeaaa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "c975c670-97cc-453e-bba6-3639cf8d5e89",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/jue@together.xyz/miniconda3/envs/nebula-fav2/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from .autonotebook import tqdm as notebook_tqdm\n"
]
}
],
"source": [
"import json\n",
"from datasets import load_dataset"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "e818dca8-bd10-4b89-9fcd-5cd9252b4e07",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Found cached dataset hellaswag (/home/jue@together.xyz/.cache/huggingface/datasets/hellaswag/default/0.1.0/512a66dd8b1b1643ab4a48aa4f150d04c91680da6a4096498a5e5f799623d5ae)\n",
"100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 3/3 [00:00<00:00, 53.00it/s]\n"
]
}
],
"source": [
"task_name = 'hellaswag'\n",
"data = load_dataset(task_name)\n",
"data.shuffle(seed=42)\n",
"with open(f'../seed_data{task_name}.jsonl', 'w') as f:\n",
" for i_item, item in enumerate(data['train']):\n",
" text = item['ctx'] + item['endings'][int(item['label'])]\n",
" f.write(\n",
" json.dumps({'text': text, 'source': task_name}) + '\\n'\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "c42aae00-be85-4b64-9325-f6a6139c6ee6",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Downloading builder script: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 3.38k/3.38k [00:00<00:00, 32.1MB/s]\n",
"Downloading metadata: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 1.91k/1.91k [00:00<00:00, 20.0MB/s]\n",
"Downloading readme: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 6.60k/6.60k [00:00<00:00, 45.1MB/s]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Downloading and preparing dataset boolq/default to /home/jue@together.xyz/.cache/huggingface/datasets/boolq/default/0.1.0/bf0dd57da941c50de94ae3ce3cef7fea48c08f337a4b7aac484e9dddc5aa24e5...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Downloading data files: 0%| | 0/2 [00:00<?, ?it/s]\n",
"Downloading data: 0%| | 0.00/6.53M [00:00<?, ?B/s]\u001b[A\n",
"Downloading data: 0%|β | 17.4k/6.53M [00:00<00:43, 150kB/s]\u001b[A\n",
"Downloading data: 1%|ββ | 54.3k/6.53M [00:00<00:26, 246kB/s]\u001b[A\n",
"Downloading data: 2%|βββ | 104k/6.53M [00:00<00:18, 346kB/s]\u001b[A\n",
"Downloading data: 3%|βββββ | 197k/6.53M [00:00<00:11, 554kB/s]\u001b[A\n",
"Downloading data: 5%|ββββββββ | 343k/6.53M [00:00<00:07, 865kB/s]\u001b[A\n",
"Downloading data: 10%|ββββββββββββββ | 623k/6.53M [00:00<00:03, 1.50MB/s]\u001b[A\n",
"Downloading data: 17%|βββββββββββββββββββββββββ | 1.12M/6.53M [00:00<00:02, 2.58MB/s]\u001b[A\n",
"Downloading data: 31%|ββββββββββββββββββββββββββββββββββββββββββββββ | 2.05M/6.53M [00:00<00:00, 4.67MB/s]\u001b[A\n",
"Downloading data: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 6.53M/6.53M [00:01<00:00, 6.28MB/s]\u001b[A\n",
"Downloading data files: 50%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 1/2 [00:01<00:01, 1.95s/it]\n",
"Downloading data: 0%| | 0.00/2.24M [00:00<?, ?B/s]\u001b[A\n",
"Downloading data: 1%|ββ | 17.4k/2.24M [00:00<00:14, 150kB/s]\u001b[A\n",
"Downloading data: 2%|ββββ | 54.3k/2.24M [00:00<00:08, 246kB/s]\u001b[A\n",
"Downloading data: 5%|βββββββ | 104k/2.24M [00:00<00:06, 347kB/s]\u001b[A\n",
"Downloading data: 9%|βββββββββββββ | 195k/2.24M [00:00<00:03, 549kB/s]\u001b[A\n",
"Downloading data: 15%|βββββββββββββββββββββββ | 341k/2.24M [00:00<00:02, 863kB/s]\u001b[A\n",
"Downloading data: 28%|ββββββββββββββββββββββββββββββββββββββββ | 617k/2.24M [00:00<00:01, 1.49MB/s]\u001b[A\n",
"Downloading data: 49%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 1.09M/2.24M [00:00<00:00, 2.53MB/s]\u001b[A\n",
"Downloading data: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 2.24M/2.24M [00:00<00:00, 2.61MB/s]\u001b[A\n",
"Downloading data files: 100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 2/2 [00:03<00:00, 1.85s/it]\n",
" \r"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Dataset boolq downloaded and prepared to /home/jue@together.xyz/.cache/huggingface/datasets/boolq/default/0.1.0/bf0dd57da941c50de94ae3ce3cef7fea48c08f337a4b7aac484e9dddc5aa24e5. Subsequent calls will reuse this data.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 2/2 [00:00<00:00, 139.08it/s]\n"
]
}
],
"source": [
"task_name = 'boolq'\n",
"data = load_dataset(task_name)\n",
"data.shuffle(seed=42)\n",
"with open(f'../seed_data{task_name}.jsonl', 'w') as f:\n",
" for i_item, item in enumerate(data['train']):\n",
" text = f\"{item['passage']}\\nQuestion: {item['question']}?\\nAnswer: {item['answer']}\"\n",
" f.write(\n",
" json.dumps({'text': text, 'source': task_name}) + '\\n'\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "878216f4-74e4-46ba-bfcd-c95348c10415",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Found cached dataset ai2_arc (/home/jue@together.xyz/.cache/huggingface/datasets/ai2_arc/ARC-Challenge/1.0.0/1569c2591ea2683779581d9fb467203d9aa95543bb9b75dcfde5da92529fd7f6)\n",
"100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 3/3 [00:00<00:00, 624.09it/s]\n"
]
}
],
"source": [
"task_name = 'arc_challenge'\n",
"data = load_dataset('ai2_arc', 'ARC-Challenge')\n",
"data.shuffle(seed=42)\n",
"with open(f'../seed_data{task_name}.jsonl', 'w') as f:\n",
" for i_item, item in enumerate(data['train']):\n",
" i_a = item['choices']['label'].index(item['answerKey'])\n",
" q = item['question']\n",
" a = item['choices']['text'][i_a]\n",
" text = \"Question: \" + q + \"\\nAnswer:\" + a\n",
" f.write(\n",
" json.dumps({'text': text, 'source': task_name}) + '\\n'\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "7cb51285-d5ce-4ae2-bd7f-ac15e87c4fb7",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Found cached dataset ai2_arc (/home/jue@together.xyz/.cache/huggingface/datasets/ai2_arc/ARC-Easy/1.0.0/1569c2591ea2683779581d9fb467203d9aa95543bb9b75dcfde5da92529fd7f6)\n",
"100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 3/3 [00:00<00:00, 426.87it/s]\n"
]
}
],
"source": [
"task_name = 'arc_easy'\n",
"data = load_dataset('ai2_arc', 'ARC-Easy')\n",
"data.shuffle(seed=42)\n",
"with open(f'../seed_data{task_name}.jsonl', 'w') as f:\n",
" for i_item, item in enumerate(data['train']):\n",
" i_a = item['choices']['label'].index(item['answerKey'])\n",
" q = item['question']\n",
" a = item['choices']['text'][i_a]\n",
" text = \"Question: \" + q + \"\\nAnswer:\" + a\n",
" f.write(\n",
" json.dumps({'text': text, 'source': task_name}) + '\\n'\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "9347c339-4559-4111-bf44-ce2b624edc9e",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Found cached dataset super_glue (/home/jue@together.xyz/.cache/huggingface/datasets/super_glue/copa/1.0.3/bb9675f958ebfee0d5d6dc5476fafe38c79123727a7258d515c450873dbdbbed)\n",
"100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 3/3 [00:00<00:00, 1055.52it/s]\n",
"Loading cached shuffled indices for dataset at /home/jue@together.xyz/.cache/huggingface/datasets/super_glue/copa/1.0.3/bb9675f958ebfee0d5d6dc5476fafe38c79123727a7258d515c450873dbdbbed/cache-06e156489a3d17ef.arrow\n",
"Loading cached shuffled indices for dataset at /home/jue@together.xyz/.cache/huggingface/datasets/super_glue/copa/1.0.3/bb9675f958ebfee0d5d6dc5476fafe38c79123727a7258d515c450873dbdbbed/cache-f4bd523109c343ed.arrow\n",
"Loading cached shuffled indices for dataset at /home/jue@together.xyz/.cache/huggingface/datasets/super_glue/copa/1.0.3/bb9675f958ebfee0d5d6dc5476fafe38c79123727a7258d515c450873dbdbbed/cache-b8d0981688b46f46.arrow\n"
]
}
],
"source": [
"task_name = 'copa'\n",
"data = load_dataset('super_glue', task_name)\n",
"data.shuffle(seed=42)\n",
"with open(f'../seed_data{task_name}.jsonl', 'w') as f:\n",
" for i_item, item in enumerate(data['train']):\n",
" i_a = item['label']\n",
" premise = item['premise']\n",
" question = item['question']\n",
" choice = item['choice1'] if i_a == 0 else item['choice2']\n",
" choice = choice[0].lower() + choice[1:]\n",
"\n",
" connector = {\n",
" \"cause\": \"because\",\n",
" \"effect\": \"therefore\",\n",
" }[question]\n",
"\n",
" text = premise.strip()[:-1] + f\" {connector}\" + ' ' + choice\n",
" f.write(\n",
" json.dumps({'text': text, 'source': task_name}) + '\\n'\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "dc24ba3b-aa6a-4665-87aa-08471a87de9b",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Found cached dataset piqa (/home/jue@together.xyz/.cache/huggingface/datasets/piqa/plain_text/1.1.0/6c611c1a9bf220943c4174e117d3b660859665baf1d43156230116185312d011)\n",
"100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 3/3 [00:00<00:00, 910.95it/s]\n",
"Loading cached shuffled indices for dataset at /home/jue@together.xyz/.cache/huggingface/datasets/piqa/plain_text/1.1.0/6c611c1a9bf220943c4174e117d3b660859665baf1d43156230116185312d011/cache-64434cd628e6e9e0.arrow\n",
"Loading cached shuffled indices for dataset at /home/jue@together.xyz/.cache/huggingface/datasets/piqa/plain_text/1.1.0/6c611c1a9bf220943c4174e117d3b660859665baf1d43156230116185312d011/cache-97a6e3c466ced62d.arrow\n",
"Loading cached shuffled indices for dataset at /home/jue@together.xyz/.cache/huggingface/datasets/piqa/plain_text/1.1.0/6c611c1a9bf220943c4174e117d3b660859665baf1d43156230116185312d011/cache-6b1e5924150382c7.arrow\n"
]
}
],
"source": [
"task_name = 'piqa'\n",
"data = load_dataset(task_name)\n",
"data.shuffle(seed=42)\n",
"with open(f'../seed_data{task_name}.jsonl', 'w') as f:\n",
" for i_item, item in enumerate(data['train']):\n",
" i_a = item['label']\n",
" goal = item['goal']\n",
" sol = item['sol1'] if i_a == 0 else item['sol2']\n",
"\n",
" text = \"Question: \" + goal + \"\\nAnswer: \" + sol\n",
" f.write(\n",
" json.dumps({'text': text, 'source': task_name}) + '\\n'\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "501744bd-0260-4a3c-89dc-df264ff3306e",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Found cached dataset winogrande (/home/jue@together.xyz/.cache/huggingface/datasets/winogrande/winogrande_xl/1.1.0/a826c3d3506aefe0e9e9390dcb53271070536586bab95849876b2c1743df56e2)\n",
"100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 3/3 [00:00<00:00, 1014.75it/s]\n",
"Loading cached shuffled indices for dataset at /home/jue@together.xyz/.cache/huggingface/datasets/winogrande/winogrande_xl/1.1.0/a826c3d3506aefe0e9e9390dcb53271070536586bab95849876b2c1743df56e2/cache-ebcf1ebbadaf243c.arrow\n",
"Loading cached shuffled indices for dataset at /home/jue@together.xyz/.cache/huggingface/datasets/winogrande/winogrande_xl/1.1.0/a826c3d3506aefe0e9e9390dcb53271070536586bab95849876b2c1743df56e2/cache-ea79c2b85e9d846f.arrow\n",
"Loading cached shuffled indices for dataset at /home/jue@together.xyz/.cache/huggingface/datasets/winogrande/winogrande_xl/1.1.0/a826c3d3506aefe0e9e9390dcb53271070536586bab95849876b2c1743df56e2/cache-5aca6c830a1dfa33.arrow\n"
]
}
],
"source": [
"task_name = 'winogrande'\n",
"data = load_dataset(task_name, 'winogrande_xl')\n",
"data.shuffle(seed=42)\n",
"with open(f'../seed_data{task_name}.jsonl', 'w') as f:\n",
" for i_item, item in enumerate(data['train']):\n",
" i_a = item['answer']\n",
" sentence = item['sentence']\n",
" option = item['option1'] if i_a == 1 else item['option2']\n",
" \n",
" text = sentence.replace('_', option)\n",
" f.write(\n",
" json.dumps({'text': text, 'source': task_name}) + '\\n'\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "65d4b641-2b78-476f-89ac-6ecb48e7d044",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Found cached dataset json (/home/jue@together.xyz/.cache/huggingface/datasets/juewang___json/juewang--target-data-72e09ed206c54e99/0.0.0/8bb11242116d547c741b2e8a1f18598ffdd40a1d4f2a2872c7a28b697434bc96)\n"
]
}
],
"source": [
"dataset = load_dataset(\"juewang/target-data\", data_files='seed_data/*.jsonl', split='train')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a0554b4f-c5c0-4621-8b91-3daf05e6fbdf",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "nebula-fav2",
"language": "python",
"name": "nebula-fav2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|