pub struct EntropyFilter {
pub max_entropy: f64,
pub min_sources: usize,
pub use_variance: bool,
pub max_variance: f64,
}Expand description
Filter for rejecting high-entropy (conflicting) entity extractions.
§Usage in RAG Systems
When multiple retrieval passes or models extract the same entity with different confidences, use this filter to:
- Accept entities where sources agree (low entropy)
- Flag/reject entities where sources disagree (high entropy)
§Example
use anno_eval::eval::calibration::EntropyFilter;
let filter = EntropyFilter::new(0.6); // Reject if entropy > 0.6
// Multiple models extracted "Apple" with these confidences:
let apple_scores = vec![0.95, 0.05, 0.5]; // Disagreement
assert!(!filter.should_keep(&apple_scores), "Should reject conflicting extractions");
let microsoft_scores = vec![0.9, 0.88, 0.92]; // Agreement
assert!(filter.should_keep(µsoft_scores), "Should keep agreeing extractions");Fields§
§max_entropy: f64Maximum allowed entropy (0.0-1.0)
min_sources: usizeMinimum number of sources required
use_variance: boolUse variance instead of entropy (faster, simpler)
max_variance: f64Maximum variance threshold (if use_variance=true)
Implementations§
Source§impl EntropyFilter
impl EntropyFilter
Sourcepub fn permissive() -> Self
pub fn permissive() -> Self
Create a permissive filter (high threshold = accepts more disagreement).
Sourcepub fn should_keep(&self, scores: &[f64]) -> bool
pub fn should_keep(&self, scores: &[f64]) -> bool
Check if scores indicate sufficient agreement to keep the extraction.
Sourcepub fn compute_score(&self, scores: &[f64]) -> f64
pub fn compute_score(&self, scores: &[f64]) -> f64
Compute the entropy/variance for logging/debugging.
Sourcepub fn agreement_grade(&self, scores: &[f64]) -> &'static str
pub fn agreement_grade(&self, scores: &[f64]) -> &'static str
Grade the level of agreement.
Trait Implementations§
Source§impl Clone for EntropyFilter
impl Clone for EntropyFilter
Source§fn clone(&self) -> EntropyFilter
fn clone(&self) -> EntropyFilter
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EntropyFilter
impl Debug for EntropyFilter
Auto Trait Implementations§
impl Freeze for EntropyFilter
impl RefUnwindSafe for EntropyFilter
impl Send for EntropyFilter
impl Sync for EntropyFilter
impl Unpin for EntropyFilter
impl UnsafeUnpin for EntropyFilter
impl UnwindSafe for EntropyFilter
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more