RAGMetricBase<T>

Base Classes · AiDotNet.RetrievalAugmentedGeneration.Evaluation

Provides a base implementation for RAG evaluation metrics with common functionality.

Implements: IRAGMetric<T>

Known derived types: AnswerCorrectnessMetric<T>, AnswerRelevanceMetric<T>, AnswerSimilarityMetric<T>, ContextCoverageMetric<T>, ContextPrecisionMetric<T>, ContextRecallMetric<T>, ContextRelevanceMetric<T>, FaithfulnessMetric<T>, NoiseRobustnessMetric<T>

For Beginners

This is the foundation for all RAG metrics.

It handles common tasks like:

  • Validating inputs (checking for null values)
  • Normalizing scores (ensuring they’re between 0 and 1)
  • Providing helper methods for common calculations

Specific metrics (Faithfulness, Similarity, etc.) just need to implement their specific scoring logic.

How It Works

This abstract class implements the IRAGMetric interface and provides common validation and utility methods for metric implementations. It ensures consistent behavior across different metrics while allowing derived classes to focus on specific evaluation logic.

Properties

Property Summary
string Description { get; } Gets the description of what this metric measures.
string Name { get; } Gets the name of this metric.

Methods

Method Summary
T Evaluate(GroundedAnswer<T> answer, string groundTruth) Evaluates a grounded answer and returns a score.