Skip to main content

ragdrift_core/
lib.rs

1//! ragdrift-core: five-dimensional drift detection for production RAG systems.
2//!
3//! This crate exposes detectors for **data**, **embedding**, **response**,
4//! **confidence**, and **query-pattern** drift, plus the underlying statistical
5//! primitives (KS, PSI, MMD, sliced Wasserstein). All numerics live here; the
6//! Python `ragdrift` package is a thin PyO3 wrapper.
7//!
8//! # Example
9//!
10//! ```
11//! use ndarray::Array2;
12//! use ragdrift_core::detectors::EmbeddingDriftDetector;
13//!
14//! let baseline = Array2::<f32>::zeros((50, 16));
15//! let mut current = Array2::<f32>::zeros((50, 16));
16//! current += 1.0;
17//!
18//! let detector = EmbeddingDriftDetector::new(0.1);
19//! let score = detector.detect(baseline.view(), current.view()).unwrap();
20//! assert!(score.score > 0.0);
21//! ```
22
23#![deny(missing_docs)]
24#![deny(unsafe_code)]
25
26pub mod detectors;
27pub mod error;
28pub mod stats;
29pub mod types;
30
31pub use error::RagDriftError;
32pub use types::{BaselineSnapshot, DriftDimension, DriftReport, DriftScore};
33
34/// Result alias used across the crate.
35pub type Result<T> = std::result::Result<T, RagDriftError>;