Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
I

inspectus

> 编程语言
Open source

LLM Analytics

712 stars0 likes1 views
WebsiteGitHub

About

LLM Analytics

Inspectus

Inspectus is a versatile visualization tool for machine learning. It runs smoothly in Jupyter notebooks via an easy-to-use Python API.

Content

  • Installation
  • Attention Visualization
    • Preview
    • Components
    • Usage
    • Tutorials
      • Huggingface model
      • Custom attention map
  • Token Visualization
    • Preview
    • Usage
  • Distribution Plot
    • Preview
    • Usage
    • Sample Use case
  • Setting up for Development
  • Citing

Installation

bash
pip install inspectus

Attention Visualization

Inspectus provides visualization tools for attention mechanisms in deep learning models. It provides a set of comprehensive views, making it easier to understand how these models work.

Preview

Click a token to select it and deselect others. Clicking again will select all again. To change the state of only one token, do shift+click

Components

Attention Matrix: Visualizes the attention scores between tokens, highlighting how each token focuses on others during processing.

Query Token Heatmap: Shows the sum of attention scores between each query and selected key tokens

Key Token Heatmap: Shows the sum of attention scores between each key and selected query tokens

Dimension Heatmap: Shows the sum of attention scores for each item in dimensions (Layers and Heads) normalized over the dimension.

Usage

Import the library

python
import inspectus

Simple usage

python
# attn: Attention map; a 2-4D tensor or attention maps from Huggingface transformers
inspectus.attention(attn, tokens)

For different query and key tokens

python
inspectus.attention(attns, query_tokens, key_tokens)

For detailed API documentation, please refer to the official documentation.

Tutorials

Huggingface model

…

Check out the notebook here: Huggingface Tutorial

Custom attention map

python
import numpy as np
import inspectus

# 2D attention representing attention values between Query and Key tokens
attn = np.random.rand(3, 3)

# Visualize the attention values using the Inspectus library
# The first argument is the attention matrix
# The second argument is the list of query tokens
# The third argument is the list of key tokens
inspectus.attention(arr, ['a', 'b', 'c'], ['d', 'e', 'f'])

Check out the notebook here: Custom attention map tutorial

Token Visualization

This tool is used to visualize some metric related to tokens. This supports multiple metrics and the metric used for the visualization can be selected using the dropdown. Along with metrics, any aditional information can be added to tokens.

Preview

Usage

python
import inspectus
inspectus.tokens(["Hello", " World", "!"], {
    'loss': [-7.375, -8.312, -7.5625],
    'entropy': [3.323, 1.0666, 0.432]
}, token_info=["info 1", "info 2", "info 3"])

Check out the notebook here: GPT2 example

Distribution Plot

The distribution plot is a plot that shows the distribution of a series of data. At each step, the distribution of the data is calculated and maximum of 5 bands are drawn from 9 basis points. (0, 6.68, 15.87, 30.85, 50.00, 69.15, 84.13, 93.32, 100.00)

Preview

Usage

python
import inspectus

inspectus.distribution({'x': [x for x in range(0, 100)]})

To focus on parts of the plot and zoom in, the minimap can be used. To select a single plot, use the legend on the top right.

For comprehensive usage guide please check the notebook here: Distribution Plot Tutorial

Sample Use case

This plot can be used to identify the existence of outliers in the data. Following notebooks demonstrate how to use the distribution plot to identify outliers in the MNIST training loss.

MNIST

Setting up for Development

Development Docs

Citing

If you use Inspectus for academic research, please cite the library using the following BibTeX entry.

bibtext
@misc{inspectus,
 author = {Varuna Jayasiri, Lakshith Nishshanke},
 title = {inspectus: A visualization and analytics tool for large language models},
 year = {2024},
 url = {https://github.com/labmlai/inspectus},
}

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言