Skip to main content

Model Activation Visualizer

Project description

+===========================================================================+
|          _____                    _____                    _____          |
|         /\    \                  /\    \                  /\    \         |
|        /::\____\                /::\    \                /::\____\        |
|       /::::|   |               /::::\    \              /:::/    /        |
|      /:::::|   |              /::::::\    \            /:::/    /         |
|     /::::::|   |             /:::/\:::\    \          /:::/    /          |
|    /:::/|::|   |            /:::/__\:::\    \        /:::/____/           |
|   /:::/ |::|   |           /::::\   \:::\    \       |::|    |            |
|  /:::/  |::|___|______    /::::::\   \:::\    \      |::|    |     _____  |
| /:::/   |::::::::\    \  /:::/\:::\   \:::\    \     |::|    |    /\    \ |
|/:::/    |:::::::::\____\/:::/  \:::\   \:::\____\    |::|    |   /::\____\|
|\::/    / ~~~~~/:::/    /\::/    \:::\  /:::/    /    |::|    |  /:::/    /|
| \/____/      /:::/    /  \/____/ \:::\/:::/    /     |::|    | /:::/    / |
|             /:::/    /            \::::::/    /      |::|____|/:::/    /  |
|            /:::/    /              \::::/    /       |:::::::::::/    /   |
|           /:::/    /               /:::/    /        \::::::::::/____/    |
|          /:::/    /               /:::/    /          ~~~~~~~~~~          |
|         /:::/    /               /:::/    /                               |
|        /:::/    /               /:::/    /                                |
|        \::/    /                \::/    /                                 |
|         \/____/                  \/____/                                  |
+===========================================================================+
Screenshot

Getting started

If uv is installed:

uv run --with openmav mav

or

uv run --with git+https://github.com/attentionmech/mav mav --model gpt2 --prompt "hello mello"

Without uv:

  1. Set up and activate a virtual environment

  2. Install the package:

    pip install openmav
    

    or

    pip install git+https://github.com/attentionmech/mav
    
  3. Run:

    mav --model gpt2 --prompt "hello mello"
    

Locally from scratch

  1. git clone https://github.com/attentionmech/mav
  2. cd mav
  3. Set up and activate a virtual environment
  4. Install the package:
    pip install .
    
  5. Run:
    mav --model gpt2 --prompt "hello mello"
    

You can replace gpt2 with other Hugging Face models for example:

  • meta-llama/Llama-3.2-1B
  • HuggingFaceTB/SmolLM-135M
  • gpt2-medium
  • gpt2-large

Note: quantized models aren't supported right now

Demos

Explanation

At every point in prediction, multiple next tokens are possible, each with a different confidence level. The tokens and the numbers near them represent these probabilities.

Layer-wise Activations

Activations are numerical values representing the forward pass through the network during inference. Each layer (or block) in GPT-style models typically consists of:

  1. An MLP sub-block
  2. An attention sub-block

For the MLP sub-block, we plot the L2 norm of activations per layer. Other metrics like average or max exist but don’t provide as much intuitive insight.

Attention Sub-block

For the attention sub-block, we measure entropy. In transformer architectures, attention determines how tokens influence one another. The entropy value gives a rough indication of how widely the attention is spread:

  • Low entropy → Sharp token-to-token relationships
  • High entropy → A broader, more diffused attention span

These are just intuitive explanations—it's best to study these concepts from multiple sources to build a solid understanding.

Contributing

IMP NOTE: The design is not good for scaling it right now to multiple backends, and stuff which i am planning.. so your pull requests will have to wait for sometime

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

openmav-0.0.4.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openmav-0.0.4-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file openmav-0.0.4.tar.gz.

File metadata

  • Download URL: openmav-0.0.4.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for openmav-0.0.4.tar.gz
Algorithm Hash digest
SHA256 5545ec8b34ad1a485edefb1061b0730e1e5698708258584cda99de5c1db42a8b
MD5 45d78d9f49ba1748444e68617071f907
BLAKE2b-256 c4f9f491bb61be04a39c53ec213fdecb9ef4b65d5624ca6a6db00f6f9210a1ba

See more details on using hashes here.

File details

Details for the file openmav-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: openmav-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for openmav-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c2ab11a67633b004440b5144cfdc3c1492b31ce7b8d602962d3a5ccd363cd73f
MD5 2587b017468512a62dbb2c9c7f93aad7
BLAKE2b-256 5e4c0235b8b3d76e0af82925a07ff1b1e684b284dbe581fffd608bf4e1d35ab5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page