Flagship Case Study
Flagship ProjectEvidence-Grounded AssistantRuns LocallyLLM-Free Rule-Based Retrieval

Dr. Md. Momenul Islam Health Assistant

Evidence-grounded health information assistant (research prototype) — In memory of Dr. Md. Momenul Islam.

Status: runs locally. The retrieval pipeline (multilingual-e5-small embeddings + bge-reranker-v2-m3 cross-encoder) needs roughly 3 GB RAM, which exceeds free-tier hosting limits. Cloud deployment is pending. The recording below shows the full system running end to end; see the GitHub README for reproducible setup.

Dr. Md. Momenul Islam Health Assistant is a research prototype designed to provide transparent, source-grounded guidance instead of unconstrained medical generation.

Watch demo (1:55)View on GitHub
Target AudienceBangla, Banglish & English Users
Retrieval ArchitectureTwo-Stage (E5-Small + BGE Reranker)
Clinical Knowledge Base14 NHS England Topics (119 Chunks)
Safety HandlingDeterministic Emergency Triage (999)

System Walkthrough

Demo

End-to-end recording of the full local Python retrieval pipeline and conversational interface.

Recording Walkthrough Highlights

  • English symptom query → retrieved NHS passage with citation
  • Banglish query (amar matha betha) → phonetic normalization → same retrieval path
  • chest pain → deterministic emergency-triage rule fires, bypasses search, shows emergency contact
  • Out-of-scope query → system declines rather than hallucinating

The Problem & Core Motivation

Why general-purpose AI is hazardous for medical questions.

When people face sudden symptoms, they increasingly turn to conversational AI chatbots. However, probabilistic text generation introduces severe clinical vulnerabilities.

The Risk

Unconstrained Generative Chatbots

  • Plausible Hallucinations: Standard large language models generate fluent, convincing text based on token probabilities rather than verified clinical evidence.
  • Lack of Transparent Grounding: Answers cannot easily be traced to a specific, certified medical authority or peer-reviewed clinical document.
  • Delayed Emergency Intervention: Conversational bots often attempt to answer acute red-flag symptoms with lifestyle tips instead of urgent escalation.
  • False Sense of Diagnostic Authority: Encouraging users to believe a software system has "diagnosed" their underlying health condition.
Our Engineering Approach

Evidence-First Health Retrieval

  • Trusted Source Retrieval: Answers are bound strictly to verified clinical documents from NHS England—no unvetted web crawling or guessing.
  • Deterministic Safety Handling: Emergency indicators bypass text retrieval entirely and trigger immediate escalation protocols.
  • Uncertainty-Aware Clarification: When user symptoms are vague or ambiguous, the assistant asks targeted follow-up questions instead of speculating.
  • Transparent Evidence Cards: Every retrieved guidance card highlights the exact original NHS source title, topic, and clinical excerpt for full user inspection.

System Architecture & Pipeline

How it works: A deterministic clinical retrieval pipeline.

The system prioritizes clinical safety at every turn. Instead of sending raw user prompts to an external generative API, every query traverses a sequential safety and retrieval pipeline.

01
User QuestionBangla, Banglish, or English query input
02
Query UnderstandingLanguage detection, normalization & topic continuity check
03
Safety / Emergency DetectionDeterministic red-flag symptom scanning (chest pain, dyspnea, shock)
04
Semantic RetrievalDense vector embedding via multilingual-e5-small (384-dim)
05
Evidence RerankingCross-encoder precision scoring via bge-reranker-v2-m3
06
Trusted NHS GuidanceRanked clinical passages with provenance metadata & uncertainty handling
07
User PresentationEvidence cards, clinical caveats, and recommended emergency actions
Dr. Md. Momenul Islam consultation interface showing multilingual consultation greeting, evidence first badge, and sample query triggers
Production Consultation Interface: Displays the bilingual disclaimer, evidence-first mandate, and quick-inquiry symptom triggers for clinical evaluation.
Dr. Md. Momenul Islam system architecture modal showing embedding dimensions, reranker specs, and verified NHS dataset chunk metrics
Architecture & Specification Modal: Outlines model configurations, chunking parameters, semantic vector dimensions, and latency profiles for clinical transparent auditing.

AI / ML & Clinical Knowledge

Two-stage retrieval over certified NHS England guidance.

Pretrained open weights are leveraged strictly for information indexing and reranking, completely decoupled from generative text generation.

Critical Architectural & API Disclosure

Current production answering does not use OpenAI, Gemini, Claude, or another external generative AI API.

Pretrained language models are run locally and self-hosted for semantic vector retrieval and cross-encoder evidence reranking. Generative LLM output is intentionally disabled to completely prevent medical hallucination, dosage fabrication, and ungrounded clinical extrapolation.

Dense Retriever384-dim

multilingual-e5-small

Transforms incoming queries and clinical chunks into dense vector representations. Trained specifically on multilingual semantic equivalence, allowing it to seamlessly bridge Bangla, phonetically transliterated Banglish (e.g. “matha betha”), and formal English clinical terminology.

  • Low inference latency (sub-120ms CPU execution)
  • Symmetric cosine similarity retrieval across multilingual token spaces
  • Generates top-K (10) preliminary candidates for reranking
Cross-Encoderm3 Architecture

bge-reranker-v2-m3

Acts as the second-stage precision filter. Rather than relying solely on bi-encoder dot products, the cross-encoder performs deep bidirectional self-attention between the query and each candidate passage.

  • Evaluates full query-passage context interaction
  • Filters false positives from keyword overlap or ambiguous symptom words
  • Yields confidence scores used for uncertainty triage

Constrained Knowledge Corpus

Curated NHS England Clinical Corpus

14Verified Topics
119Clinical Chunks

Unlike search-augmented bots that pull unvetted forum discussions or commercial blogs, Dr. Md. Momenul Islam operates on a strictly closed, verified corpus extracted from official NHS England clinical guidelines.

Topics cover acute community concerns, including fever management, diarrhea and rehydration, chest pain identification, asthma exacerbations, and pediatric warning signs. The system does not claim universal medical knowledge; if a query falls outside the indexed corpus, the assistant transparently reports that verified evidence is unavailable rather than guessing.

Clinical Safety Architecture

Deterministic triage: Emergency escalation over guidance.

In medical interactions, missing an acute clinical emergency is catastrophic. The pipeline classifies every turn into four distinct tiers before rendering evidence.

Tier 1: Ordinary Query

Answerable Clinical Query

Query clearly aligns with verified NHS clinical topics (e.g. “oral rehydration for dehydration”). Matches trusted chunks with high confidence score and renders grounded evidence cards.

Tier 2: Ambiguous Query

Uncertainty & Clarification

Input indicates symptoms but lacks clinical specificity. Rather than offering premature advice, the assistant prompts targeted clarifying questions.

Tier 3: Emergency Red-Flag

Urgent Escalation (999)

Detects life-threatening symptoms (cardiac signs, respiratory distress, anaphylaxis). Immediately suppresses normal information and presents prominent emergency escalation advice.

Tier 4: Out-of-Scope

Transparent Boundary

Query involves off-topic queries or conditions not present in the 14 verified NHS guidelines. Transparently declines to speculate and advises consulting a qualified doctor.

Real-World Clinical Safety Progression

Bangla / Banglish Triage
User Query 1“amar buk e betha”(Translation: “I have chest pain”)
System Behavior: Ambiguous Query Triage

Chest pain can range from mild muscular strain or gastroesophageal reflux to acute myocardial infarction. Because critical discriminators are missing, the system does not guess. It prompts:

“Chest pain requires careful attention. Does the pain feel like heavy pressure or tightness? Does it radiate to your arm, neck, or jaw, or are you feeling short of breath?”
User Follow-Up“amar buk e betha, shash niteo koshto hocche”(Translation: “Chest pain, and having difficulty breathing”)
System Behavior: Immediate Emergency Escalation

The combination of chest discomfort with dyspnea (difficulty breathing) triggers deterministic red-flag escalation. Normal informational retrieval is immediately overridden.

CRITICAL MEDICAL NOTICE:

These combined symptoms may indicate a medical emergency (such as acute coronary syndrome). Immediately call Bangladesh Emergency Services at 999 or proceed to the nearest hospital emergency room.Do not wait for online symptom guidance.

Important Notice: The assistant provides immediate triage guidance to help users recognize urgency; it is a software interface and does not automatically dial or contact emergency services on the user’s behalf.

Context Engineering & Conversation Isolation

Context-aware dialogue without clinical cross-contamination.

In conversational healthcare, blindly appending chat history creates dangerous medical confusion. Dr. Md. Momenul Islam implements deterministic topic continuity classification.

State: NEW_TOPIC

Strict Context Reset

Triggered when the user pivots to an unrelated clinical subject. Previous turn symptoms are scrubbed from active retrieval memory so previous diagnoses do not pollute new vector embeddings.

State: CONTEXT_DEPENDENT

Anaphora & Pronoun Linking

Triggered when the user asks a dependent question (e.g. “how long will it last?”). The system anchors the inquiry to the active condition established in the immediately prior turn.

State: SAME_TOPIC_REFINEMENT

Anatomical & Symptom Specialization

Triggered when the user provides additional precision on the same anatomical region or symptom (e.g. specifying pain location or duration).

Context Reset Flow

Preventing Cross-Contamination

Turn 1

Query: “My child has a high fever for 2 days.”

Active context: Pediatric Febrile Illness
Turn 2

Query: “amar buk e betha” (Chest pain)

NEW_TOPIC Classified

Child fever symptoms are strictly purged from the active query context. Retrieval focuses exclusively on adult/acute chest pain guidance without pediatric fever pollution.

Context Preservation Flow

Anatomical Refinement

Turn 1

Query: “amar pa betha korche” (My leg is hurting)

Active context: Lower Limb Pain
Turn 2

Query: “gorar kache” (Near the heel / ankle)

SAME_TOPIC_REFINEMENT

Leg pain context is preserved and merged into “leg pain near heel/ankle”, accurately steering retrieval toward Achilles tendonitis and ankle sprain guidance.

Multi-Threaded Session Architecture

Isolated Browser State

Users often investigate distinct clinical concerns across different sessions or family members. The frontend maintains independent conversation threads:

Conversation A
Pediatric FeverIsolated turn history, clinical state, and NHS pediatric chunks
Conversation B (Active)
Chest Pain TriageActive evaluation of cardiac warning signs; 0% context leakage from Thread A
Conversation C
Leg / Ankle InjuryMusculoskeletal guidance and recovery protocols; strictly separated

Data Architecture & User Privacy

Anonymous-first design with local-only storage.

Health inquiries represent exceptionally sensitive personal information. The platform adopts a zero-retention posture on the server.

Anonymous-First

No Account or Sign-Up

Users can access the full clinical retrieval pipeline immediately. No phone numbers, email addresses, names, or national ID verifications are required.

Client-Side Persistence

Local Browser Storage

All past conversations, symptom threads, and clinical cards reside exclusively in the user’s browser localStorage. Data never syncs to a remote user database.

Stateless Backend

Zero Cloud Conversation Logs

The FastAPI backend receives queries strictly for stateless embedding and reranking. Queries are evaluated in-memory and immediately discarded without database persistence.

Compliance & Medical Disclaimer Integrity

We believe engineering credibility requires absolute honesty about regulatory scope. Dr. Md. Momenul Islam does not claim formal HIPAA, GDPR, or certified medical device compliance.

It is engineered as an educational and technical research prototype demonstrating evidence-grounded retrieval techniques. It should not be used as an institutional electronic health records (EHR) system or as a replacement for clinical evaluation by a certified physician.

Engineering Deep-Dive

Real engineering challenge: From retrieval bug to context isolation.

Building safety-critical systems reveals subtle architectural failure modes that standard RAG tutorials overlook. Here is how a silent retrieval bug was diagnosed and resolved.

01

The Bug: Unconditional Context Merging

During early multi-turn testing, a user submitted a detailed query regarding pediatric febrile convulsions (“child fever above 102F”). Three turns later in the same session, the user suddenly entered an acute personal complaint: “amar buk e betha” (“I have chest pain”).

Observed Pipeline Failure:Query vector = Embed(“child fever above 102F [SEP] amar buk e betha”)
Top Retrieved Chunk: “Febrile Seizures in Children under 5” (Similarity: 0.81)
Cardiac Emergency Triage: FAILED TO TRIGGER (Suppressed by fever noise)

Because the conversation loop unconditionally concatenated previous turn summaries into the embedding prompt, the dense retriever weighted the cumulative pediatric fever terms higher than the single new chest pain phrase. The life-threatening symptom was dangerously buried under historical conversation noise.

02

Root Cause Analysis

A standard conversational buffer assumes conversational continuity. But in clinical health information, human users frequently switch from asking questions about a family member to an urgent acute personal crisis. Treating multi-turn dialogue as a single growing bag of tokens is fundamentally unsafe.

03

The Solution: Deterministic Topic Continuity Classifier

We introduced a strict pre-retrieval classification step before vector generation:

  1. Symptom Entity Extraction: Identify anatomical references, symptom descriptors, and emergency triggers in the new query.
  2. Continuity Decision: Compare the extracted entities against the prior active context. If the new turn introduces disjoint organ systems (e.g. Pediatric / Temperature vs Thoracic / Cardiac) without connecting conjunctions, it is classified as NEW_TOPIC.
  3. Strict Context Purge: When NEW_TOPIC fires, the historical summary buffer is purged to zero length before embedding. The chest pain query is evaluated in complete isolation, immediately triggering emergency triage.
Post-Fix Pipeline Output:Classification: NEW_TOPIC (Score: 0.98) → Context purged
Emergency Scan: DETECTED [Chest Pain] → Triage Escalation Active
Output: Immediate 999 Medical Emergency Escalation Notice

Technical Architecture

Complete technology stack.

A balanced architecture combining modern frontend ergonomics, self-hosted Python inference, and deterministic safety filters.

Frontend Engineering

  • ReactDeclarative component hierarchy with zero heavy state library bloat
  • TypeScriptStrict typing across medical query models and UI states
  • ViteOptimized bundler providing fast HMR and lightweight production chunks
  • Tailwind CSSUtility-first styling powering the responsive assistant interface

Backend & Inference API

  • PythonCore language for ML inference, tokenization, and vector manipulation
  • FastAPIHigh-throughput async web framework with automatic OpenAPI documentation

AI & Semantic Retrieval

  • multilingual-e5-smallDense sentence embedding supporting Bangla, Banglish, and English
  • bge-reranker-v2-m3Cross-encoder model for high-precision query-passage relevance scoring

Knowledge & Safety Governance

  • NHS England GuidanceCurated corpus of 14 verified topics across 119 clinical chunks
  • Deterministic Triage EnginePattern-matched emergency escalation overriding standard retrieval
  • Generation: DisabledZero external LLM calls (OpenAI, Gemini, Claude intentionally suppressed)

Persistence & Infrastructure

  • localStorageClient-side encrypted-ready session persistence with zero cloud tracking
  • VercelGlobal CDN edge deployment for the frontend application
  • Docker & Tailscale FunnelContainerized self-hosted inference node with secure TLS mesh tunneling

Honest Engineering Scope

Current limitations & future roadmap.

Medical systems demand radical transparency regarding what they can and cannot do.

Current Scope

Active Limitations

  • Curated Corpus Boundary: Clinical knowledge is restricted to the 14 verified NHS England topics (119 chunks). Unindexed clinical queries receive out-of-scope notices.
  • English Source Passages: While queries in Bangla and Banglish are mapped semantically, the underlying NHS guidance excerpts are rendered in their certified English text to prevent translation drift or clinical mistranslation.
  • Generative Output Disabled: Synthesized conversational answers are intentionally turned off. Users read exact excerpts rather than summarized prose.
  • Educational Prototype: The application is a technology demonstrator. It is not an Electronic Health Record (EHR) and never substitutes for examination by a licensed physician.
Planned Roadmap

Future Directions (Not Current)

  • Optional Authentication: Optional user sign-in to support persistent health logs without compromising the anonymous-first default.
  • End-to-End Encrypted Cloud Backup: User-controlled zero-knowledge backup for conversation history across multiple devices.
  • Expanded Source Governance: Ingestion of certified localized Bangladesh health guidance (DGHS protocols) vetted by clinical advisory panels.
  • Strictly Constrained Generation: Investigating constrained decoders that can synthesize Bangla summaries exclusively utilizing extracted tokens from retrieved evidence.