RelevanceEvaluator class
Evaluates how well an AI response addresses the user's question.
Returns a NumericMetric named "Relevance" scored 1–5 (fail below 3).
Requires a ChatConfiguration with an AI model (GPT-4o recommended).
- Inheritance
-
- Object
- QualityEvaluatorBase
- RelevanceEvaluator
- Annotations
-
- @Source(name: 'RelevanceEvaluator.cs', namespace: 'Microsoft.Extensions.AI.Evaluation.Quality', repository: 'dotnet/extensions', path: 'src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/')
Constructors
Properties
-
evaluationMetricNames
→ List<
String> -
The names of the EvaluationMetrics produced by this evaluator.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
buildEvaluationInstructions(
List< ChatMessage> messages, ChatResponse modelResponse, List<EvaluationContext> additionalContext) → List<ChatMessage> ? -
Builds the evaluation instructions (system + user messages).
override
-
evaluate(
Iterable< ChatMessage> messages, ChatResponse modelResponse, {ChatConfiguration? chatConfiguration, Iterable<EvaluationContext> ? additionalContext, CancellationToken? cancellationToken}) → Future<EvaluationResult> -
Evaluates
modelResponseand returns an EvaluationResult.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- relevanceMetricName → const String
- The name of the NumericMetric returned by this evaluator.