Skip to main content

Crate ragdrift_core

Crate ragdrift_core 

Source
Expand description

Pure-Rust core for ragdrift.

This crate computes drift scores between a baseline and a current sample across five dimensions used in RAG monitoring: data, embedding, response, confidence, and query-pattern.

The crate is split into two layers:

  • stats holds the underlying statistical primitives (Kolmogorov-Smirnov, PSI, MMD, Wasserstein).
  • detectors composes the primitives into batch detectors that take baseline and current samples and return a DriftScore.
use ndarray::Array1;
use ragdrift_core::detectors::ConfidenceDriftDetector;

let baseline = Array1::from(vec![0.9, 0.85, 0.92, 0.88, 0.91]);
let current = Array1::from(vec![0.6, 0.55, 0.62, 0.58, 0.61]);
let detector = ConfidenceDriftDetector::default();
let score = detector.detect(&baseline.view(), &current.view()).unwrap();
assert!(score.exceeded);

Re-exports§

pub use error::RagDriftError;
pub use error::Result;
pub use types::BaselineSnapshot;
pub use types::DriftDimension;
pub use types::DriftReport;
pub use types::DriftScore;

Modules§

detectors
High-level drift detectors. Each composes one or more stats primitives into a DriftScore.
error
Error type used across the crate.
stats
Statistical primitives used by the detectors.
types
Public data types: drift scores, reports, and baseline snapshots.