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.
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.
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.
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.
multilingual-e5-small (384-dim)bge-reranker-v2-m3

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.
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
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
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.
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.
Uncertainty & Clarification
Input indicates symptoms but lacks clinical specificity. Rather than offering premature advice, the assistant prompts targeted clarifying questions.
Urgent Escalation (999)
Detects life-threatening symptoms (cardiac signs, respiratory distress, anaphylaxis). Immediately suppresses normal information and presents prominent emergency escalation advice.
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“amar buk e betha”(Translation: “I have chest pain”)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?”
“amar buk e betha, shash niteo koshto hocche”(Translation: “Chest pain, and having difficulty breathing”)The combination of chest discomfort with dyspnea (difficulty breathing) triggers deterministic red-flag escalation. Normal informational retrieval is immediately overridden.
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.
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.
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.
Anatomical & Symptom Specialization
Triggered when the user provides additional precision on the same anatomical region or symptom (e.g. specifying pain location or duration).
Preventing Cross-Contamination
Query: “My child has a high fever for 2 days.”
Query: “amar buk e betha” (Chest pain)
NEW_TOPIC ClassifiedChild fever symptoms are strictly purged from the active query context. Retrieval focuses exclusively on adult/acute chest pain guidance without pediatric fever pollution.
Anatomical Refinement
Query: “amar pa betha korche” (My leg is hurting)
Query: “gorar kache” (Near the heel / ankle)
SAME_TOPIC_REFINEMENTLeg 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 StateUsers often investigate distinct clinical concerns across different sessions or family members. The frontend maintains independent conversation threads:
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.
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.
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.
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.
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”).
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.
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.
The Solution: Deterministic Topic Continuity Classifier
We introduced a strict pre-retrieval classification step before vector generation:
- Symptom Entity Extraction: Identify anatomical references, symptom descriptors, and emergency triggers in the new query.
- 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. - Strict Context Purge: When
NEW_TOPICfires, the historical summary buffer is purged to zero length before embedding. The chest pain query is evaluated in complete isolation, immediately triggering emergency triage.
Classification: NEW_TOPIC (Score: 0.98) → Context purged
Emergency Scan: DETECTED [Chest Pain] → Triage Escalation Active
Output: Immediate 999 Medical Emergency Escalation NoticeTechnical 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.
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.
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.