Skip to main content

ragdrift_core/
lib.rs

1//! Pure-Rust core for ragdrift.
2//!
3//! This crate computes drift scores between a baseline and a current sample
4//! across five dimensions used in RAG monitoring: data, embedding, response,
5//! confidence, and query-pattern.
6//!
7//! The crate is split into two layers:
8//!
9//! - [`stats`] holds the underlying statistical primitives
10//!   (Kolmogorov-Smirnov, PSI, MMD, Wasserstein).
11//! - [`detectors`] composes the primitives into batch detectors that take
12//!   baseline and current samples and return a [`DriftScore`].
13//!
14//! ```rust
15//! use ndarray::Array1;
16//! use ragdrift_core::detectors::ConfidenceDriftDetector;
17//!
18//! let baseline = Array1::from(vec![0.9, 0.85, 0.92, 0.88, 0.91]);
19//! let current = Array1::from(vec![0.6, 0.55, 0.62, 0.58, 0.61]);
20//! let detector = ConfidenceDriftDetector::default();
21//! let score = detector.detect(&baseline.view(), &current.view()).unwrap();
22//! assert!(score.exceeded);
23//! ```
24
25#![deny(missing_docs)]
26#![deny(unsafe_code)]
27#![warn(rust_2018_idioms)]
28
29pub mod detectors;
30pub mod error;
31pub mod stats;
32pub mod types;
33
34pub use error::{RagDriftError, Result};
35pub use types::{BaselineSnapshot, DriftDimension, DriftReport, DriftScore};