You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: notebooks/03-exploratory-data-analysis.ipynb
+73-18Lines changed: 73 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -1,34 +1,76 @@
1
1
{
2
-
"nbformat": 4,
3
-
"nbformat_minor": 5,
4
-
"metadata": {
5
-
"kernelspec": {
6
-
"display_name": "Python 3",
7
-
"language": "python",
8
-
"name": "python3"
9
-
},
10
-
"language_info": {
11
-
"name": "python",
12
-
"version": "3.10.0"
13
-
}
14
-
},
15
2
"cells": [
16
3
{
17
4
"cell_type": "markdown",
5
+
"id": "9ae22037",
18
6
"metadata": {},
19
-
"source": "# Notebook 03 — Extraction and Precision\n\n\n\n**Duration:** ~30 minutes\n\n\n\nIn notebooks 01 and 02 you connected to an LLM and explored how it behaves. Now we give it real data for the first time.\n\n\n\nThe dataset is the **Privacy Act 2020** — a New Zealand Act of Parliament published as XML on the government's legislation website. We will fetch it live, parse it into sections, and then try two different methods for extracting structured information from those sections:\n\n\n\n1. A **rule-based method** (regular expressions) — deterministic, precise, but rigid\n\n2. An **LLM-based method** — flexible, but probabilistic and sometimes wrong\n\n\n\nBy the end of this notebook you will have measured the gap between these two approaches on real data — and started thinking about what that means for research at scale."
7
+
"source": [
8
+
"# Notebook 03 — Extraction and Precision\n",
9
+
"\n",
10
+
"\n",
11
+
"\n",
12
+
"**Duration:** ~30 minutes\n",
13
+
"\n",
14
+
"\n",
15
+
"\n",
16
+
"In notebooks 01 and 02 you connected to an LLM and explored how it behaves. Now we give it real data for the first time.\n",
17
+
"\n",
18
+
"\n",
19
+
"\n",
20
+
"The dataset is the **Privacy Act 2020** — a New Zealand Act of Parliament published as XML on the government's legislation website. We will fetch it live, parse it into sections, and then try two different methods for extracting structured information from those sections:\n",
21
+
"\n",
22
+
"\n",
23
+
"\n",
24
+
"1. A **rule-based method** (regular expressions) — deterministic, precise, but rigid\n",
25
+
"\n",
26
+
"2. An **LLM-based method** — flexible, but probabilistic and sometimes wrong\n",
27
+
"\n",
28
+
"\n",
29
+
"\n",
30
+
"By the end of this notebook you will have measured the gap between these two approaches on real data — and started thinking about what that means for research at scale."
31
+
]
20
32
},
21
33
{
22
34
"cell_type": "markdown",
23
35
"metadata": {},
24
-
"source": "## Setup\n\nRun this cell first. If you stored your Groq API key in Colab Secrets (notebook 01), it will load automatically."
36
+
"source": [
37
+
"## Setup\n",
38
+
"\n",
39
+
"Run this cell first. If you stored your Groq API key in Colab Secrets (notebook 01), it will load automatically."
40
+
]
25
41
},
26
42
{
27
43
"cell_type": "code",
28
44
"execution_count": null,
29
45
"metadata": {},
30
46
"outputs": [],
31
-
"source": "# ============================================================\n# SETUP CELL — Run this once at the start of every notebook\n# ============================================================\n\n!pip install groq requests lxml Pillow\nimport os, json, base64, requests, io\nfrom groq import Groq\nfrom lxml import etree\nfrom PIL import Image\nfrom IPython.display import Image as IPImage, display\n\n# Load API key from Colab Secrets (set up in notebook 01)\ntry:\n from google.colab import userdata\n os.environ[\"GROQ_API_KEY\"] = userdata.get(\"GROQ_API_KEY\")\n print(\"API key loaded from Colab Secrets.\")\nexcept Exception:\n os.environ[\"GROQ_API_KEY\"] = \"paste_your_key_here\" # <-- fallback: paste key here\n print(\"Could not load from Secrets. Paste your key in the line above.\")\n\nclient = Groq(api_key=os.environ[\"GROQ_API_KEY\"])\nTEXT_MODEL = \"llama-3.3-70b-versatile\"\nVISION_MODEL = \"meta-llama/llama-4-maverick-17b-128e-instruct\"\n\nprint(\"Setup complete.\")"
"**Next up:** Notebook 04 moves from extraction to analysis. Instead of pulling out cross-references, you will ask the LLM to generate themes from the same corpus — and then test whether those themes hold up under scrutiny."
0 commit comments