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.3.tar.gz (20.3 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.3-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: deepdrift-1.1.3.tar.gz
  • Upload date:
  • Size: 20.3 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.3.tar.gz
Algorithm Hash digest
SHA256 dc0b324473ef2da860fffdc47c3565031f6a2469e432afdab23f738cf4b578b9
MD5 19a9903d80ff18f3a0099ef934518c29
BLAKE2b-256 62ea1049a362ecb54380fa5529caa84d14356dfce7f27a47965af917521e3e4e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: deepdrift-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 13.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 56b9ac413b2abb1af6c836d8128e2cf4f2131bc89de9460576a756487aa3b471
MD5 ab37bf3ddca597d9980878ad10a702d5
BLAKE2b-256 db26e15ccf1905f6df4341a25b95a6130d5ff8d8e2fb9e967dfaefe17343ef34

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