Metadata-Version: 2.4
Name: anchor-drift
Version: 1.0.0
Summary: White-box LLM semantic drift detector using physical constant anchors
Author-email: Teligeng <147654390@qq.com>
License: MIT
Project-URL: Homepage, https://doi.org/10.5281/zenodo.21360603
Keywords: llm,interpretability,semantic-drift,evaluation,anchor
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: torch>=2.0
Requires-Dist: transformers>=4.40
Requires-Dist: numpy
Requires-Dist: scipy

# Anchor Drift Detector

**White-box LLM semantic drift detector using physical constant anchors.**

> 📄 Academic paper: [10.5281/zenodo.21360603](https://doi.org/10.5281/zenodo.21360603)

## Quick Start

```bash
pip install anchor-drift
anchor-drift --model-a Qwen/Qwen2.5-0.5B --model-b Qwen/Qwen2.5-7B
```

Or in Python:

```python
from anchor_drift import detect, format_report

report = detect('Qwen/Qwen2.5-0.5B', 'bert-base-chinese',
                causal_a=True, causal_b=False)
print(format_report(report))
```

## What It Does

- Projects any LLM's hidden states into a 3D coordinate system defined by physical constants (c, h, G)
- Compares two models' semantic geometry independent of architecture or dimension
- Produces a drift report with z-score significance testing
- Detects structural degradation (quantization errors, weight corruption) with zero false positives from random noise

## Key Features

- **Architecture-agnostic** — Works with BERT, Qwen, GPT, Llama; causal and encoder models
- **Dimension-independent** — Compares 768D vs 3584D models directly in 3D anchor space
- **Zero false positives** — Immune to random noise; only detects structured semantic changes
- **Category-level analysis** — Pinpoints which concept domains (animals, emotions, abstractions) drift most

## Why Physical Constants?

Six coordinate systems were tested (high-frequency words, mathematical constants, PCA). All achieve cross-model stability >0.96 — but only c/h/G provides **theoretical interpretability**: each constant defines an ontological boundary (finite/infinite, continuous/discrete, local/global).

## License

MIT — see [paper](https://doi.org/10.5281/zenodo.21360603) for academic citation.
