← Projects

RAG Drift Monitor

Compare retrieval distances before and after changing a small document corpus.

This experiment compares eight retrieval queries before and after a corpus change. The setup uses 19 Wikipedia articles, the all-MiniLM-L6-v2 embedding model, and ChromaDB. Four articles were replaced before the second run.

The saved report contains the distances, source documents, and thresholds from April 12, 2026.

Compare the runs

For each query, subtract the baseline distance from the changed-corpus distance:

delta = drifted_dist - baseline_dist

The report marks a delta of at least 0.05 as degraded and at least 0.10 as requiring review. Those thresholds belong to this experiment.

The saved results contain six healthy queries, one degraded query, and one requiring review. Four queries changed source documents. Two of those remained below the degraded threshold. The other four queries have zero distance change.

Read the result carefully

A changed source can matter even below the distance threshold. Review the retrieved passage alongside the score.

The report measures retrieval changes. It contains no generated-answer evaluation, relevance labels, or production traffic. It cannot establish an answer-quality improvement or a general false-positive rate.

Inspect the report

The Python summary script recalculates the states from the saved distances:

Terminal window
python summarize-drift.py report.json

Keep the embedding model, distance metric, chunking, and query set fixed when comparing corpus revisions. Changes to those settings need their own baseline.

Technologies: Python, sentence-transformers, ChromaDB, Streamlit.

Results

Distances from the saved April 12, 2026 report comparing eight queries across corpus revisions.

Retrieval distances for eight queries
QueryBaselineChangedDeltaState
How does attention work in transformer models?0.32870.39070.0620degraded
What causes hallucinations in large language models?0.33290.43440.1015review required
How does retrieval-augmented generation improve accuracy?0.45290.46180.0089healthy
What is the difference between dense and sparse retrieval?0.49890.52760.0287healthy
How are word embeddings trained?0.32390.32390.0000healthy
What is cosine similarity used for in semantic search?0.26720.26720.0000healthy
How does fine-tuning differ from pretraining?0.34790.34790.0000healthy
What are the main challenges in information retrieval evaluation?0.43560.43560.0000healthy

Download report.json

Related code