Spaces:
Sleeping
fix(docs): KI-127 — correct cascade arithmetic, 224 -> 206 corpus PDFs
Browse filesThe KI-126 cascade-agent miscounted by treating regulatory PDFs as a separate
category added on top of the 206. Reality: 206 PDFs total, comprising
188 product PDFs across 19 insurers + 18 regulatory IRDAI/NHA docs.
Ground truth (verified against disk + HF dataset):
rag/corpus/ -> 206 PDFs in 20 dirs (19 real insurer dirs + 1 regulatory dir)
rag/extracted/ -> 206 JSONs
rag/vectors/chroma.sqlite3 -> 7,295 chunks across 206 policy_ids
kb/policies/*.md -> 222 markdown sheets (was 224 pre-deletion; -2 brochures)
Files corrected (11 hits):
• CLAUDE.md L7 — corpus 224 -> 206 + 20-insurer -> 19-insurer (regulatory
is a slug but not an insurer)
• rag/README.md L30 — 224 PDFs -> 206 PDFs
• README.md L15 — 224-document -> 206-document
• README.md L44 — 224 docs / 206 product / 20 insurers -> 206 / 188 / 19
• README.md L522-523 — 224 source PDFs / 206 across 20 -> 206 / 188 / 19
• README.md L547 — 224 markdown -> 222 markdown
• README.md L595 — section heading (224) -> (206)
• README.md L599 — Product PDFs 206 -> 188
• README.md L603 — Policy markdown sheets 224 -> 222
• README.md L884 — 206 product PDFs total -> 188 product PDFs total
• README.md L892 — regenerates 224 -> regenerates 222
• README.md L922 — Voyage blocks 224-PDF ingest -> 206-PDF
- CLAUDE.md +1 -1
- README.md +11 -11
- rag/README.md +1 -1
|
@@ -4,7 +4,7 @@ This file is read by Claude Code (and any compatible AI tool) at the start of a
|
|
| 4 |
|
| 5 |
## Project at a glance
|
| 6 |
|
| 7 |
-
- **What:** a voice-first AI advisor for Indian health insurance — RAG over a curated
|
| 8 |
- **Live:** https://rohitsar567-insurancebot.hf.space (HF Space; rebuild triggered on every push to `origin main`).
|
| 9 |
- **Repos:** `origin` is the HF Space at `huggingface.co/spaces/rohitsar567/InsuranceBot`. `github` is the mirror at `github.com/rohitsar567/insurance-sales-bot`. Data lives separately at `huggingface.co/datasets/rohitsar567/insurance-bot-data` (with a GitHub mirror that uses LFS).
|
| 10 |
- **Local dev path:** `~/Developer/Insurance Sales Bot/` (NOT `~/Documents/Personal/AI Work/...` — the older path that occasionally shows up in stale scripts; iCloud-synced + TCC-restricted).
|
|
|
|
| 4 |
|
| 5 |
## Project at a glance
|
| 6 |
|
| 7 |
+
- **What:** a voice-first AI advisor for Indian health insurance — RAG over a curated 206-document corpus (188 product PDFs across 19 insurers + 18 regulatory IRDAI/NHA docs, 7,295 chunks), Sarvam STT/TTS, 4-gate faithfulness, 19-insurer scorecard (regulatory tracked separately).
|
| 8 |
- **Live:** https://rohitsar567-insurancebot.hf.space (HF Space; rebuild triggered on every push to `origin main`).
|
| 9 |
- **Repos:** `origin` is the HF Space at `huggingface.co/spaces/rohitsar567/InsuranceBot`. `github` is the mirror at `github.com/rohitsar567/insurance-sales-bot`. Data lives separately at `huggingface.co/datasets/rohitsar567/insurance-bot-data` (with a GitHub mirror that uses LFS).
|
| 10 |
- **Local dev path:** `~/Developer/Insurance Sales Bot/` (NOT `~/Documents/Personal/AI Work/...` — the older path that occasionally shows up in stale scripts; iCloud-synced + TCC-restricted).
|
|
@@ -12,7 +12,7 @@ short_description: Voice-first AI advisor for Indian health insurance
|
|
| 12 |
|
| 13 |
# Insurance Sales Portfolio Expert
|
| 14 |
|
| 15 |
-
**A voice-first, BFSI-compliance-grade AI advisor for Indian health insurance.** Built as a Sarvam AI take-home, deployed on HuggingFace Spaces, with grounding, citations, faithfulness gates, and a curated
|
| 16 |
|
| 17 |
| | |
|
| 18 |
|---|---|
|
|
@@ -41,7 +41,7 @@ short_description: Voice-first AI advisor for Indian health insurance
|
|
| 41 |
|
| 42 |
## 1. Executive summary
|
| 43 |
|
| 44 |
-
A **voice-first health-insurance advisor** for Indian buyers, grounded in a curated corpus of **
|
| 45 |
|
| 46 |
The bot is **consumer-facing in experience, B2B in commercial application.** The realistic deployment is an insurer or aggregator white-labelling this advisor on top of Sarvam's ASR/TTS/LLM stack. The build deliberately optimises for the artifacts a BFSI buyer would audit: provenance, refusal behaviour, eval rigor, citation grammar.
|
| 47 |
|
|
@@ -519,8 +519,8 @@ The bot is two flows running together — the customer's experience and the tech
|
|
| 519 |
│
|
| 520 |
▼
|
| 521 |
┌─────────────────────────────────────────────────────────────────────────┐
|
| 522 |
-
│
|
| 523 |
-
│ ·
|
| 524 |
│ · 18 regulatory PDFs (IRDAI master circulars, Insurance Act, etc.) │
|
| 525 |
│ · Playwright same-origin fetch past Akamai for irdai.gov.in │
|
| 526 |
└─────────────────────────────────────────────────────────────────────────┘
|
|
@@ -544,7 +544,7 @@ The bot is two flows running together — the customer's experience and the tech
|
|
| 544 |
| **Scorecard** | `backend/scorecard.py` | Pure Python; 24 of 62 fields → 6 sub-scores → A–F |
|
| 545 |
| **Admin** | `backend/admin.py` | LLM health, chain reorder, force-fresh probe; IP-gated |
|
| 546 |
| **Eval** | `eval/` | Gold Q&A pipelines + the judge chain (Mistral Large 3 675B primary, different family from brain) grader |
|
| 547 |
-
| **Knowledge base** | `kb/` |
|
| 548 |
|
| 549 |
### 4.3 Model stack
|
| 550 |
|
|
@@ -592,15 +592,15 @@ Every D-NNN in the legacy decisions log is now a stand-alone ADR — see [`70-do
|
|
| 592 |
|
| 593 |
## 5. Data architecture
|
| 594 |
|
| 595 |
-
### 5.1 The corpus (
|
| 596 |
|
| 597 |
| Type | Count | Source | Notes |
|
| 598 |
|---|---|---|---|
|
| 599 |
-
| Product PDFs |
|
| 600 |
| Regulatory PDFs | 18 | irdai.gov.in, indiacode.nic.in, others | Playwright rescue past Akamai |
|
| 601 |
| Structured extractions (JSON) | 206 | fast-brain chain (Nemotron 30B / Qwen 80B / Groq Llama-3.3 fallback) extraction | 62-field Pydantic schema |
|
| 602 |
| Vector chunks (Chroma) | 7,295 | BGE-small @ 800/120 | One sqlite + HNSW binaries |
|
| 603 |
-
| Policy markdown sheets |
|
| 604 |
|
| 605 |
19 insurers: Acko, Aditya Birla, Bajaj Allianz, Care Health, Cholamandalam MS, Go Digit, HDFC ERGO, ICICI Lombard, IFFCO Tokio, ManipalCigna, National Insurance, New India Assurance, Niva Bupa, Oriental Insurance, Reliance General, Royal Sundaram, SBI General, Star Health, Tata AIG.
|
| 606 |
|
|
@@ -881,7 +881,7 @@ This section is written so a fresh **Claude Code** session pointed at an empty d
|
|
| 881 |
|
| 882 |
### 10.2 Build sequence
|
| 883 |
|
| 884 |
-
1. **Corpus acquisition** — use `tools/` agent crawl + Playwright fallback (see [ADR-017](70-docs/60-decisions/ADR-017-irdai-corpus-playwright-rescue.md)) to fetch 19 insurers' PDFs (
|
| 885 |
|
| 886 |
2. **Structured extraction** — `rag/extract.py` runs fast-brain chain (Nemotron 30B / Qwen 80B / Groq Llama-3.3 fallback) over each PDF with the 62-field Pydantic schema. Output to `rag/extracted/<policy_id>.json`.
|
| 887 |
|
|
@@ -889,7 +889,7 @@ This section is written so a fresh **Claude Code** session pointed at an empty d
|
|
| 889 |
|
| 890 |
4. **Data publish** — push `rag/corpus/`, `rag/extracted/`, `rag/vectors/` to HF Dataset `rohitsar567/insurance-bot-data`.
|
| 891 |
|
| 892 |
-
5. **Knowledge base regeneration** — `python -m rag.build_kb` regenerates
|
| 893 |
|
| 894 |
6. **Backend** — implement FastAPI app with the endpoints listed in §4.2. Key files: `backend/main.py`, `backend/orchestrator.py`, `backend/faithfulness.py`, `backend/persona.py`, `backend/translator.py`, `backend/translation_check.py`, `backend/profile_extractor.py`, `backend/profile_rag.py`, `backend/session_state.py`, `backend/scorecard.py`, `backend/admin.py`, `backend/providers/*`.
|
| 895 |
|
|
@@ -919,7 +919,7 @@ A new Claude Code session should ingest these to bootstrap understanding:
|
|
| 919 |
|---|---|---|
|
| 920 |
| IRDAI URLs return Akamai bot-challenge HTML | Initial corpus crawl | Playwright same-origin fetch (ADR-017) |
|
| 921 |
| Sarvam-M output cap 2048 tokens truncates JSON | Extraction phase | Use fast-brain chain (Nemotron 30B / Qwen 80B / Groq Llama-3.3 fallback) instead (ADR-019) |
|
| 922 |
-
| Voyage 3 RPM free-tier blocks
|
| 923 |
| Multiple LLM providers' free-tier limits collide on grader | Eval phase | Consolidate to NIM (ADR-019) |
|
| 924 |
| HF Space 1 GB cap rejects vector DB | Deploy phase | Split data to HF Dataset (ADR-020) |
|
| 925 |
| Chroma sqlite3 (157 MB) exceeds GitHub 100 MB per-file limit | GitHub mirror | Use Git LFS for the data repo (ADR-024) |
|
|
|
|
| 12 |
|
| 13 |
# Insurance Sales Portfolio Expert
|
| 14 |
|
| 15 |
+
**A voice-first, BFSI-compliance-grade AI advisor for Indian health insurance.** Built as a Sarvam AI take-home, deployed on HuggingFace Spaces, with grounding, citations, faithfulness gates, and a curated 206-document corpus.
|
| 16 |
|
| 17 |
| | |
|
| 18 |
|---|---|
|
|
|
|
| 41 |
|
| 42 |
## 1. Executive summary
|
| 43 |
|
| 44 |
+
A **voice-first health-insurance advisor** for Indian buyers, grounded in a curated corpus of **206 documents** — 188 product documents from 19 leading insurers plus 18 IRDAI / regulatory documents — extracted into a 62-field structured schema with a rules-based A–F scorecard and a **4-gate hallucination defense** on every reply.
|
| 45 |
|
| 46 |
The bot is **consumer-facing in experience, B2B in commercial application.** The realistic deployment is an insurer or aggregator white-labelling this advisor on top of Sarvam's ASR/TTS/LLM stack. The build deliberately optimises for the artifacts a BFSI buyer would audit: provenance, refusal behaviour, eval rigor, citation grammar.
|
| 47 |
|
|
|
|
| 519 |
│
|
| 520 |
▼
|
| 521 |
┌─────────────────────────────────────────────────────────────────────────┐
|
| 522 |
+
│ 206 source PDFs in HF Dataset rohitsar567/insurance-bot-data │
|
| 523 |
+
│ · 188 product PDFs across 19 insurers │
|
| 524 |
│ · 18 regulatory PDFs (IRDAI master circulars, Insurance Act, etc.) │
|
| 525 |
│ · Playwright same-origin fetch past Akamai for irdai.gov.in │
|
| 526 |
└─────────────────────────────────────────────────────────────────────────┘
|
|
|
|
| 544 |
| **Scorecard** | `backend/scorecard.py` | Pure Python; 24 of 62 fields → 6 sub-scores → A–F |
|
| 545 |
| **Admin** | `backend/admin.py` | LLM health, chain reorder, force-fresh probe; IP-gated |
|
| 546 |
| **Eval** | `eval/` | Gold Q&A pipelines + the judge chain (Mistral Large 3 675B primary, different family from brain) grader |
|
| 547 |
+
| **Knowledge base** | `kb/` | 222 markdown policy sheets + scorecard + reviews + premiums + audit trail |
|
| 548 |
|
| 549 |
### 4.3 Model stack
|
| 550 |
|
|
|
|
| 592 |
|
| 593 |
## 5. Data architecture
|
| 594 |
|
| 595 |
+
### 5.1 The corpus (206 documents)
|
| 596 |
|
| 597 |
| Type | Count | Source | Notes |
|
| 598 |
|---|---|---|---|
|
| 599 |
+
| Product PDFs | 188 | 19 insurers' public websites | Wordings + Brochures + CIS |
|
| 600 |
| Regulatory PDFs | 18 | irdai.gov.in, indiacode.nic.in, others | Playwright rescue past Akamai |
|
| 601 |
| Structured extractions (JSON) | 206 | fast-brain chain (Nemotron 30B / Qwen 80B / Groq Llama-3.3 fallback) extraction | 62-field Pydantic schema |
|
| 602 |
| Vector chunks (Chroma) | 7,295 | BGE-small @ 800/120 | One sqlite + HNSW binaries |
|
| 603 |
+
| Policy markdown sheets | 222 | Generated from extractions | One per policy_id in `kb/policies/` |
|
| 604 |
|
| 605 |
19 insurers: Acko, Aditya Birla, Bajaj Allianz, Care Health, Cholamandalam MS, Go Digit, HDFC ERGO, ICICI Lombard, IFFCO Tokio, ManipalCigna, National Insurance, New India Assurance, Niva Bupa, Oriental Insurance, Reliance General, Royal Sundaram, SBI General, Star Health, Tata AIG.
|
| 606 |
|
|
|
|
| 881 |
|
| 882 |
### 10.2 Build sequence
|
| 883 |
|
| 884 |
+
1. **Corpus acquisition** — use `tools/` agent crawl + Playwright fallback (see [ADR-017](70-docs/60-decisions/ADR-017-irdai-corpus-playwright-rescue.md)) to fetch 19 insurers' PDFs (188 product PDFs total) + 18 regulatory PDFs into `rag/corpus/`.
|
| 885 |
|
| 886 |
2. **Structured extraction** — `rag/extract.py` runs fast-brain chain (Nemotron 30B / Qwen 80B / Groq Llama-3.3 fallback) over each PDF with the 62-field Pydantic schema. Output to `rag/extracted/<policy_id>.json`.
|
| 887 |
|
|
|
|
| 889 |
|
| 890 |
4. **Data publish** — push `rag/corpus/`, `rag/extracted/`, `rag/vectors/` to HF Dataset `rohitsar567/insurance-bot-data`.
|
| 891 |
|
| 892 |
+
5. **Knowledge base regeneration** — `python -m rag.build_kb` regenerates 222 markdown sheets in `kb/policies/` from extracted JSONs.
|
| 893 |
|
| 894 |
6. **Backend** — implement FastAPI app with the endpoints listed in §4.2. Key files: `backend/main.py`, `backend/orchestrator.py`, `backend/faithfulness.py`, `backend/persona.py`, `backend/translator.py`, `backend/translation_check.py`, `backend/profile_extractor.py`, `backend/profile_rag.py`, `backend/session_state.py`, `backend/scorecard.py`, `backend/admin.py`, `backend/providers/*`.
|
| 895 |
|
|
|
|
| 919 |
|---|---|---|
|
| 920 |
| IRDAI URLs return Akamai bot-challenge HTML | Initial corpus crawl | Playwright same-origin fetch (ADR-017) |
|
| 921 |
| Sarvam-M output cap 2048 tokens truncates JSON | Extraction phase | Use fast-brain chain (Nemotron 30B / Qwen 80B / Groq Llama-3.3 fallback) instead (ADR-019) |
|
| 922 |
+
| Voyage 3 RPM free-tier blocks 206-PDF ingest | Embedding phase | Switch to local BGE-small (ADR-011) |
|
| 923 |
| Multiple LLM providers' free-tier limits collide on grader | Eval phase | Consolidate to NIM (ADR-019) |
|
| 924 |
| HF Space 1 GB cap rejects vector DB | Deploy phase | Split data to HF Dataset (ADR-020) |
|
| 925 |
| Chroma sqlite3 (157 MB) exceeds GitHub 100 MB per-file limit | GitHub mirror | Use Git LFS for the data repo (ADR-024) |
|
|
@@ -27,7 +27,7 @@ Lineage for every artefact below is documented in [`kb/AUDIT_TRAIL.md`](../kb/AU
|
|
| 27 |
|
| 28 |
| Path | Source of truth | Notes |
|
| 29 |
| --- | --- | --- |
|
| 30 |
-
| `rag/corpus/<insurer>/*.pdf` | insurer CDNs |
|
| 31 |
| `rag/extracted/<policy_id>.json` | `extract.py` | 206 JSONs, one per policy, conforming to `schema.HealthPolicy`. Generated; never hand-edit. |
|
| 32 |
| `rag/vectors/chroma.sqlite3` + HNSW binaries | `ingest.py` | Persistent Chroma store. Symlinked to `rag/_hf_dataset_backup/rag/vectors/` for the offline canonical copy. |
|
| 33 |
| `rag/policies.duckdb` | `extract.py` | DuckDB rollup of the 62-field JSONs; used for SQL-style filters in `backend/main.py`. |
|
|
|
|
| 27 |
|
| 28 |
| Path | Source of truth | Notes |
|
| 29 |
| --- | --- | --- |
|
| 30 |
+
| `rag/corpus/<insurer>/*.pdf` | insurer CDNs | 206 PDFs (188 product PDFs across 19 insurers + 18 regulatory IRDAI/NHA docs). Not in git — hydrated at Docker build from the companion HF dataset. |
|
| 31 |
| `rag/extracted/<policy_id>.json` | `extract.py` | 206 JSONs, one per policy, conforming to `schema.HealthPolicy`. Generated; never hand-edit. |
|
| 32 |
| `rag/vectors/chroma.sqlite3` + HNSW binaries | `ingest.py` | Persistent Chroma store. Symlinked to `rag/_hf_dataset_backup/rag/vectors/` for the offline canonical copy. |
|
| 33 |
| `rag/policies.duckdb` | `extract.py` | DuckDB rollup of the 62-field JSONs; used for SQL-style filters in `backend/main.py`. |
|