Skip to main content
This example demonstrates how to build a robust question-answering system using NeMo Guardrails with knowledge base integration, fact-checking, and hallucination prevention.

Overview

This QA system features:
  • Knowledge base retrieval for accurate answers
  • Fact-checking using AlignScore or self-check mechanisms
  • Hallucination detection to prevent fabricated answers
  • Confidence scoring for answer reliability
  • Graceful degradation when answers are uncertain

Basic QA System with Fact-Checking

1

Configuration

2

Define conversation flows

3

Add knowledge base documents

Place your documents in the kb/ folder:
kb/report.md

Advanced QA with Custom Fact-Checking

1

Configure AlignScore fact-checking

2

Create custom fact-checking flow

Custom RAG with Fact & Hallucination Checking

1

Configuration with multiple checks

2

Custom RAG implementation

3

QA flow with checking

Usage Examples

Conversation Examples

1

Accurate answer from KB

2

Potentially inaccurate answer

3

No information available

4

Off-topic question

Confidence Thresholds

Adjust thresholds based on your accuracy requirements:
Then in your flow:

Testing Your QA System

Best Practices

  1. Curate Quality KB - Ensure knowledge base has accurate, well-structured content
  2. Set Appropriate Thresholds - Balance false positives vs. false negatives
  3. Provide Context - Include metadata in KB documents for better retrieval
  4. Monitor Accuracy - Track fact-checking scores over time
  5. Handle Uncertainty - Gracefully refuse to answer when confidence is low
  6. Update Regularly - Keep knowledge base current with latest information

Project Structure