Hallucination Detection System

U

@

·

Build a multi-layer hallucination detection system for RAG with entailment checking, citation verification, and factual consistency scoring.

73 copies0 forks
Build a hallucination detection system for RAG outputs.

## RAG System Description
{{rag_system}}

## Document Corpus
{{corpus_description}}

## Acceptable Hallucination Rate
{{hallucination_threshold}}

Implement multi-layer detection:

```python
class HallucinationDetector:
    def detect(self, query: str, context: List[str], response: str) -> DetectionResult:
        """
        Layer 1: Entailment checking (NLI model)
        Layer 2: Citation verification
        Layer 3: Factual consistency scoring
        Layer 4: Confidence calibration
        """
        pass
    
    def get_evidence(self, claim: str, context: List[str]) -> Evidence:
        """Find supporting/contradicting evidence"""
        pass
```

Include:
- Model selection for each layer
- Threshold tuning methodology
- False positive/negative trade-offs
- User-facing confidence indicators

Details

Category

Coding

Use Cases

Hallucination detectionQuality assuranceRAG safety

Works Best With

claude-sonnet-4-20250514gpt-4o
Created Shared

Create your own prompt vault and start sharing