pub struct Faithfulness<M: BaseChatModel> { /* private fields */ }Expand description
Faithfulness evaluator (hallucination detection): how faithful an answer is to the reference context.
Splits prediction into atomic claims and asks the judge per claim whether it can be derived from reference;
pass rate = derivable claims / total claims.
Implementations§
Source§impl<M: BaseChatModel> Faithfulness<M>
impl<M: BaseChatModel> Faithfulness<M>
Sourcepub fn with_llm_split(self, v: bool) -> Self
pub fn with_llm_split(self, v: bool) -> Self
Splits claims with the LLM (default: rule-based on punctuation; LLM split handles comma compound sentences)
Sourcepub fn with_empty_score(self, score: f64) -> Self
pub fn with_empty_score(self, score: f64) -> Self
Score for an empty prediction: default 0.0 (no answer = not faithful); can be set to 1.0 for “not fabricating is faithful”
Sourcepub fn with_max_context_chars(self, max: usize) -> Self
pub fn with_max_context_chars(self, max: usize) -> Self
Per-claim reference-context transmission cap (chars). P2-5: default 2000, preventing a long reference from being fully stuffed into the prompt once per claim.
Trait Implementations§
Source§impl<M: BaseChatModel> Evaluator for Faithfulness<M>
impl<M: BaseChatModel> Evaluator for Faithfulness<M>
Source§fn eval<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_input: &'life1 str,
prediction: &'life2 str,
reference: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Score, EvalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn eval<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_input: &'life1 str,
prediction: &'life2 str,
reference: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Score, EvalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Scores a single prediction
Auto Trait Implementations§
impl<M> Freeze for Faithfulness<M>where
M: Freeze,
impl<M> RefUnwindSafe for Faithfulness<M>where
M: RefUnwindSafe,
impl<M> Send for Faithfulness<M>
impl<M> Sync for Faithfulness<M>
impl<M> Unpin for Faithfulness<M>where
M: Unpin,
impl<M> UnsafeUnpin for Faithfulness<M>where
M: UnsafeUnpin,
impl<M> UnwindSafe for Faithfulness<M>where
M: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more