# vaibhav-rj/rag-pipeline architecture

> Architecture diagram of the GitHub repository vaibhav-rj/rag-pipeline, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vaibhav-rj/rag-pipeline
- Repository: https://github.com/vaibhav-rj/rag-pipeline

## Overview

This repository documents an experimental clinical-trials RAG system rather than a conventional application with sampled runtime source. Its documented workflow retrieves clinical-trial context with domain-tuned encoders, then generates grounded answers; experiments also produce reference answers and evaluate retrieval and end-to-end quality. RAG1 and RAG2 represent retrieval improvements, while RAG3 focuses on generation. Relationships below follow the README descriptions; notebook internals were not available for inspection.

Main entry points: [`RAG_CT_complete_compressed/RAG3`](https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/RAG3) (RAG3 generation tuning), [`RAG_CT_complete_compressed/ct-rag-pipeline.ipynb`](https://github.com/vaibhav-rj/rag-pipeline/blob/main/RAG_CT_complete_compressed/ct-rag-pipeline.ipynb) (Fine-tuned retrieval), [`RAG_CT_complete_compressed/RAG1`](https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/RAG1) (RAG1 embeddings), [`RAG_CT_complete_compressed/rag_pipeline_evaluation`](https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/rag_pipeline_evaluation) (Pipeline evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_retrieval["Retrieval experiments"]
  node_rag1["RAG1 embeddings"]
  node_rag2["RAG2 query encoding"]
  node_retrieval_system["Fine-tuned retrieval"]
  node_trial_data[("Clinical-trial data")]
end

subgraph group_generation["Answer generation"]
  node_reference_answers["Reference answers"]
  node_rag3["RAG3 generation tuning"]
  node_answer_quality["Grounded answers"]
end

subgraph group_evaluation["Evaluation"]
  node_evaluation["Pipeline evaluation"]
  node_rag3_evaluation["RAG3 evaluation"]
end

node_researcher(("User"))
node_qwen{{"Qwen reference model"}}
node_llama{{"Llama 3.1 8B"}}
node_judge{{"Judge LLM"}}

node_trial_data -->|"tunes embeddings"| node_rag1
node_rag1 -->|"improves retrieval"| node_retrieval_system
node_rag2 -->|"specializes encoding"| node_retrieval_system
node_researcher -.->|"submits query"| node_retrieval_system
node_retrieval_system -->|"supplies context"| node_rag3
node_qwen -->|"generates references"| node_reference_answers
node_reference_answers -.->|"guides tuning"| node_rag3
node_rag3 -->|"adapts with QLoRA"| node_llama
node_rag3 -->|"generates answers"| node_answer_quality
node_answer_quality -->|"evaluated end-to-end"| node_evaluation
node_judge -->|"scores answers"| node_evaluation
node_rag3 -->|"evaluates generation"| node_rag3_evaluation

click node_rag1 "https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/RAG1"
click node_rag2 "https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/RAG2"
click node_retrieval_system "https://github.com/vaibhav-rj/rag-pipeline/blob/main/RAG_CT_complete_compressed/ct-rag-pipeline.ipynb"
click node_trial_data "https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/RAG1/Embedding_model"
click node_rag3 "https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/RAG3"
click node_answer_quality "https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/RAG3"
click node_evaluation "https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/rag_pipeline_evaluation"
click node_rag3_evaluation "https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/RAG3/rag3_evaluation"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_rag1,node_rag2,node_retrieval_system,node_trial_data,node_researcher toneBlue
class node_reference_answers,node_rag3,node_answer_quality toneAmber
class node_evaluation,node_rag3_evaluation toneMint
class node_qwen,node_llama,node_judge toneIndigo
```

## Components

### Retrieval experiments

- [RAG1 embeddings](https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/RAG1): `RAG_CT_complete_compressed/RAG1`
- [RAG2 query encoding](https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/RAG2): `RAG_CT_complete_compressed/RAG2`
- [Fine-tuned retrieval](https://github.com/vaibhav-rj/rag-pipeline/blob/main/RAG_CT_complete_compressed/ct-rag-pipeline.ipynb): `RAG_CT_complete_compressed/ct-rag-pipeline.ipynb`
- [Clinical-trial data](https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/RAG1/Embedding_model): `RAG_CT_complete_compressed/RAG1/Embedding_model`

### Answer generation

- **Reference answers**
- [RAG3 generation tuning](https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/RAG3): `RAG_CT_complete_compressed/RAG3`
- [Grounded answers](https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/RAG3): `RAG_CT_complete_compressed/RAG3`

### Evaluation

- [Pipeline evaluation](https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/rag_pipeline_evaluation): `RAG_CT_complete_compressed/rag_pipeline_evaluation`
- [RAG3 evaluation](https://github.com/vaibhav-rj/rag-pipeline/tree/main/RAG_CT_complete_compressed/RAG3/rag3_evaluation): `RAG_CT_complete_compressed/RAG3/rag3_evaluation`

### Other components

- **User**
- **Qwen reference model**
- **Llama 3.1 8B**
- **Judge LLM**

## Connections

- Clinical-trial data → RAG1 embeddings: tunes embeddings (evidence: `README.md`)
- RAG1 embeddings → Fine-tuned retrieval: improves retrieval (evidence: `README.md`)
- RAG2 query encoding → Fine-tuned retrieval: specializes encoding (evidence: `README.md`)
- User → Fine-tuned retrieval: submits query
- Fine-tuned retrieval → RAG3 generation tuning: supplies context (evidence: `README.md`)
- Qwen reference model → Reference answers: generates references (evidence: `README.md`)
- Reference answers → RAG3 generation tuning: guides tuning
- RAG3 generation tuning → Llama 3.1 8B: adapts with QLoRA (evidence: `README.md`)
- RAG3 generation tuning → Grounded answers: generates answers (evidence: `README.md`)
- Grounded answers → Pipeline evaluation: evaluated end-to-end (evidence: `README.md`)
- Judge LLM → Pipeline evaluation: scores answers (evidence: `README.md`)
- RAG3 generation tuning → RAG3 evaluation: evaluates generation (evidence: `README.md`)
