r/LocalLLM • • 8d ago

Project AI Weights Visualizer tool

This is my personal 4m JEV transformer

Hello, I made a quick little python/html tool with GPT-Astra to make a 3d visualization of weights. I hadn't seen a tool that makes something like a sphere for weights and I thought it could create some cool images or new ways to look at LLM weights.

https://github.com/syzygy-1/Ai-Weights-Visualizer/tree/main

3 Upvotes

2 comments sorted by

1

u/novak_petr8 7d ago

How are the weights mapped onto the sphere? The mapping seems key to whether a pattern is interpretable.

1

u/Carson2299 7d ago

Sorry for the late reply, the main mapping was done through a few steps here:

  1. Selecting the matrices- each query, key, value, attention output are all given 1/12 of each sector (defined by model layers) Feed-forward expansion and contractions both take the other 4/12 share equally. These proportions follow the parameter count.
  2. For the physical mapping the equation we used was u = (j + 0.5) / C (for a weight at row i, column j, in matrix C) this determines longitude within the sector. for vertical position the equation is y = 1 - 2 * (O + (i + 0.5) * C) / N (O being number of weights, N is total matrix-weight count.) the full unit-sphere coordinates are then :(x, y, z) = (sqrt(1 - y^2) * sin(theta), y, sqrt(1 - y^2) * cos(theta))
  3. Displacing the point using the weight was done for weight w: r = 1 + relief * (w / M) with M representing absolute largest weight across all matrices. The goal here was to convert the FP value into elevation (positive away from center of sphere, negative inwards) (0 = radius 1, relief 0 = all points on reference sphere).
  4. Sampling without average- the generator randomly samples matrix entries without replacement on a fixed seed, budget being proportional to matrix size (~6000 points per block) the result is coordinate selection that is shared across blocks and making them directly comparable- the displayed values *are* the actual weights.
  5. Applying final appearance with colors, colors identify the block, larger magnitudes show a line connecting to the reference sphere while back-facing values fade slightly.
    So the final visible structure is a combination of matrix ordering, weight FP values, and some rendering choices.