Clinical RAG
Offline German clinical-guideline QA with hybrid retrieval and grounded refusal

Answers clinical questions in German over seven guidelines, cites the passages it used, and declines when the retrieved context does not support an answer, so no patient data has to leave the hospital. Refusal is measured as its own rate. Retrieval combines BM25 (which keys on literal values such as age bands and intervals) with dense retrieval, fuses them with Reciprocal Rank Fusion, and reranks with a cross-encoder that scores each query-passage pair jointly. PDFs are parsed with Docling into structure-aware chunks that keep section hierarchy, recommendations and tables as citation metadata. Answers are evaluated with a local LLM judge from a different model family than the generator, cross-checked against a stronger independent judge.
What it does
- Hybrid BM25 + dense retrieval → Reciprocal Rank Fusion (k=60) → cross-encoder rerank → near-duplicate suppression
- Structure-aware chunking (300-500 tokens) parses section hierarchy, recommendations and tables, preserving metadata for citation
- Two-stage routing: guideline first, then document
- Grounded generation with citations, or refusal when the context does not support an answer
- Cross-lingual retrieval: English queries over German sources
- Two-command deployment on a single T4 GPU (no Docker, no Ollama, no accounts); incremental ingestion tracks PDFs by content hash
- All retrieval hyperparameters in one env-var-overridable module for A/B sweeps
Pipeline
- 1AWMF PDFs → Docling Parse
- 2Structure-Aware Chunking (300-500 tok)
- 3Dense (Chroma) + BM25 Indexes
- 4Guideline → Document Router → RRF → Rerank
- 5Grounded Generation or Refusal
Results
| Recall@5 (12-question benchmark) | 0.889 |
|---|---|
| Refusal correctness (out-of-domain questions) | 1.000 |
| Refusal correctness (37-question set, 7 guidelines)includes English queries over German sources | 0.838 |