Humanity Metric
The Humanity metric evaluates the emotional depth and human-likeness of AI responses using the NRC Emotion Lexicon.Overview
The metric analyzes eight emotion categories:| Emotion | Description |
|---|---|
| Anger | Expressions of frustration, annoyance, hostility |
| Anticipation | Forward-looking, expectant expressions |
| Disgust | Expressions of distaste or aversion |
| Fear | Expressions of worry, anxiety, concern |
| Joy | Expressions of happiness, satisfaction, pleasure |
| Sadness | Expressions of sorrow, disappointment |
| Surprise | Expressions of unexpectedness |
| Trust | Expressions of confidence, reliability |
- Emotional Entropy: Shannon entropy measuring emotional diversity
- Spearman Correlation: Correlation with ground truth emotional distribution
Installation
Basic Usage
Parameters
Required Parameters
| Parameter | Type | Description |
|---|---|---|
retriever | Type[Retriever] | Data source class |
Optional Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
verbose | bool | False | Enable verbose logging |
Output Schema
HumanityMetric
Understanding the Metrics
Emotional Entropy
Measures the diversity of emotions in a response using Shannon entropy:| Entropy | Interpretation |
|---|---|
| > 2.5 | High diversity - uses many emotions naturally |
| 1.5 - 2.5 | Moderate diversity - balanced emotional expression |
| < 1.5 | Low diversity - dominated by few emotions |
| 0 | Only one emotion or no emotional content |
Spearman Correlation
Measures how well the assistant’s emotional distribution matches the ground truth:| Correlation | Interpretation |
|---|---|
| > 0.5 | Strong positive - emotions align well with expected |
| 0.0 - 0.5 | Weak positive - some alignment |
| ≈ 0.0 | No correlation - emotions are unrelated |
| < 0.0 | Negative - emotions diverge from expected |
Complete Example
Visualization
Emotion Distribution Bar Chart
Entropy Distribution
Use Cases
Customer Service
Customer Service
Responses should show trust, anticipation, and appropriate empathy:
- High trust for reliability
- Joy for positive interactions
- Some sadness/understanding for complaints
Mental Health Support
Mental Health Support
Should match user’s emotional tone appropriately:
- High Spearman correlation with ground truth
- Balanced emotional diversity
- Appropriate expressions of care and support
Technical Documentation
Technical Documentation
May have lower emotional content (which is appropriate):
- Low entropy is acceptable
- Trust should still be present
- Neutral emotional tone
Creative Writing
Creative Writing
Should show high emotional diversity:
- High entropy (>2.0)
- Varied emotions across interactions
- Natural emotional range
Interpretation Guidelines
High Emotional Entropy (>2.0)
The response expresses a diverse range of emotions, appearing more natural and human-like. Good for:- Creative writing
- Emotional support
- Engaging conversation
Low Emotional Entropy (below 1.0)
The response is dominated by few emotions or is emotionally neutral. May be:- Appropriate for technical content
- Concerning for empathetic contexts
- Sign of robotic responses
Zero Entropy
Only one emotion detected or no emotional content. Could indicate:- Purely factual response (acceptable for technical queries)
- Lack of appropriate emotional expression (concerning for support contexts)