<?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.us-east-2.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>Why Groq Feels Like Cheating</title>
      <dc:creator>Priyanshu</dc:creator>
      <pubDate>Tue, 23 Jun 2026 06:44:52 +0000</pubDate>
      <link>https://dev.to/priyanshu79/why-groq-feels-like-cheating-29hm</link>
      <guid>https://dev.to/priyanshu79/why-groq-feels-like-cheating-29hm</guid>
      <description>&lt;p&gt;I've been building a multi-agent LangGraph pipeline recently, and like most people stitching together free-tier LLM providers, I ended up comparing Groq against the usual suspects. The difference wasn't subtle. Other providers felt like a normal API call — you send a request, you wait, text streams back at a pace you've gotten used to. Groq felt like cheating. A 70B-parameter model returning a full response faster than I could finish reading the prompt I'd just typed.&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9co95x02r8o0k9lku3nj.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9co95x02r8o0k9lku3nj.png" alt=" " width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My first assumption was the boring one: Groq must just have better GPUs, or more of them, or some clever load balancing trick. That assumption is wrong, and the actual answer is a lot more interesting than "more compute."&lt;/p&gt;

&lt;p&gt;Groq doesn't run GPUs at all. They built their own chip from scratch, called the LPU — Language Processing Unit — and the entire thing exists because of a bet that the way GPUs are designed is fundamentally mismatched to what LLM inference actually needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  The wrong intuition: "just better hardware"
&lt;/h2&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F92172ashaqj7dlpnri4e.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F92172ashaqj7dlpnri4e.png" alt=" " width="800" height="140"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's worth sitting with why "better GPUs" feels like the obvious answer. Every AI performance story for the last five years has been a GPU story — bigger clusters, more H100s, better interconnects. Nvidia's dominance is so total that "AI chip" and "GPU" have basically become synonymous in casual conversation.&lt;/p&gt;

&lt;p&gt;But GPUs were never actually designed for this job. They were designed for graphics rendering, then repurposed for deep learning because their parallel architecture happened to suit matrix multiplication well — which is most of what neural networks are made of. That repurposing worked brilliantly for training, where you're crunching enormous batches of data and raw parallel throughput is what matters.&lt;/p&gt;

&lt;p&gt;Inference, especially single-request, real-time token generation, is a different problem. And it turns out GPUs carry a lot of training-oriented baggage that actively works against them here.&lt;/p&gt;

&lt;h2&gt;
  
  
  The actual bottleneck: the memory wall
&lt;/h2&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fauuifyenvr7rvslhdxsj.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fauuifyenvr7rvslhdxsj.png" alt=" " width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The real constraint in LLM inference isn't how many calculations a chip can do — it's how fast it can feed those calculations with data. This is sometimes called the "memory wall," and it's the whole reason Groq's architecture exists.&lt;/p&gt;

&lt;p&gt;On a standard GPU, model weights live in HBM — High Bandwidth Memory — which sits physically separate from the compute cores, on its own memory stack. HBM is fast compared to a hard drive, but it's still a clear hop away from where the actual math happens. Every time the chip needs a weight, it has to reach across that gap. During training, with massive batch sizes, that overhead gets amortized away. During single-request inference, where you're generating one token at a time, the compute units spend a huge fraction of their time just waiting on data to arrive.&lt;/p&gt;

&lt;p&gt;Groq's answer was almost stubbornly simple: stop putting memory off-chip. The LPU uses SRAM — the same type of memory normally reserved for tiny CPU caches — as its &lt;em&gt;primary&lt;/em&gt; weight storage, not a cache layer sitting in front of slower memory. Hundreds of megabytes of it, sitting directly on the compute die.&lt;/p&gt;

&lt;p&gt;The bandwidth difference this produces is enormous. Groq's on-chip SRAM delivers memory bandwidth upwards of 80 terabytes per second, compared to roughly 8 terabytes per second for GPU off-chip HBM — about a 10x gap before you even account for anything else. Independent teardowns put the access-speed advantage of SRAM over HBM at roughly 20x once you factor in latency, not just raw bandwidth.&lt;/p&gt;

&lt;h2&gt;
  
  
  The second piece: throwing out unpredictability
&lt;/h2&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsekdyj15j64u4rkysjgd.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsekdyj15j64u4rkysjgd.png" alt=" " width="642" height="1114"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Memory bandwidth alone doesn't fully explain Groq's numbers. The other half of the story is determinism, and it's the part that took me longer to actually appreciate.&lt;/p&gt;

&lt;p&gt;GPUs are general-purpose chips, which means they rely on dynamic, runtime scheduling — hardware queues, cache hit/miss decisions, arbitration between competing tasks — all figured out on the fly, while the chip is running. That flexibility is a feature for the huge range of workloads a GPU has to support. But it has a cost: the timing of any given operation isn't fully knowable in advance, and when hundreds of cores need to synchronize, any delay in one place propagates through the whole system.&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fab6jzj34ufqhvlv65yt3.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fab6jzj34ufqhvlv65yt3.png" alt=" " width="568" height="1400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Groq's compiler takes the opposite approach. Because the LPU's architecture has no caches, no dynamic memory allocation, and no runtime scheduling decisions to make, the entire execution graph — every operation, every instruction, every chip-to-chip handoff — can be calculated &lt;em&gt;ahead of time&lt;/em&gt;, down to individual clock cycles. The chip isn't deciding what to do next while it runs; it's executing a schedule that was already fully solved before a single token was generated.&lt;/p&gt;

&lt;p&gt;This sounds like it should just be "less flexible," and it is — but for a workload as repetitive and predictable as transformer inference, that traded-away flexibility buys you the removal of almost all the overhead that makes GPU inference timing fuzzy. Groq's own engineering material describes this as a software-first design philosophy: rather than adapting a chip built for something else, they built hardware specifically to make the compiler's job of scheduling deterministic and complete.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this actually buys you, in real numbers
&lt;/h2&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fainqu7jg8d9rc8ii2kzz.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fainqu7jg8d9rc8ii2kzz.png" alt=" " width="800" height="563"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The architecture story is nice, but the numbers are what make it land. Independent benchmarking has shown Llama 2 70B running at around 300 tokens per second on Groq, versus 30–40 tokens per second on an Nvidia H100 — roughly a 10x difference. For a smaller model like Llama 3 8B, Groq has demonstrated 1,300+ tokens per second against roughly 100 tokens per second on an H100.&lt;/p&gt;

&lt;p&gt;There's also a counterintuitive energy story here. You'd expect a chip doing the same work faster to use more power in the moment, and it does — but it spends so much less &lt;em&gt;time&lt;/em&gt; doing the work that the total energy cost per token actually comes out lower. Groq reports something in the range of 1–3 joules per token, compared to 10–30 joules per token on H100-based systems. Less data movement (the expensive part, energetically) plus less total time in a high-power active state nets out to a real efficiency win, not just a speed one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The catch — because there's always a catch
&lt;/h2&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3k54pdpj0j15u819p6yg.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3k54pdpj0j15u819p6yg.png" alt=" " width="795" height="55"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;None of this is free, and the tradeoffs are exactly where the SRAM decision bites back.&lt;/p&gt;

&lt;p&gt;SRAM is fast, but it's also physically large and expensive per bit compared to HBM or DRAM — that's precisely why every other chip in the industry only uses it for tiny cache layers instead of primary storage. Groq's bet means each individual LPU can only hold a relatively small amount of memory on-chip. A 70B-parameter model doesn't fit on one chip; it doesn't really fit on a handful of chips either. Serving something that size at scale reportedly requires hundreds of LPUs working in close coordination, wired together with a custom high-speed interconnect Groq calls a plesiosynchronous protocol, designed specifically so chip-to-chip communication stays just as deterministic as everything happening inside a single chip.&lt;/p&gt;

&lt;p&gt;That's a lot of physical silicon for one model, and it shows up directly in the economics: estimates put Groq's hardware cost meaningfully higher than an equivalent-throughput GPU setup, chip-for-chip. Groq's bet is that for latency-critical workloads, this is the right trade to make — when an application genuinely needs sub-300ms response times, the comparison isn't "Groq versus a cheaper GPU option," it's "Groq versus the feature not working at all."&lt;/p&gt;

&lt;p&gt;It's also why Groq isn't trying to train the next frontier model. The LPU's entire design is optimized around the fixed, predictable computation pattern of running an already-trained model. Training is a much messier, less predictable workload — exactly the kind of job determinism doesn't help with. Groq has made peace with this division of labor: run other labs' open-weight models (Llama, Mixtral, DeepSeek, Qwen) as fast and cheaply as possible, rather than compete on building the model itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this is heading
&lt;/h2&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft9yr733bdce3xnpzxt46.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft9yr733bdce3xnpzxt46.png" alt=" " width="800" height="68"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The most interesting recent development here is that this is no longer framed as "Groq vs. Nvidia." Nvidia's upcoming Vera Rubin platform actually pairs Groq's LPUs alongside Rubin GPUs in a single heterogeneous system — GPUs handle the prefill stage and attention computation during decode, while LPUs take over the latency-sensitive feed-forward and mixture-of-experts execution. Rather than one architecture replacing the other, the industry seems to be converging on using each chip for what it's actually good at: GPUs for the parallel, throughput-heavy parts of inference, LPUs for the sequential, latency-sensitive parts.&lt;/p&gt;

&lt;p&gt;That's a pretty satisfying resolution to the "wait, how is this so fast" question I started with. It's not that Groq found a trick GPU makers missed — it's that they asked a genuinely different question. Nvidia optimized for "how do we do as much computation as possible." Groq optimized for "how do we make sure compute is never waiting on anything." For training, the first question matters more. For the kind of real-time, conversational, agentic systems a lot of us are building right now, the second one might matter more than we've been giving it credit for.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I write about what I'm learning while building AI systems — currently a multi-agent financial due-diligence pipeline on LangGraph, and a RAG-based healthcare triage tool. More on both soon.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>rag</category>
      <category>agents</category>
      <category>llm</category>
    </item>
    <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>
