Evaluation Metrics
Understanding evaluation metrics helps you measure and optimize your guardrails configuration. This guide explains the metrics used for different rail types and how to interpret them.Dialog Rails Metrics
Dialog rails (topical rails) are evaluated on three key tasks:User Intent Accuracy
Measures how accurately the system identifies user intents (canonical forms). Calculation:- High accuracy (>85%): Excellent intent detection
- Medium accuracy (70-85%): May need more examples or similarity matching
- Low accuracy (<70%): Insufficient training data or unclear canonical forms
1
Add More Examples
Include diverse user message variations:
2
Use Similarity Matching
Enable semantic similarity for near-matches:
3
Increase Vector Database Samples
Use more samples per intent:
Bot Intent Accuracy
Measures correctness of next step prediction (bot canonical forms). Calculation:- Evaluates flow logic correctness
- Tests if the right action follows user intent
- Validates conversation flow design
Bot Message Accuracy
Measures whether generated responses match expected bot messages. Calculation:- Define clear bot message templates
- Use consistent bot message names
- Ensure flows lead to appropriate responses
Benchmark Results
NeMo Guardrails has been evaluated on public datasets:Chit-Chat Dataset
76 intents, 226 test samples Top Performers:Using k=3 samples per intent still achieves 82% accuracy with text-davinci-003, showing the importance of few-shot examples.
Banking Dataset
77 intents, 231 test samples (domain-specific) Top Performers:Key Insights
- Few-Shot Learning Matters: k=3 examples provide significant improvement over k=1
- Similarity Helps: Semantic matching improves accuracy for models like gpt-3.5-turbo
- Smaller Models Viable: 7B models achieve 70-80% accuracy with similarity matching
- Compact Prompts Effective: Shorter prompts sometimes outperform longer ones
Moderation Rails Metrics
Moderation rails are evaluated separately for input and output:Input Moderation (Jailbreak Detection)
Metrics:
Benchmark Results (100 harmful prompts):
Output Moderation
Metrics:Output moderation requires manual review for accurate assessment, as automated evaluation cannot reliably judge content safety.
LlamaGuard Performance
Comparing Self-Check vs. LlamaGuard on OpenAI Moderation test set (1,680 samples, 31.1% harmful):
ToxicChat Dataset (10,165 samples, 7.2% harmful):
Interpretation:
- LlamaGuard: Higher precision, fewer false positives
- Self-Check: Higher recall, more defensive (catches more attacks but more false positives)
Fact-Checking Metrics
Fact-checking rails measure factual grounding:Entailment Accuracy
Metrics:Benchmark Results (MSMARCO, 200 samples)
Trade-offs:
- LLM-based: Higher accuracy, slower, more expensive
- AlignScore: Fast inference, good accuracy, requires model hosting
Interpreting Fact-Checking Results
Result: Correct ✓ Result: Correct ✓ (correctly identified as not factual)Hallucination Detection Metrics
Hallucination rails detect when the model fabricates information:Detection Metrics
Benchmark Results (50 false premise questions)
Example False Premise Question:
Running Custom Evaluations
Evaluate with your own datasets:Topical Rails
1
Prepare Configuration
Ensure your config has user messages:
2
Run Evaluation
3
Review Output
Moderation Rails
1
Prepare Dataset
Create a text file with one prompt per line:
2
Run Evaluation
Fact-Checking Rails
1
Prepare Dataset
Create a JSON file:
2
Run Evaluation
Evaluation Parameters Reference
Topical Rails
Moderation Rails
Fact-Checking Rails
Best Practices for Evaluation
- Establish Baselines: Run initial evaluation before optimizing
- Use Balanced Datasets: Equal positive and negative examples
- Test Incrementally: Evaluate after each configuration change
- Track Metrics Over Time: Monitor trends, not just point-in-time results
- Validate with Real Data: Supplement benchmarks with production samples
- Document Results: Keep evaluation history for analysis
Next Steps
Vulnerability Scanning
Test against attack vectors
Evaluation Guide
Detailed evaluation workflows