soldni commited on
Commit
aebec90
1 Parent(s): 95da235

instructions, more

Browse files
Files changed (2) hide show
  1. README.md +24 -3
  2. match.ipynb +40 -18
README.md CHANGED
@@ -95,7 +95,28 @@ configs:
95
 
96
  Sourced from https://github.com/mosaicml/llm-foundry/blob/main/scripts/eval/local_data/world_knowledge/jeopardy_all.jsonl
97
 
98
- Description: Jeopardy consists of 2,117 Jeopardy questions separated into 5 categories:
99
- Literature, American History, World History, Word Origins, and Science. The model is expected
100
- to give the exact correct response to the question. It was custom curated by MosaicML from a
101
  larger Jeopardy set available on [Huggingface](https://huggingface.co/datasets/jeopardy).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
  Sourced from https://github.com/mosaicml/llm-foundry/blob/main/scripts/eval/local_data/world_knowledge/jeopardy_all.jsonl
97
 
98
+ Description: Jeopardy consists of 2,117 Jeopardy questions separated into 5 categories:
99
+ Literature, American History, World History, Word Origins, and Science. The model is expected
100
+ to give the exact correct response to the question. It was custom curated by MosaicML from a
101
  larger Jeopardy set available on [Huggingface](https://huggingface.co/datasets/jeopardy).
102
+
103
+ ## How to use
104
+
105
+ ```python
106
+ from datasets import load_dataset
107
+
108
+ dataset = load_dataset("soldni/jeopardy", "mosaicml_gauntlet")
109
+ model = ...
110
+ tokenizer = ...
111
+
112
+ # Given context, try to predict the continuation
113
+ for row in dataset:
114
+ input_ids = tokenizer(row['context'], return_tensors='pt').to(model.device)
115
+ outputs = model.generate(input_ids, max_new_tokens=100)
116
+ decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
117
+ correct = row['continuation'] in decoded
118
+ print("Gold:", row['continuation'])
119
+ print("Pred:", decoded)
120
+ print("Correct?", correct)
121
+ print("----")
122
+ ```
match.ipynb CHANGED
@@ -258,14 +258,16 @@
258
  },
259
  {
260
  "cell_type": "code",
261
- "execution_count": 5,
262
  "metadata": {},
263
  "outputs": [
264
  {
265
  "name": "stdout",
266
  "output_type": "stream",
267
  "text": [
268
- "Missing: 0\n"
 
 
269
  ]
270
  }
271
  ],
@@ -275,6 +277,8 @@
275
  "\n",
276
  "missing = [{**v, 'key': k} for k, v in new_questions.items() if k not in old_questions_subset]\n",
277
  "print(f\"Missing: {len(missing)}\")\n",
 
 
278
  "for m in missing:\n",
279
  " print(m['context'])\n",
280
  " print(m['continuation'])\n",
@@ -291,13 +295,21 @@
291
  },
292
  {
293
  "cell_type": "code",
294
- "execution_count": 10,
295
  "metadata": {},
296
  "outputs": [
 
 
 
 
 
 
 
 
297
  {
298
  "data": {
299
  "application/vnd.jupyter.widget-view+json": {
300
- "model_id": "33f3bd1d30d54874b990c17e34b44bb8",
301
  "version_major": 2,
302
  "version_minor": 0
303
  },
@@ -311,28 +323,21 @@
311
  {
312
  "data": {
313
  "application/vnd.jupyter.widget-view+json": {
314
- "model_id": "17dae484d5ef4a7bb1b2204da34da4ca",
315
  "version_major": 2,
316
  "version_minor": 0
317
  },
318
  "text/plain": [
319
- "Creating parquet from Arrow format: 0ba [00:00, ?ba/s]"
320
  ]
321
  },
322
  "metadata": {},
323
  "output_type": "display_data"
324
  },
325
- {
326
- "name": "stderr",
327
- "output_type": "stream",
328
- "text": [
329
- "No files have been modified since last commit. Skipping to prevent empty commit.\n"
330
- ]
331
- },
332
  {
333
  "data": {
334
  "application/vnd.jupyter.widget-view+json": {
335
- "model_id": "491d1a420a6246fb9d74201437e0d490",
336
  "version_major": 2,
337
  "version_minor": 0
338
  },
@@ -346,7 +351,7 @@
346
  {
347
  "data": {
348
  "application/vnd.jupyter.widget-view+json": {
349
- "model_id": "ea3ec39f1ba145c6a5457bc34912cf72",
350
  "version_major": 2,
351
  "version_minor": 0
352
  },
@@ -357,13 +362,27 @@
357
  "metadata": {},
358
  "output_type": "display_data"
359
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
  {
361
  "data": {
362
  "text/plain": [
363
- "CommitInfo(commit_url='https://huggingface.co/datasets/soldni/jeopardy/commit/1618cf7f59f5e0a5132eb99cd43b3180e359fe78', commit_message='Upload dataset', commit_description='', oid='1618cf7f59f5e0a5132eb99cd43b3180e359fe78', pr_url=None, pr_revision=None, pr_num=None)"
364
  ]
365
  },
366
- "execution_count": 10,
367
  "metadata": {},
368
  "output_type": "execute_result"
369
  }
@@ -372,12 +391,15 @@
372
  "all_questions = []\n",
373
  "mosaicml_gauntlet = []\n",
374
  "for row in old_questions:\n",
375
- " key = ' '.join([ch for ch in f\"{row['context']} {row['continuation']}\" if ch not in punctuation and ch not in whitespace])\n",
376
  " all_questions.append(row)\n",
377
  " row['mosaicml_gauntlet'] = key in new_questions\n",
378
  " if row['mosaicml_gauntlet']:\n",
379
  " mosaicml_gauntlet.append(row)\n",
380
  "\n",
 
 
 
381
  "mosaicml_gauntlet_dataset = datasets.Dataset.from_list(mosaicml_gauntlet)\n",
382
  "all_questions_dataset = datasets.Dataset.from_list(all_questions)\n",
383
  "\n",
 
258
  },
259
  {
260
  "cell_type": "code",
261
+ "execution_count": 17,
262
  "metadata": {},
263
  "outputs": [
264
  {
265
  "name": "stdout",
266
  "output_type": "stream",
267
  "text": [
268
+ "Missing: 0\n",
269
+ "Old questions: 2220\n",
270
+ "New questions: 2113\n"
271
  ]
272
  }
273
  ],
 
277
  "\n",
278
  "missing = [{**v, 'key': k} for k, v in new_questions.items() if k not in old_questions_subset]\n",
279
  "print(f\"Missing: {len(missing)}\")\n",
280
+ "print(f\"Old questions: {len(old_questions_subset)}\")\n",
281
+ "print(f\"New questions: {len(new_questions)}\")\n",
282
  "for m in missing:\n",
283
  " print(m['context'])\n",
284
  " print(m['continuation'])\n",
 
295
  },
296
  {
297
  "cell_type": "code",
298
+ "execution_count": 19,
299
  "metadata": {},
300
  "outputs": [
301
+ {
302
+ "name": "stdout",
303
+ "output_type": "stream",
304
+ "text": [
305
+ "Mosaicml Gauntlet: 2116\n",
306
+ "All questions: 216930\n"
307
+ ]
308
+ },
309
  {
310
  "data": {
311
  "application/vnd.jupyter.widget-view+json": {
312
+ "model_id": "b0db52ff66c84083984ce81539bb3129",
313
  "version_major": 2,
314
  "version_minor": 0
315
  },
 
323
  {
324
  "data": {
325
  "application/vnd.jupyter.widget-view+json": {
326
+ "model_id": "e07846cf593e47e78cc7c62d179c5baa",
327
  "version_major": 2,
328
  "version_minor": 0
329
  },
330
  "text/plain": [
331
+ "Creating parquet from Arrow format: 0%| | 0/3 [00:00<?, ?ba/s]"
332
  ]
333
  },
334
  "metadata": {},
335
  "output_type": "display_data"
336
  },
 
 
 
 
 
 
 
337
  {
338
  "data": {
339
  "application/vnd.jupyter.widget-view+json": {
340
+ "model_id": "af4036c1ed13441c9a6cc1de5558dfa3",
341
  "version_major": 2,
342
  "version_minor": 0
343
  },
 
351
  {
352
  "data": {
353
  "application/vnd.jupyter.widget-view+json": {
354
+ "model_id": "e23eca2e0aac433baba52069b40c2e3a",
355
  "version_major": 2,
356
  "version_minor": 0
357
  },
 
362
  "metadata": {},
363
  "output_type": "display_data"
364
  },
365
+ {
366
+ "data": {
367
+ "application/vnd.jupyter.widget-view+json": {
368
+ "model_id": "7a6982d43029428c98258352ec90bf28",
369
+ "version_major": 2,
370
+ "version_minor": 0
371
+ },
372
+ "text/plain": [
373
+ "README.md: 0%| | 0.00/2.34k [00:00<?, ?B/s]"
374
+ ]
375
+ },
376
+ "metadata": {},
377
+ "output_type": "display_data"
378
+ },
379
  {
380
  "data": {
381
  "text/plain": [
382
+ "CommitInfo(commit_url='https://huggingface.co/datasets/soldni/jeopardy/commit/95da23525ad41487becfaf821be025ccefda6a34', commit_message='Upload dataset', commit_description='', oid='95da23525ad41487becfaf821be025ccefda6a34', pr_url=None, pr_revision=None, pr_num=None)"
383
  ]
384
  },
385
+ "execution_count": 19,
386
  "metadata": {},
387
  "output_type": "execute_result"
388
  }
 
391
  "all_questions = []\n",
392
  "mosaicml_gauntlet = []\n",
393
  "for row in old_questions:\n",
394
+ " key = ''.join([ch for ch in f\"{row['context']} {row['continuation']}\" if ch not in punctuation and ch not in whitespace])\n",
395
  " all_questions.append(row)\n",
396
  " row['mosaicml_gauntlet'] = key in new_questions\n",
397
  " if row['mosaicml_gauntlet']:\n",
398
  " mosaicml_gauntlet.append(row)\n",
399
  "\n",
400
+ "print(f\"Mosaicml Gauntlet: {len(mosaicml_gauntlet)}\")\n",
401
+ "print(f\"All questions: {len(all_questions)}\")\n",
402
+ "\n",
403
  "mosaicml_gauntlet_dataset = datasets.Dataset.from_list(mosaicml_gauntlet)\n",
404
  "all_questions_dataset = datasets.Dataset.from_list(all_questions)\n",
405
  "\n",