The repository or configuration that created this release differ from a previous release. View details.
vlmprobe
Exploring Model Internals Beyond the Answer
vlmprobe brings lens readouts, attention explanations, causal interventions, and sparse autoencoders into one model-bound interface. It supports vision-language models, language models, and a ViT image-classification control. Bind a loaded model once, select layers and token groups, and inspect how its internal computation relates to a chosen answer.
- Lens: read vocabulary predictions from residual states, attention heads, or projected visual embeddings.
- Attention: compare attention patterns and target-conditioned spatial attributions on the same input.
- Causal: replace activations, isolate paths, block attention routes, or steer residual states and measure the resulting change.
- SAE: train or load sparse dictionaries, inspect feature activity, and measure feature interventions with reconstruction controls.
Explicit adapters handle hook locations, expanded visual-token coordinates, and model readouts. Results retain tensors and experiment metadata; shared visualization functions turn them into heatmaps, image overlays, curves, and connection graphs. Capability checks distinguish an unsupported operation from a measured zero effect.
Documentation · Demos · Visualization · Technical report · Papers and datasets
Installation
Python 3.10+ is required. Install release 1.0.1 from GitHub:
python -m pip install "vlmprobe[sae,transformers,visualization] @ git+https://github.com/gexinh/vlm-prob.git@v1.0.1"
The published package is also available on PyPI:
python -m pip install --upgrade "vlmprobe[sae,transformers,visualization]"
For tensor methods and custom PyTorch adapters, install the base package:
python -m pip install vlmprobe
The Python import name is vlmprobe. Existing vlm_probing imports remain
compatible, including adapter registration and saved Python objects.
import vlmprobe
probe = vlmprobe.Prober(model, processor) # use your loaded model
result = probe.lens.logit(tokens="last_prompt").run(inputs)
The base package requires only PyTorch. The transformers extra targets
Transformers 5.3.x and includes Accelerate, Torchvision, and Pillow;
visualization provides the plotting dependencies. Add notebooks when using
Jupyter. Model weights and complete datasets are downloaded separately.
To develop the library in a checkout, use
python -m pip install -e ".[transformers,visualization,notebooks]".
The package guide covers wheels and release publication.
Quick Start
This example loads Qwen3-VL-2B-Instruct on one CUDA GPU. Replace
example.jpg with your image, or use an image from the bundled demos.
import torch
from PIL import Image
from transformers import AutoModelForImageTextToText, AutoProcessor
from vlmprobe import Prober
model_id = "Qwen/Qwen3-VL-2B-Instruct"
model = AutoModelForImageTextToText.from_pretrained(
model_id, dtype=torch.bfloat16, device_map={"": "cuda:0"},
attn_implementation="eager",
)
processor = AutoProcessor.from_pretrained(model_id)
probe = Prober(model, processor)
messages = [{"role": "user", "content": [
{"type": "image"},
{"type": "text", "text": "What is in this image?"},
]}]
prompt = processor.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True,
)
inputs = probe.prepare(
prompt=prompt, image=Image.open("example.jpg").convert("RGB"), device="cuda:0",
)
print(probe.describe()["methods"]["lens.logit"])
result = probe.lens.logit(layers=[0, 13, 27], tokens="last_prompt").run(inputs)
token_id = result.tensors["logits"][-1, 0].argmax().item()
print(processor.tokenizer.decode([token_id]))
result.save("outputs/logit_lens")
# Read projected image tokens in the input embedding space.
visual = probe.lens.embed(tokens="visual").run(inputs, top_k=5)
# Observe the attention actually used by the language decoder.
attention = probe.attention.profile(
layers=[27], queries="last_prompt", include_attention=True,
).run(inputs)
Use a model you have already loaded, and pass its native processor dictionary
directly to .run(...) when convenient. Layer indices are zero-based; tokens
refer to the expanded sequence, including image positions. The
model guides explain each architecture's input contract.
from vlmprobe import visualization as viz
answer_id = processor.tokenizer.encode(" yellow", add_special_tokens=False)[0]
ax = viz.plot_lens_heatmap(result, target_token_id=answer_id)
ax.figure.savefig("outputs/lens.png", bbox_inches="tight")
This plots one vocabulary token's rank across selected layers and positions. A complete answer can contain several tokens; choose the intended subword explicitly, or use complete-answer metrics for interventions.
| Common operation | Purpose |
|---|---|
Prober(model, processor=None) |
Bind a caller-owned model and resolve its adapter. |
probe.describe() |
Inspect available methods, sites, and missing capabilities. |
probe.prepare(prompt=..., image=..., device=...) |
Convert formatted text and images into native inputs. |
probe.lens / probe.attention / probe.causal / probe.sae |
Configure a model-bound analysis method. |
method.run(inputs, ...) |
Execute a probe and return ProbeResult. |
method.fit_batches(...) / method.load(...) |
Calibrate or restore Tuned/Attention Lens; Jacobian Lens has a separate estimator. |
result.save(directory) |
Save CPU tensors and JSON metadata. |
The API guide covers selectors, complete-answer metrics, paired-input alignment, and result shapes. Visualization describes reusable plotting functions. The demos walk through input preparation, live model calls, calibration when needed, and plotting. Every method guide includes parameter defaults and a complete input-to-output example. A small CPU example exercises the API without downloading pretrained weights.
Model Support
Eight VLM families have explicit adapters. Text-only GPT-2/Llama and a ViT classifier provide complementary controls. Availability is method-specific; see the capability matrix.
| Family | Example checkpoint | Guide |
|---|---|---|
| Qwen3-VL | Qwen3-VL-2B-Instruct | Usage |
| Qwen2.5-VL | Qwen2.5-VL-3B-Instruct | Usage |
| Qwen2-VL | Qwen2-VL-2B-Instruct | Usage |
| Qwen3.5 | Qwen3.5-4B; hybrid attention restrictions | Usage |
| SmolVLM | SmolVLM-500M-Instruct | Usage |
| InternVL | InternVL3-1B-hf | Usage |
| LLaVA | llava-1.5-7b-hf | Usage |
| Pixtral | Pixtral-12B-2409 | Usage |
| Language models | GPT-2 / Llama | GPT-2 · Llama |
| Vision classifier | ViT-B/16 | Usage |
Methods
Each guide explains the implemented computation, parameters, outputs, and relationship to its original paper. Reusable primitives are labeled separately from paper methods.
| Family | Method guides |
|---|---|
| Lens | Logit · Tuned · Attention Lens · Jacobian · EmbedLens · Patchscopes |
| Attention | Rollout · Grad-CAM, ATTATTR, TAM, Beyond Intuition · Generic relevance · ViT DTD/LRP |
| Causal | Activation patching · IOI-style path patching · Attribution patching · Attention Knockout · EAP / EAP-IG · Residual steering / VSV |
| SAE | ReLU · TopK · Gated · JumpReLU · AbsTopK · BatchTopK · Matryoshka BatchTopK · Archetypal TopK · Archetypal JumpReLU · Matching Pursuit · Signed MP · Nonnegative OMP · Signed OMP · QSAE |
| Supporting tools | Attention profile · Head logit attribution · Probability reweighting · Temperature |
Package Architecture
src/vlmprobe/ # public import name; shares the implementation below
src/vlm_probing/
prober.py # shared model-bound entry point
api/ # method factories, capture and replay
adapters/ # explicit architecture and token-layout contracts
lenses/ # BaseLens and concrete readout methods
attention/ # BaseAttention and concrete attention methods
causal/ # BaseCausal and concrete interventions/estimators
sae/ # native dictionaries, one trainer, artifacts and model cards
training/ # calibration, checkpoint import and resume
visualization/ # shared heatmaps, overlays, curves and graphs
core/ # results and execution traces
demos/ # runnable notebooks, compact measurements and input images
docs/ # model, method, API and source guides
Family base classes keep algorithm implementations small; adapters let them share model execution. Architecture and adapter contracts describe these boundaries.
References
The paper and dataset index links the original method papers, author implementations, and datasets used for demonstrations and lens calibration. The technical report compares real readouts, explanations, and interventions on shared cases across five pretrained VLMs, with language and vision controls.
Credits
SAE integration draws on SAELens, ViT-Prisma and Overcomplete. Our native algorithms and checkpoint converters retain source attribution and MIT license notices; see SAE provenance.
Metadata
Release files for vlmprobe 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Change of provenance
The repository or configuration that created these release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| vlmprobe-1.0.1.tar.gz | 667.8 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vlmprobe-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.4 MB
Release files / vlmprobe-1.0.1.tar.gz
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | vlmprobe-1.0.1.tar.gz |
|---|---|
| Size | 667.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7b01619b2fb5ef4484db04bc4241cd26e11d269f0628e9e9a44e34972e8d7d32
|
|
BLAKE2b-256 checksum How to use checksums |
e15e7ac89587e88bd9804244056509919a3f26e607e1b4644c6eed07df75bbf0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logRelease files / vlmprobe-1.0.1-py3-none-any.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | vlmprobe-1.0.1-py3-none-any.whl |
|---|---|
| Size | 705.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
28543b37a9806ca10f0ebf866cd30290f7c265d272263c48f3360a979f4f461c
|
|
BLAKE2b-256 checksum How to use checksums |
590949caa826df14204e40fe80b224f01aec5ac93c7747999d1c8633c8686760
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logSecurity for vlmprobe 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Change of provenance
The repository that created this release differs from a previous release.
While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.
Repository
- Removed 0.9.0 GitHub: gexinh/vlm-probing
- Added 1.0.1 GitHub: gexinh/vlm-prob
Attestation for vlmprobe-1.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.