Skip to main content

Five-dimensional drift detection for production RAG systems. Rust core, Python bindings.

Project description

ragdrift

Five-dimensional drift detection for production RAG systems. Rust core, Python bindings.

CI PyPI crates.io Docs License

The problem

Your RAG system is in production. The retriever silently starts returning slightly worse results because your corpus drifted. The model gets more confident but no better calibrated. The mix of intents your users send shifts week-over-week. None of this surfaces as a 5xx, none of it fails your tests, none of it fires your latency alerts.

By the time someone notices in a Slack thread, it has been broken for weeks.

ragdrift watches five dimensions at once and gives you a single threshold-able report. The numerical core is Rust; the Python wheel is a thin PyO3 binding that releases the GIL on the heavy paths.

Install

pip install ragdrift-py

The PyPI distribution is ragdrift-py (the bare ragdrift name on PyPI was taken by an unrelated project). The Python import is still import ragdrift, same convention as pyyaml/yaml or opencv-python/cv2. The Rust crates on crates.io are unaffected — cargo add ragdrift works.

Optional extras:

pip install 'ragdrift-py[opensearch,aws]'        # adapter + CloudWatch exporter
pip install 'ragdrift-py[pgvector,prometheus]'
pip install 'ragdrift-py[pinecone,datadog]'

30-second quickstart

import numpy as np
from ragdrift import RagDriftMonitor

baseline = np.load("baseline_embeddings.npy")  # (n, 768) float32
current  = np.load("current_embeddings.npy")

monitor = RagDriftMonitor(embedding_threshold=0.05)
report = monitor.evaluate(
    baseline_embeddings=baseline,
    current_embeddings=current,
)
if report.any_exceeded():
    print(report.to_json())

The five dimensions

Dimension Method What it catches
Embedding MMD² (RBF) + sliced Wasserstein corpus or model embedding distribution shift
Data per-feature KS + PSI tabular feature drift (latency, retrieval count, etc.)
Response KS on lengths, optional SW response length / semantic shift
Confidence KS, optional ECE delta confidence score collapse, calibration breakage
Query k-means + symmetric KL intent-mix shift in incoming queries

See docs for the math and citations.

Why not X?

  • Arize Phoenix is great for embedding visualization and notebook-style exploration. It does not give you a single Rust-fast scalar you can alert on from Lambda.
  • Evidently is excellent for tabular drift and report generation. It does not have a sliced-Wasserstein-on-embeddings primitive in the hot path.
  • WhyLabs / NannyML are mature monitoring platforms — useful, vendor-tied, not embeddable as a library inside your service.
  • Roll your own: most teams write the first 80% in 200 lines of numpy and then hit a wall when MMD on 10k×768 takes 8 seconds in pure Python.

ragdrift is the library you reach for when you want the math right, the runtime tight, and a single dependency that handles all five dimensions.

Architecture

                       +----------------------+
                       |  RagDriftMonitor     |
                       |  (Python facade)     |
                       +----------+-----------+
                                  |
            +---------+-----------+-----------+--------+
            |         |           |           |        |
     EmbeddingDrift  DataDrift  ResponseDrift  ConfidenceDrift  QueryDrift
            |         |           |           |        |
            +---------+-----------+-----------+--------+
                                  |
                           ragdrift._native
                          (PyO3, GIL-released)
                                  |
                          ragdrift-core (Rust)
                          KS  PSI  MMD  SW  k-means

Status

0.1.0 — alpha. API may change in 0.x. Semver respected within 0.x.y; minor versions are allowed to break the surface. Core math is well-tested (45+ Rust tests, 25+ Python tests); production deployments should pin an exact version.

Contributing

See CONTRIBUTING.md. All quality gates must pass on Linux, macOS, and Windows for Python 3.10–3.13 before merge.

License

Dual-licensed under MIT or Apache-2.0 (Rust convention). Pick whichever suits.

LICENSE-MIT · LICENSE-APACHE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ragdrift_py-0.1.3.tar.gz (44.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ragdrift_py-0.1.3-cp310-abi3-win_amd64.whl (320.1 kB view details)

Uploaded CPython 3.10+Windows x86-64

ragdrift_py-0.1.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (413.8 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

ragdrift_py-0.1.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (395.6 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

ragdrift_py-0.1.3-cp310-abi3-macosx_11_0_arm64.whl (370.6 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

ragdrift_py-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl (381.7 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file ragdrift_py-0.1.3.tar.gz.

File metadata

  • Download URL: ragdrift_py-0.1.3.tar.gz
  • Upload date:
  • Size: 44.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ragdrift_py-0.1.3.tar.gz
Algorithm Hash digest
SHA256 810d282b1feed4dd0aa9154af4152f535a4ab2fb40311a35245a799557e5f3fc
MD5 a38982dcc3d470861d2d662fe6ff351c
BLAKE2b-256 ff4a82a3143cbdc147ce4d138fa1df34aee312128d136575bec33dffe4db496f

See more details on using hashes here.

Provenance

The following attestation bundles were made for ragdrift_py-0.1.3.tar.gz:

Publisher: release.yml on MukundaKatta/ragdrift

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ragdrift_py-0.1.3-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: ragdrift_py-0.1.3-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 320.1 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ragdrift_py-0.1.3-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0ad03c16009e2b07975997ac8117b0e5649d9f36ff432ce4a8806b700abcd86b
MD5 b4f14e244945a72a747cef74877039c1
BLAKE2b-256 9aab7f04a0401ed70bcae8477e8c24b45e0644b8464a0a21e6b9d1cbffb0f115

See more details on using hashes here.

Provenance

The following attestation bundles were made for ragdrift_py-0.1.3-cp310-abi3-win_amd64.whl:

Publisher: release.yml on MukundaKatta/ragdrift

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ragdrift_py-0.1.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ragdrift_py-0.1.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 61bf7fa97dcdc8b2f94d76bfc929e672b2a6c0e7988b5a6936a746fa74ed068e
MD5 07880f50b6243bd335bf393cc3c70d9c
BLAKE2b-256 dbca05435e2c62880890db60e5d6971881ad22f621e88fb1a861e6bff7fedd79

See more details on using hashes here.

Provenance

The following attestation bundles were made for ragdrift_py-0.1.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on MukundaKatta/ragdrift

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ragdrift_py-0.1.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ragdrift_py-0.1.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9ad7ff53bf2f6134469f6d1f113dae0f253593725f13305b087d6bd1d9a24c60
MD5 d0f05edd85a54907ccc8cc61042a6700
BLAKE2b-256 6e827a6e4b983ea44fb04a70728a38633404ab4d9d63fb811e2326d9dcd17a17

See more details on using hashes here.

Provenance

The following attestation bundles were made for ragdrift_py-0.1.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on MukundaKatta/ragdrift

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ragdrift_py-0.1.3-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ragdrift_py-0.1.3-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c15168617143f6a19b57646da455a3e367ca5133a80ae7a1fea814d69b696474
MD5 f966b4fa6d45061bc80e45b024bdc196
BLAKE2b-256 e4c752d4941cc468cca91261eafdaaef0d3ad06673cd7e9802421d335d8d67dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for ragdrift_py-0.1.3-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on MukundaKatta/ragdrift

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ragdrift_py-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ragdrift_py-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 283d1b55c5b044dd4356b4f4b20265614cff9ea96f25f4132009847e5dbd5281
MD5 b654012e55b98781c22b32bdf5dae483
BLAKE2b-256 b818c6c7c0ce45ea698a99a8e6b3c2376fc7ad1734e29c82cd8c3575c495bbb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for ragdrift_py-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on MukundaKatta/ragdrift

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page