Overview
This example showcases:- Custom RAG implementation with knowledge base integration
- Fact-checking using self-check mechanisms
- Hallucination detection for bot responses
- Integration with LangChain for retrieval
Configuration
Create the configuration file
Define your models and enable output rails for fact-checking and hallucination detection.
Implement the custom RAG action
Create a custom action that performs retrieval and prepares context for fact-checking.
Usage
Expected Behavior
Query with accurate context
When asking a question that can be answered from the knowledge base:The fact-checking rail verifies the answer against retrieved chunks.
Key Features
- Custom RAG Integration: Implements custom retrieval logic using LangChain
- Fact-Checking: Validates responses against retrieved context
- Hallucination Detection: Prevents the model from generating unsupported claims
- Context Storage: Stores relevant chunks and prompts for verification
Advanced: AlignScore Fact-Checking
For more advanced fact-checking, you can use AlignScore:Related Examples
- QA System - Question-answering with knowledge bases
- Custom Guardrails - Building custom rail logic
- Customer Support - Enterprise chatbot with RAG