ragdrift-core
Pure-Rust core for ragdrift: 5-dimensional drift detection for production RAG systems.
This crate is the numerical engine. It has no Python or FFI surface and is
suitable for embedding in a Rust service that wants to compute drift scores
without going through Python. The Python bindings live in ragdrift-py
in the same workspace.
What it computes
- Data drift — feature-wise Kolmogorov-Smirnov and Population Stability Index.
- Embedding drift — Maximum Mean Discrepancy (RBF kernel, median-heuristic bandwidth) plus sliced Wasserstein-1 over the embedding matrix.
- Response drift — distribution shift over response length and unigram entropy, with optional embedding-based semantic shift.
- Confidence drift — KS test on score distributions plus Expected Calibration Error delta.
- Query-pattern drift — k-means cluster assignment shift (KL divergence).
Quick example
use Array2;
use EmbeddingDriftDetector;
let baseline: = zeros;
let current: = zeros;
let detector = default;
let score = detector.detect.unwrap;
println!;
License
Dual-licensed under MIT or Apache-2.0 at your option.