# parmarjh/medical-rag-using-meditron-7b-llm architecture

> Architecture diagram of the GitHub repository parmarjh/medical-rag-using-meditron-7b-llm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/parmarjh/medical-rag-using-meditron-7b-llm
- Repository: https://github.com/parmarjh/medical-rag-using-meditron-7b-llm

## Overview

##### Project type and purpose
- This is a Retrieval-Augmented Generation (RAG) QA Web App in the medical domain. It uses:
- Meditron-7B LLM for generation
- PubMedBERT for embedding text
- Qdrant as the vector store
- A small web frontend (templates/index.html) for user interaction
- Purpose: ingest medical documents (PDFs) into a vector database, retrieve relevant passages at query time, and feed them to the LLM to produce precise answers to medical questions.

##### File structure
- ingest.py: pipeline to read PDFs under Data/, extract text, compute embeddings with PubMedBERT, and push them into Qdrant.
- retriever.py: code that wraps Qdrant queries—takes an embedding of the user’s query and returns the top-k similar document chunks.
- rag.py: orchestrates the RAG flow (may also serve as the web server or API entrypoint):
- accepts user input from the frontend
- calls retriever.py to get context
- invokes Meditron-7B LLM with prompt + context
- returns the generated answer
- templates/index.html: a simple HTML page for users to submit questions and display answers
- requirements.txt: lists Python dependencies (FastAPI/Flask or similar, transformers, qdrant-client, etc.)

##### README for additional insights
- Confirms the stack: “Medical RAG QA App using Meditron 7B LLM, Qdrant Vector Database, and PubMedBERT Embedding Model.”

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Offline Ingestion Pipeline"
        Data["Source Documents (PDFs)"]:::data
        Ingest["Ingestion Service\n(ingest.py)"]:::service
        PubMedEmb["PubMedBERT Embedding Model"]:::model
        DB["Qdrant Vector DB"]:::db
    end

    subgraph "Online Query Pipeline"
        Browser["Browser UI\n(templates/index.html)"]:::ui
        API["RAG API\n(rag.py)"]:::service
        PubMedEmbQ["Query Embedding\n(PubMedBERT)"]:::model
        Retriever["Retrieval Service\n(retriever.py)"]:::service
        QSearch["Qdrant Vector Search"]:::db
        Gen["Meditron-7B LLM"]:::model
    end

    subgraph "Project Artifacts"
        Req["requirements.txt"]:::doc
        Readme["README.md"]:::doc
    end

    Data -->|"raw PDF"| Ingest
    Ingest -->|"extracted text"| PubMedEmb
    PubMedEmb -->|"embeddings + metadata"| DB

    Browser -->|"question text"| API
    API -->|"query text"| PubMedEmbQ
    PubMedEmbQ -->|"query embedding"| Retriever
    Retriever -->|"query embedding"| QSearch
    QSearch -->|"top-k chunks"| Retriever
    Retriever -->|"document chunks"| API
    API -->|"prompt + context"| Gen
    Gen -->|"generated answer"| API
    API -->|"answer"| Browser

    click Data "https://github.com/parmarjh/medical-rag-using-meditron-7b-llm/tree/main/Data/"
    click Ingest "https://github.com/parmarjh/medical-rag-using-meditron-7b-llm/blob/main/ingest.py"
    click Retriever "https://github.com/parmarjh/medical-rag-using-meditron-7b-llm/blob/main/retriever.py"
    click API "https://github.com/parmarjh/medical-rag-using-meditron-7b-llm/blob/main/rag.py"
    click Browser "https://github.com/parmarjh/medical-rag-using-meditron-7b-llm/blob/main/templates/index.html"
    click Req "https://github.com/parmarjh/medical-rag-using-meditron-7b-llm/blob/main/requirements.txt"
    click Readme "https://github.com/parmarjh/medical-rag-using-meditron-7b-llm/blob/main/README.md"

    classDef service fill:#AED6F1,stroke:#1F618D,color:#1B2631;
    classDef model fill:#FAD7A0,stroke:#B9770E,color:#512E5F;
    classDef db fill:#ABEBC6,stroke:#196F3D,color:#1D8348;
    classDef ui fill:#FCF3CF,stroke:#B7950B,color:#7D6608;
    classDef data fill:#D5DBDB,stroke:#7B7D7D,color:#1C2833;
    classDef doc fill:#E8DAEF,stroke:#6C3483,color:#4A235A;
```
