Zero-Training Hidden-State Monitoring for Robustness in Vision, Language, and Generative Models
Project description
DeepDrift
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
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
- Zenodo: 10.5281/zenodo.18622319
- GitHub: https://github.com/Eutonics/DeepDrift
- PyPI: https://pypi.org/project/deepdrift/
- Hugging Face Demo: DeepDrift Explorer
📈 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
710c4134de288a42634324abc95fc56b43a7bffa2c65f406daabcc5ef8005065
|
|
| MD5 |
14213aa53dca994890d798763e640004
|
|
| BLAKE2b-256 |
b7240db026eacf663aa8dc49d6c04d731c785f952ad62ec598585e81cb55540b
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3a6b16ace584b84eb2464a841b91ed8478fda76516315bc32448bb2268ff2bb
|
|
| MD5 |
a4f6ed1830e8220d0675b204c48a95ea
|
|
| BLAKE2b-256 |
7314a65d651ea35368f5d4938f53e60ca399a29c97ab7e39f2a62785c00225f7
|