Case study
Legal/Medical Research Engine
Cited extractive answers over a large EU legal and medical corpus without storing queries.
At a glance
Plain summary for recruiters and visitors. Technical detail follows below.
- What it is
- I built a research search tool that answers questions over EU legal and medical documents with cited passages. Queries are not stored by design.
- What I owned
- Solo end to end. Ingestion, chunking, embedding index, retrieval, answer assembly, privacy design, and demo deployment.
- Why it matters
- Analysts and researchers save time when they need a cited passage instead of reading long PDF sets manually. Confidence scores show when retrieval is weak.
- Try it on this page vs full project
- The try-it box searches a small curated corpus on Cloudflare Workers. The private stack indexes 65,000+ documents with Chroma and FastAPI. That full index is on request.
Quick comparison
- This page demo
Curated Worker corpus. Hybrid retrieval and extractive answers with citations. No query storage.
- Full stack on request
Full Chroma index, larger document set, and FastAPI backend from the private repo.

Problem
Legal and medical professionals need fast answers over large document sets without storing sensitive query content.
Method
Built a RAG pipeline over 65,000+ documents with vector retrieval, citations, and confidence scores. Designed so queries are not stored.
Result
Delivers cited answers quickly for EU legal and medical guidelines without storing queries. Recruiters can try a curated query on this page. The full 65,000 document index stays on request.
Architecture
How the system is shaped. Full implementation stays private.
Step 1
Ingest
Chunk EU legal and medical guideline text with provenance metadata.
Step 2
Index
Embedding model + vector store (full Chroma stack in private repo). Free demo uses a curated Worker corpus.
Step 3
Retrieve
Hybrid semantic + keyword retrieval with top-k passages.
Step 4
Answer
Extractive synthesis with citations and confidence. No paid LLM required for the portfolio demo.
Step 5
Privacy
Queries are not persisted. Portfolio demo discloses curated-subset limits.
Public demo scope
The in-page widget uses a curated Worker corpus. Queries are not stored. The full 65,000 document index stays on request.
| Scope | Status | Note |
|---|---|---|
| Public demo corpus | Curated subset | |
| Query storage | None | |
| Full document index | On request |
Algorithm
Hybrid retrieve-then-extract
Score passages by query overlap / semantic similarity, then build a cited answer from top excerpts.
tokens = tokenize(question)
candidates = rank(corpus, tokens, top_k)
answer = stitch_excerpts(candidates) # with [1][2] citations
confidence = f(top_score, k)
return answer, sources, confidenceKey logic
Compact illustrative snippet (Hybrid retrieval score (illustrative)). Not the full codebase.
function hybridScore(doc, queryTokens, queryVec, alpha = 0.65) {
const bm25 = bm25Score(doc.tokens, queryTokens);
const semantic = cosine(queryVec, doc.embedding);
return alpha * semantic + (1 - alpha) * bm25;
}
function rankPassages(corpus, question, topK = 8) {
const tokens = tokenize(question);
const queryVec = embed(question);
return corpus
.map((doc) => ({ doc, score: hybridScore(doc, tokens, queryVec) }))
.sort((a, b) => b.score - a.score)
.slice(0, topK);
}Stack
Try a live query
Free Cloudflare demo over a curated corpus. Not the full private index. Queries are not stored on the server. Recent tries stay in your browser only.
Suggested (click to run):
Source code
Full source is available to hiring managers on request. The public page shows architecture, algorithms, and compact proofs only.