Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

mllm-token-visualiser

Latest version: v0.7.1

Overview

Last scanned
1 Dec 2026
Published
1 Dec 2026
PyPI package Publisher: rafkatgaleev
0 Stars
0 Forks
2 Versions
Python Repo language

Scan summary

mllm-token-visualiser was last scanned on 1 Dec 2026 at version 0.7.1. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 2 versions, all published on 1 Dec 2026.
  • Findings: No rules fired in version 0.7.1.

Versions

2 versions published
Versions and the rules that fired in each
VersionPublishedStatus
0.7.1 LATEST 1 Dec 2026 No rules fired
0.7.0 1 Dec 2026 No rules fired

No rules fired in 0.7.1

Findings

Findings for v0.7.1. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 0.7.1; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

MLLM Token Visualiser

Measure how text, images, video, and audio expand into model context—and estimate their memory cost before inference.

mllm-token-visualiser is a Python library for analysing tokenised multimodal inputs without loading complete model weights. It exposes one typed, model-independent API while keeping processor-specific behaviour inside adapters.

The library distinguishes user text, modality positions, chat-template overhead, and padding instead of treating every special token as removable noise.

Features

  • Counts total, text, image, video, audio, and template tokens.
  • Uses each model family's processor and chat template.
  • Preserves interleaved multimodal content order.
  • Excludes padding through the attention mask.
  • Estimates input_ids memory and decoder KV-cache memory.
  • Loads processor/configuration metadata rather than full model weights.
  • Provides an adapter interface for adding further model families.

Supported models

Model family Text Image Video Audio Status
Qwen3-VL ✅ ✅ ✅ — Implemented
Qwen3-Omni ✅ ✅ ✅ ✅ Implemented
MiniCPM-o 4.5 ✅ ✅ ✅ ✅ Implemented
Gemma 4 ✅ ✅ Checkpoint-dependent Checkpoint-dependent Implemented
NVIDIA Nemotron 3 Nano Omni FP8 ✅ ✅ ✅ ✅ Implemented

Gemma 4 modality support depends on the selected checkpoint and its processor. The adapter can account for image, video, and audio placeholders when the checkpoint supports them. Audio support is read from config.audio_config, so local paths and renamed fine-tunes work: it is set for E2B, E4B, and 12B, and null for 26B-A4B and 31B. Only a config without that attribute falls back to the model ID, with a warning. The 12B checkpoints use model_type gemma4_unified, which is not yet registered or tested, so they are matched by model ID only.

MiniCPM-o 4.5 video frames are sampled the way minicpmo-utils 1.0.6 (get_video_frame_audio_segments, used by the model card) does it: one frame per started second (ceil(duration) frames), or 64 uniformly spaced frames for videos longer than 64 seconds. Each frame is one image with max_slice_nums=1, and use_image_id=False when the conversation contains video. Frames are decoded with PyAV, so this path does not need the ffmpeg executable. The stack_frames high-refresh mode and the MAX_NUM_FRAMES environment override are not modelled.

The Nemotron adapter has been checked against the processor of nvidia/Nemotron-3-Nano-Omni-30B-A3B-Reasoning-FP8 (revision 0acd4b1c). Other precision variants may use different revisions of the remote processor and have not yet been validated. Nemotron 3 Nano Omni currently supports one video per request. Video files are sampled with PyAV before being passed to the model processor.

This project is still pre-1.0; its public API and report schema may evolve.

What it reports

Metric Meaning
total_tokens All active input positions, excluding padding
text_tokens Tokens produced by user-provided text only
image_tokens Image positions inserted into model context
video_tokens Video positions inserted into model context
audio_tokens Audio positions inserted into model context
template_tokens Roles, separators, generation prompt, and other template overhead
token_id_bytes Memory occupied by the input_ids tensor
kv_cache_bytes Estimated KV-cache memory for the analysed input
kv_cache_bytes_per_token Estimated decoder KV-cache cost per active context position
segments Per-content token counts with message index, content index, role, and modality
spans The whole active sequence as contiguous runs: text, image, video, audio, or template, with the source item and decoded text
media One entry per image/video/audio: tokens, interior overhead, placeholder groups, source-file metadata, and processor details
metadata Library/Transformers versions, adapter, processor class, generation-prompt flag, and KV-cache dimensions
assumptions The accounting and estimation assumptions that apply to this report
warnings Problems detected during analysis, for example a span that could not be aligned

KV-cache values are architectural estimates. They exclude model weights, encoder activations, temporary attention buffers, framework overhead, and allocator fragmentation.

Detailed report

Token spans

report.spans maps every active position to its origin, in sequence order. Spans always cover the whole active sequence exactly once:

for span in report.spans:
    print(span.start, span.end, span.kind, span.content_index, repr(span.text))
0     3     template None '<|im_start|>system\n'
3     9     text     0    'You are a helpful assistant.'
...
17    18    template None '<|vision_start|>'
18    210   image    1    None
210   211   template None '<|vision_end|>'
  • Media spans come from the processor's placeholder positions and are exact. One item can produce several spans, for example one per video frame group.
  • Template positions between the first and last placeholder of one media item, such as frame timestamps, are attributed to that item (message_index/content_index set, kind == "template"). The total appears as MediaDetail.overhead_tokens.
  • Each Text item is located in conversation order. exact is False when its isolated tokenization does not appear verbatim because the tokenizer merged it with neighbouring template characters (for example ":" + newline). The item is then located by its characters and the span includes the merged token.
  • If spans cannot be aligned, the report still contains all counts and explains the problem in warnings.
Media details
for item in report.media:
    print(item.modality, item.tokens, item.overhead_tokens, item.properties)

Measured with Qwen/Qwen3-VL-8B-Instruct and Transformers 5.14.1 on examples/assets/video_sample.mp4 (1024×432, 25.1 s, 23.976 fps):

video 11200 207 {'duration_seconds': 25.108, 'grid_thw': [25, 28, 64], 'frames_sampled': 50,
                 'tokens_per_frame_group': 448, 'tokens_per_second': 446.07, ...}

Source properties (width, height, duration_seconds, source_fps, sample_rate) are read from file headers only. Processor properties depend on the model family: patch grids for Qwen, pooled patches for Gemma 4, slices and sampled frames for MiniCPM-o, and tiles and sampled frames for Nemotron.

Terminal view
report.show()  # summary, composition, items, token map, warnings, assumptions
report.show(show_template=True)  # also list decoded chat-template spans
report.show(width=80, map_rows=4)  # bar/map width in cells, map height in rows

Abridged output (bar shortened, one item row shown) for Qwen/Qwen3-VL-8B-Instruct with examples/detailed_report.py:

Total tokens          11,639
KV cache (estimate)   1.60 GiB  (144.00 KiB per token, bfloat16)

Composition
█▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒··
  Kind          Tokens    Share    KV cache
  ██ text           15     0.1%    2.11 MiB
  ▓▓ image         192     1.6%   27.00 MiB
  ▒▒ video      11,200    96.2%    1.54 GiB
  ░░ audio           0     0.0%         0 B
  ·· template      232     2.0%   32.62 MiB

Input items
  Msg  Role    Item      Tokens  Share  Details
    1  user    ▒▒ video  11,200  96.2%  1024×432 → 1024×448, 25.108 s, 50 frames,
                                        grid 25×28×64, 446.07 tok/s, 224 tok/frame,
                                        +207 overhead

Each kind has its own colour and glyph (█ text, ▓ image, ▒ video, ░ audio, · template), so the view also works without colour, for example with NO_COLOR=1 or in logs. In the token map one cell stands for several positions and shows their majority kind; use report.spans or the template view for exact positions. mllm_tokens.display.render_report() returns the rich renderable for embedding in other output.

HTML report
report.save_html("report.html")  # one self-contained file, no external assets
report.save_html("report.html", embed_media=True)  # also embed image thumbnails
html = report.to_html(title="Qwen3-VL, 25 s clip")

The page shows the total, the KV-cache estimate, a composition bar, a token map with one lane per kind (hover, or focus it and use the arrow keys, to see each span's positions, owner, and decoded text), the input items with their media properties, the decoded template spans, and the warnings, assumptions, and run details. Every chart has a table view, the page follows the system light or dark theme (with a toggle; ?theme=dark also works), and "Download JSON" saves report.to_json().

By default the file contains no media: only counts, file names, header metadata, and decoded text and template spans. embed_media=True adds 240 px JPEG thumbnails of image inputs; keep it off for reports you share.

Breakdowns and export
report.tokens_by_kind()  # {'text': ..., 'image': ..., 'template': ...}
report.token_shares()  # fraction of total_tokens per kind
report.kv_cache_bytes_by_kind()  # estimated KV-cache bytes per kind

report.to_json()  # versioned JSON with derived breakdowns and field accuracy
report.segments_csv()  # one row per content item
report.spans_csv()  # one row per span

to_json() includes schema_version and a field_accuracy map that labels each count as processor-exact, tokenizer-based, derived, or estimated.

Why special-token filtering is not enough

An MLLM context contains more than ordinary text tokens:

total context
├── user text
├── image / video / audio positions
└── template overhead
    ├── role markers
    ├── separators and newlines
    └── optional generation prompt

Removing every special token would also remove genuine modality positions, while template fragments such as role text or newlines may remain. The library instead combines the original structured input with the final processor output.

Requirements

  • Python >=3.11,<3.15
  • PyTorch 2.13 or later
  • Transformers >=5.2,<5.15 (newer versions break the Gemma 4 adapter; support is planned)
  • PyAV 18 or later for Nemotron and MiniCPM-o video decoding
  • FFmpeg shared libraries for processor paths that decode audio or video through TorchCodec

TorchAudio 2.11 supports PyTorch 2.11 and later through PyTorch's stable ABI. TorchCodec 0.16 adds support for FFmpeg 9.

Installation

Install from PyPI:

pip install mllm-token-visualiser
# or, in a uv project
uv add mllm-token-visualiser

The package is imported as mllm_tokens and installs the mllm-tokens command. For Qwen3-Omni, add the optional utilities with pip install "mllm-token-visualiser[omni]".

PyTorch is a dependency. If you need a specific CUDA or CPU build, install PyTorch first by following the PyTorch instructions.

Development installation

The project uses uv for dependency management and packaging.

git clone https://github.com/Rafkat/mllm-token-visualiser.git
cd mllm-token-visualiser
uv sync

Install optional Qwen3-Omni utilities with:

uv sync --extra omni
Install a built wheel

Build the distribution:

uv build

Install version 0.7.0 into another uv project:

uv add ../mllm-token-visualiser/dist/mllm_token_visualiser-0.7.1-py3-none-any.whl
FFmpeg and video support

TorchCodec requires an FFmpeg installation that exposes shared libraries. On macOS with Homebrew:

brew install ffmpeg
ffmpeg -version

Recent TorchCodec releases support FFmpeg major versions 4 through 9. The FFmpeg executable being available in PATH does not by itself guarantee that the operating-system dynamic loader can locate libavutil, libavcodec, and the other shared libraries.

For Qwen video processing, TorchCodec can be selected explicitly:

FORCE_QWENVL_VIDEO_READER=torchcodec \
  uv run python examples/basic_video.py

Quick start

from mllm_tokens import Analyzer, Image, Message, Text

analyzer = Analyzer.from_pretrained("Qwen/Qwen3-VL-8B-Instruct")

messages = [
    Message.user(
        Image("examples/assets/image_sample.jpg"),
        Text("Describe this image."),
    )
]

report = analyzer.analyze(messages)
report.print_dict()

Analyzer.from_pretrained() loads the processor and configuration needed for analysis, not complete model weights. Reuse an Analyzer across inputs to avoid repeatedly loading processor metadata.

Command line

Installing the package adds mllm-tokens (also available as python -m mllm_tokens). Content is given in conversation order as positional arguments: a media file path (the modality comes from its extension), image:PATH, video:PATH, audio:PATH, text:TEXT, or any other text.

# Terminal view (add --show-template to list decoded template spans)
mllm-tokens analyze Qwen/Qwen3-VL-8B-Instruct examples/assets/image_sample.jpg "What is this?"

# Other formats: --format json|html|spans-csv|segments-csv, or inferred from -o
mllm-tokens analyze Qwen/Qwen3-VL-8B-Instruct clip.mp4 "Describe." -o report.html
mllm-tokens analyze google/gemma-4-e4b-it --system "Be brief." photo.png "Caption it." -f json

# Same input, several models (table, --format json, or --format csv)
mllm-tokens compare examples/assets/video_sample.mp4 "Describe the video." \
  -m Qwen/Qwen3-VL-8B-Instruct -m google/gemma-4-e4b-it \
  -m nvidia/Nemotron-3-Nano-Omni-30B-A3B-Reasoning-FP8 --trust-remote-code

Other options: --trust-remote-code (MiniCPM-o and Nemotron processors), --kv-dtype, --no-generation-prompt, and --embed-media for HTML. In compare, a model that fails (for example, one that does not accept the given modality) is shown as an error row and the others are still compared.

Output of the compare command above with the 25 s sample video (processor and config files only, transformers 5.14.1):

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • pypi-releases mllm-token-visualiser

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

CVE

Java4Shell (CVE-2026-114938): Easy to Crash, Hard to Exploit — Less Than 0.12% of JVMs Estimated at Risk of RCE

PolinRider Returns
Research

PolinRider Returns: Hijacked npm Packages Use Ethereum Blockchain to Conceal Malware Infrastructure

Critical Apache HTTP Server Flaw Exposes Web Servers to RCE (1)
CVE

CVE-2026-119618: Critical Apache HTTP Server Flaw Exposes Web Servers to Remote Code Execution

Frame 2085668439 (1)
Group 1261154229