rag-pathology
RAGAS gives you a score. rag-pathology tells you what's wrong.
Diagnoses RAG pipeline failures by type and location. Four Soils classification. Epistemic mismatch detection. Zero dependencies.
pip install rag-pathology
The Problem
Your RAG pipeline scores 0.6 on RAGAS. Now what? Is it a retrieval problem? A generation problem? Are you retrieving facts when the user asked for procedures? RAGAS won't tell you. Neither will DeepEval, TruLens, or Promptfoo.
rag-pathology diagnoses the specific pathology at each stage of your pipeline.
Four Soils Classification
Every query is classified into one of four failure types (inspired by Mark 4:3-8):
| Soil | Meaning | Fix |
|---|---|---|
| PATH | Total retrieval miss — relevant docs exist but weren't retrieved | Fix embeddings, chunk size, or query expansion |
| ROCKY | Good retrieval but generation ignores the context | Strengthen grounding prompt, add citations |
| THORNY | Good retrieval + generation, but noisy context corrupts output | Add reranking, reduce top-k |
| GOOD | Successful RAG | No action needed |
Quick Start
from rag_pathology import RAGDiagnoser, RAGQuery, Chunk
diagnoser = RAGDiagnoser("my_pipeline")
query = RAGQuery(
query="What is Ghana's GDP growth rate?",
retrieved_chunks=[
Chunk("Ghana GDP growth is 6.0% in 2025", score=0.95),
Chunk("Recipe for jollof rice", score=0.1),
],
generated_answer="Ghana's GDP growth rate is 6.0%.",
)
diagnosis = diagnoser.diagnose_query(query)
print(diagnosis.soil_type) # SoilType.GOOD
print(diagnosis.failure_stage) # FailureStage.NONE
print(diagnosis.evidence) # "Healthy RAG: relevance=0.45, grounding=0.67..."
# Pipeline-level diagnosis
pipeline = diagnoser.pipeline_diagnosis()
print(pipeline.summary())
print(pipeline.overall_health) # 0.67
print(pipeline.recommendations) # ["33% of queries are THORNY..."]
Epistemic Mismatch Detection
Detects when your retrieval returns the wrong type of knowledge:
- User asks "How do I register a company?" (PROCEDURAL)
- RAG retrieves "Companies in Ghana must register with RGD" (FACTUAL)
- Structurally relevant, epistemically wrong type
License
MIT
Release files for rag-pathology 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rag_pathology-0.1.0.tar.gz | 11.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rag_pathology-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.9 kB
Release files / rag_pathology-0.1.0.tar.gz
| Download URL | rag_pathology-0.1.0.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ee81578a5f60596464dc11f0c492fa08965857f6def704a4021cefdbd870505
|
|
BLAKE2b-256 checksum How to use checksums |
e2363363d1583435d7d94a6d6f6777ebd9e2b5d96e04bf3ad94e971c123294c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / rag_pathology-0.1.0-py3-none-any.whl
| Download URL | rag_pathology-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8358bc29ca98a8166efec57ba8c0b0c55a6f5e2de9a9b735aa3d426db1241b90
|
|
BLAKE2b-256 checksum How to use checksums |
871e3dd78e98728f3a9fb86e6a9c367cba4b5d786ddcf97b6a9f6b22e60b23db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|