Spectral Context Pruner

Spectral Context Pruner

Twenty real context chunks, embedded with all-MiniLM-L6-v2. Toggle chunks and watch the eigenvalue spectrum, the entropy, and the effective rank respond. Every number is computed live in your browser from the actual similarity matrix.

all-MiniLM-L6-v2
384 dims · 20 chunks
cosine · jacobi · shannon

Context window

    Pruner

    8
    MethodKeptCoverage Eff. rankTokens

    Cosine similarity matrix — S = E Eᵀ

    −0.45
    +1.0 ringed = kept by pruner

    Each cell is the cosine between two chunks. Zero is the neutral midpoint — unrelated chunks sit near it, so the bright blocks are the redundancy. Hover any cell for the pair.

    Eigenvalue spectrum of S

    Eigenvalues are the squared singular values of E, sorted largest first, and they always sum to n because the diagonal of S is exactly 1. Dividing them by n gives a probability distribution for free — that is what Shannon entropy consumes. A tall first bar with a long flat tail means the context says one thing repeatedly.

    Effective rank is exp(H) where H = −Σ pᵢ log pᵢ and p = λ/n. It answers “how many genuinely distinct things are in this context?” — a continuous count, not an integer. Twenty identical chunks score 1.0; twenty unrelated chunks score 20.0. Eigenvalues are computed with a cyclic Jacobi rotation solver; the similarity matrix was precomputed once from the real encoder, and every subset you select is a principal submatrix of it.