pub struct PairwiseJudge<M: BaseChatModel> { /* private fields */ }Expand description
Pairwise-comparison evaluator (an LLM as the judge, picks one of two).
P1-1: implements the PairwiseEvaluator trait and can join the pointwise Evaluators in EvalRunner
unified report; calling compare directly still yields the fine-grained Verdict (A wins / B wins / tie).
Implementations§
Source§impl<M: BaseChatModel> PairwiseJudge<M>
impl<M: BaseChatModel> PairwiseJudge<M>
Sourcepub fn with_rubric(self, rubric: impl Into<String>) -> Self
pub fn with_rubric(self, rubric: impl Into<String>) -> Self
Sets a custom rubric (builder style).
Sourcepub async fn compare(
&self,
input: &str,
a: &str,
b: &str,
) -> Result<Verdict, EvalError>
pub async fn compare( &self, input: &str, a: &str, b: &str, ) -> Result<Verdict, EvalError>
Compares answers A and B, returning which is better.
Runs twice with A/B swapped to eliminate position bias: a consistent winner in both counts,
otherwise a tie. P2-4: the two asks are independent and fire concurrently via future::join
(eliminating the N+1 serial round-trips).
Trait Implementations§
Source§impl<M: BaseChatModel> PairwiseEvaluator for PairwiseJudge<M>
P1-1: enters EvalRunner as a PairwiseEvaluator, judging the two candidates
as (a=prediction, b=reference). Score mapping: 1.0 = A wins,
0.5 = tie, 0.0 = B wins, and the label keeps the verdict meaning (a_wins / tie / b_wins).
impl<M: BaseChatModel> PairwiseEvaluator for PairwiseJudge<M>
P1-1: enters EvalRunner as a PairwiseEvaluator, judging the two candidates
as (a=prediction, b=reference). Score mapping: 1.0 = A wins,
0.5 = tie, 0.0 = B wins, and the label keeps the verdict meaning (a_wins / tie / b_wins).