Compare commits

...
2 Commits
Author SHA1 Message Date
KeshavAnandCode ebe592a6b1 finmished beta 2026-03-30 19:38:37 -05:00
KeshavAnandCode c6bc1216df cleaned up and run 2026-03-30 17:52:52 -05:00
4 changed files with 1360 additions and 78 deletions

No files matched your search

+1
View File
@@ -2,6 +2,7 @@
data/raw/ data/raw/
data/processed/ data/processed/
data/vectorstore/ data/vectorstore/
data/qdrant_local/
*.pdf *.pdf
*.epub *.epub
*.mobi *.mobi
+401
View File
@@ -0,0 +1,401 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "1b771833",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/keshav/code/apush-rag/.venv/lib/python3.14/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 pathlib import Path\n",
"from tqdm import tqdm\n",
"from sentence_transformers import SentenceTransformer\n",
"from qdrant_client import QdrantClient\n",
"from qdrant_client.models import Distance, VectorParams, PointStruct"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "4ffbf396",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loaded 5530 child chunks\n",
"Sample: ch01_s000_p000 — Chapter 1: Old Worlds and New\n"
]
}
],
"source": [
"project_root = Path().resolve().parent\n",
"children_path = project_root / \"data\" / \"processed\" / \"chunks_children.json\"\n",
"\n",
"with open(children_path) as f:\n",
" children = json.load(f)\n",
"\n",
"print(f\"Loaded {len(children)} child chunks\")\n",
"print(f\"Sample: {children[0]['chunk_id']} — {children[0]['section_title']}\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "da5ff826",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2.11.0+cu130\n",
"True\n",
"NVIDIA GeForce RTX 5080\n"
]
}
],
"source": [
"import torch\n",
"print(torch.__version__)\n",
"print(torch.cuda.is_available()) # must be True\n",
"print(torch.cuda.get_device_name(0)) # should say RTX 5080"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "6261dd22",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"<All keys matched successfully>\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Model loaded ✓\n",
"Device: cuda:0\n"
]
}
],
"source": [
"model = SentenceTransformer(\"nomic-ai/nomic-embed-text-v1.5\", trust_remote_code=True)\n",
"# First run downloads ~300MB then caches it\n",
"# Will automatically use your GPU if torch sees it\n",
"\n",
"VECTOR_DIM = 768\n",
"COLLECTION = \"apush_chunks\"\n",
"\n",
"print(\"Model loaded ✓\")\n",
"print(f\"Device: {model.device}\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "7bde5821",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Query vector dim: 768 ✓\n"
]
}
],
"source": [
"def embed_batch(texts: list[str]) -> list[list[float]]:\n",
" prefixed = [f\"search_document: {t}\" for t in texts]\n",
" return model.encode(\n",
" prefixed,\n",
" normalize_embeddings=True,\n",
" batch_size=64,\n",
" show_progress_bar=False,\n",
" ).tolist()\n",
"\n",
"def embed_query(query: str) -> list[float]:\n",
" return model.encode(\n",
" f\"search_query: {query}\",\n",
" normalize_embeddings=True,\n",
" ).tolist()\n",
"\n",
"# Quick test\n",
"test_vec = embed_query(\"causes of the American Revolution\")\n",
"print(f\"Query vector dim: {len(test_vec)} ✓\")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "9812826b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collection created ✓\n"
]
}
],
"source": [
"qdrant = QdrantClient(path=str(project_root / \"data\" / \"qdrant_local\"))\n",
"\n",
"# Delete and recreate if it already exists\n",
"if qdrant.collection_exists(COLLECTION):\n",
" qdrant.delete_collection(COLLECTION)\n",
" print(\"Deleted existing collection\")\n",
"\n",
"qdrant.create_collection(\n",
" collection_name=COLLECTION,\n",
" vectors_config=VectorParams(size=VECTOR_DIM, distance=Distance.COSINE),\n",
")\n",
"print(\"Collection created ✓\")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "e40d06a0",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Embedding: 100%|██████████| 87/87 [00:18<00:00, 4.78it/s]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Indexed 5530 chunks ✓\n"
]
}
],
"source": [
"BATCH_SIZE = 64\n",
"points = []\n",
"\n",
"for i in tqdm(range(0, len(children), BATCH_SIZE), desc=\"Embedding\"):\n",
" batch = children[i : i + BATCH_SIZE]\n",
" vectors = embed_batch([c[\"text\"] for c in batch])\n",
"\n",
" for j, (chunk, vector) in enumerate(zip(batch, vectors)):\n",
" points.append(PointStruct(\n",
" id = i + j,\n",
" vector = vector,\n",
" payload = {\n",
" \"chunk_id\": chunk[\"chunk_id\"],\n",
" \"parent_id\": chunk[\"parent_id\"],\n",
" \"chapter_num\": chunk[\"chapter_num\"],\n",
" \"chapter_title\": chunk[\"chapter_title\"],\n",
" \"section_title\": chunk[\"section_title\"],\n",
" \"textbook_page\": chunk[\"textbook_page\"],\n",
" \"is_chapter_review\": chunk[\"is_chapter_review\"],\n",
" \"text\": chunk[\"text\"], # store text too for quick access\n",
" }\n",
" ))\n",
"\n",
"# Upload in one shot\n",
"qdrant.upsert(collection_name=COLLECTION, points=points)\n",
"print(f\"\\nIndexed {len(points)} chunks ✓\")"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "0b21d67f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Vectors in collection: 5530\n",
"Expected: 5530\n",
"Match: True ✓\n"
]
}
],
"source": [
"info = qdrant.get_collection(COLLECTION)\n",
"count = info.points_count\n",
"print(f\"Vectors in collection: {count}\")\n",
"print(f\"Expected: {len(children)}\")\n",
"print(f\"Match: {count == len(children)} ✓\")"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "0766bbd2",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Query: 'causes of the American Revolution'\n",
" 0.767 | Ch5 › The Coming of Independence › p.153\n",
" 0.737 | Ch6 › Democratizing Freedom › p.178\n",
"\n",
"Query: 'how did slavery expand in the south'\n",
" 0.814 | Ch11 › The Old South › p.327\n",
" 0.802 | Ch9 › The Rise of the West › p.265\n",
"\n",
"Query: 'what was the New Deal'\n",
" 0.779 | Ch21 › The Second New Deal › p.691\n",
" 0.762 | Ch23 › The Truman Presidency › p.765\n",
"\n",
"Query: 'civil rights movement Rosa Parks'\n",
" 0.801 | Ch24 › The Freedom Movement › p.799\n",
" 0.756 | Ch24 › Chapter Review › p.810\n",
"\n",
"Query: 'manifest destiny westward expansion'\n",
" 0.795 | Ch9 › The Free Individual › p.279\n",
" 0.730 | Ch17 › Becoming a World Power › p.558\n"
]
}
],
"source": [
"from qdrant_client.models import QueryRequest\n",
"\n",
"for q in test_queries:\n",
" results = qdrant.query_points(\n",
" collection_name=COLLECTION,\n",
" query=embed_query(q),\n",
" limit=2,\n",
" ).points\n",
"\n",
" print(f\"\\nQuery: '{q}'\")\n",
" for r in results:\n",
" p = r.payload\n",
" print(f\" {r.score:.3f} | Ch{p['chapter_num']} › {p['section_title']} › p.{p['textbook_page']}\")"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "1832d0c6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Ready for notebook 3 — query pipeline ✓\n",
"Qdrant db path: /home/keshav/code/apush-rag/data/qdrant_local\n"
]
}
],
"source": [
"# Nothing to save — just note the query prefix for notebook 3\n",
"# When searching always use: embed_query(\"your question here\")\n",
"# The model lives at: nomic-ai/nomic-embed-text-v1.5\n",
"# The collection is at: project_root / data / qdrant_local\n",
"# Collection name: apush_chunks\n",
"\n",
"print(\"Ready for notebook 3 — query pipeline ✓\")\n",
"print(f\"Qdrant db path: {project_root / 'data' / 'qdrant_local'}\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "fd5119ca",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'qdrant' is not defined",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mNameError\u001b[39m Traceback (most recent call last)",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[2]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m qdrant.close()\n",
"\u001b[31mNameError\u001b[39m: name 'qdrant' is not defined"
]
}
],
"source": [
"qdrant.close()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "16058429",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"VRAM free: 11.2 GB\n"
]
},
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mThe Kernel crashed while executing code in the current cell or a previous cell. \n",
"\u001b[1;31mPlease review the code in the cell(s) to identify a possible cause of the failure. \n",
"\u001b[1;31mClick <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. \n",
"\u001b[1;31mView Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details."
]
}
],
"source": [
"import torch\n",
"\n",
"del model # delete the sentence transformer\n",
"torch.cuda.empty_cache()\n",
"print(f\"VRAM free: {torch.cuda.mem_get_info()[0]/1e9:.1f} GB\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"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.14.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
+186 -78
View File
@@ -20,7 +20,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 18, "execution_count": 2,
"id": "11896305", "id": "11896305",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -262,7 +262,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 19, "execution_count": 3,
"id": "991dbad2", "id": "991dbad2",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -496,7 +496,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 20, "execution_count": 4,
"id": "43e20197", "id": "43e20197",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -596,7 +596,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 22, "execution_count": 6,
"id": "c2563864", "id": "c2563864",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -652,7 +652,7 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Loaded 177 entries from page map\n" "Loaded 353 entries from page map\n"
] ]
} }
], ],
@@ -664,15 +664,14 @@
"with open(page_map_path) as f:\n", "with open(page_map_path) as f:\n",
" page_map = yaml.safe_load(f)\n", " page_map = yaml.safe_load(f)\n",
"\n", "\n",
"# Build fast lookup: section title → real page (will be None for now)\n",
"section_page_lookup = {}\n", "section_page_lookup = {}\n",
"for ch_num, ch_data in page_map[\"chapters\"].items():\n", "for ch_num, ch_data in page_map[\"chapters\"].items():\n",
" # Chapter-level entry\n",
" section_page_lookup[ch_data[\"title\"]] = ch_data.get(\"real_page\")\n", " section_page_lookup[ch_data[\"title\"]] = ch_data.get(\"real_page\")\n",
" # Section-level entries\n",
" if ch_data.get(\"sections\"):\n", " if ch_data.get(\"sections\"):\n",
" for section_title, real_page in ch_data[\"sections\"].items():\n", " for section_title, real_page in ch_data[\"sections\"].items():\n",
" section_page_lookup[section_title] = real_page\n", " section_page_lookup[(ch_num, section_title)] = real_page\n",
" if section_title not in section_page_lookup:\n",
" section_page_lookup[section_title] = real_page\n",
"\n", "\n",
"print(f\"Loaded {len(section_page_lookup)} entries from page map\")" "print(f\"Loaded {len(section_page_lookup)} entries from page map\")"
] ]
@@ -687,37 +686,78 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"('Half-title Page', 2) → y=0\n", "Total entries: 221\n",
"('Physical/Political Map of The United States', 5) → y=0\n", "Still y=0: 36\n",
"('Political Map of The World', 6) → y=0\n", "\n",
"('Title Page', 7) → y=0\n", "Sample (should now be non-zero for section headers):\n",
"('Copyright', 10) → y=0\n", " ('An Old World: Western Europe', 75) → y=93.6\n",
"('Dedication', 13) → y=0\n", " ('Contact', 80) → y=92.1\n",
"('Contents', 14) → y=0\n", " ('The Spanish Empire', 88) → y=90.9\n",
"('List of Maps, Tables, and Figures', 22) → y=0\n", " ('The French and Dutch Empires', 108) → y=92.1\n",
"('About the Authors', 32) → y=0\n", " ('Chapter Review', 120) → y=93.6\n",
"('Preface', 34) → y=0\n" " ('Chapter 2: European Colonies and Native Nations, 1600⠍1660', 124) → y=0.0\n",
" ('England and the Americas', 129) → y=92.1\n",
" ('Early English Exploration and Colonization', 138) → y=92.1\n",
" ('The Chesapeake', 142) → y=92.1\n",
" ('Origins of American Slavery', 150) → y=92.1\n",
"\n",
"Could not locate on page (will use y=0 fallback):\n",
" p2: Half-title Page\n",
" p7: Title Page\n",
" p13: Dedication\n",
" p59: Chapter 1: Old Worlds and New\n",
" p124: Chapter 2: European Colonies and Native Nations, 1600⠍1660\n",
" p193: Chapter 3: Creating Anglo-America, 1660⠍1750\n",
" p246: North America at Mid-Century\n",
" p253: Chapter 4: Slavery, Freedom, and the Struggle for Empire to 1763\n",
" p325: Chapter 5: The American Revolution, 1763⠍1783\n",
" p381: Chapter 6: The Revolution Within\n"
] ]
} }
], ],
"source": [ "source": [
"# Build a lookup from (title, pdf_page_1indexed) → y coordinate\n",
"# This is what gives us pixel-precise section boundaries\n",
"toc_full = doc.get_toc(simple=False)\n", "toc_full = doc.get_toc(simple=False)\n",
"\n", "\n",
"toc_coord_lookup = {}\n", "toc_coord_lookup = {}\n",
"not_found = []\n",
"\n",
"for item in toc_full:\n", "for item in toc_full:\n",
" level = item[0]\n", " level = item[0]\n",
" title = item[1]\n", " title = item[1]\n",
" page_1idx = item[2]\n", " page_1idx = item[2]\n",
" dest = item[3] if len(item) > 3 else {}\n", " dest = item[3] if len(item) > 3 else {}\n",
" y = dest.get(\"y\", 0) if isinstance(dest, dict) else 0\n", " y = dest.get(\"y\", 0) if isinstance(dest, dict) else 0\n",
"\n",
" # If y=0 (page-only link), search for the title text on the page\n",
" if y == 0:\n",
" page = doc[page_1idx - 1] # 0-indexed\n",
" hits = page.search_for(title)\n",
" if hits:\n",
" y = hits[0].y0 # top of first match\n",
" else:\n",
" # Try searching for just the first few words (TOC titles sometimes\n",
" # differ slightly from the printed heading)\n",
" short = \" \".join(title.split()[:4])\n",
" hits = page.search_for(short)\n",
" if hits:\n",
" y = hits[0].y0\n",
" else:\n",
" not_found.append((title, page_1idx))\n",
" y = 0 # fallback — whole page\n",
"\n",
" toc_coord_lookup[(title, page_1idx)] = y\n", " toc_coord_lookup[(title, page_1idx)] = y\n",
"\n", "\n",
"# Sanity check — print a few to confirm y values are non-zero\n", "# Sanity check\n",
"sample = list(toc_coord_lookup.items())[:10]\n", "print(f\"Total entries: {len(toc_coord_lookup)}\")\n",
"for k, v in sample:\n", "print(f\"Still y=0: {len(not_found)}\")\n",
" print(f\"{k} → y={v}\")" "print(\"\\nSample (should now be non-zero for section headers):\")\n",
"for k, v in list(toc_coord_lookup.items())[14:24]: # skip front matter, show ch1+\n",
" print(f\" {k} → y={v:.1f}\")\n",
"\n",
"if not_found:\n",
" print(f\"\\nCould not locate on page (will use y=0 fallback):\")\n",
" for t, p in not_found[:10]:\n",
" print(f\" p{p}: {t}\")"
] ]
}, },
{ {
@@ -762,6 +802,63 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": 10,
"id": "75737655",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"✓ \"We the People\" → y=92.1 (matched 'We the People')\n",
"✗ The \"Second War of Independence\" — check page 531 manually\n",
"✗ The Post-Cold War World — check page 1700 manually\n"
]
}
],
"source": [
"import re\n",
"\n",
"def clean_for_search(title: str) -> str:\n",
" replacements = {\n",
" '“': '\"', 'â€\\x9d': '\"', '’': \"'\",\n",
" 'â€\"': '—', '‘': \"'\",\n",
" '⠍': '-', '⠒': \"'\",\n",
" }\n",
" for bad, good in replacements.items():\n",
" title = title.replace(bad, good)\n",
" return title\n",
"\n",
"# The 3 known stragglers — fix them directly\n",
"stragglers = [\n",
" ('\"We the People\"', 472),\n",
" ('The \"Second War of Independence\"', 531),\n",
" ('The Post-Cold War World', 1700),\n",
"]\n",
"\n",
"for clean_title, page_1idx in stragglers:\n",
" page = doc[page_1idx - 1]\n",
" \n",
" # Try progressively shorter substrings of the cleaned title\n",
" words = clean_title.split()\n",
" for n in range(len(words), 1, -1):\n",
" snippet = \" \".join(words[:n]).strip('\"') # strip quotes too\n",
" hits = page.search_for(snippet)\n",
" if hits:\n",
" # Update the ORIGINAL (dirty) key in the lookup\n",
" dirty_key = next(\n",
" k for k in toc_coord_lookup \n",
" if k[1] == page_1idx and clean_for_search(k[0]) == clean_title\n",
" )\n",
" toc_coord_lookup[dirty_key] = hits[0].y0\n",
" print(f\"✓ {clean_title} → y={hits[0].y0:.1f} (matched '{snippet}')\")\n",
" break\n",
" else:\n",
" print(f\"✗ {clean_title} — check page {page_1idx} manually\")"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "b4b3ffea", "id": "b4b3ffea",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -791,7 +888,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": 12,
"id": "f7d6a626", "id": "f7d6a626",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -888,7 +985,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 13,
"id": "01a14318", "id": "01a14318",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -896,23 +993,23 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"✓ Rebuilt 5474 children with parent_id field\n", "✓ Rebuilt 5530 children with parent_id field\n",
"✗ Failed: 0\n", "✗ Failed: 0\n",
"\n", "\n",
"Sample child:\n", "Sample child:\n",
" chunk_id: ch02_s014_p008\n", " chunk_id: ch02_s014_p002\n",
" parent_id: ch02_s014_parent\n", " parent_id: ch02_s014_parent\n",
" type: child\n", " type: child\n",
"Child chunks: 5474\n", "Child chunks: 5530\n",
"Parent chunks: 204\n", "Parent chunks: 204\n",
"Total: 5678\n", "Total: 5734\n",
"\n", "\n",
"Expected parents: 204 (one per unique section)\n", "Expected parents: 204 (one per unique section)\n",
"\n", "\n",
"Sample parent:\n", "Sample parent:\n",
" ID: ch04_s026_parent\n", " ID: ch04_s026_parent\n",
" Citation: Chapter 4: Slavery, Freedom, and the Struggle for Empire to 1763 › Slavery and Empire › page number not yet added\n", " Citation: Chapter 4: Slavery, Freedom, and the Struggle for Empire to 1763 › Slavery and Empire › approx. p. 111\n",
" Word count: 2754\n", " Word count: 2787\n",
" Preview: Of the estimated 10 million Africans transported to the Americas between 1492 and 1820, more than half arrived between 1700 and 1800. The Atlantic slave trade would later be condemned as a crime against humanity. But in the eighteenth century, it was a regularized business in which European merchant\n" " Preview: Of the estimated 10 million Africans transported to the Americas between 1492 and 1820, more than half arrived between 1700 and 1800. The Atlantic slave trade would later be condemned as a crime against humanity. But in the eighteenth century, it was a regularized business in which European merchant\n"
] ]
} }
@@ -958,7 +1055,7 @@
" ch_title = section[\"chapter_title\"]\n", " ch_title = section[\"chapter_title\"]\n",
" is_header = section[\"is_chapter_header\"]\n", " is_header = section[\"is_chapter_header\"]\n",
" is_review = \"Chapter Review\" in title\n", " is_review = \"Chapter Review\" in title\n",
" real_page = section_page_lookup.get(title)\n", " real_page = section_page_lookup.get((ch_num, title)) or section_page_lookup.get(title)\n",
"\n", "\n",
" # Pre-compute parent_id for this section\n", " # Pre-compute parent_id for this section\n",
" parent_id = f\"ch{ch_num:02d}_s{section_idx:03d}_parent\"\n", " parent_id = f\"ch{ch_num:02d}_s{section_idx:03d}_parent\"\n",
@@ -1060,7 +1157,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": 14,
"id": "87f74abb", "id": "87f74abb",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -1069,71 +1166,71 @@
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Chunks per chapter:\n", "Chunks per chapter:\n",
" Ch 01: 186 chunks\n", " Ch 01: 189 chunks\n",
" Ch 02: 195 chunks\n", " Ch 02: 199 chunks\n",
" Ch 03: 173 chunks\n", " Ch 03: 176 chunks\n",
" Ch 04: 194 chunks\n", " Ch 04: 197 chunks\n",
" Ch 05: 185 chunks\n", " Ch 05: 185 chunks\n",
" Ch 06: 153 chunks\n", " Ch 06: 155 chunks\n",
" Ch 07: 161 chunks\n", " Ch 07: 164 chunks\n",
" Ch 08: 192 chunks\n", " Ch 08: 193 chunks\n",
" Ch 09: 166 chunks\n", " Ch 09: 168 chunks\n",
" Ch 10: 193 chunks\n", " Ch 10: 195 chunks\n",
" Ch 11: 158 chunks\n", " Ch 11: 160 chunks\n",
" Ch 12: 171 chunks\n", " Ch 12: 173 chunks\n",
" Ch 13: 189 chunks\n", " Ch 13: 191 chunks\n",
" Ch 14: 217 chunks\n", " Ch 14: 218 chunks\n",
" Ch 15: 188 chunks\n", " Ch 15: 189 chunks\n",
" Ch 16: 209 chunks\n", " Ch 16: 210 chunks\n",
" Ch 17: 200 chunks\n", " Ch 17: 201 chunks\n",
" Ch 18: 239 chunks\n", " Ch 18: 239 chunks\n",
" Ch 19: 206 chunks\n", " Ch 19: 208 chunks\n",
" Ch 20: 177 chunks\n", " Ch 20: 179 chunks\n",
" Ch 21: 205 chunks\n", " Ch 21: 207 chunks\n",
" Ch 22: 221 chunks\n", " Ch 22: 224 chunks\n",
" Ch 23: 172 chunks\n", " Ch 23: 174 chunks\n",
" Ch 24: 212 chunks\n", " Ch 24: 215 chunks\n",
" Ch 25: 234 chunks\n", " Ch 25: 237 chunks\n",
" Ch 26: 220 chunks\n", " Ch 26: 221 chunks\n",
" Ch 27: 213 chunks\n", " Ch 27: 216 chunks\n",
" Ch 28: 245 chunks\n", " Ch 28: 247 chunks\n",
"\n", "\n",
"Text length — min: 80, max: 2251, avg: 510\n", "Text length — min: 80, max: 2251, avg: 506\n",
"\n", "\n",
"======================================================================\n", "======================================================================\n",
"SAMPLE CHUNKS — FULL TEXT\n", "SAMPLE CHUNKS — FULL TEXT\n",
"======================================================================\n", "======================================================================\n",
"\n", "\n",
"[ch01_s001_p000]\n", "[ch01_s001_p000]\n",
"Citation : Chapter 1: Old Worlds and New › An Old World: North America › page number not yet added\n", "Citation : Chapter 1: Old Worlds and New › An Old World: North America › approx. p. 4\n",
"PDF page : 62\n", "PDF page : 62\n",
"Text :\n", "Text :\n",
"The most striking feature of Native American society at the time Europeans arrived was its sheer diversity. Each group had its own political system and set of religious beliefs, and North America was home to hundreds of mutually unintelligible languages. Indians did not define “America” as a continent or hemisphere. They did not think of themselves as a single people, and Native Americans still today identify primarily as separate nations. Identity centered on the immediate social group—a family, clan, town, nation, or confederacy. When Europeans first arrived, many Indians saw them as simply one group among many. Their first thought was how to use the newcomers to enhance their standing in relation to other Native peoples rather than to unite against them. The sharp dichotomy between “Indians” and “white” persons did not emerge until later in the colonial era.\n", "The most striking feature of Native American society at the time Europeans arrived was its sheer diversity. Each group had its own political system and set of religious beliefs, and North America was home to hundreds of mutually unintelligible languages. Indians did not define “America” as a continent or hemisphere. They did not think of themselves as a single people, and Native Americans still today identify primarily as separate nations. Identity centered on the immediate social group—a family, clan, town, nation, or confederacy. When Europeans first arrived, many Indians saw them as simply one group among many. Their first thought was how to use the newcomers to enhance their standing in relation to other Native peoples rather than to unite against them. The sharp dichotomy between “Indians” and “white” persons did not emerge until later in the colonial era.\n",
"----------------------------------------------------------------------\n", "----------------------------------------------------------------------\n",
"\n", "\n",
"[ch04_s026_p000]\n", "[ch04_s026_p000]\n",
"Citation : Chapter 4: Slavery, Freedom, and the Struggle for Empire to 1763 › Slavery and Empire › page number not yet added\n", "Citation : Chapter 4: Slavery, Freedom, and the Struggle for Empire to 1763 › Slavery and Empire › approx. p. 111\n",
"PDF page : 256\n", "PDF page : 256\n",
"Text :\n", "Text :\n",
"Of the estimated 10 million Africans transported to the Americas between 1492 and 1820, more than half arrived between 1700 and 1800. The Atlantic slave trade would later be condemned as a crime against humanity. But in the eighteenth century, it was a regularized business in which European merchants, African traders, and American planters engaged in complex bargaining over human lives, all with the expectation of securing a profit. The slave trade was a vital part of world commerce. Every European empire in the Americas utilized slave labor and battled for control of this lucrative trade. The asiento—an agreement whereby Spain subcontracted to a foreign power the right to provide slaves to Spanish America—was an important diplomatic prize. Britain’s acquisition of the asiento from the Dutch in the Treaty of Utrecht of 1713 was a major step in its rise to commercial supremacy.\n", "Of the estimated 10 million Africans transported to the Americas between 1492 and 1820, more than half arrived between 1700 and 1800. The Atlantic slave trade would later be condemned as a crime against humanity. But in the eighteenth century, it was a regularized business in which European merchants, African traders, and American planters engaged in complex bargaining over human lives, all with the expectation of securing a profit. The slave trade was a vital part of world commerce. Every European empire in the Americas utilized slave labor and battled for control of this lucrative trade. The asiento—an agreement whereby Spain subcontracted to a foreign power the right to provide slaves to Spanish America—was an important diplomatic prize. Britain’s acquisition of the asiento from the Dutch in the Treaty of Utrecht of 1713 was a major step in its rise to commercial supremacy.\n",
"----------------------------------------------------------------------\n", "----------------------------------------------------------------------\n",
"\n", "\n",
"[ch11_s076_p000]\n", "[ch11_s076_p000]\n",
"Citation : Chapter 11: The Peculiar Institution › The Old South › page number not yet added\n", "Citation : Chapter 11: The Peculiar Institution › The Old South › approx. p. 327\n",
"PDF page : 671\n", "PDF page : 671\n",
"Text :\n", "Text :\n",
"When Frederick Douglass was born, slavery was already an old institution in America. Two centuries had passed since the first twenty Africans were landed in Virginia from a Dutch ship. After abolition in the North, slavery had become the “peculiar institution” of the South—that is, an institution unique to southern society. The Mason-Dixon Line, drawn by two surveyors in the eighteenth century to settle a boundary dispute between Maryland and Pennsylvania, eventually became the dividing line between slavery and freedom.\n", "When Frederick Douglass was born, slavery was already an old institution in America. Two centuries had passed since the first twenty Africans were landed in Virginia from a Dutch ship. After abolition in the North, slavery had become the “peculiar institution” of the South—that is, an institution unique to southern society. The Mason-Dixon Line, drawn by two surveyors in the eighteenth century to settle a boundary dispute between Maryland and Pennsylvania, eventually became the dividing line between slavery and freedom.\n",
"----------------------------------------------------------------------\n", "----------------------------------------------------------------------\n",
"\n", "\n",
"[ch18_s122_p000]\n", "[ch18_s122_p000]\n",
"Citation : Chapter 18: The Progressive Era, 1900⠍1916 › An Urban Age and a Consumer Society › page number not yet added\n", "Citation : Chapter 18: The Progressive Era, 1900⠍1916 › An Urban Age and a Consumer Society › approx. p. 578\n",
"PDF page : 1110\n", "PDF page : 1110\n",
"Text :\n", "Text :\n",
"The Progressive era was a period of explosive economic growth, fueled by increasing industrial production, a rapid rise in population, and the continued expansion of the consumer marketplace. In the first decade of the twentieth century, the economy’s total output rose by about 85 percent. For the last time in American history, farms and cities grew together. As farm prices recovered from their low point during the depression of the 1890s, American agriculture entered what would later be remembered as its “golden age.” The expansion of urban areas stimulated demand for farm goods. Farm families poured into the western Great Plains. More than 1 million claims for free government land were filed under the Homestead Act of 1862—more than in the previous forty years. Between 1900 and 1910, the combined population of Texas and Oklahoma rose by nearly 2 million, and Kansas, Nebraska, and the Dakotas added 800,000. Irrigation transformed the Imperial Valley of California and parts of Arizona into major areas of commercial farming.\n", "The Progressive era was a period of explosive economic growth, fueled by increasing industrial production, a rapid rise in population, and the continued expansion of the consumer marketplace. In the first decade of the twentieth century, the economy’s total output rose by about 85 percent. For the last time in American history, farms and cities grew together. As farm prices recovered from their low point during the depression of the 1890s, American agriculture entered what would later be remembered as its “golden age.” The expansion of urban areas stimulated demand for farm goods. Farm families poured into the western Great Plains. More than 1 million claims for free government land were filed under the Homestead Act of 1862—more than in the previous forty years. Between 1900 and 1910, the combined population of Texas and Oklahoma rose by nearly 2 million, and Kansas, Nebraska, and the Dakotas added 800,000. Irrigation transformed the Imperial Valley of California and parts of Arizona into major areas of commercial farming.\n",
"----------------------------------------------------------------------\n", "----------------------------------------------------------------------\n",
"\n", "\n",
"[ch26_s178_p000]\n", "[ch26_s178_p000]\n",
"Citation : Chapter 26: The Conservative Turn, 1969⠍1988 › President Nixon › page number not yet added\n", "Citation : Chapter 26: The Conservative Turn, 1969⠍1988 › President Nixon › approx. p. 853\n",
"PDF page : 1630\n", "PDF page : 1630\n",
"Text :\n", "Text :\n",
"Richard Nixon’s presidency bridged the eras of liberalism under Kennedy and Johnson and the conservatism of the Reagan era. Nixon was the first president from California, and his victory signaled the growing power of the conservative Sunbelt in national politics. From the vantage point of the early twenty-first century, it is difficult to recall how marginal conservatism seemed at the end of World War II. Associated in many minds with conspiracy theories, anti-Semitism, and preference for social hierarchy over democracy and equality, conservatism seemed a relic of a discredited past.\n", "Richard Nixon’s presidency bridged the eras of liberalism under Kennedy and Johnson and the conservatism of the Reagan era. Nixon was the first president from California, and his victory signaled the growing power of the conservative Sunbelt in national politics. From the vantage point of the early twenty-first century, it is difficult to recall how marginal conservatism seemed at the end of World War II. Associated in many minds with conspiracy theories, anti-Semitism, and preference for social hierarchy over democracy and equality, conservatism seemed a relic of a discredited past.\n",
@@ -1173,7 +1270,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": 15,
"id": "f1bc3f74", "id": "f1bc3f74",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -1182,12 +1279,12 @@
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Top 10 largest parents:\n", "Top 10 largest parents:\n",
" 6,944 words — The American Dilemma\n", " 6,972 words — The American Dilemma\n",
" 6,690 words — The Transformation of the West\n", " 6,690 words — The Transformation of the West\n",
" 6,226 words — The Golden Age\n", " 6,247 words — The Golden Age\n",
" 5,697 words — The New Movements and the Rights Revolution\n", " 5,697 words — The New Movements and the Rights Revolution\n",
" 5,279 words — The Anticommunist Crusade\n", " 5,301 words — The Making of Radical Reconstruction\n",
" 5,278 words — The Making of Radical Reconstruction\n", " 5,298 words — The Anticommunist Crusade\n",
" 5,071 words — Varieties of Progressivism\n", " 5,071 words — Varieties of Progressivism\n",
" 4,972 words — Culture Wars\n", " 4,972 words — Culture Wars\n",
" 4,885 words — The Meaning of Freedom\n", " 4,885 words — The Meaning of Freedom\n",
@@ -1217,7 +1314,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": 16,
"id": "8355e686", "id": "8355e686",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -1228,7 +1325,7 @@
"Before capping: 204 parents\n", "Before capping: 204 parents\n",
"After capping: 229 parents\n", "After capping: 229 parents\n",
"New max parent: 3,973 words\n", "New max parent: 3,973 words\n",
"New avg parent: 1,915 words\n" "New avg parent: 1,921 words\n"
] ]
} }
], ],
@@ -1276,7 +1373,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": 17,
"id": "dad7c6d3", "id": "dad7c6d3",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -1297,7 +1394,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": null,
"id": "0ef0c08a", "id": "0ef0c08a",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -1308,15 +1405,26 @@
"Parent lookup entries: 204\n", "Parent lookup entries: 204\n",
"Children with missing parent: 0\n", "Children with missing parent: 0\n",
"Duplicate capped parent IDs: none ✓\n", "Duplicate capped parent IDs: none ✓\n",
"Saved 5474 children → /home/keshav/code/apush-rag/data/processed/chunks_children.json\n", "Saved 5530 children → /home/keshav/code/apush-rag/data/processed/chunks_children.json\n",
"Saved 204 parent entries → /home/keshav/code/apush-rag/data/processed/parent_lookup.json\n", "Saved 204 parent entries → /home/keshav/code/apush-rag/data/processed/parent_lookup.json\n",
"\n", "\n",
"Round-trip test:\n", "Round-trip test:\n",
" Child ID: ch02_s014_p008\n", " Child ID: ch02_s014_p002\n",
" Parent ID: ch02_s014_parent\n", " Parent ID: ch02_s014_parent\n",
" Parent parts found: 1\n", " Parent parts found: 1\n",
" Citation: Chapter 2: European Colonies and Native Nations, 1600⠍1660 › New Englanders Divided\n" " Citation: Chapter 2: European Colonies and Native Nations, 1600⠍1660 › New Englanders Divided\n"
] ]
},
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mThe Kernel crashed while executing code in the current cell or a previous cell. \n",
"\u001b[1;31mPlease review the code in the cell(s) to identify a possible cause of the failure. \n",
"\u001b[1;31mClick <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. \n",
"\u001b[1;31mView Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details."
]
} }
], ],
"source": [ "source": [
+772
View File
@@ -0,0 +1,772 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "bb92b402",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/keshav/code/apush-rag/.venv/lib/python3.14/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",
"import re\n",
"from pathlib import Path\n",
"from sentence_transformers import SentenceTransformer\n",
"from qdrant_client import QdrantClient\n",
"from openai import OpenAI\n",
"from rich.console import Console\n",
"from rich.panel import Panel\n",
"from rich.text import Text\n",
"from rich import print as rprint"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "c889967b",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Warning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads.\n",
"<All keys matched successfully>\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"All loaded ✓\n"
]
}
],
"source": [
"project_root = Path().resolve().parent\n",
"\n",
"# Embedding model\n",
"model = SentenceTransformer(\"nomic-ai/nomic-embed-text-v1.5\", trust_remote_code=True)\n",
"\n",
"# Qdrant\n",
"qdrant = QdrantClient(path=str(project_root / \"data\" / \"qdrant_local\"))\n",
"COLLECTION = \"apush_chunks\"\n",
"\n",
"# Parent lookup\n",
"with open(project_root / \"data\" / \"processed\" / \"parent_lookup.json\") as f:\n",
" parent_lookup = json.load(f)\n",
"\n",
"# Local Qwen via llama-server\n",
"llm = OpenAI(\n",
" base_url=\"http://127.0.0.1:11434/v1\",\n",
" api_key=\"not-needed\",\n",
")\n",
"\n",
"console = Console()\n",
"print(\"All loaded ✓\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "863a7515",
"metadata": {},
"outputs": [],
"source": [
"def embed_query(query: str) -> list[float]:\n",
" return model.encode(\n",
" f\"search_query: {query}\",\n",
" normalize_embeddings=True,\n",
" ).tolist()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "b90a4761",
"metadata": {},
"outputs": [],
"source": [
"TOP_K = 5 # fetch more, re-rank by score\n",
"\n",
"def retrieve(query: str) -> dict:\n",
" hits = qdrant.query_points(\n",
" collection_name=COLLECTION,\n",
" query=embed_query(query),\n",
" limit=TOP_K,\n",
" ).points\n",
"\n",
" # Confidence tiers based on top score\n",
" top_score = hits[0].score if hits else 0\n",
" if top_score >= 0.82:\n",
" confidence = \"HIGH\"\n",
" conf_color = \"green\"\n",
" elif top_score >= 0.62:\n",
" confidence = \"MEDIUM\"\n",
" conf_color = \"yellow\"\n",
" else:\n",
" confidence = \"LOW\"\n",
" conf_color = \"red\"\n",
"\n",
" # Deduplicate by parent_id — no point fetching same section twice\n",
" seen_parents = set()\n",
" unique_hits = []\n",
" for h in hits:\n",
" pid = h.payload[\"parent_id\"]\n",
" if pid not in seen_parents:\n",
" seen_parents.add(pid)\n",
" unique_hits.append(h)\n",
"\n",
" # Fetch full parent text for each unique hit\n",
" sources = []\n",
" for h in unique_hits:\n",
" pid = h.payload[\"parent_id\"]\n",
" parts = parent_lookup.get(pid, [])\n",
" full_text = \"\\n\\n\".join(p[\"text\"] for p in parts)\n",
"\n",
" sources.append({\n",
" \"score\": h.score,\n",
" \"chapter_num\": h.payload[\"chapter_num\"],\n",
" \"chapter_title\": h.payload[\"chapter_title\"],\n",
" \"section_title\": h.payload[\"section_title\"],\n",
" \"textbook_page\": h.payload[\"textbook_page\"],\n",
" \"text\": full_text,\n",
" })\n",
"\n",
" return {\n",
" \"query\": query,\n",
" \"confidence\": confidence,\n",
" \"conf_color\": conf_color,\n",
" \"top_score\": top_score,\n",
" \"sources\": sources,\n",
" }"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "98205255",
"metadata": {},
"outputs": [],
"source": [
"SYSTEM_PROMPT = SYSTEM_PROMPT = \"\"\"You are an expert AP US History tutor. Do not think before answering. Answer immediately and directly.\n",
"Answer the student's question using ONLY the textbook passages provided...if u use outside info state it explicitly\n",
"Rules:\n",
"- Be accurate and specific — cite section and page number inline like (Ch5, p.153)\n",
"- If the passages don't fully answer the question, say so clearly\n",
"- Never invent facts not present in the passages\n",
"- If you don't know or you think something about the question is wrong don't reinforce...admit it\n",
"- Questions outside the textbook should be answered fast but with a disclaimer that it isn't in the textbook\n",
"- Don't yap for too long...keep it direct and correct yet lenghty enough to be very very detailed and a great response\n",
"- Asnwer in a format that suits the detail needed to answer the question (e.g. a full very long essay for LEQ, 1 pagaraph detailed response for SAQ, one word if one wrod, etc....answer normally bnut with great details)\n",
"- ANSWER ASAP, and keep answers lss than 8192 tokens if you don't know anwer very very brielfy in like 1 workd\n",
"\"\"\"\n",
"\n",
"def synthesize(retrieved: dict) -> str:\n",
" context_parts = []\n",
" for s in retrieved[\"sources\"]:\n",
" context_parts.append(\n",
" f\"[Ch{s['chapter_num']} › {s['section_title']} › p.{s['textbook_page']}]\\n{s['text']}\"\n",
" )\n",
" context = \"\\n\\n---\\n\\n\".join(context_parts)\n",
"\n",
" user_message = f\"<|im_start|>user\\n/no_think\\n\\nTEXTBOOK PASSAGES:\\n{context}\\n\\nQUESTION: {retrieved['query']}<|im_end|>\\n<|im_start|>assistant\\n\"\n",
" messages = [\n",
" {\"role\": \"system\", \"content\": SYSTEM_PROMPT},\n",
" {\"role\": \"user\", \"content\": user_message},\n",
" ]\n",
"\n",
" response = llm.chat.completions.create(\n",
" model=\"qwen3.5-9b\",\n",
" messages=messages,\n",
" max_tokens=2048,\n",
" temperature=0.1,\n",
" extra_body={\"thinking\": False}, # hard disable at llama.cpp level\n",
" )\n",
" print(\"RAW:\", repr(response.choices[0].message.content))\n",
"\n",
" content = response.choices[0].message.content\n",
"\n",
" # Strip any leftover think tags just in case\n",
" if content:\n",
" content = re.sub(r\"<think>.*?</think>\", \"\", content, flags=re.DOTALL).strip()\n",
"\n",
" # If still empty, model ignored /no_think — extract from reasoning_content\n",
" if not content:\n",
" raw = getattr(response.choices[0].message, \"reasoning_content\", \"\") or \"\"\n",
" if \"</think>\" in raw:\n",
" content = raw.split(\"</think>\")[-1].strip()\n",
"\n",
" return content or \"⚠ Model returned empty response\""
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "2515b025",
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import display, Markdown\n",
"\n",
"def display_answer(retrieved: dict, answer: str):\n",
" conf = retrieved[\"confidence\"]\n",
" score = retrieved[\"top_score\"]\n",
" colors = {\"HIGH\": \"🟢\", \"MEDIUM\": \"🟡\", \"LOW\": \"🔴\"}\n",
" icon = colors[conf]\n",
"\n",
" md = f\"\"\"\n",
"{icon} **CONFIDENCE: {conf}** (score: {score:.3f})\n",
"\n",
"---\n",
"\n",
"### Q: {retrieved['query']}\n",
"\n",
"{answer}\n",
"\n",
"---\n",
"\n",
"**Sources:**\n",
"\"\"\"\n",
" for i, s in enumerate(retrieved[\"sources\"], 1):\n",
" snippet = s[\"text\"][:200].replace(\"\\n\", \" \")\n",
" md += f\"\\n**[{i}]** Ch{s['chapter_num']} › {s['section_title']} › p.{s['textbook_page']} *(score: {s['score']:.3f})*\\n> {snippet}...\\n\"\n",
"\n",
" display(Markdown(md))"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "e1cfea1b",
"metadata": {},
"outputs": [],
"source": [
"def ask(query: str):\n",
" retrieved = retrieve(query)\n",
" answer = synthesize(retrieved)\n",
" display_answer(retrieved, answer)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "d38bd0bd",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RAW: 'Based on the provided textbook passages, **Martin Luther King Jr. did not agree with Malcolm X.** In fact, the texts describe their philosophies as fundamentally opposed.\\n\\nThe passages explicitly state that Malcolm X was a \"sharp critic of the ideas of integration and nonviolence, and of King’s practice of appealing to American values.\" Malcolm X proclaimed, \"I don\\'t see any American dream. I see an American nightmare,\" and called for Black self-defense against violence, whereas King advocated for nonviolent resistance and a \"revolution in values\" to create a better distribution of wealth for \"all God\\'s children.\"\\n\\nHowever, the texts do note a point of convergence regarding **economic justice and the failure of the federal government to address poverty**, which eventually led King to adopt more radical language similar to Malcolm X\\'s earlier critiques:\\n\\n1. **Shared Focus on Economic Grievances:** Both leaders recognized that civil rights legislation (voting rights, desegregation) did not solve the material deprivation of Black Americans. King declared that \"voting rights... could not be eaten or made into clothing and shelter.\" He called for a \"Bill of Rights for the Disadvantaged\" and a \"revolution in values\" to address wealth distribution, moving beyond the movement\\'s initial focus on legal equality.\\n2. **Critique of the Status Quo:** Malcolm X criticized the \"American nightmare\" and the failure of the federal government to protect Black citizens. Similarly, King\\'s later rhetoric became more radical as he confronted the \"entrenched power\" of white political machines (like Mayor Daley in Chicago) and the inability of nonviolent tactics to achieve economic goals in the North.\\n3. **Divergent Methods:** Despite these shared frustrations, their methods remained distinct. Malcolm X advocated for Black nationalism, self-defense, and separation from white society (symbolized by dropping his surname to \"X\"). King maintained a commitment to nonviolence and integration, even as his language became more militant.\\n\\nThe texts do not provide evidence of agreement between the two; rather, they highlight Malcolm X\\'s role as an intellectual father of the Black Power movement that emerged as a reaction to the perceived limitations of the integrationist civil rights movement led by King.'\n"
]
},
{
"data": {
"text/markdown": [
"\n",
"🟡 **CONFIDENCE: MEDIUM** (score: 0.642)\n",
"\n",
"---\n",
"\n",
"### Q: why did mlk agree with malcomx so much\n",
"\n",
"Based on the provided textbook passages, **Martin Luther King Jr. did not agree with Malcolm X.** In fact, the texts describe their philosophies as fundamentally opposed.\n",
"\n",
"The passages explicitly state that Malcolm X was a \"sharp critic of the ideas of integration and nonviolence, and of King’s practice of appealing to American values.\" Malcolm X proclaimed, \"I don't see any American dream. I see an American nightmare,\" and called for Black self-defense against violence, whereas King advocated for nonviolent resistance and a \"revolution in values\" to create a better distribution of wealth for \"all God's children.\"\n",
"\n",
"However, the texts do note a point of convergence regarding **economic justice and the failure of the federal government to address poverty**, which eventually led King to adopt more radical language similar to Malcolm X's earlier critiques:\n",
"\n",
"1. **Shared Focus on Economic Grievances:** Both leaders recognized that civil rights legislation (voting rights, desegregation) did not solve the material deprivation of Black Americans. King declared that \"voting rights... could not be eaten or made into clothing and shelter.\" He called for a \"Bill of Rights for the Disadvantaged\" and a \"revolution in values\" to address wealth distribution, moving beyond the movement's initial focus on legal equality.\n",
"2. **Critique of the Status Quo:** Malcolm X criticized the \"American nightmare\" and the failure of the federal government to protect Black citizens. Similarly, King's later rhetoric became more radical as he confronted the \"entrenched power\" of white political machines (like Mayor Daley in Chicago) and the inability of nonviolent tactics to achieve economic goals in the North.\n",
"3. **Divergent Methods:** Despite these shared frustrations, their methods remained distinct. Malcolm X advocated for Black nationalism, self-defense, and separation from white society (symbolized by dropping his surname to \"X\"). King maintained a commitment to nonviolence and integration, even as his language became more militant.\n",
"\n",
"The texts do not provide evidence of agreement between the two; rather, they highlight Malcolm X's role as an intellectual father of the Black Power movement that emerged as a reaction to the perceived limitations of the integrationist civil rights movement led by King.\n",
"\n",
"---\n",
"\n",
"**Sources:**\n",
"\n",
"**[1]** Ch25 › The Changing Black Movement › p.826 *(score: 0.642)*\n",
"> Even at its moment of triumph, the civil rights movement confronted a crisis as it sought to move from access to schools, public accommodations, and the voting booth to the economic divide separating ...\n",
"\n",
"**[2]** Ch25 › The Civil Rights Revolution › p.816 *(score: 0.641)*\n",
"> With the sit-ins, college students for the first time stepped onto the stage of American history as the leading force for social change. In April 1960, Ella Baker, a longtime civil rights organizer, c...\n",
"\n",
"**[3]** Ch13 › Fruits of Manifest Destiny › p.385 *(score: 0.638)*\n",
"> In the 1840s, slavery moved to the center stage of American politics. It did so not in the moral language or with the immediatist program of abolitionism, but as a result of the nation’s territorial e...\n",
"\n",
"**[4]** Ch25 › 1968 › p.844 *(score: 0.637)*\n",
"> The Sixties reached their climax in 1968, a year when momentous events succeeded each other so rapidly that the foundations of society seemed to be dissolving. Late January 1968 saw the Tet offensive,...\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ask(\"why did mlk agree with malcomx so much\")"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "c9047e77",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RAW: 'Based on the provided textbook passages, the premise of your question is incorrect. The U.S. government did **not** treat Japanese Americans well during World War II; it subjected them to one of the most severe violations of civil liberties in American history.\\n\\nAccording to the text, the government treated Japanese Americans poorly for the following reasons:\\n\\n* **Mass Internment:** In February 1942, President Roosevelt issued **Executive Order 9066**, which ordered the removal of all persons of Japanese descent from the West Coast. This resulted in the forced relocation of more than **110,000 men, women, and children**, nearly two-thirds of whom were **American citizens** (nisei). They were moved to internment camps behind barbed-wire fences, often living in makeshift shacks or former horse stables (Ch22, p.729).\\n* **Lack of Due Process:** The text states there were \"no court hearings, no due process, and no writs of habeas corpus.\" The Supreme Court upheld this policy in *Korematsu v. United States* (1944), with Justice Hugo Black insisting the order was not based on race but on military necessity, though Justice Jackson\\'s dissent argued it was a \"subtle blow to liberty\" and that guilt should not be inheritable (Ch22, p.729).\\n* **Racial Prejudice and Propaganda:** The text notes that long-standing prejudices combined with the attack on Pearl Harbor produced \"unprecedented hatred of Japan.\" Propaganda portrayed Japanese Americans as potential spies, rats, dogs, and snakes, blaming aggression on a \"violent racial or national character\" rather than tyrannical rulers (Ch22, p.729).\\n* **Harsh Conditions:** Internees were subjected to \"quasi-military discipline,\" including early roll calls, armed guards, and searchlights shining all night. Privacy was difficult, and medical facilities were often nonexistent (Ch22, p.729).\\n* **Contrast with Other Groups:** The text explicitly contrasts this treatment with German and Italian Americans, noting the government \"bent over backward to include\" them, arresting only a handful of nationals while viewing every person of Japanese ethnicity as a potential spy (Ch22, p.729).\\n\\nWhile the government did market war bonds to internees and established a loyalty oath program, the text describes the internment as the \"largest violation of American civil liberties in the twentieth century\" and notes that the Supreme Court later repudiated the *Korematsu* decision in 2018, calling it \"gravely wrong\" (Ch22, p.729).'\n"
]
},
{
"data": {
"text/markdown": [
"\n",
"🟡 **CONFIDENCE: MEDIUM** (score: 0.771)\n",
"\n",
"---\n",
"\n",
"### Q: why did the us govt treat japanese americans so well in ww2\n",
"\n",
"Based on the provided textbook passages, the premise of your question is incorrect. The U.S. government did **not** treat Japanese Americans well during World War II; it subjected them to one of the most severe violations of civil liberties in American history.\n",
"\n",
"According to the text, the government treated Japanese Americans poorly for the following reasons:\n",
"\n",
"* **Mass Internment:** In February 1942, President Roosevelt issued **Executive Order 9066**, which ordered the removal of all persons of Japanese descent from the West Coast. This resulted in the forced relocation of more than **110,000 men, women, and children**, nearly two-thirds of whom were **American citizens** (nisei). They were moved to internment camps behind barbed-wire fences, often living in makeshift shacks or former horse stables (Ch22, p.729).\n",
"* **Lack of Due Process:** The text states there were \"no court hearings, no due process, and no writs of habeas corpus.\" The Supreme Court upheld this policy in *Korematsu v. United States* (1944), with Justice Hugo Black insisting the order was not based on race but on military necessity, though Justice Jackson's dissent argued it was a \"subtle blow to liberty\" and that guilt should not be inheritable (Ch22, p.729).\n",
"* **Racial Prejudice and Propaganda:** The text notes that long-standing prejudices combined with the attack on Pearl Harbor produced \"unprecedented hatred of Japan.\" Propaganda portrayed Japanese Americans as potential spies, rats, dogs, and snakes, blaming aggression on a \"violent racial or national character\" rather than tyrannical rulers (Ch22, p.729).\n",
"* **Harsh Conditions:** Internees were subjected to \"quasi-military discipline,\" including early roll calls, armed guards, and searchlights shining all night. Privacy was difficult, and medical facilities were often nonexistent (Ch22, p.729).\n",
"* **Contrast with Other Groups:** The text explicitly contrasts this treatment with German and Italian Americans, noting the government \"bent over backward to include\" them, arresting only a handful of nationals while viewing every person of Japanese ethnicity as a potential spy (Ch22, p.729).\n",
"\n",
"While the government did market war bonds to internees and established a loyalty oath program, the text describes the internment as the \"largest violation of American civil liberties in the twentieth century\" and notes that the Supreme Court later repudiated the *Korematsu* decision in 2018, calling it \"gravely wrong\" (Ch22, p.729).\n",
"\n",
"---\n",
"\n",
"**Sources:**\n",
"\n",
"**[1]** Ch22 › The American Dilemma › p.729 *(score: 0.771)*\n",
"> The unprecedented attention to freedom as the defining characteristic of American life had implications that went far beyond wartime mobilization. World War II reshaped Americans’ understanding of the...\n",
"\n",
"**[2]** Ch22 › Chapter 22: Fighting for the Four Freedoms: World War II, 1941⠍1945 › p.712 *(score: 0.770)*\n",
"> What steps led to American participation in World War II? How did the United States mobilize economic resources and promote popular support for the war effort? What visions of America’s postwar role b...\n",
"\n",
"**[3]** Ch22 › Chapter Review › p.746 *(score: 0.749)*\n",
"> 1. Why did most Americans support isolationism in the 1930s? 2. What factors after 1939 led to U.S. involvement in World War II? 3. How did government, business, and labor work together to promote wa...\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ask(\"why did the us govt treat japanese americans so well in ww2\")"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "ea66da95",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RAW: 'Here are specific New Deal policies with dates and detailed evidence from the provided textbook passages, organized for use in an LEQ (Long Essay Question):\\n\\n**1. Financial Stabilization and Banking Reform (1933)**\\n* **Emergency Banking Act (March 1933):** Declared a \"bank holiday\" to halt all bank operations, then provided funds to shore up threatened institutions (Ch21, p.680).\\n* **Glass-Steagall Act (1933):** Barred commercial banks from buying/selling stocks and established the **Federal Deposit Insurance Corporation (FDIC)** to insure individual depositor accounts (Ch21, p.680).\\n* **Taking off the Gold Standard (1933):** Severed the link between currency and gold reserves to allow issuance of more money to stimulate business activity (Ch21, p.680).\\n\\n**2. Public Works and Regional Development (1933–1934)**\\n* **Civilian Conservation Corps (CCC) (March 1933):** Employed unemployed young men on forest preservation, flood control, and park improvement projects; paid $30/month; over 3 million passed through camps by 1942 (Ch21, p.680).\\n* **Public Works Administration (PWA) (1933):** Directed by Harold Ickes; contracted with private construction companies to build roads, schools, hospitals, and public facilities (e.g., Triborough Bridge, Overseas Highway); appropriated $3.3 billion (Ch21, p.680).\\n* **Civil Works Administration (CWA) (November 1933):** Directly hired workers for construction projects (highways, tunnels, airports); employed over 4 million by January 1934 before being dissolved due to spiraling costs (Ch21, p.680).\\n* **Tennessee Valley Authority (TVA) (1933):** Built dams to prevent floods/deforestation and provide cheap electric power in a seven-state region; put the federal government in the business of selling electricity in competition with private companies (Ch21, p.680).\\n* **Grand Coulee Dam (1941 operation):** Largest man-made structure in world history; produced >40% of nation’s hydroelectric power; created thousands of jobs but caused environmental costs (salmon extinction) and displaced Colville tribes (Ch21, p.678).\\n\\n**3. Agricultural Relief (1933)**\\n* **Agricultural Adjustment Act (AAA) (1933):** Authorized government to set production quotas and pay farmers to plant less to raise prices; ordered 6+ million pigs slaughtered in 1933 (Ch21, p.680).\\n* **Impact:** Raised farm prices/incomes but ignored landless workers; encouraged eviction of tenants/sharecroppers; failed to help Dust Bowl victims (Ch21, p.680).\\n\\n**4. Labor Rights and Unionization (1933–1935)**\\n* **National Industrial Recovery Act (NRA) (1933):** Established industry codes for output, prices, and working conditions; Section 7a recognized workers’ right to organize unions (Ch21, p.680).\\n* **Wagner Act (National Labor Relations Act of 1935):** Established the **National Labor Relations Board (NLRB)** to regulate employment/bargaining practices and facilitate unionization (Ch21, p.708).\\n* **Congress of Industrial Organizations (CIO) (1935):** Umbrella organization of semiskilled industrial unions formed as Committee for Industrial Organization, renamed in 1938 (Ch21, p.708).\\n* **Sit-down Strikes (mid-1930s):** Tactic where workers refused to leave factories, making production impossible; proved effective for CIO organizing drives (Ch21, p.708).\\n\\n**5. Social Welfare and Housing (1933–1935)**\\n* **Federal Emergency Relief Administration (FERA) (May 1933):** Made grants to local agencies to aid impoverished citizens (Ch21, p.680).\\n* **Social Security Act (1935):** Created Social Security system with retirement pensions, unemployment insurance, disability insurance, and public assistance (welfare) (Ch21, p.708).\\n* **Home Owners Loan Corporation (1933) & Federal Housing Administration (FHA) (1933–1934):** Insured long-term mortgages to protect homeowners from foreclosure and stimulate construction; FHA guaranteed mortgages with low down payments (Ch21, p.680).\\n* **Resettlement Administration (1934):** Relocated rural/urban families to federally planned communities (e.g., Greenbelt near Washington, D.C.) (Ch21, p.680).\\n\\n**6. Communication and Cultural Reform (1933)**\\n* **Federal Communications Commission (FCC) (1933):** Established to oversee broadcast airwaves and telephone communications (Ch21, p.680).\\n* **Securities and Exchange Commission (SEC) (1933):** Created to regulate stock and bond markets (Ch21, p.680).\\n* **Works Progress Administration (WPA) (Second New Deal):** Provided jobs for millions on construction and arts projects (Ch21, p.708).\\n\\n**7. Native American Policy (1934)**\\n* **Indian Reorganization Act (1934):** Increased access for Native Americans to land and self-governance; part of the \"Indian New Deal\" (Ch21, p.708).\\n\\n**8. Prohibition Repeal (1933)**\\n* **Twenty-first Amendment (1933):** Ratified to repeal the Eighteenth Amendment, legalizing manufacture/transpoLine truncated
]
},
{
"data": {
"text/markdown": [
"\n",
"🟡 **CONFIDENCE: MEDIUM** (score: 0.692)\n",
"\n",
"---\n",
"\n",
"### Q: which are some new deal policies bullet point evidences with dates in great detail i can use for my LEQ\n",
"\n",
"Here are specific New Deal policies with dates and detailed evidence from the provided textbook passages, organized for use in an LEQ (Long Essay Question):\n",
"\n",
"**1. Financial Stabilization and Banking Reform (1933)**\n",
"* **Emergency Banking Act (March 1933):** Declared a \"bank holiday\" to halt all bank operations, then provided funds to shore up threatened institutions (Ch21, p.680).\n",
"* **Glass-Steagall Act (1933):** Barred commercial banks from buying/selling stocks and established the **Federal Deposit Insurance Corporation (FDIC)** to insure individual depositor accounts (Ch21, p.680).\n",
"* **Taking off the Gold Standard (1933):** Severed the link between currency and gold reserves to allow issuance of more money to stimulate business activity (Ch21, p.680).\n",
"\n",
"**2. Public Works and Regional Development (1933–1934)**\n",
"* **Civilian Conservation Corps (CCC) (March 1933):** Employed unemployed young men on forest preservation, flood control, and park improvement projects; paid $30/month; over 3 million passed through camps by 1942 (Ch21, p.680).\n",
"* **Public Works Administration (PWA) (1933):** Directed by Harold Ickes; contracted with private construction companies to build roads, schools, hospitals, and public facilities (e.g., Triborough Bridge, Overseas Highway); appropriated $3.3 billion (Ch21, p.680).\n",
"* **Civil Works Administration (CWA) (November 1933):** Directly hired workers for construction projects (highways, tunnels, airports); employed over 4 million by January 1934 before being dissolved due to spiraling costs (Ch21, p.680).\n",
"* **Tennessee Valley Authority (TVA) (1933):** Built dams to prevent floods/deforestation and provide cheap electric power in a seven-state region; put the federal government in the business of selling electricity in competition with private companies (Ch21, p.680).\n",
"* **Grand Coulee Dam (1941 operation):** Largest man-made structure in world history; produced >40% of nation’s hydroelectric power; created thousands of jobs but caused environmental costs (salmon extinction) and displaced Colville tribes (Ch21, p.678).\n",
"\n",
"**3. Agricultural Relief (1933)**\n",
"* **Agricultural Adjustment Act (AAA) (1933):** Authorized government to set production quotas and pay farmers to plant less to raise prices; ordered 6+ million pigs slaughtered in 1933 (Ch21, p.680).\n",
"* **Impact:** Raised farm prices/incomes but ignored landless workers; encouraged eviction of tenants/sharecroppers; failed to help Dust Bowl victims (Ch21, p.680).\n",
"\n",
"**4. Labor Rights and Unionization (1933–1935)**\n",
"* **National Industrial Recovery Act (NRA) (1933):** Established industry codes for output, prices, and working conditions; Section 7a recognized workers’ right to organize unions (Ch21, p.680).\n",
"* **Wagner Act (National Labor Relations Act of 1935):** Established the **National Labor Relations Board (NLRB)** to regulate employment/bargaining practices and facilitate unionization (Ch21, p.708).\n",
"* **Congress of Industrial Organizations (CIO) (1935):** Umbrella organization of semiskilled industrial unions formed as Committee for Industrial Organization, renamed in 1938 (Ch21, p.708).\n",
"* **Sit-down Strikes (mid-1930s):** Tactic where workers refused to leave factories, making production impossible; proved effective for CIO organizing drives (Ch21, p.708).\n",
"\n",
"**5. Social Welfare and Housing (1933–1935)**\n",
"* **Federal Emergency Relief Administration (FERA) (May 1933):** Made grants to local agencies to aid impoverished citizens (Ch21, p.680).\n",
"* **Social Security Act (1935):** Created Social Security system with retirement pensions, unemployment insurance, disability insurance, and public assistance (welfare) (Ch21, p.708).\n",
"* **Home Owners Loan Corporation (1933) & Federal Housing Administration (FHA) (1933–1934):** Insured long-term mortgages to protect homeowners from foreclosure and stimulate construction; FHA guaranteed mortgages with low down payments (Ch21, p.680).\n",
"* **Resettlement Administration (1934):** Relocated rural/urban families to federally planned communities (e.g., Greenbelt near Washington, D.C.) (Ch21, p.680).\n",
"\n",
"**6. Communication and Cultural Reform (1933)**\n",
"* **Federal Communications Commission (FCC) (1933):** Established to oversee broadcast airwaves and telephone communications (Ch21, p.680).\n",
"* **Securities and Exchange Commission (SEC) (1933):** Created to regulate stock and bond markets (Ch21, p.680).\n",
"* **Works Progress Administration (WPA) (Second New Deal):** Provided jobs for millions on construction and arts projects (Ch21, p.708).\n",
"\n",
"**7. Native American Policy (1934)**\n",
"* **Indian Reorganization Act (1934):** Increased access for Native Americans to land and self-governance; part of the \"Indian New Deal\" (Ch21, p.708).\n",
"\n",
"**8. Prohibition Repeal (1933)**\n",
"* **Twenty-first Amendment (1933):** Ratified to repeal the Eighteenth Amendment, legalizing manufacture/transportation/sale of alcoholic beverages (Ch21, p.680).\n",
"\n",
"**9. Postwar Economic Vision (1942–1944)**\n",
"* **National Resources Planning Board (NRPB) Reports (1942–1943):** Proposed \"full-employment economy,\" expanded welfare state, and \"new bill of rights\" including education, healthcare, housing, and jobs (Ch22, p.727).\n",
"* **Economic Bill of Rights (1944):** FDR’s proposal for full employment, adequate income, medical care, education, and decent home for all Americans (Ch22, p.727).\n",
"* **GI Bill of Rights (Servicemen’s Readjustment Act of 1944):** Provided unemployment pay, scholarships, low-cost mortgages, pensions, and job training to veterans; by 1946, 1 million attended college, 4 million received home mortgages (Ch22, p.727).\n",
"* **Full Employment Bill (1945–1946):** Attempted to establish \"right to employment\" for all Americans; passed in 1946 only after \"Full\" was removed and commitment to government job creation eliminated (Ch22, p.727).\n",
"\n",
"---\n",
"\n",
"**Sources:**\n",
"\n",
"**[1]** Ch22 › Visions of Postwar Freedom › p.727 *(score: 0.692)*\n",
"> The prospect of an affluent future provided a point of unity between New Dealers and conservatives, business and labor. And the promise of prosperity to some extent united two of the most celebrated b...\n",
"\n",
"**[2]** Ch21 › Chapter 21: The New Deal, 1932⠍1940 › p.678 *(score: 0.682)*\n",
"> What were the major policy initiatives of the New Deal in the Hundred Days? Who were the main proponents of economic justice in the 1930s, and what measures did they advocate? What were the major init...\n",
"\n",
"**[3]** Ch26 › The Reagan Revolution › p.877 *(score: 0.682)*\n",
"> Ronald Reagan followed a most unusual path to the presidency. Originally a New Deal Democrat and head of the Screen Actors Guild (the only union leader ever to reach the White House), he emerged in th...\n",
"\n",
"**[4]** Ch21 › The First New Deal › p.680 *(score: 0.675)*\n",
"> It is indeed paradoxical that Franklin D. Roosevelt, who had been raised in privilege on a New York country estate, came to be beloved as the symbolic representative of ordinary citizens. But like Lin...\n",
"\n",
"**[5]** Ch21 › Chapter Review › p.708 *(score: 0.675)*\n",
"> and the Columbia River project reflected broader changes in American life during the New Deal. 2. What actions did President Roosevelt and Congress take to help the banking system recover as well as ...\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ask(\"which are some new deal policies bullet point evidences with dates in great detail i can use for my LEQ\")"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "4415fcca",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RAW: 'The provided textbook passages do not contain information about who invented calculus or the centrifuge. Therefore, I cannot answer this question using only the text provided.\\n\\nHowever, based on general historical knowledge (outside the provided text):\\n\\n* **Calculus** was independently developed in the mid-17th century by **Isaac Newton** (England) and **Gottfried Wilhelm Leibniz** (Germany). Newton developed it first (around 1665–1666) but published later; Leibniz published his version first (1684) and developed the notation still used today.\\n* The **centrifuge** was invented in the 19th century. The first practical centrifuge was developed by **John Benjamin Dancer** in 1864, who created a machine to separate blood components. Earlier versions existed in the 18th century (e.g., by **Benjamin Franklin** for separating milk), but Dancer is credited with the first practical laboratory centrifuge.'\n"
]
},
{
"data": {
"text/markdown": [
"\n",
"🟡 **CONFIDENCE: MEDIUM** (score: 0.654)\n",
"\n",
"---\n",
"\n",
"### Q: Who invented caluclus and the cetntrifuge\n",
"\n",
"The provided textbook passages do not contain information about who invented calculus or the centrifuge. Therefore, I cannot answer this question using only the text provided.\n",
"\n",
"However, based on general historical knowledge (outside the provided text):\n",
"\n",
"* **Calculus** was independently developed in the mid-17th century by **Isaac Newton** (England) and **Gottfried Wilhelm Leibniz** (Germany). Newton developed it first (around 1665–1666) but published later; Leibniz published his version first (1684) and developed the notation still used today.\n",
"* The **centrifuge** was invented in the 19th century. The first practical centrifuge was developed by **John Benjamin Dancer** in 1864, who created a machine to separate blood components. Earlier versions existed in the 18th century (e.g., by **Benjamin Franklin** for separating milk), but Dancer is credited with the first practical laboratory centrifuge.\n",
"\n",
"---\n",
"\n",
"**Sources:**\n",
"\n",
"**[1]** Ch1 › Contact › p.13 *(score: 0.654)*\n",
"> At the beginning of the fifteenth century, one might have predicted that China would establish the world’s first global empire. Between 1405 and 1433, Admiral Zheng He led seven large naval expedition...\n",
"\n",
"**[2]** Ch9 › Chapter Review › p.288 *(score: 0.654)*\n",
"> explain how they influenced the market economy. 2. How did state and local governments promote the national economy in respond to competing territorial claims by European or Native nations? 4. How di...\n",
"\n",
"**[3]** Ch5 › The Coming of Independence › p.153 *(score: 0.630)*\n",
"> Opposition to the Intolerable Acts now spread to small towns and rural areas that had not participated actively in previous resistance. In September 1774, in the town of Worcester, Massachusetts, 4,60...\n",
"\n",
"**[4]** Ch16 › Chapter 16: America⠒s Gilded Age, 1870⠍1890 › p.500 *(score: 0.610)*\n",
"> What factors combined to make the United States a mature industrial society after the Civil War? How did the economic development of the Gilded Age affect American freedom? How did reformers of the pe...\n",
"\n",
"**[5]** Ch11 › Resistance to Slavery › p.342 *(score: 0.605)*\n",
"> Confronted with federal, state, and local authorities committed to preserving slavery, and outnumbered within the South as a whole by the white population, slaves could only rarely express their desir...\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ask(\"Who invented caluclus and the cetntrifuge\")"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "1d5982bb",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RAW: 'The provided textbook passages **do not argue** that Martin Luther King Jr. was a \"better\" activist than Rosa Parks. In fact, the text presents both as essential, complementary figures with distinct but equally vital roles in the civil rights movement.\\n\\nHere is the detailed breakdown based **only** on the provided text:\\n\\n1. **Rosa Parks as the Catalyst and Symbol:**\\n * The text identifies Rosa Parks as the spark for the \"mass phase\" of the movement. Her arrest on December 1, 1955, \"sparked a yearlong Montgomery bus boycott\" (Ch24 › The Freedom Movement › p.799).\\n * She is described as the \"ideal person to become a symbol of the fight\" because she was \"dignified, accomplished,\" and a veteran of Black politics who had already tried to register to vote and served as a secretary to E.D. Nixon (Ch24 › The Freedom Movement › p.799).\\n * The text emphasizes her role as an \"ordinary Black\" representing the \"determination to resist the daily injustices and indignities of the Jim Crow South\" (Ch24 › The Freedom Movement › p.799).\\n * Time magazine named her one of the 100 most significant persons of the twentieth century (Ch24 › The Freedom Movement › p.799).\\n\\n2. **Martin Luther King Jr. as the National Symbol and Orator:**\\n * The text states that the Montgomery Bus Boycott \"marked the emergence of twenty-six-year-old Martin Luther King Jr.... as the movement’s national symbol\" (Ch24 › The Freedom Movement › p.799).\\n * King is credited with outlining the movement\\'s philosophy of \"peaceful civil disobedience\" and \"nonviolent resistance,\" drawing on Henry David Thoreau and Mahatma Gandhi (Ch24 › The Freedom Movement › p.799).\\n * He founded the Southern Christian Leadership Conference (SCLC) in 1956 to press for desegregation (Ch24 › The Freedom Movement › p.799).\\n * His speeches, such as \"I Have a Dream,\" merged the Black experience with the nation\\'s values and linked the American \"color line\" to the global struggle for freedom (Ch24 › The Freedom Movement › p.799).\\n\\n3. **The Text\\'s View on Their Relationship:**\\n * The text explicitly states that the civil rights revolution \"built on earlier struggles\" and that Parks\\'s life \"makes clear that the civil rights revolution built on earlier struggles\" (Ch24 › The Freedom Movement › p.799).\\n * It notes that Parks was a \"veteran of Black politics\" who had been active since the 1930s, implying her activism was foundational and long-standing, whereas King\\'s prominence emerged specifically during the Montgomery boycott (Ch24 › The Freedom Movement › p.799).\\n * The text does not rank them as \"better\" or \"worse.\" Instead, it portrays Parks as the catalyst who provided the \"symbol of ordinary Blacks’ determination\" and King as the leader who provided the \"national symbol,\" the philosophical framework, and the organizational structure (SCLC) to expand the movement beyond Montgomery (Ch24 › The Freedom Movement › p.799).\\n\\n**Conclusion:**\\nThe textbook does not argue that MLK was a better activist. It argues that they played different, necessary roles: Parks was the **catalyst and symbol of ordinary resistance**, while King was the **national leader and strategist** who articulated the movement\\'s philosophy and expanded its reach. The text suggests the movement required both the \"foot soldiers\" like Parks and the \"national symbol\" like King to succeed (Ch24 › The Freedom Movement › p.799).'\n"
]
},
{
"data": {
"text/markdown": [
"\n",
"🟡 **CONFIDENCE: MEDIUM** (score: 0.714)\n",
"\n",
"---\n",
"\n",
"### Q: why does the textbook argue that mlk was a better activist than rosa parks\n",
"\n",
"The provided textbook passages **do not argue** that Martin Luther King Jr. was a \"better\" activist than Rosa Parks. In fact, the text presents both as essential, complementary figures with distinct but equally vital roles in the civil rights movement.\n",
"\n",
"Here is the detailed breakdown based **only** on the provided text:\n",
"\n",
"1. **Rosa Parks as the Catalyst and Symbol:**\n",
" * The text identifies Rosa Parks as the spark for the \"mass phase\" of the movement. Her arrest on December 1, 1955, \"sparked a yearlong Montgomery bus boycott\" (Ch24 › The Freedom Movement › p.799).\n",
" * She is described as the \"ideal person to become a symbol of the fight\" because she was \"dignified, accomplished,\" and a veteran of Black politics who had already tried to register to vote and served as a secretary to E.D. Nixon (Ch24 › The Freedom Movement › p.799).\n",
" * The text emphasizes her role as an \"ordinary Black\" representing the \"determination to resist the daily injustices and indignities of the Jim Crow South\" (Ch24 › The Freedom Movement › p.799).\n",
" * Time magazine named her one of the 100 most significant persons of the twentieth century (Ch24 › The Freedom Movement › p.799).\n",
"\n",
"2. **Martin Luther King Jr. as the National Symbol and Orator:**\n",
" * The text states that the Montgomery Bus Boycott \"marked the emergence of twenty-six-year-old Martin Luther King Jr.... as the movement’s national symbol\" (Ch24 › The Freedom Movement › p.799).\n",
" * King is credited with outlining the movement's philosophy of \"peaceful civil disobedience\" and \"nonviolent resistance,\" drawing on Henry David Thoreau and Mahatma Gandhi (Ch24 › The Freedom Movement › p.799).\n",
" * He founded the Southern Christian Leadership Conference (SCLC) in 1956 to press for desegregation (Ch24 › The Freedom Movement › p.799).\n",
" * His speeches, such as \"I Have a Dream,\" merged the Black experience with the nation's values and linked the American \"color line\" to the global struggle for freedom (Ch24 › The Freedom Movement › p.799).\n",
"\n",
"3. **The Text's View on Their Relationship:**\n",
" * The text explicitly states that the civil rights revolution \"built on earlier struggles\" and that Parks's life \"makes clear that the civil rights revolution built on earlier struggles\" (Ch24 › The Freedom Movement › p.799).\n",
" * It notes that Parks was a \"veteran of Black politics\" who had been active since the 1930s, implying her activism was foundational and long-standing, whereas King's prominence emerged specifically during the Montgomery boycott (Ch24 › The Freedom Movement › p.799).\n",
" * The text does not rank them as \"better\" or \"worse.\" Instead, it portrays Parks as the catalyst who provided the \"symbol of ordinary Blacks’ determination\" and King as the leader who provided the \"national symbol,\" the philosophical framework, and the organizational structure (SCLC) to expand the movement beyond Montgomery (Ch24 › The Freedom Movement › p.799).\n",
"\n",
"**Conclusion:**\n",
"The textbook does not argue that MLK was a better activist. It argues that they played different, necessary roles: Parks was the **catalyst and symbol of ordinary resistance**, while King was the **national leader and strategist** who articulated the movement's philosophy and expanded its reach. The text suggests the movement required both the \"foot soldiers\" like Parks and the \"national symbol\" like King to succeed (Ch24 › The Freedom Movement › p.799).\n",
"\n",
"---\n",
"\n",
"**Sources:**\n",
"\n",
"**[1]** Ch24 › Chapter Review › p.810 *(score: 0.714)*\n",
"> transformed American life in the 1950s. 3. Identify the prescribed roles and aspirations for women during the patriotic act? 5. How did governmental policies, business practices, and individual choi...\n",
"\n",
"**[2]** Ch24 › The Freedom Movement › p.799 *(score: 0.711)*\n",
"> Not until the 1960s would young white rebels find their cause, as the seeds of dissent planted by the social critics and Beats flowered in an outpouring of political activism, new attitudes toward sex...\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ask(\"why does the textbook argue that mlk was a better activist than rosa parks\")"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "8f00c9a7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RAW: '**LEQ Response: The Impact of Salutary Neglect on the American Revolution**\\n\\n**Context:**\\nThe American Revolution was not merely a war for independence from Great Britain, but a profound transformation in the definition of freedom, citizenship, and economic liberty. While the immediate catalyst was taxation without representation, the intellectual and political foundations of the revolution were laid during the era of \"salutary neglect\" in the first half of the 18th century. This period, characterized by weak imperial authority and the self-governance of the colonies, allowed American elites to develop a distinct political culture that prioritized local autonomy and the rights of Englishmen. However, the revolution also had complex and often contradictory consequences for different groups, including Native Americans, enslaved people, and women, as the new nation grappled with the limits of its own ideals of liberty.\\n\\n**Thesis:**\\nThe era of salutary neglect contributed to the American Revolution by fostering a political culture rooted in local self-government and a belief in the rights of Englishmen, which empowered colonial assemblies to challenge British authority; however, the revolution ultimately redefined freedom in ways that expanded political participation for white men while simultaneously diminishing the freedoms of Native Americans, Loyalists, and enslaved people, revealing the tension between the ideal of liberty and the reality of social hierarchy.\\n\\n**Line of Reasoning:**\\n\\nFirst, the era of salutary neglect, in which British governments largely left the colonies to govern themselves, allowed American elites to develop a robust tradition of self-rule that directly challenged British imperial control. During this period, colonial assemblies, dominated by wealthy landowners, merchants, and lawyers, increasingly asserted their power over appointed governors and councils. For example, in Pennsylvania, the assembly eliminated the governor\\'s council to create a unicameral legislature, wresting control of finance and the militia from the Penn family (Ch4, p.120). This experience of self-governance led Americans to view themselves as defenders of \"the people\\'s liberty\" and to believe that assemblies possessed the same rights as the British House of Commons (Ch4, p.120). When Britain attempted to reassert imperial authority through measures like the Stamp Act and the Townshend Acts, colonists interpreted these as violations of their long-held rights to self-determination. The expansion of the \"public sphere\" during this time, with the proliferation of newspapers, clubs, and taverns, further democratized political debate and allowed ordinary citizens to participate in discussions of public affairs, reinforcing the belief that the government should be accountable to the people (Ch4, p.120).\\n\\nSecond, the revolution redefined the concept of economic freedom, shifting from a traditional view that prioritized the public good over individual property rights to a new ideal of \"free labor\" and free trade. During the Revolution, economic dislocations such as inflation and shortages led to debates over price controls. While some advocated for government intervention to fix prices and wages in the name of the public good, the influence of Adam Smith\\'s *The Wealth of Nations* and the belief in the \"invisible hand\" of the market led to the ascendancy of free trade advocates who argued that unregulated economic freedom produced social harmony (Ch6, p.184). This shift sharpened the distinction between a northern economy relying on \"free labor\" and a southern economy dependent on enslaved labor, as the decline of indentured servitude and apprenticeship removed the \"halfway houses\" between slavery and freedom for white men (Ch6, p.184). However, this new economic freedom was built on the dispossession of Native Americans, whose land was necessary to fulfill the vision of widespread land ownership that leaders like Thomas Jefferson and Noah Webster believed was essential for national freedom (Ch6, p.184).\\n\\nThird, while the revolution expanded political participation for white men, it simultaneously diminished the freedoms of Native Americans, Loyalists, and enslaved people, demonstrating that the new nation\\'s definition of liberty was racially and gendered. The war brought destruction to Native Americans who fought on both sides, as British troops burned Catawba towns and American General John Sullivan led an expedition to destroy Haudenosaunee settlements, burning forty towns and destroying thousands of bushels of corn (Ch5, p.162). Although some Native nations like the Oneidas joined the Americans, most Native nations allied with the British to protect their lands from colonial encroachment, and the American victory ultimately led to the loss of Native independence (Ch5, p.162). Similarly, the revolution diminished the freedoms of Loyalists, who faced persecuLine truncated
]
},
{
"data": {
"text/markdown": [
"\n",
"🟡 **CONFIDENCE: MEDIUM** (score: 0.705)\n",
"\n",
"---\n",
"\n",
"### Q: How did the era of salutrary neglect contribute to the American revolution...write a full length LEQ with a good context thesis and nuanced line of reasoning able to get full 6/6 on the APUSH LEQ\n",
"\n",
"**LEQ Response: The Impact of Salutary Neglect on the American Revolution**\n",
"\n",
"**Context:**\n",
"The American Revolution was not merely a war for independence from Great Britain, but a profound transformation in the definition of freedom, citizenship, and economic liberty. While the immediate catalyst was taxation without representation, the intellectual and political foundations of the revolution were laid during the era of \"salutary neglect\" in the first half of the 18th century. This period, characterized by weak imperial authority and the self-governance of the colonies, allowed American elites to develop a distinct political culture that prioritized local autonomy and the rights of Englishmen. However, the revolution also had complex and often contradictory consequences for different groups, including Native Americans, enslaved people, and women, as the new nation grappled with the limits of its own ideals of liberty.\n",
"\n",
"**Thesis:**\n",
"The era of salutary neglect contributed to the American Revolution by fostering a political culture rooted in local self-government and a belief in the rights of Englishmen, which empowered colonial assemblies to challenge British authority; however, the revolution ultimately redefined freedom in ways that expanded political participation for white men while simultaneously diminishing the freedoms of Native Americans, Loyalists, and enslaved people, revealing the tension between the ideal of liberty and the reality of social hierarchy.\n",
"\n",
"**Line of Reasoning:**\n",
"\n",
"First, the era of salutary neglect, in which British governments largely left the colonies to govern themselves, allowed American elites to develop a robust tradition of self-rule that directly challenged British imperial control. During this period, colonial assemblies, dominated by wealthy landowners, merchants, and lawyers, increasingly asserted their power over appointed governors and councils. For example, in Pennsylvania, the assembly eliminated the governor's council to create a unicameral legislature, wresting control of finance and the militia from the Penn family (Ch4, p.120). This experience of self-governance led Americans to view themselves as defenders of \"the people's liberty\" and to believe that assemblies possessed the same rights as the British House of Commons (Ch4, p.120). When Britain attempted to reassert imperial authority through measures like the Stamp Act and the Townshend Acts, colonists interpreted these as violations of their long-held rights to self-determination. The expansion of the \"public sphere\" during this time, with the proliferation of newspapers, clubs, and taverns, further democratized political debate and allowed ordinary citizens to participate in discussions of public affairs, reinforcing the belief that the government should be accountable to the people (Ch4, p.120).\n",
"\n",
"Second, the revolution redefined the concept of economic freedom, shifting from a traditional view that prioritized the public good over individual property rights to a new ideal of \"free labor\" and free trade. During the Revolution, economic dislocations such as inflation and shortages led to debates over price controls. While some advocated for government intervention to fix prices and wages in the name of the public good, the influence of Adam Smith's *The Wealth of Nations* and the belief in the \"invisible hand\" of the market led to the ascendancy of free trade advocates who argued that unregulated economic freedom produced social harmony (Ch6, p.184). This shift sharpened the distinction between a northern economy relying on \"free labor\" and a southern economy dependent on enslaved labor, as the decline of indentured servitude and apprenticeship removed the \"halfway houses\" between slavery and freedom for white men (Ch6, p.184). However, this new economic freedom was built on the dispossession of Native Americans, whose land was necessary to fulfill the vision of widespread land ownership that leaders like Thomas Jefferson and Noah Webster believed was essential for national freedom (Ch6, p.184).\n",
"\n",
"Third, while the revolution expanded political participation for white men, it simultaneously diminished the freedoms of Native Americans, Loyalists, and enslaved people, demonstrating that the new nation's definition of liberty was racially and gendered. The war brought destruction to Native Americans who fought on both sides, as British troops burned Catawba towns and American General John Sullivan led an expedition to destroy Haudenosaunee settlements, burning forty towns and destroying thousands of bushels of corn (Ch5, p.162). Although some Native nations like the Oneidas joined the Americans, most Native nations allied with the British to protect their lands from colonial encroachment, and the American victory ultimately led to the loss of Native independence (Ch5, p.162). Similarly, the revolution diminished the freedoms of Loyalists, who faced persecution and the seizure of property by local and state governments, despite the Treaty of Paris promising that they would not suffer persecution (Ch5, p.162). Finally, while the revolution inspired some enslaved people to seek freedom by fighting in the Continental army or fleeing to British lines, slavery became more deeply entrenched in the South, and the boundaries of full citizenship became more rigidly based on race and gender (Ch6, p.176).\n",
"\n",
"In conclusion, the era of salutary neglect was a crucial precursor to the American Revolution, as it allowed colonial elites to cultivate a political culture of self-government and a belief in the rights of Englishmen that fueled resistance to British authority. However, the revolution itself was a complex process that redefined freedom in ways that expanded political and economic liberty for white men while marginalizing Native Americans, Loyalists, and enslaved people. The new nation's commitment to liberty was thus paradoxical, as it sought to secure independence and equality for its citizens while simultaneously denying these rights to others, a tension that would continue to shape American history long after independence was achieved.\n",
"\n",
"---\n",
"\n",
"**Sources:**\n",
"\n",
"**[1]** Ch6 › Defining Economic Freedom › p.184 *(score: 0.705)*\n",
"> In economic as well as political and religious affairs, the Revolution rewrote the definition of freedom. In colonial America, slavery was one part of a broad spectrum of kinds of unfree labor. In the...\n",
"\n",
"**[2]** Ch5 › Securing Independence › p.162 *(score: 0.692)*\n",
"> Declaring Americans independent was one thing; winning independence another. The newly created American army confronted the greatest military power on earth. Viewing the Americans as traitors, Britain...\n",
"\n",
"**[3]** Ch6 › Chapter 6: The Revolution Within › p.176 *(score: 0.691)*\n",
"> How did equality become a stronger component of American freedom after the Revolution? How did the expansion of religious liberty after the Revolution reflect the new American ideal of freedom? How di...\n",
"\n",
"**[4]** Ch4 › The Public Sphere › p.120 *(score: 0.689)*\n",
"> Colonial politics for most of the eighteenth century was considerably less tempestuous than in the seventeenth, with its bitter struggles for power and frequent armed conflicts. Political stability in...\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ask(\"How did the era of salutrary neglect contribute to the American revolution...write a full length LEQ with a good context thesis and nuanced line of reasoning able to get full 6/6 on the APUSH LEQ\")"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "56507669",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RAW: \"I cannot answer this question using the provided textbook passages because there is no information about the Harlem Renaissance in the texts. The passages cover early European colonization (French, Dutch, English, Spanish), the American Revolution, and the Adams presidency (1790s), but do not mention the Harlem Renaissance.\\n\\nIf you'd like, I can provide general information about the Harlem Renaissance outside the textbook, but please note this is not from the provided passages.\\n\\n**General Information (not from textbook):**\\nThe Harlem Renaissance was a cultural, social, and artistic explosion centered in Harlem, New York City, during the 1920s and 1930s. Key facts include:\\n\\n- **Time Period:** Roughly 1918–1937, peaking in the 1920s\\n- **Location:** Harlem, Manhattan, New York City\\n- **Key Figures:** Langston Hughes, Zora Neale Hurston, James Weldon Johnson, Countee Cullen, Duke Ellington, Louis Armstrong, Langston Hughes, W.E.B. Du Bois, Alain Locke\\n- **Themes:** African American identity, racial pride, jazz music, literature, visual arts, and political activism\\n- **Significance:** First major African American cultural movement; challenged racial stereotypes; influenced civil rights movement; produced enduring works in literature, music, and art\\n- **Context:** Great Migration (African Americans moving from rural South to urban North); post-WWI racial tensions; economic prosperity of the 1920s\\n- **Legacy:** Laid groundwork for Civil Rights Movement; established African American cultural institutions; influenced global perceptions of Black culture\\n\\nWould you like me to provide more specific details about any aspect of the Harlem Renaissance?\"\n"
]
},
{
"data": {
"text/markdown": [
"\n",
"🟡 **CONFIDENCE: MEDIUM** (score: 0.621)\n",
"\n",
"---\n",
"\n",
"### Q: Spitball facts about teh harlmen reniassacnce\n",
"\n",
"I cannot answer this question using the provided textbook passages because there is no information about the Harlem Renaissance in the texts. The passages cover early European colonization (French, Dutch, English, Spanish), the American Revolution, and the Adams presidency (1790s), but do not mention the Harlem Renaissance.\n",
"\n",
"If you'd like, I can provide general information about the Harlem Renaissance outside the textbook, but please note this is not from the provided passages.\n",
"\n",
"**General Information (not from textbook):**\n",
"The Harlem Renaissance was a cultural, social, and artistic explosion centered in Harlem, New York City, during the 1920s and 1930s. Key facts include:\n",
"\n",
"- **Time Period:** Roughly 1918–1937, peaking in the 1920s\n",
"- **Location:** Harlem, Manhattan, New York City\n",
"- **Key Figures:** Langston Hughes, Zora Neale Hurston, James Weldon Johnson, Countee Cullen, Duke Ellington, Louis Armstrong, Langston Hughes, W.E.B. Du Bois, Alain Locke\n",
"- **Themes:** African American identity, racial pride, jazz music, literature, visual arts, and political activism\n",
"- **Significance:** First major African American cultural movement; challenged racial stereotypes; influenced civil rights movement; produced enduring works in literature, music, and art\n",
"- **Context:** Great Migration (African Americans moving from rural South to urban North); post-WWI racial tensions; economic prosperity of the 1920s\n",
"- **Legacy:** Laid groundwork for Civil Rights Movement; established African American cultural institutions; influenced global perceptions of Black culture\n",
"\n",
"Would you like me to provide more specific details about any aspect of the Harlem Renaissance?\n",
"\n",
"---\n",
"\n",
"**Sources:**\n",
"\n",
"**[1]** Ch1 › The French and Dutch Empires › p.27 *(score: 0.621)*\n",
"> If the Black Legend inspired a sense of superiority among Spain’s European rivals, the precious metals that poured from the Americas into the Spanish treasury aroused the desire to try to match Spain’...\n",
"\n",
"**[2]** Ch8 › The Adams Presidency › p.237 *(score: 0.612)*\n",
"> In 1792, Washington won unanimous reelection. Four years later, he decided to retire from public life, in part to establish the precedent that the presidency is not a life office. In his Farewell Addr...\n",
"\n",
"**[3]** Ch5 › Securing Independence › p.162 *(score: 0.612)*\n",
"> Declaring Americans independent was one thing; winning independence another. The newly created American army confronted the greatest military power on earth. Viewing the Americans as traitors, Britain...\n",
"\n",
"**[4]** Ch2 › Chapter 2: European Colonies and Native Nations, 1600⠍1660 › p.40 *(score: 0.611)*\n",
"> What were the main contours of English colonization in the seventeenth century? What drew English settlers to North America, and how did Native peoples respond to incoming colonists? What was the sign...\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ask(\"Spitball facts about teh harlmen reniassacnce\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"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.14.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}