<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hafiza Sadia on Medium]]></title>
        <description><![CDATA[Stories by Hafiza Sadia on Medium]]></description>
        <link>https://medium.com/@medihawaq24?source=rss-732c96d4a43a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KSpVqGv7zWqN9I9y3eOmIQ.jpeg</url>
            <title>Stories by Hafiza Sadia on Medium</title>
            <link>https://medium.com/@medihawaq24?source=rss-732c96d4a43a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 09:50:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@medihawaq24/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Beyond Chatbots: Building MediQ, an AI Medical Assistant Using RAG]]></title>
            <link>https://medium.com/@medihawaq24/beyond-chatbots-building-mediq-an-ai-medical-assistant-using-rag-1bc4b8ffb056?source=rss-732c96d4a43a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1bc4b8ffb056</guid>
            <category><![CDATA[ai-in-healthcare]]></category>
            <category><![CDATA[medical-rag-system]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning-python]]></category>
            <dc:creator><![CDATA[Hafiza Sadia]]></dc:creator>
            <pubDate>Mon, 26 Oct 2026 20:32:33 GMT</pubDate>
            <atom:updated>2026-10-26T20:32:33.489Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E2B3oczTNJ1eDaU5FXlbAg.png" /></figure><p><em>By Hafiza Sadia Bibi</em></p><p><em>How I built a Medical RAG System using Python, FastAPI, LangChain, and FAISS to explore document-based medical question answering.</em></p><p>Artificial intelligence is transforming how people search for and understand information. However, in healthcare-related applications, generating a fluent answer is not enough. Users also need to understand where information comes from and whether it is supported by the available evidence.</p><p>This challenge inspired me to build <strong>MediQ</strong>, an experimental <strong>AI Medical Assistant</strong> that uses Retrieval-Augmented Generation (RAG) to answer questions about uploaded medical documents.</p><p>MediQ is a <strong>Medical RAG System</strong> that allows users to upload medical PDFs, ask questions about their contents, and inspect retrieved source passages. It combines document processing, semantic search, vector indexing, and large language models in a web application.</p><p>In this article, I explain how I built MediQ, the technologies behind it, the challenges I explored, and the initial benchmark results.</p><h3>1. Why I Built MediQ</h3><p>General-purpose AI models can explain concepts and generate answers, but they do not automatically show what a particular document says.</p><p>For example, imagine uploading a diabetes guideline and asking:</p><p><em>“What does this document say about diabetes management?”</em></p><p>A general AI model might generate a plausible response based on its existing knowledge. That response may contain information that does not appear in the uploaded PDF.</p><p>I wanted to explore a different approach: retrieving relevant document passages first and using them as context for answer generation.</p><p>My goals were to:</p><ul><li>Retrieve relevant information from uploaded medical PDFs.</li><li>Display source passages and page references for inspection.</li><li>Distinguish document-based answers from general AI-generated information.</li><li>Handle questions when the available document evidence is insufficient.</li><li>Evaluate retrieval configurations rather than relying only on example chatbot responses.</li></ul><p>MediQ is an educational AI project, not a clinically validated diagnostic or treatment system.</p><h3>2. What Is a Medical RAG System?</h3><p>Retrieval-Augmented Generation (RAG) combines information retrieval with language-model-based response generation.</p><p>Instead of relying only on a language model’s existing knowledge, a RAG application searches an external document collection and provides relevant passages as context.</p><p>For medical document question answering, the workflow is:</p><p><strong>Medical PDFs → Text Extraction → Chunking → Embeddings → FAISS Search → Relevant Passages → AI-Generated Response → Source Inspection</strong></p><p>Each component has a specific responsibility:</p><ul><li><strong>Text extraction:</strong> Converts PDF content into machine-readable text.</li><li><strong>Chunking:</strong> Splits long documents into smaller passages.</li><li><strong>Embeddings:</strong> Converts text into numerical representations.</li><li><strong>FAISS:</strong> Searches document vectors for semantically relevant passages.</li><li><strong>Language model:</strong> Generates a natural-language response using the retrieved context.</li><li><strong>Source inspection:</strong> Helps users examine the material used to inform an answer.</li></ul><p>This approach can make AI-powered medical question answering more transparent, but retrieval alone cannot guarantee that a response is medically correct.</p><h3>3. Technologies Used to Build MediQ</h3><p>I developed MediQ using Python-based AI components and a web interface.</p><p><strong>FastAPI — Backend</strong></p><p>FastAPI provides the backend API and coordinates document ingestion, retrieval, and question-answering requests.</p><p><strong>LangChain — RAG Workflow</strong></p><p>LangChain helps organize the retrieval workflow and connect retrieved context with language-model inference.</p><p><strong>FAISS — Vector Search</strong></p><p>FAISS indexes document embeddings and retrieves candidate passages based on vector similarity.</p><p><strong>Sentence Transformers — Text Embeddings</strong></p><p>The documented configuration uses all-MiniLM-L6-v2 to represent document passages and support semantic retrieval.</p><p><strong>Groq — Language-Model Inference</strong></p><p>Groq provides access to hosted language models that generate responses using the context supplied by the application.</p><p><strong>pypdf — PDF Processing</strong></p><p>pypdf extracts text and page information from uploaded PDF documents, helping connect retrieved passages to their source locations.</p><p><strong>Frontend — User Interface</strong></p><p>The web interface provides access to Evidence Chat, PDF Ingestion, Benchmark &amp; Research, and About &amp; System.</p><p>Together, these technologies form a complete application for experimenting with a <strong>Python-based Medical PDF Q&amp;A</strong> workflow.</p><h3>4. How MediQ Works</h3><p>The application has two main stages: document ingestion and question answering.</p><h3>Stage A: Document Ingestion</h3><p><strong>1. Upload a PDF</strong></p><p>The user uploads a medical document through the web interface.</p><p><strong>2. Extract text</strong></p><p>The backend extracts available text and preserves page-level metadata.</p><p><strong>3. Split text into chunks</strong></p><p>The extracted content is divided into smaller passages using a recursive text-splitting strategy. Chunk size and overlap affect how much context each passage contains.</p><p><strong>4. Remove duplicate content</strong></p><p>Content-hash deduplication helps reduce repeated passages before indexing.</p><p><strong>5. Generate embeddings</strong></p><p>Sentence Transformers converts the text chunks into numerical vectors.</p><p><strong>6. Build the FAISS index</strong></p><p>The embeddings are stored in a FAISS index so that relevant passages can be retrieved when a question is submitted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ib1yigoiJeWgR_wwUfW8uQ.png" /></figure><h3>Stage B: Medical Question Answering</h3><p><strong>1. Submit a question</strong></p><p>The user asks a question through Evidence Chat.</p><p><strong>2. Convert the question into an embedding</strong></p><p>The question is represented as a vector using the embedding model.</p><p><strong>3. Retrieve and filter passages</strong></p><p>The system searches the FAISS index and applies relevance filtering to identify candidate passages.</p><p><strong>4. Generate a response</strong></p><p>The selected context is passed to the configured language model to generate a natural-language answer.</p><p><strong>5. Display the answer and sources</strong></p><p>The interface presents the response and makes relevant source information available for inspection.</p><p>This is the central idea behind MediQ: retrieval provides document context, while the language model generates the response.</p><h3>5. Two Modes for Different Questions</h3><p>MediQ separates document-based question answering from general medical information.</p><h3>Document Evidence Mode</h3><p>This mode is intended for questions about uploaded and indexed documents. It retrieves relevant passages and provides source information so users can inspect the evidence.</p><p>When the available evidence does not meet the configured relevance threshold, the system can return an insufficient-evidence response.</p><h3>General Medical Information Mode</h3><p>This mode allows broader questions without requiring the response to be grounded in the uploaded document collection.</p><p>Its output is distinguished from information verified against uploaded PDFs.</p><p>Both modes have limitations. Document retrieval does not guarantee correct interpretation, and general model responses may contain errors. Neither mode replaces qualified medical professionals.</p><h3>6. Understanding Relevance Scoring</h3><p>A vector search system needs a way to compare question and document representations.</p><p>MediQ’s documented retrieval implementation uses L2-normalized embeddings and converts squared Euclidean distance into cosine similarity.</p><p><strong>For two normalized vectors, u and v:</strong></p><p>‖u − v‖₂² = 2 − 2(u · v)</p><p><strong>Therefore:</strong></p><p>S_cosine = 1 − d_L²² / 2</p><p>The resulting similarity score helps compare vectors, but it is <strong>not the probability that an answer is correct.</strong></p><p>A retrieved passage may be related to a question without directly supporting the generated answer. Relevance thresholds therefore need to be evaluated against representative examples rather than treated as universal measures of medical certainty.</p><h3>7. Initial Benchmark: Testing Retrieval Configurations</h3><p>I evaluated four retrieval configurations using 12 curated questions based on diabetes-care guidelines.</p><p><strong>Documented Results</strong></p><ul><li><strong>EXP-A (Baseline):</strong> Recall 79.1%, Precision 83.3%, MRR 0.917, latency 32.4 ms.</li><li><strong>EXP-B (Balanced):</strong> Recall 74.6%, Precision 72.2%, MRR 0.833, latency 25.6 ms.</li><li><strong>EXP-C (Fine-grained):</strong> Recall 67.7%, Precision 72.2%, MRR 0.861, latency 24.1 ms.</li><li><strong>EXP-D (Top-k = 5):</strong> Recall 77.4%, Precision 70.0%, MRR 0.833, latency 28.4 ms.</li></ul><p><em>These small-scale results are not independent clinical validation.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PnYfeWk_Fl5T2kkn49aEAA.png" /></figure><p><strong>What I Learned</strong></p><ul><li><strong>Chunk size matters:</strong> Smaller chunks did not always improve retrieval.</li><li><strong>Top-k involves trade-offs:</strong> Higher recall can come with lower precision.</li><li><strong>Abstention needs testing:</strong> A 12-question benchmark cannot establish broad reliability or prove hallucinations are eliminated.</li></ul><p>This experiment highlights why a Medical RAG System needs systematic evaluation, not just successful example queries.</p><h3>8. Challenges and Lessons Learned</h3><p>Building MediQ involved more than connecting a vector database to a language model.</p><p><strong>Retrieval quality is different from answer quality.</strong> A passage may mention the correct topic without directly answering the question.</p><p><strong>Citations must support the response.</strong> Showing a document name or page number is useful only when the retrieved content actually supports the associated claim.</p><p><strong>Configuration matters.</strong> PDF processing, indexing, API requests, and model settings must work together for the application to respond correctly.</p><p><strong>Uncertainty should be communicated.</strong> When evidence is insufficient, the application should make that limitation clear rather than present an unsupported answer confidently.</p><p>These lessons helped me understand the practical engineering challenges involved in building an AI Medical Assistant.</p><h3>9. Limitations and Future Improvements</h3><p>MediQ is still an experimental project.</p><p>The initial benchmark contains only 12 curated questions, so future evaluation should include more questions and a wider range of medical topics.</p><p>Potential improvements include:</p><ul><li>Testing hybrid keyword and vector search.</li><li>Evaluating additional embedding models.</li><li>Experimenting with cross-encoder reranking.</li><li>Measuring answer faithfulness and citation correctness.</li><li>Testing different document formats, tables, and scanned PDFs.</li><li>Improving privacy, security, and reliability testing.</li></ul><p>Medical documents can contain sensitive information, so the application should not be assumed to meet healthcare compliance requirements without appropriate assessment.</p><h3>Conclusion</h3><p>MediQ is my exploration of <strong>Medical AI</strong>, Retrieval-Augmented Generation, and document-based question answering.</p><p>By combining FastAPI, LangChain, FAISS, Sentence Transformers, pypdf, and hosted language-model inference, I built a web application that retrieves information from medical PDFs and presents responses with source information for inspection.</p><p>The initial benchmark demonstrates that retrieval settings involve trade-offs and should be tested systematically. The results remain preliminary, and the application is not clinically validated.</p><p>Through this project, I explored the full development workflow — from PDF ingestion and embeddings to vector search, response generation, interface design, and evaluation.</p><p>My next steps are to expand the benchmark, strengthen evidence attribution, and test the application more rigorously.</p><p>The broader goal is to build AI applications that do more than generate answers: they should help users inspect the evidence and understand the limitations behind those answers.</p><h3>Explore the Project</h3><p><strong>GitHub Repository:</strong><br><a href="https://github.com/Hafiza-sadia/Professional-Medical-RAG-Portal">https://github.com/Hafiza-sadia/Professional-Medical-RAG-Portal</a></p><p><strong>Author:</strong> Hafiza Sadia Bibi</p><p><strong>Technologies:</strong> Python, FastAPI, LangChain, FAISS, Sentence Transformers, Groq, and pypdf.</p><h3>References</h3><ol><li>Lewis, P., et al. (2020). <em>Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks.</em> <a href="https://arxiv.org/abs/2005.11401">https://arxiv.org/abs/2005.11401</a></li><li>Reimers, N., and Gurevych, I. (2019). <em>Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks.</em> <a href="https://arxiv.org/abs/1908.10084">https://arxiv.org/abs/1908.10084</a></li><li>Johnson, J., Douze, M., and Jégou, H. (2019). <em>Billion-scale similarity search with GPUs.</em> <a href="https://arxiv.org/abs/1702.08734">https://arxiv.org/abs/1702.08734</a></li><li>American Diabetes Association. <em>Standards of Care in Diabetes.</em> <a href="https://diabetesjournals.org/care">https://diabetesjournals.org/care</a></li></ol><p><em>Disclaimer: MediQ is an educational and experimental AI project. It is not intended to diagnose conditions, prescribe treatments, or replace qualified medical professionals.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1bc4b8ffb056" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond Fluent Answers: Why Reliability Is the Next Big Challenge for Large Language Models]]></title>
            <link>https://medium.com/@medihawaq24/beyond-fluent-answers-why-reliability-is-the-next-big-challenge-for-large-language-models-ca543c5a7859?source=rss-732c96d4a43a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca543c5a7859</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Hafiza Sadia]]></dc:creator>
            <pubDate>Tue, 20 Oct 2026 21:34:37 GMT</pubDate>
            <atom:updated>2026-10-20T21:34:37.462Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TwV4A49zNjBT_A7QDMoDdA.png" /></figure><p><strong>Author: Hafiza Sadia</strong><br>Artificial Intelligence | Machine Learning | Natural Language Processing (NLP)</p><p><strong>LinkedIn:</strong> <a href="https://linkedin.com/in/hafiza-sadia-192a7730b">Hafiza Sadia</a></p><p><em>Exploring AI hallucinations, the limitations of current solutions, and what it takes to build more trustworthy AI systems.</em></p><p><strong>Introduction</strong></p><p>Large Language Models (LLMs) have changed the way people interact with artificial intelligence. From answering questions and generating content to assisting with programming and research, these systems can produce responses that often appear clear, confident, and remarkably human-like.</p><p>However, an important question remains: <em>Can we trust an AI system simply because its answer sounds convincing?</em></p><p>The answer is no.</p><p>LLMs can generate incorrect facts, invent references, misinterpret information, or provide unsupported explanations while maintaining a confident tone. This problem, commonly known as AI hallucination, has become a major challenge in the development of reliable generative AI.</p><p>As these systems become part of everyday workflows, improving their reliability is just as important as expanding their capabilities.</p><p><strong>1. When Fluent Language Becomes Misleading</strong></p><p>One of the most fascinating properties of LLMs is their ability to create coherent text. However, fluency and factual correctness are not synonymous.</p><p>Many generative LLMs are trained to predict the next token based on previous context. Through this process, they learn statistical patterns from data and generate coherent language. However, this does not guarantee that every generated statement is factually correct.</p><p>Take a simple example.</p><p>A student asks an AI-powered assistant to suggest research papers on a particular subject. The assistant provides paper titles, authors, publication years, and academic references. Everything seems professional, but one of the suggested papers does not exist.</p><p>The issue is not the quality of the generated text. It is the lack of verifiable factual information.</p><p>Generating a plausible response does not equal generating a verifiable response. That is why evaluating LLMs requires more than analyzing their communication abilities.</p><p><strong>2. Why Do Large Language Models Hallucinate?</strong></p><p>AI hallucinations can arise for several reasons. They should not be understood as a single technical problem with one universal solution.</p><p><strong>Incomplete or unreliable information</strong></p><p>Training datasets can contain outdated information, conflicting statements, errors, and gaps. Models may consequently produce answers that reflect imperfect patterns in their training data.</p><p><strong>Limitations in available knowledge</strong></p><p>An LLM may be asked about a recent event, a specialized research topic, or information that was not adequately represented in its training data. Rather than reliably identifying the knowledge gap, the model may generate a plausible but inaccurate answer.</p><p><strong>Insufficient context</strong></p><p>A question may lack important details, or the model may misunderstand the user’s intention. In such cases, the response can be misleading even when the model produces grammatically correct language.</p><p><strong>Lack of effective verification</strong></p><p>Answer generation and verification are two distinct tasks. If an application lacks appropriate verification processes, the model may generate claims without checking them against authoritative sources.</p><p>These issues highlight the need for further research on hallucinations. Reliability depends on several factors: the model, the data used, the information available during inference, and the methods used to verify generated answers.</p><p><strong>3. Can Retrieval-Augmented Generation Help?</strong></p><p>Retrieval-Augmented Generation (RAG) is one approach researchers and developers use to improve the grounding of LLM responses.</p><p>In a conventional generative workflow, a model primarily relies on its learned parameters and the context supplied in the prompt. A RAG system adds an information retrieval step, allowing it to search an external collection of documents before generating an answer.</p><p>A typical RAG pipeline consists of three stages:</p><ol><li><strong>Retrieval:</strong> Relevant documents or passages are selected in response to a query.</li><li><strong>Augmentation:</strong> The retrieved information is added to the context provided to the LLM.</li><li><strong>Generation:</strong> The model uses the question and retrieved context to formulate a response.</li></ol><p>For example, a university assistant could retrieve information from official admission guidelines before answering a student’s question about eligibility requirements.</p><p>This approach can make answers more relevant to available evidence and help applications use information that changes over time.</p><p>However, RAG does not eliminate hallucinations.</p><p>A retrieval system may select irrelevant passages, miss important information, or return outdated documents. Even when useful evidence is available, a model may misinterpret it or make claims that the documents do not support.</p><p>Therefore, a reliable RAG application requires more than connecting a language model to a document collection. Retrieval quality, source credibility, evidence-grounded generation, and response evaluation all matter.</p><p><strong>4. Moving Beyond a Single Solution</strong></p><p>If hallucinations have multiple causes, addressing them requires a combination of techniques.</p><p><strong>Evidence verification</strong></p><p>Important claims should be checked against reliable sources. In research applications, for example, publication titles, author details, and scientific claims should be verified rather than accepted solely because an LLM presents them confidently.</p><p><strong>Better uncertainty estimation</strong></p><p>An AI system should ideally recognize when it lacks sufficient evidence to answer a question. Expressing uncertainty or requesting clarification can be more useful than generating an unsupported response.</p><p>Although researchers are investigating different methods for estimating uncertainty, reliably determining when an LLM is likely to be wrong remains challenging.</p><p><strong>Improved evaluation</strong></p><p>LLMs should be evaluated on factual correctness and evidence consistency, not only fluency or relevance. Different tasks also require different evaluation methods.</p><p>A system intended to summarize documents, for example, should be assessed on whether its summary accurately reflects the source material.</p><p><strong>Human oversight</strong></p><p>In high-impact settings, human review remains important. AI-generated information should be treated as an input to informed decision-making rather than an unquestionable final answer.</p><p>These approaches address different aspects of reliability. Their effectiveness depends on the application, the quality of the evidence, and how the complete system is designed.</p><p><strong>5. Why This Matters for the Future of AI</strong></p><p>The consequences of hallucinations vary depending on the context and application of AI.</p><p>In creative writing, invented details may be harmless or even desirable. However, an invented citation in a research paper could undermine the credibility of the work. In domains such as medicine and law, inaccurate information may have much more serious consequences.</p><p>Reliability is therefore a necessity, not a luxury.</p><p>Another important challenge concerns the multilingual capabilities of these systems. Excellent performance in one language does not guarantee reliable behavior in another, such as Urdu or Roman Urdu. Differences in dataset availability, linguistic properties, and evaluation resources can affect performance.</p><p>This creates opportunities for researchers studying Natural Language Processing to investigate how LLMs behave across languages and contexts.</p><p>Further progress may depend on several directions, including more effective retrieval, better evidence verification, uncertainty estimation, improved evaluation techniques, and computationally efficient models.</p><p><strong>Conclusion</strong></p><p>Large Language Models have demonstrated remarkable capabilities in language generation and information processing. However, their ability to produce convincing text does not guarantee factual accuracy.</p><p>Hallucinations expose an important distinction between generating a plausible answer and producing a trustworthy one.</p><p>Approaches such as Retrieval-Augmented Generation, evidence verification, uncertainty estimation, and improved evaluation offer promising ways to address this challenge. Nevertheless, no single technique guarantees complete reliability.</p><p>As AI continues to evolve, researchers and developers must pay attention not only to model capabilities but also to the quality of the information these systems produce.</p><p><strong>The next major step in AI is not simply making language models sound more intelligent. It is making their answers more dependable, verifiable, and worthy of trust.</strong></p><p><strong>References and Further Reading</strong></p><ol><li>Huang, L., et al. (2025). <em>A Survey on Hallucination in Large Language Models: Principles, Taxonomy, Challenges, and Open Questions.</em> ACM Transactions on Information Systems. <a href="https://doi.org/10.1145/3703155">https://doi.org/10.1145/3703155</a></li><li>Lewis, P., et al. (2020). <em>Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks.</em> Advances in Neural Information Processing Systems. <a href="https://arxiv.org/abs/2005.11401">https://arxiv.org/abs/2005.11401</a></li><li>Ji, Z., et al. (2023). <em>Survey of Hallucination in Natural Language Generation.</em> ACM Computing Surveys. <a href="https://arxiv.org/abs/2202.03629">https://arxiv.org/abs/2202.03629</a></li></ol><p><em>Note: This article is an educational overview based on existing research. It does not report original experiments.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca543c5a7859" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>