build-small-hackathon/ai-model-xray
๐ฌ AI Model X-Ray โ Structural Health Scanner
Which layers of your transformer are compressible? Which are fragile?
Select a model or paste any HuggingFace model ID. The scanner extracts attention graphs, computes the spectral simplicial hierarchy per layer, and classifies each layer as immune (safe to prune), buffer (caution), or critical (do not touch).
Based on the spectral principle ฮปโ(T(G)) โค ฮปโ(G), validated on 45,000+ graphs with zero violations. Formally verified in Lean 4.
How it works
For each layer we average every attention head's map over a small probe set (16 sentences for text models, 16 CIFAR-10 images for vision), flatten it to a signature, and join heads whose signatures correlate (Pearson r > 0.3). On that head-to-head graph G we compute:
- ฮปโ(G) โ algebraic connectivity of the head graph.
- T(G) โ the triangle graph (edges of
Gthat share a triangle). - ฮปโ(T(G)) and the coherence ratio ฯ = ฮปโ(T(G)) / ฮปโ(G).
- FI โ the fragility index: fraction of edges sitting in zero triangles.
High ฯ with zero FI means a layer is triangle-redundant โ its head structure has slack and is safe to prune. Low ฯ means the layer is structurally load-bearing.
Pre-loaded models (BERT, GPT-2, ViT) show instantly from a precomputed cache. Custom model IDs and DistilBERT trigger a live scan on ZeroGPU.
๐ฌ Demo: [YouTube link TBD] ๐ See also: Octopus AI
Built by Cognitive Engineering ๐จ๐ญ
