CoolFace
Apppublic

build-small-hackathon/ai-model-xray

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
2likes
App README

๐Ÿ”ฌ 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 G that 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.

RegimeConditionMeaning
๐ŸŸข Immuneฯ > 0.8, FI = 0safe to prune
๐ŸŸก Buffer0.5 โ‰ค ฯ โ‰ค 0.8prune with caution
๐Ÿ”ด Criticalฯ < 0.5do not prune

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 ๐Ÿ‡จ๐Ÿ‡ญ