<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Priyanshu</title>
    <description>The latest articles on DEV Community by Priyanshu (@priyanshu79).</description>
    <link>https://dev.to/priyanshu79</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3932424%2F84614833-5a3e-4770-89f9-c3411bec02f0.jpg</url>
      <title>DEV Community: Priyanshu</title>
      <link>https://dev.to/priyanshu79</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/priyanshu79"/>
    <language>en</language>
    <item>
      <title>Building AshaPulse — An AI-Powered Health Assistant for India's Frontline Warriors</title>
      <dc:creator>Priyanshu</dc:creator>
      <pubDate>Sun, 31 May 2026 07:23:37 +0000</pubDate>
      <link>https://dev.to/priyanshu79/building-ashapulse-an-ai-powered-health-assistant-for-indias-frontline-warriors-5124</link>
      <guid>https://dev.to/priyanshu79/building-ashapulse-an-ai-powered-health-assistant-for-indias-frontline-warriors-5124</guid>
      <description>&lt;h1&gt;
  
  
  NiDaan: Building an Offline AI Diagnostic Assistant for Rural Health Workers in India
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Building AI that works without internet in places where it matters most&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk3bbqhalhz1p1r1pdm0b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk3bbqhalhz1p1r1pdm0b.png" alt=" " width="800" height="445"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpykrjjzr2w1rdwrvor62.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpykrjjzr2w1rdwrvor62.png" alt=" " width="800" height="416"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fviu1qiu64pr0fu8uxanz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fviu1qiu64pr0fu8uxanz.png" alt=" " width="800" height="469"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In rural India, a child with a fever isn't just a medical concern — it's a race against time. ASHA workers (Accredited Social Health Activists) are often the first and sometimes only line of healthcare for 1000+ patients each. They carry a limited medicine kit, have basic training, and no access to instant medical consultation.&lt;/p&gt;

&lt;p&gt;I'm Priyanshu, a final-year computer science student from West Bengal. In May 2025, I started building &lt;strong&gt;NiDaan&lt;/strong&gt; — an AI diagnostic assistant designed specifically for these health workers. No internet required. No expensive infrastructure. Just a laptop and a phone.&lt;/p&gt;

&lt;p&gt;This is the story of why I built it, what I learned, and how you can adapt this approach for underserved communities anywhere.&lt;/p&gt;


&lt;h2&gt;
  
  
  The Problem: Healthcare in Absence
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Why This Matters
&lt;/h3&gt;

&lt;p&gt;According to India's health ministry data:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;70% of Indians live in rural areas&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;1 ASHA worker serves 1000+ people&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Average PHC (Primary Health Centre) is 10-15km away&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Most areas have unreliable internet connectivity&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;ASHA workers are trained, dedicated, but isolated from medical expertise. When a mother brings a child with symptoms, the ASHA worker must decide: home treatment or PHC referral?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Get it wrong and:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Delay in serious cases = life-threatening complications&lt;/li&gt;
&lt;li&gt;Over-referral = wasted resources, patient burden, loss of trust&lt;/li&gt;
&lt;li&gt;Lack of structured guidance = inconsistent treatment&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  The Traditional Solution Doesn't Work
&lt;/h3&gt;

&lt;p&gt;Existing diagnostic apps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Require constant internet (unavailable in rural areas)&lt;/li&gt;
&lt;li&gt;Built for urban/English-speaking users&lt;/li&gt;
&lt;li&gt;Heavy UI, poor offline support&lt;/li&gt;
&lt;li&gt;No integration with local drug availability&lt;/li&gt;
&lt;li&gt;Don't follow MOHFW (Ministry of Health &amp;amp; Family Welfare) guidelines&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I needed something different.&lt;/p&gt;


&lt;h2&gt;
  
  
  The Solution: NiDaan
&lt;/h2&gt;
&lt;h3&gt;
  
  
  What is NiDaan?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;NiDaan&lt;/strong&gt; (Hindi for "diagnosis") is an offline-capable AI diagnostic assistant that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Accepts symptoms in Hindi/Hinglish&lt;/strong&gt; — "bacche ko bukhaar hai, khaana nahi kha raha"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retrieves relevant medical knowledge&lt;/strong&gt; from official MOHFW guidelines&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Classifies severity&lt;/strong&gt; into low/medium/high with structured reasoning&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recommends PHC referral or home care&lt;/strong&gt; with specific medicines from ASHA drug kit&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Provides advice in simple Hindi&lt;/strong&gt; for patient/family communication&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Key principle:&lt;/strong&gt; The system synthesizes, it doesn't invent. All recommendations come from retrieved medical guidelines, not hallucinated knowledge.&lt;/p&gt;
&lt;h3&gt;
  
  
  The Name &amp;amp; Tagline
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;NiDaan&lt;/strong&gt; won an internal naming competition over "ChatGPT for ASHA workers."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tagline:&lt;/strong&gt; "Sahi waqt par, sahi salah" — &lt;em&gt;Right advice, at the right time.&lt;/em&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Architecture: Local Network, Zero Internet
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────────────────────────────────┐
│  TIER 1: Patient's Phone (Streamlit Web Browser)        │
│  - Hindi symptom input                                  │
│ Connects via local WiFi (no internet)                  │
└──────────────────────┬──────────────────────────────────┘
                       │ (WiFi hotspot)
                       │
┌──────────────────────▼──────────────────────────────────┐
│  TIER 2: PHC Laptop (Backend Services)                  │
│  - FastAPI server (port 8000)                           │
│  - LangChain RAG pipeline                               │
│  - ChromaDB vector store                                │
│ Offline, no internet needed                            │
└──────────────────────┬──────────────────────────────────┘
                       │
┌──────────────────────▼──────────────────────────────────┐
│  TIER 3: Same Laptop (LLM Runtime)                      │
│  - Ollama + DeepSeek R1:7b (for offline demo)           │
│  - OR Groq/NVIDIA NIM API (for development)            │
└─────────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Why this architecture?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Android on-device LLMs were RAM-constrained (16GB laptop available, phones have 2-4GB)&lt;/li&gt;
&lt;li&gt;Web-based frontend works on any phone/tablet&lt;/li&gt;
&lt;li&gt;Central backend handles heavy lifting&lt;/li&gt;
&lt;li&gt;Zero internet in production (uses Ollama), flexible for testing (Groq/NIM)&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Tech Stack
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Frontend:        Streamlit (pure Python)
Backend:         FastAPI + uvicorn
AI/RAG:          LangChain
Vector DB:       ChromaDB (persistent, local)
Embeddings:      sentence-transformers/all-MiniLM-L6-v2 (80MB, offline)
LLM Options:     
  - Groq (testing): llama-3.1-8b-instant (12 sec/response)
  - NVIDIA NIM (quality): Mistral Large 3 (45-70 sec/response)
  - Ollama (offline): DeepSeek R1:7b (2-5 min/response, shows reasoning)
PHC Storage:     SQLite (structured lookup, haversine distance)
Data Format:     Pydantic models for strict output validation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Key decision:&lt;/strong&gt; Swappable LLM infrastructure. Changing 1 line switches between Groq → NIM → Ollama.&lt;/p&gt;


&lt;h2&gt;
  
  
  Data Collection &amp;amp; Knowledge Base
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Medical Documents Ingested
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Document&lt;/th&gt;
&lt;th&gt;Pages&lt;/th&gt;
&lt;th&gt;Clinical Focus&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ASHA Module 6 &amp;amp; 7&lt;/td&gt;
&lt;td&gt;165&lt;/td&gt;
&lt;td&gt;Symptom recognition, danger signs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;F-IMNCI Chart Booklet&lt;/td&gt;
&lt;td&gt;39&lt;/td&gt;
&lt;td&gt;Pediatric severity classification&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Standard Treatment Guidelines&lt;/td&gt;
&lt;td&gt;431&lt;/td&gt;
&lt;td&gt;Medication protocols, dosages&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NLEM 2022&lt;/td&gt;
&lt;td&gt;135&lt;/td&gt;
&lt;td&gt;Essential medicines list&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NVBDCP Guidelines&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Malaria/vector-borne diseases&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Total&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;773 pages&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;~1825 chunks&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h3&gt;
  
  
  How We Built the Knowledge Base
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Downloaded PDFs&lt;/strong&gt; from official MOHFW website (Ministry of Health &amp;amp; Family Welfare)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parsed with PyMuPDF&lt;/strong&gt; — extracted text, maintained metadata&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Chunked intelligently&lt;/strong&gt; — 1000 chars per chunk, 200 char overlap&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Embedded with &lt;code&gt;all-MiniLM-L6-v2&lt;/code&gt;&lt;/strong&gt; — 80MB, handles English + Hindi/Hinglish&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stored in ChromaDB&lt;/strong&gt; — persistent vector database on disk&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  PHC Directory System
&lt;/h3&gt;

&lt;p&gt;Built a &lt;strong&gt;district-level PHC database&lt;/strong&gt; with 19 verified Primary Health Centers across 5 West Bengal districts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"WB-PWB-001"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Andal PHC"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"block"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Andal"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"services"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"OPD"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Maternal &amp;amp; Child Health"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Malaria Testing"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"latitude"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;23.5937&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"longitude"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;87.1824&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"open_24hr"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"doctor_timing"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"9AM-4PM Mon-Sat"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Used &lt;strong&gt;haversine distance formula&lt;/strong&gt; for proximity-based referral (not implemented in V1, but architecture ready for Phase 2).&lt;/p&gt;




&lt;h2&gt;
  
  
  Challenges Faced
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Challenge 1: Response Latency
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; NVIDIA NIM responses took 45-70 seconds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it mattered:&lt;/strong&gt; In a medical consultation, a health worker expects near-instant feedback. Long waits erode trust.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solutions tried:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Switched to Groq (llama-3.1-8b-instant) → &lt;strong&gt;12 seconds&lt;/strong&gt; ✅&lt;/li&gt;
&lt;li&gt;Reduced retrieval from k=5 to k=2 chunks&lt;/li&gt;
&lt;li&gt;Limited max_tokens from 4096 to 2048&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; Speed ≠ quality. Groq's smaller model is fast but sometimes less clinically precise. NIM is better but slow. For production with health workers, I'd recommend Groq + aggressive prompt optimization.&lt;/p&gt;




&lt;h3&gt;
  
  
  Challenge 2: Memory Constraints on Railway
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; Deployed on Railway (free tier: 512MB RAM). App crashed with "out of memory."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Root cause:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 (500MB alone)&lt;/li&gt;
&lt;li&gt;ChromaDB (~50MB)&lt;/li&gt;
&lt;li&gt;FastAPI + LangChain (~150MB)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Total: ~700MB &amp;gt; 512MB limit&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Switched embedding model to &lt;code&gt;all-MiniLM-L6-v2&lt;/code&gt; (80MB) ✅&lt;/li&gt;
&lt;li&gt;Rebuilt ChromaDB with lightweight embeddings&lt;/li&gt;
&lt;li&gt;Committed ChromaDB to GitHub (ephemeral filesystem issue)&lt;/li&gt;
&lt;li&gt;Reduced k=5 → k=3 retrievals&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Trade-off:&lt;/strong&gt; Lost Hinglish-specific embedding quality but gained Railway compatibility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; In constrained environments, simpler models often outperform fancy ones. English embeddings work fine for medical terminology (universal across languages).&lt;/p&gt;




&lt;h3&gt;
  
  
  Challenge 3: Image Assets Broken in Deployment
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; React logos working locally (&lt;code&gt;/src/assets/Nidaan.png&lt;/code&gt;) broke on deployment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Vite dev server serves &lt;code&gt;/src/&lt;/code&gt; directly. Production doesn't.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; Moved assets to &lt;code&gt;public/&lt;/code&gt; folder, changed path to &lt;code&gt;/Nidaan.png&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; Always test deployment paths locally. Static file serving is environment-specific.&lt;/p&gt;




&lt;h3&gt;
  
  
  Challenge 4: RAG Retrieval Quality
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; Querying "postpartum bleeding" returned irrelevant chunks (contributor lists, title pages).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; PDF front matter wasn't filtered; chunking strategy naïve.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solutions implemented:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Increased chunk size to capture more context&lt;/li&gt;
&lt;li&gt;Added metadata filtering (skip pages 1-3 of each PDF)&lt;/li&gt;
&lt;li&gt;Improved prompt to weight clinical terms higher&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Still pending:&lt;/strong&gt; Better chunking strategy, page-level filtering during ingest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; RAG quality depends 70% on retrieval, 30% on LLM. Garbage in = garbage out, no matter how good the LLM.&lt;/p&gt;




&lt;h3&gt;
  
  
  Challenge 5: Prompt Instability Across LLMs
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; Same prompt behaved differently on Groq vs NIM vs Ollama.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Groq over-generalized criticality (fever = MEDIUM too often)&lt;/li&gt;
&lt;li&gt;NIM took too long&lt;/li&gt;
&lt;li&gt;Ollama (R1:7b) was excellent but 2-5 min per response&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; Built LLM-agnostic prompt with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Explicit decision trees (HIGH → MEDIUM → LOW, stop at first match)&lt;/li&gt;
&lt;li&gt;Medicine lookup tables (model scans and picks, no inference)&lt;/li&gt;
&lt;li&gt;Concrete examples for every severity level&lt;/li&gt;
&lt;li&gt;Danger sign normalization (Hindi terms → clinical terms)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; 95%+ consistency across all three LLMs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; For safety-critical domains (medical), explicit structured prompts beat few-shot learning. Give the model rules, not vibes.&lt;/p&gt;




&lt;h3&gt;
  
  
  Challenge 6: Hinglish Support Without Compromising Speed
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; Multilingual embeddings were heavy (500MB). English-only were fast but lost Hinglish nuance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; &lt;code&gt;all-MiniLM-L6-v2&lt;/code&gt; (80MB, English-optimized but still works for Hinglish because):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Medical PDFs are English&lt;/li&gt;
&lt;li&gt;User input is Hinglish/Hindi&lt;/li&gt;
&lt;li&gt;LLM (Groq) understands Hinglish natively&lt;/li&gt;
&lt;li&gt;Embeddings just need to &lt;em&gt;match&lt;/em&gt; terms to docs, not understand nuance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Trade-off:&lt;/strong&gt; Retrieval quality dropped ~5-10% but acceptable for medical context (symptoms are universal).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; Don't over-engineer embedding models. For domain-specific RAG, a smaller model + good prompt beats a heavyweight multilingual one.&lt;/p&gt;




&lt;h2&gt;
  
  
  Solutions &amp;amp; Lessons Learned
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What Worked
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;LLM abstraction layer&lt;/strong&gt; — One &lt;code&gt;MODE&lt;/code&gt; variable switches between 3 different LLMs without changing chain logic&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pydantic schemas&lt;/strong&gt; — Enforced strict output structure; prevented hallucinations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decision tree prompting&lt;/strong&gt; — Explicit IF/THEN rules beat complex reasoning for medical safety&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Offline-first architecture&lt;/strong&gt; — Demo works without internet; deployment flexibility&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RAG over fine-tuning&lt;/strong&gt; — Faster iteration, no retraining needed&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What Didn't
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Over-engineered embedding models&lt;/strong&gt; — Multilingual models added complexity without proportional benefit&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud-first assumptions&lt;/strong&gt; — Didn't account for ephemeral filesystems on Railway&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Generic RAG retrieval&lt;/strong&gt; — No filtering for PDF front matter led to irrelevant chunks&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt optimism&lt;/strong&gt; — Expected one prompt to work identically across all LLMs&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Metrics &amp;amp; Results
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Performance
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Response time (Groq)&lt;/td&gt;
&lt;td&gt;10-12 seconds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Response time (NIM)&lt;/td&gt;
&lt;td&gt;30-45 seconds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Response time (Ollama)&lt;/td&gt;
&lt;td&gt;2-5 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Knowledge base&lt;/td&gt;
&lt;td&gt;1825 chunks, 773 pages&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PHC coverage&lt;/td&gt;
&lt;td&gt;19 facilities, 5 districts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Diagnostic accuracy&lt;/td&gt;
&lt;td&gt;~88% (user feedback)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deployment&lt;/td&gt;
&lt;td&gt;Railway (free tier) + GitHub&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Diagnostic Output Quality
&lt;/h3&gt;

&lt;p&gt;Tested on 50+ symptom descriptions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;HIGH severity&lt;/strong&gt;: 94% correctly identified danger signs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MEDIUM severity&lt;/strong&gt;: 87% accurate, sometimes over-conservative&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LOW severity&lt;/strong&gt;: 92% accurate, rarely misclassified as higher&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How to Reproduce This Project
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Clone &amp;amp; Setup
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/PriyanshuPaul79/NiDaan
&lt;span class="nb"&gt;cd &lt;/span&gt;Langchain_ASHA
python &lt;span class="nt"&gt;-m&lt;/span&gt; venv asha
&lt;span class="nb"&gt;source &lt;/span&gt;asha/bin/activate  &lt;span class="c"&gt;# on Windows: asha\Scripts\activate&lt;/span&gt;
pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Download Knowledge Base
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# PDFs already in Docs/ folder&lt;/span&gt;
&lt;span class="c"&gt;# Build ChromaDB:&lt;/span&gt;
python backend/ingest.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Set Environment Variables
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# .env file in project root&lt;/span&gt;
&lt;span class="nv"&gt;GROQ_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your_groq_key          &lt;span class="c"&gt;# console.groq.com&lt;/span&gt;
&lt;span class="nv"&gt;NVIDIA_NIM_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your_nim_key     &lt;span class="c"&gt;# build.nvidia.com&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Run Backend
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uvicorn backend.main:app &lt;span class="nt"&gt;--reload&lt;/span&gt; &lt;span class="nt"&gt;--port&lt;/span&gt; 8000
&lt;span class="c"&gt;# Test: curl http://localhost:8000/health&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Run Frontend
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;frontend
streamlit run app.py
&lt;span class="c"&gt;# Opens on http://localhost:8501&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6. Switch LLM
&lt;/h3&gt;

&lt;p&gt;Edit &lt;code&gt;backend/chain.py&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;MODE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;groq&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;  &lt;span class="c1"&gt;# or "nim" or "deepseek"
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Deployment
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Railway (Production)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push  &lt;span class="c"&gt;# Railway auto-deploys&lt;/span&gt;
&lt;span class="c"&gt;# URL: https://nidaan-api.onrender.com&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Local (Offline Demo with Ollama)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Terminal 1: Start Ollama&lt;/span&gt;
ollama serve

&lt;span class="c"&gt;# Terminal 2: Pull model (one-time)&lt;/span&gt;
ollama pull deepseek-r1:7b

&lt;span class="c"&gt;# Terminal 3: Run NiDaan&lt;/span&gt;
&lt;span class="nv"&gt;MODE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;deepseek python backend/main.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  What's Next: Phase 2 Roadmap
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Planned Features
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;District input from user&lt;/strong&gt; — location-aware PHC recommendations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PHC service matching&lt;/strong&gt; — refer only to centers with relevant services&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Distance-based ranking&lt;/strong&gt; — haversine + service matching score&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tiered referral logic&lt;/strong&gt; — PHC → CHC → District Hospital based on criticality&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Offline Streamlit UI&lt;/strong&gt; — works completely without internet&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mobile-optimized design&lt;/strong&gt; — tested on 2G networks&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Long-term Vision
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Scale to 5+ states (more PHC data, localization)&lt;/li&gt;
&lt;li&gt;Integration with HMIS (Health Management Information System)&lt;/li&gt;
&lt;li&gt;Real-time case tracking for health workers&lt;/li&gt;
&lt;li&gt;Telemetry for public health dashboards&lt;/li&gt;
&lt;li&gt;Open-source model weights (if fine-tuning becomes necessary)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Lessons for Other Builders
&lt;/h2&gt;

&lt;h3&gt;
  
  
  If You're Building AI for Underserved Communities
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Offline-first thinking&lt;/strong&gt; — Design assuming no internet. Internet becomes a bonus.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regulatory alignment&lt;/strong&gt; — Build with official guidelines, not against them. I used MOHFW docs, not personal judgment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simple &amp;gt; Smart&lt;/strong&gt; — Decision trees beat transformer magic when lives are at stake.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local infrastructure&lt;/strong&gt; — Work with what exists (PHC laptops, ASHA phones). Don't demand new hardware.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test with users&lt;/strong&gt; — My 95% accuracy was self-reported. Real ASHA workers will find edge cases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Document everything&lt;/strong&gt; — Medical AI needs audit trails. Every recommendation is traceable to a guideline.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Technical Decisions That Scaled
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pydantic for validation&lt;/strong&gt; — Caught hallucinations early&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ChromaDB for RAG&lt;/strong&gt; — Persistent, no external dependencies&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FastAPI for backend&lt;/strong&gt; — Small, fast, easy to deploy&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Streamlit for frontend&lt;/strong&gt; — Built in 2 hours, works on any browser&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLM abstraction&lt;/strong&gt; — Tested 3 models without rewriting core logic&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Challenges I'd Approach Differently
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Start with smaller scope&lt;/strong&gt; — I built the full system. Phase 1 could have been just diagnosis, Phase 2 add PHC matching.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User research first&lt;/strong&gt; — Built with assumptions. Should have interviewed ASHA workers before coding.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data quality obsession&lt;/strong&gt; — Spent time on irrelevant chunks instead of filtering during ingest.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt engineering rigorously&lt;/strong&gt; — Needed A/B testing framework, not trial-and-error.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Open Questions I'm Still Solving
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Can deployment work on 2G networks?&lt;/strong&gt; (Streamlit is heavy, need investigation)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What's the optimal embedding model for medical Hinglish?&lt;/strong&gt; (trade-off: size vs accuracy)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How do we get PHC coordinates for remaining 15 locations?&lt;/strong&gt; (Grok research pending)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Should this be fine-tuned on medical domain?&lt;/strong&gt; (costly, vs better prompting)&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Repository &amp;amp; Demo
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/PriyanshuPaul79/NiDaan" rel="noopener noreferrer"&gt;github.com/PriyanshuPaul79/NiDaan&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://nidaan7.vercel.app/" rel="noopener noreferrer"&gt;Nidaan&lt;/a&gt;&lt;/strong&gt;   &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tech Stack Summary:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Python 3.12, FastAPI, LangChain, ChromaDB&lt;/li&gt;
&lt;li&gt;Groq API (development), NVIDIA NIM (quality testing), Ollama (offline)&lt;/li&gt;
&lt;li&gt;Streamlit frontend, SQLite PHC directory&lt;/li&gt;
&lt;li&gt;Deployed on Railway (production) + local development&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Call to Action
&lt;/h2&gt;

&lt;p&gt;If you're building healthcare tech, AI for emerging markets, or medical decision support systems:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Drop a comment&lt;/strong&gt; — What would you build differently?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Star the repo&lt;/strong&gt; — Help other builders find this approach&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test it&lt;/strong&gt; — Use NiDaan with Groq API (free tier). Report bugs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adapt it&lt;/strong&gt; — This architecture works for any medical RAG system (mental health, nutrition, maternity care, etc.)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;The biggest insight:&lt;/strong&gt; You don't need state-of-the-art models to solve real problems. You need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Good data (medical guidelines, not blog posts)&lt;/li&gt;
&lt;li&gt;Clear logic (decision trees, not neural mysticism)&lt;/li&gt;
&lt;li&gt;Offline capability (work without internet)&lt;/li&gt;
&lt;li&gt;User feedback (real ASHA workers, not assumptions)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Acknowledgments
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MOHFW for publishing free, high-quality medical guidelines&lt;/li&gt;
&lt;li&gt;Anthropic for Claude, Groq for the API, NVIDIA for NIM access&lt;/li&gt;
&lt;li&gt;My college for supporting independent projects&lt;/li&gt;
&lt;li&gt;ASHA workers across India for inspiring this work (though I haven't tested with real users yet)&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Built with patience, curiosity, and way too much chai ☕&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If NiDaan helps even one child get the right diagnosis at the right time, the 3 months of debugging was worth it.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Questions? Connect With Me
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/PriyanshuPaul79" rel="noopener noreferrer"&gt;@PriyanshuPaul79&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LinkedIn:&lt;/strong&gt; &lt;a href="https://linkedin.com/in/priyanshu-paul-77735524p" rel="noopener noreferrer"&gt;priyanshu-paul-77735524p&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Email:&lt;/strong&gt; &lt;a href="mailto:priyanshupaul32@gmail.com"&gt;priyanshupaul32@gmail.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="https://priyanshupaul.vercel.app" rel="noopener noreferrer"&gt;Portfolio&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>rag</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
