# sithum02/vlm-token-budget architecture

> Architecture diagram of the GitHub repository sithum02/vlm-token-budget, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sithum02/vlm-token-budget
- Repository: https://github.com/sithum02/vlm-token-budget

## Overview

This repository is a training-free visual-token reduction study for small vision-language models. The main workflow loads POPE, TextVQA, or MME examples, encodes each image, reduces its visual tokens with matched-budget strategies, generates answers, and scores the results. Separate analysis tools test paired significance, summarize results, visualize kept tokens, and benchmark runtime. The excerpts show the evaluation orchestration and several analysis relationships; benchmark internals and some model methods were not sampled, so those links are included only where documented by the README.

Main entry points: [`run_eval.py`](https://github.com/sithum02/vlm-token-budget/blob/main/run_eval.py) (Experiment runner), [`tools/visualize_tokens.py`](https://github.com/sithum02/vlm-token-budget/blob/main/tools/visualize_tokens.py) (Token visualization), [`results`](https://github.com/sithum02/vlm-token-budget/tree/main/results) (Prediction results), [`tokenbudget/data.py`](https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/data.py) (Task loaders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Benchmark inputs"]
  node_loaders["Task loaders<br/>[data.py]"]
end

subgraph group_inference["Model inference"]
  node_runner["Experiment runner<br/>[run_eval.py]"]
  node_vlm["VLM adapter<br/>[models.py]"]
  node_vision["Image encoding<br/>[models.py]"]
  node_question_scores["Attention scoring<br/>[models.py]"]
  node_reduction["Token reducers<br/>[reducers.py]"]
  node_generation["Answer generation<br/>[models.py]"]
end

subgraph group_evaluation["Scoring and analysis"]
  node_metrics["Task metrics<br/>[metrics.py]"]
  node_compute["Compute estimates<br/>[flops.py]"]
  node_artifacts["Prediction results"]
  node_bootstrap["Paired bootstrap<br/>[significance.py]"]
  node_summaries["Result summaries<br/>[summarize.py]"]
  node_timing["Hardware benchmark<br/>[benchmark.py]"]
end

subgraph group_inspection["Study inspection"]
  node_visualization["Token visualization"]
end

node_researcher(("Researcher"))
node_hub[("Dataset Hub")]
node_gpu(("Local GPU"))

node_researcher -->|"runs study"| node_runner
node_hub -->|"provides datasets"| node_loaders
node_loaders -->|"yields examples"| node_runner
node_runner -->|"loads model"| node_vlm
node_runner -->|"encodes images"| node_vision
node_runner -->|"requests scores"| node_question_scores
node_runner -->|"reduces tokens"| node_reduction
node_runner -->|"requests answers"| node_generation
node_runner -->|"scores predictions"| node_metrics
node_runner -->|"estimates cost"| node_compute
node_runner -->|"writes results"| node_artifacts
node_artifacts -->|"resamples results"| node_bootstrap
node_bootstrap -->|"uses scorers"| node_metrics
node_artifacts -->|"collects scores"| node_summaries
node_summaries -->|"uses task definitions"| node_metrics
node_researcher -->|"benchmarks runtime"| node_timing
node_researcher -->|"inspects tokens"| node_visualization
node_visualization -->|"encodes and answers"| node_vlm
node_visualization -->|"applies methods"| node_reduction
node_visualization -->|"loads POPE sample"| node_loaders
node_gpu -.->|"executes inference"| node_vlm
node_gpu -.->|"measures runtime"| node_timing

click node_loaders "https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/data.py"
click node_runner "https://github.com/sithum02/vlm-token-budget/blob/main/run_eval.py"
click node_vlm "https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/models.py"
click node_vision "https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/models.py"
click node_question_scores "https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/models.py"
click node_reduction "https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/reducers.py"
click node_generation "https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/models.py"
click node_metrics "https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/metrics.py"
click node_compute "https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/flops.py"
click node_artifacts "https://github.com/sithum02/vlm-token-budget/tree/main/results"
click node_bootstrap "https://github.com/sithum02/vlm-token-budget/blob/main/tools/significance.py"
click node_summaries "https://github.com/sithum02/vlm-token-budget/blob/main/tools/summarize.py"
click node_timing "https://github.com/sithum02/vlm-token-budget/blob/main/tools/benchmark.py"
click node_visualization "https://github.com/sithum02/vlm-token-budget/blob/main/tools/visualize_tokens.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_loaders toneBlue
class node_runner,node_vlm,node_vision,node_question_scores,node_reduction,node_generation,node_hub toneAmber
class node_metrics,node_compute,node_artifacts,node_bootstrap,node_summaries,node_timing toneMint
class node_visualization toneRose
class node_researcher,node_gpu toneIndigo
```

## Components

### Benchmark inputs

- [Task loaders](https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/data.py): `tokenbudget/data.py`

### Model inference

- [Experiment runner](https://github.com/sithum02/vlm-token-budget/blob/main/run_eval.py): `run_eval.py`
- [VLM adapter](https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/models.py): `tokenbudget/models.py`
- [Image encoding](https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/models.py): `tokenbudget/models.py`
- [Attention scoring](https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/models.py): `tokenbudget/models.py`
- [Token reducers](https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/reducers.py): `tokenbudget/reducers.py`
- [Answer generation](https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/models.py): `tokenbudget/models.py`

### Scoring and analysis

- [Task metrics](https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/metrics.py): `tokenbudget/metrics.py`
- [Compute estimates](https://github.com/sithum02/vlm-token-budget/blob/main/tokenbudget/flops.py): `tokenbudget/flops.py`
- [Prediction results](https://github.com/sithum02/vlm-token-budget/tree/main/results): `results`
- [Paired bootstrap](https://github.com/sithum02/vlm-token-budget/blob/main/tools/significance.py): `tools/significance.py`
- [Result summaries](https://github.com/sithum02/vlm-token-budget/blob/main/tools/summarize.py): `tools/summarize.py`
- [Hardware benchmark](https://github.com/sithum02/vlm-token-budget/blob/main/tools/benchmark.py): `tools/benchmark.py`

### Study inspection

- [Token visualization](https://github.com/sithum02/vlm-token-budget/blob/main/tools/visualize_tokens.py): `tools/visualize_tokens.py`

### Other components

- **Researcher**
- **Dataset Hub**
- **Local GPU**

## Connections

- Researcher → Experiment runner: runs study (evidence: `README.md`)
- Dataset Hub → Task loaders: provides datasets (evidence: `tokenbudget/data.py`)
- Task loaders → Experiment runner: yields examples (evidence: `run_eval.py`)
- Experiment runner → VLM adapter: loads model (evidence: `run_eval.py`)
- Experiment runner → Image encoding: encodes images (evidence: `run_eval.py`)
- Experiment runner → Attention scoring: requests scores (evidence: `run_eval.py`)
- Experiment runner → Token reducers: reduces tokens (evidence: `run_eval.py`)
- Experiment runner → Answer generation: requests answers (evidence: `run_eval.py`)
- Experiment runner → Task metrics: scores predictions (evidence: `run_eval.py`)
- Experiment runner → Compute estimates: estimates cost (evidence: `run_eval.py`)
- Experiment runner → Prediction results: writes results (evidence: `run_eval.py`)
- Prediction results → Paired bootstrap: resamples results (evidence: `tools/significance.py`)
- Paired bootstrap → Task metrics: uses scorers (evidence: `tools/significance.py`)
- Prediction results → Result summaries: collects scores (evidence: `tools/summarize.py`)
- Result summaries → Task metrics: uses task definitions (evidence: `tools/summarize.py`)
- Researcher → Hardware benchmark: benchmarks runtime (evidence: `README.md`)
- Researcher → Token visualization: inspects tokens (evidence: `tools/visualize_tokens.py`)
- Token visualization → VLM adapter: encodes and answers (evidence: `tools/visualize_tokens.py`)
- Token visualization → Token reducers: applies methods (evidence: `tools/visualize_tokens.py`)
- Token visualization → Task loaders: loads POPE sample (evidence: `tools/visualize_tokens.py`)
- Local GPU → VLM adapter: executes inference
- Local GPU → Hardware benchmark: measures runtime
