Package dev.dokimos.core.evaluators
Class ContextualRelevanceEvaluator
java.lang.Object
dev.dokimos.core.BaseEvaluator
dev.dokimos.core.evaluators.ContextualRelevanceEvaluator
- All Implemented Interfaces:
Evaluator
Evaluator that measures how relevant retrieved context chunks are to a user's input query.
This evaluator uses pointwise relevance scoring, where each context chunk is scored independently between 0.0 (completely irrelevant) and 1.0 (highly relevant). The final score is the mean average of all individual chunk scores.
Example usage:
var evaluator = ContextualRelevanceEvaluator.builder()
.name("contextual-relevance")
.judge(llmClient)
.threshold(0.5)
.build();
var testCase = EvalTestCase.builder()
.input("What are symptoms of dehydration?")
.actualOutput("retrievalContext", List.of(
"Dehydration symptoms include thirst, dry mouth, and fatigue.",
"The Pacific Ocean is the largest ocean on Earth.",
"Severe dehydration can cause dizziness and confusion."
))
.build();
EvalResult result = evaluator.evaluate(testCase);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for constructing ContextualRelevanceEvaluator instances.static final recordRepresents the relevance score for a single context chunk. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a new builder for constructing the contextual relevance evaluator.Methods inherited from class dev.dokimos.core.BaseEvaluator
evaluate, evaluateAsync, evaluateAsync, name, threshold
-
Method Details
-
builder
Creates a new builder for constructing the contextual relevance evaluator.- Returns:
- a new builder
-