feat: add notebook example
Browse files- .pre-commit-config.yaml +4 -0
- notebooks/demo.ipynb +77 -0
.pre-commit-config.yaml
CHANGED
|
@@ -79,3 +79,7 @@ repos:
|
|
| 79 |
args: [--fix]
|
| 80 |
# Run the formatter.
|
| 81 |
- id: ruff-format
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
args: [--fix]
|
| 80 |
# Run the formatter.
|
| 81 |
- id: ruff-format
|
| 82 |
+
- repo: https://github.com/kynan/nbstripout
|
| 83 |
+
rev: 0.5.0 # use the latest version
|
| 84 |
+
hooks:
|
| 85 |
+
- id: nbstripout
|
notebooks/demo.ipynb
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": null,
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"outputs": [],
|
| 8 |
+
"source": [
|
| 9 |
+
"import pprint\n",
|
| 10 |
+
"import random"
|
| 11 |
+
]
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"cell_type": "code",
|
| 15 |
+
"execution_count": null,
|
| 16 |
+
"metadata": {},
|
| 17 |
+
"outputs": [],
|
| 18 |
+
"source": [
|
| 19 |
+
"from llmdataparser import ParserRegistry\n",
|
| 20 |
+
"ParserRegistry.list_parsers()"
|
| 21 |
+
]
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
"cell_type": "code",
|
| 25 |
+
"execution_count": null,
|
| 26 |
+
"metadata": {},
|
| 27 |
+
"outputs": [],
|
| 28 |
+
"source": [
|
| 29 |
+
"mmlu_parser = ParserRegistry.get_parser('mmlu')\n",
|
| 30 |
+
"mmlu_parser.load()"
|
| 31 |
+
]
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"cell_type": "code",
|
| 35 |
+
"execution_count": null,
|
| 36 |
+
"metadata": {},
|
| 37 |
+
"outputs": [],
|
| 38 |
+
"source": [
|
| 39 |
+
"mmlu_parser.parse(split_names=['dev', 'test'])\n",
|
| 40 |
+
"parsed_data = mmlu_parser.get_parsed_data"
|
| 41 |
+
]
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
"cell_type": "code",
|
| 45 |
+
"execution_count": null,
|
| 46 |
+
"metadata": {},
|
| 47 |
+
"outputs": [],
|
| 48 |
+
"source": [
|
| 49 |
+
"index = random.randint(0, len(parsed_data))\n",
|
| 50 |
+
"print(f\"Question: \\n-------------------\\n {parsed_data[index].prompt}\")\n",
|
| 51 |
+
"print(\"-------------------\")\n",
|
| 52 |
+
"print(f\"Answer: \\n-------------------\\n{parsed_data[index].answer_letter}\")"
|
| 53 |
+
]
|
| 54 |
+
}
|
| 55 |
+
],
|
| 56 |
+
"metadata": {
|
| 57 |
+
"kernelspec": {
|
| 58 |
+
"display_name": "llmdata",
|
| 59 |
+
"language": "python",
|
| 60 |
+
"name": "python3"
|
| 61 |
+
},
|
| 62 |
+
"language_info": {
|
| 63 |
+
"codemirror_mode": {
|
| 64 |
+
"name": "ipython",
|
| 65 |
+
"version": 3
|
| 66 |
+
},
|
| 67 |
+
"file_extension": ".py",
|
| 68 |
+
"mimetype": "text/x-python",
|
| 69 |
+
"name": "python",
|
| 70 |
+
"nbconvert_exporter": "python",
|
| 71 |
+
"pygments_lexer": "ipython3",
|
| 72 |
+
"version": "3.12.7"
|
| 73 |
+
}
|
| 74 |
+
},
|
| 75 |
+
"nbformat": 4,
|
| 76 |
+
"nbformat_minor": 2
|
| 77 |
+
}
|