MEDIQUERY / INDEPENDENT PROJECT
Clinical RAG & Document Retrieval Platform
An answer is only as good as its evidence.
I built a React and FastAPI biomedical research application to search literature and return answers with source references. The question behind it: how do you keep the evidence connected as information moves through the system?
Python / FastAPI / React / LangChain / ChromaDB / BioBERT / Docker
Explore document selection ↓
01 / BUILDING THE EVIDENCE PIPELINE
Keep the source
with the text.
- 01
Collect
PubMed search and abstract records through Entrez. Articles without an abstract are skipped.
- 02
Prepare
Title + abstract split into character chunks: 512 characters, with 64-character overlap. Source metadata stays attached.
- 03
Embed & store
dmis-lab/biobert-base-cased-v1.2 through HuggingFaceEmbeddings, CPU and normalised embeddings, stored in ChromaDB.
- 04
Retrieve & answer
MMR requests up to five chunks, considering up to fifteen candidates. A LangChain chain supplies labelled context to Llama-3.1-8B-Instruct via Hugging Face.
Ingestion, search and generation are separate modules. The API queues ingestion as a FastAPI background task; this does not establish a durable job service.
02 / RETRIEVAL EXPLORER
Similar is useful.
Different can be useful, too.
BioBERT supplies a biomedical language representation. Maximum Marginal Relevance adds a selection trade-off: query similarity versus similarity to documents already chosen. That trade-off does not guarantee a better answer.
SYNTHETIC RETRIEVAL DEMONSTRATION / k = 3
Five fictional documents, two-dimensional vectors. No biomedical findings or original MediQuery pipeline are executed.
Without JavaScript: similarity selects A, B, C. The same MMR calculation at λ = 0.5 selects A, D, B.
| Document | Cosine | Selected |
|---|---|---|
| A Cohort notes | 0.999 | #1 |
| B Cohort summary | 0.995 | #2 |
| C Sampling appendix | 0.800 | #3 |
| D Measurement notes | 0.600 | — |
| E Archive index | 0.000 | — |
A and B both point close to the query. Similarity alone does not penalise how close they are to each other.
The calculation, in plain sight
λ × similarity(query, candidate) − (1 − λ) × max similarity(candidate, selected)
The first choice is the most query-similar document. Exact ties retain fixture order. Scores are not probabilities or evidence quality.
- A: query-similar seed
- B: cosine 0.995
- C: cosine 0.800
03 / ANSWERS AND ATTRIBUTION
A citation is
a place to check.
The generation prompt asks for [Source: title] citations and supplies retrieved, source-labelled chunks. The model is configured with 512 new tokens and temperature 0.1.
THE IMPORTANT BOUNDARY
The code retrieves again to build the displayed sources, deduplicating titles and returning a 200-character snippet with each source record. That list is not a guaranteed record of the exact context used for generation.
A citation makes inspection possible. It does not prove that an answer is supported, complete or clinically correct. The reviewed code does not automatically validate every citation against the generated text.
04 / WHAT I CAN VERIFY
Grounding needs
its own checks.
Four existing API tests passed in an isolated review with vector, ingestion and generation boundaries stubbed. They check health, a stats response and invalid short requests; they do not establish retrieval quality or live model behaviour.
This project demonstrates my work connecting ingestion, retrieval and generation across a full-stack application. Next, I would reuse the same retrieved context for both the answer and source list, then evaluate citation support and retrieval choices on a defined dataset.
Explore the MediQuery source ↗