Geometric OOD detection for LLM hidden states
Project description
geood
Geometric OOD detection for LLM hidden states.
Perplexity misses out-of-distribution inputs when the model is fluent in the OOD domain. geood detects them using hidden-state geometry (intrinsic dimensionality + Mahalanobis distance).
Paper: The Geometric Blind Spot of Perplexity (Tabares Montilla, 2026)
Install
pip install geood
Usage
import geood
# Calibrate with your in-distribution texts (once)
detector = geood.calibrate("meta-llama/Llama-3-8B", ref_texts)
# Detect OOD (many times)
result = detector.detect("def quicksort(arr): ...")
print(result.is_ood) # True
print(result.explain()) # "OOD detected: ref_dim=33.8, mahalanobis=12.3"
# Save/load for deployment
detector.save("my_detector.geood")
detector = geood.load("my_detector.geood")
How it works
LLM hidden states for in-distribution inputs occupy a high-dimensional subspace. OOD inputs collapse to low dimensionality, even when perplexity says they're familiar. geood calibrates on your reference corpus and detects this geometric collapse.
Key results
| Method | Code AUROC (LLaMA) | Code AUROC (Mistral) |
|---|---|---|
| Perplexity | 0.352 | 0.150 |
| geood (Mahalanobis) | 1.000 | 1.000 |
| geood (Intrinsic dim) | 1.000 | 1.000 |
Code has lower perplexity than math (2.57 vs 2.76) but collapses geometrically (dim 4 vs 34). Perplexity is blind; geometry detects it.
License
MIT
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
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 geood-0.1.0.tar.gz.
File metadata
- Download URL: geood-0.1.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28002e8457e75334cc7bb7526c850d7f9fa90c7cc48ddbc374c304dfae546190
|
|
| MD5 |
fe0577356b414b5c305f4c06a9b61281
|
|
| BLAKE2b-256 |
65b73d9abbb910eb14648f1371b8a4f9fad2cde2a4dd73321cefbca1a65da791
|
File details
Details for the file geood-0.1.0-py3-none-any.whl.
File metadata
- Download URL: geood-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
873292f7598b3eac14b54bd52d04dedb08452f74f5308b8e4ab54b4fa61ff658
|
|
| MD5 |
b51ac9a86ba7952a255142dbe2425461
|
|
| BLAKE2b-256 |
f4049a3a3c7ef551f85abdf2ccc193ea6be92c5a7d6af28f08291035befa10ea
|