# jytmelon/g-prune architecture

> Architecture diagram of the GitHub repository jytmelon/g-prune, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jytmelon/g-prune
- Repository: https://github.com/jytmelon/g-prune

## Overview

G-Prune is a training-free visual-token pruning framework integrated into LLaVA-NeXT. The main evaluation path loads a multimodal model, prepares a question and image input, and invokes generation; within the model, visual features are encoded, resampled/projected, and combined with language-model processing. The README describes graph-based visual-token pruning and evaluation, while the tree also shows interleave and video evaluation areas. Some of those paths were not sampled, so their internal call relationships are not asserted here.

Main entry points: [`LLaVA-NeXT/llava/eval/model_vqa.py`](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/eval/model_vqa.py) (VQA evaluation), [`LLaVA-NeXT/llava/model/multimodal_resampler/builder.py`](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_resampler/builder.py) (Resampler selection), [`LLaVA-NeXT/llava/model/llava_arch.py`](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/llava_arch.py) (Multimodal architecture), [`LLaVA-NeXT/llava/model/multimodal_encoder/builder.py`](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_encoder/builder.py) (Vision encoder selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_evaluation["Evaluation and prompts"]
  node_vqa["VQA evaluation<br/>[model_vqa.py]"]
  node_interleave_eval["Interleave evaluation"]
  node_conversation["Conversation formatting<br/>[conversation.py]"]
  node_image_prep["Image preparation<br/>[mm_utils.py]"]
  node_answers["Answer output"]
end

subgraph group_loading["Model loading"]
  node_model_loader["Model loader<br/>[builder.py]"]
end

subgraph group_vision["Visual processing"]
  node_vision_builder["Vision encoder selection<br/>[builder.py]"]
  node_clip_encoder["CLIP encoder<br/>[clip_encoder.py]"]
  node_siglip_encoder["SigLIP encoder<br/>[siglip_encoder.py]"]
  node_resampler_builder["Resampler selection<br/>[builder.py]"]
  node_masked_drop["Masked drop<br/>[masked_drop.py]"]
  node_perceiver["Perceiver resampler<br/>[perceiver.py]"]
  node_qformer["Q-Former resampler<br/>[qformer.py]"]
  node_spatial_pool["Spatial pooling<br/>[spatial_pool.py]"]
  node_projector["Vision projector<br/>[builder.py]"]
  node_pooler_projector["Pooler projector"]
end

subgraph group_inference["Multimodal inference"]
  node_language_variants["Language model variants"]
  node_llama_core["Llama model core<br/>[modeling_llama.py]"]
  node_multimodal_arch["Multimodal architecture<br/>[llava_arch.py]"]
  node_token_pruning["Graph token pruning<br/>[llava_arch.py]"]
end

node_user(("Evaluation input"))

node_user -->|"provides questions"| node_vqa
node_vqa -->|"loads model"| node_model_loader
node_vqa -->|"formats prompt"| node_conversation
node_vqa -->|"prepares images"| node_image_prep
node_vqa -->|"writes answers"| node_answers
node_model_loader -->|"selects model"| node_language_variants
node_language_variants -->|"extends architecture"| node_multimodal_arch
node_language_variants -->|"uses core"| node_llama_core
node_multimodal_arch -->|"builds encoder"| node_vision_builder
node_multimodal_arch -->|"builds resampler"| node_resampler_builder
node_multimodal_arch -->|"builds projector"| node_projector
node_vision_builder -->|"selects encoder"| node_clip_encoder
node_vision_builder -->|"selects encoder"| node_siglip_encoder
node_resampler_builder -->|"selects resampler"| node_masked_drop
node_resampler_builder -->|"selects resampler"| node_perceiver
node_resampler_builder -->|"selects resampler"| node_qformer
node_resampler_builder -->|"selects resampler"| node_spatial_pool
node_projector -->|"uses pooler"| node_pooler_projector
node_multimodal_arch -.->|"prunes visual tokens"| node_token_pruning
node_user -.->|"submits evaluation"| node_interleave_eval

click node_vqa "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/eval/model_vqa.py"
click node_interleave_eval "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/eval/evaluate_interleave.py"
click node_conversation "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/conversation.py"
click node_image_prep "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/mm_utils.py"
click node_model_loader "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/builder.py"
click node_language_variants "https://github.com/jytmelon/g-prune/tree/main/LLaVA-NeXT/llava/model/language_model"
click node_llama_core "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/language_model/modeling_llama.py"
click node_multimodal_arch "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/llava_arch.py"
click node_token_pruning "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/llava_arch.py"
click node_vision_builder "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_encoder/builder.py"
click node_clip_encoder "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_encoder/clip_encoder.py"
click node_siglip_encoder "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_encoder/siglip_encoder.py"
click node_resampler_builder "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_resampler/builder.py"
click node_masked_drop "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_resampler/masked_drop.py"
click node_perceiver "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_resampler/perceiver.py"
click node_qformer "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_resampler/qformer.py"
click node_spatial_pool "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_resampler/spatial_pool.py"
click node_projector "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_projector/builder.py"
click node_pooler_projector "https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_projector/pooler_projector.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_vqa,node_interleave_eval,node_conversation,node_image_prep,node_answers toneBlue
class node_model_loader toneAmber
class node_vision_builder,node_clip_encoder,node_siglip_encoder,node_resampler_builder,node_masked_drop,node_perceiver,node_qformer,node_spatial_pool,node_projector,node_pooler_projector toneMint
class node_language_variants,node_llama_core,node_multimodal_arch,node_token_pruning toneRose
class node_user toneIndigo
```

## Components

### Evaluation and prompts

- [VQA evaluation](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/eval/model_vqa.py): `LLaVA-NeXT/llava/eval/model_vqa.py`
- [Interleave evaluation](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/eval/evaluate_interleave.py): `LLaVA-NeXT/llava/eval/evaluate_interleave.py`
- [Conversation formatting](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/conversation.py): `LLaVA-NeXT/llava/conversation.py`
- [Image preparation](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/mm_utils.py): `LLaVA-NeXT/llava/mm_utils.py`
- **Answer output**

### Model loading

- [Model loader](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/builder.py): `LLaVA-NeXT/llava/model/builder.py`

### Visual processing

- [Vision encoder selection](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_encoder/builder.py): `LLaVA-NeXT/llava/model/multimodal_encoder/builder.py`
- [CLIP encoder](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_encoder/clip_encoder.py): `LLaVA-NeXT/llava/model/multimodal_encoder/clip_encoder.py`
- [SigLIP encoder](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_encoder/siglip_encoder.py): `LLaVA-NeXT/llava/model/multimodal_encoder/siglip_encoder.py`
- [Resampler selection](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_resampler/builder.py): `LLaVA-NeXT/llava/model/multimodal_resampler/builder.py`
- [Masked drop](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_resampler/masked_drop.py): `LLaVA-NeXT/llava/model/multimodal_resampler/masked_drop.py`
- [Perceiver resampler](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_resampler/perceiver.py): `LLaVA-NeXT/llava/model/multimodal_resampler/perceiver.py`
- [Q-Former resampler](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_resampler/qformer.py): `LLaVA-NeXT/llava/model/multimodal_resampler/qformer.py`
- [Spatial pooling](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_resampler/spatial_pool.py): `LLaVA-NeXT/llava/model/multimodal_resampler/spatial_pool.py`
- [Vision projector](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_projector/builder.py): `LLaVA-NeXT/llava/model/multimodal_projector/builder.py`
- [Pooler projector](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/multimodal_projector/pooler_projector.py): `LLaVA-NeXT/llava/model/multimodal_projector/pooler_projector.py`

### Multimodal inference

- [Language model variants](https://github.com/jytmelon/g-prune/tree/main/LLaVA-NeXT/llava/model/language_model): `LLaVA-NeXT/llava/model/language_model`
- [Llama model core](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/language_model/modeling_llama.py): `LLaVA-NeXT/llava/model/language_model/modeling_llama.py`
- [Multimodal architecture](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/llava_arch.py): `LLaVA-NeXT/llava/model/llava_arch.py`
- [Graph token pruning](https://github.com/jytmelon/g-prune/blob/main/LLaVA-NeXT/llava/model/llava_arch.py): `LLaVA-NeXT/llava/model/llava_arch.py`

### Other components

- **Evaluation input**

## Connections

- Evaluation input → VQA evaluation: provides questions (evidence: `LLaVA-NeXT/llava/eval/model_vqa.py`)
- VQA evaluation → Model loader: loads model (evidence: `LLaVA-NeXT/llava/eval/model_vqa.py`)
- VQA evaluation → Conversation formatting: formats prompt (evidence: `LLaVA-NeXT/llava/eval/model_vqa.py`)
- VQA evaluation → Image preparation: prepares images (evidence: `LLaVA-NeXT/llava/eval/model_vqa.py`)
- VQA evaluation → Answer output: writes answers (evidence: `LLaVA-NeXT/llava/eval/model_vqa.py`)
- Model loader → Language model variants: selects model (evidence: `LLaVA-NeXT/llava/model/builder.py`)
- Language model variants → Multimodal architecture: extends architecture (evidence: `LLaVA-NeXT/llava/model/language_model/llava_llama.py`)
- Language model variants → Llama model core: uses core (evidence: `LLaVA-NeXT/llava/model/language_model/llava_llama.py`)
- Multimodal architecture → Vision encoder selection: builds encoder (evidence: `LLaVA-NeXT/llava/model/llava_arch.py`)
- Multimodal architecture → Resampler selection: builds resampler (evidence: `LLaVA-NeXT/llava/model/llava_arch.py`)
- Multimodal architecture → Vision projector: builds projector (evidence: `LLaVA-NeXT/llava/model/llava_arch.py`)
- Vision encoder selection → CLIP encoder: selects encoder (evidence: `LLaVA-NeXT/llava/model/multimodal_encoder/builder.py`)
- Vision encoder selection → SigLIP encoder: selects encoder (evidence: `LLaVA-NeXT/llava/model/multimodal_encoder/builder.py`)
- Resampler selection → Masked drop: selects resampler (evidence: `LLaVA-NeXT/llava/model/multimodal_resampler/builder.py`)
- Resampler selection → Perceiver resampler: selects resampler (evidence: `LLaVA-NeXT/llava/model/multimodal_resampler/builder.py`)
- Resampler selection → Q-Former resampler: selects resampler (evidence: `LLaVA-NeXT/llava/model/multimodal_resampler/builder.py`)
- Resampler selection → Spatial pooling: selects resampler (evidence: `LLaVA-NeXT/llava/model/multimodal_resampler/builder.py`)
- Vision projector → Pooler projector: uses pooler (evidence: `LLaVA-NeXT/llava/model/multimodal_projector/builder.py`)
- Multimodal architecture → Graph token pruning: prunes visual tokens (evidence: `README.md`)
- Evaluation input → Interleave evaluation: submits evaluation
