Skip to main content

Zero-Training Hidden-State Monitoring for Robustness in Vision, Language, and Generative Models

Project description

DeepDrift

PyPI version Python versions License: MIT Downloads GitHub stars DOI


DeepDrift is a runtime neural network monitoring library based on analyzing the rate of change of hidden states — Semantic Velocity.

It requires no additional training, calibrates only on normal data, and introduces <1.5% computational overhead.

Zero‑training — no gradient updates, no labeled failures
Architecture‑agnostic — works with PyTorch models (ViT, CNN, MLP, Transformers)
Cross‑domain — validated on LLMs, RL, vision, and diffusion models
Production‑ready — sparse sampling, IQR thresholding, <1.5% overhead
Open source — MIT license, pip installable


📊 Graphical Abstract

DeepDrift Overview Semantic Velocity monitors internal hidden‑state dynamics across four domains: LLM hallucination detection, RL failure prediction, Vision Transformer OOD detection, and diffusion memorization detection.


🚀 Installation

From PyPI (recommended)

pip install deepdrift

From source (latest development version)

git clone https://github.com/Eutonics/DeepDrift.git
cd DeepDrift
pip install -e .

For experiments and development (extra dependencies)

pip install -e ".[all]"

🔧 Quick Start

Vision Transformer OOD Detection

from deepdrift import DeepDriftMonitor
from torchvision.models import vit_b_16

model = vit_b_16(pretrained=True)
monitor = DeepDriftMonitor(
    model,
    layer_names=['encoder.layers.11'],  # monitor last layer
    pooling='cls'
)

x = torch.randn(1, 3, 224, 224)
_ = model(x)
vel = monitor.get_spatial_velocity()
print(f"Peak velocity: {max(vel):.4f}")

RL Agent Failure Prediction

from deepdrift import DeepDriftMonitor
from stable_baselines3 import PPO

model = PPO.load("ppo_lunarlander")
monitor = DeepDriftMonitor(
    model.policy,
    layer_names=None,  # auto-detect
    pooling='flatten'
)

obs = env.reset()
while True:
    vel = monitor.get_temporal_velocity()
    if vel > threshold:  # anomaly detected!
        print("⚠️ Agent panic detected!")
    # ... take action

📚 Documentation


📈 Key Results

Domain Model / Algo AUC Cohen's d Lead Time
LLM Hallucination Qwen-2.5-7B 0.891 3.12 7.2 tokens
RL (LunarLander) PPO 0.968 2.47 12.3 steps
RL (CartPole) DQN 0.985 2.79 168 steps
RL (CartPole+noise) PPO 1.000 3.37 97 steps
ViT OOD ViT-B/16 0.817
Diffusion Memorization U-Net 3× earlier

🧪 Reproducibility

All experiments are fully reproducible:

git clone https://github.com/Eutonics/DeepDrift.git
cd DeepDrift
pip install -e ".[all]"
bash scripts/reproduce_all.sh

Results will be saved in results/ and paper/figures/.


📖 Citation

If you use DeepDrift in your research, please cite:

@article{evtushenko2026deepdrift,
  title={DeepDrift: Zero-Training Hidden-State Monitoring for Robustness in Vision, Language, and Generative Models},
  author={Alexey Evtushenko},
  year={2026},
  journal={arXiv preprint},
  url={https://github.com/Eutonics/DeepDrift}
}

📄 License

MIT License © 2026 Alexey Evtushenko


DeepDrift was developed as independent research. No affiliation with Yandex, K‑Dense, or any other organization.

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

deepdrift-1.1.4.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

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

deepdrift-1.1.4-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file deepdrift-1.1.4.tar.gz.

File metadata

  • Download URL: deepdrift-1.1.4.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for deepdrift-1.1.4.tar.gz
Algorithm Hash digest
SHA256 710c4134de288a42634324abc95fc56b43a7bffa2c65f406daabcc5ef8005065
MD5 14213aa53dca994890d798763e640004
BLAKE2b-256 b7240db026eacf663aa8dc49d6c04d731c785f952ad62ec598585e81cb55540b

See more details on using hashes here.

File details

Details for the file deepdrift-1.1.4-py3-none-any.whl.

File metadata

  • Download URL: deepdrift-1.1.4-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for deepdrift-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c3a6b16ace584b84eb2464a841b91ed8478fda76516315bc32448bb2268ff2bb
MD5 a4f6ed1830e8220d0675b204c48a95ea
BLAKE2b-256 7314a65d651ea35368f5d4938f53e60ca399a29c97ab7e39f2a62785c00225f7

See more details on using hashes here.

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