How liliupeng28/icml26-cvsearch works
1. Repository shape
- The repo is organized as three major subsystems: cvsearch/ for the CVSearch orchestration logic, llava/ for multimodal LLM backbones and serving/training utilities, and sam3/ for the visual expert and region-search machinery.
- In practice, CVSearch is the top-level pipeline, while LLaVA and SAM3 are the model/runtime dependencies it composes.
2. CVSearch core
- cvsearch/CVSearch.py and cvsearch/perform_CVSearch.py appear to be the main inference entrypoints for the paper’s “assess-then-search” workflow.
- cvsearch/models/ contains backbone-specific wrappers for LLaVA, InternVL, QwenVL, and SAM3, plus search-specific helpers like tree.py and utils.py.
- This layer is where the framework decides when to answer directly, when to invoke visual search, and how to merge search results back into the final reasoning step.
3. Search strategy boundary
- The architectural boundary in CVSearch is between language-side assessment/reasoning and vision-side exploration.
- The search side uses semantic-aware patching and iterative bottom-up exploration rather than a fixed grid, which is why there is dedicated tree/search logic instead of just image preprocessing.
- The repository’s benchmark-specific example prompts in cvsearch/ic_examples/ indicate that search behavior is conditioned by task format and benchmark style.
4. Backbone model adapters
- cvsearch/models/modeling_llava.py, modeling_internvl.py, and modeling_qwenvl.py provide a compatibility layer over different multimodal LLM families.
- These wrappers likely normalize prompt format, image input handling, and response parsing so the search controller can work across multiple model backbones.
- modeling_sam3.py connects the search framework to the SAM3 visual expert.
5. LLaVA subsystem
- llava/ is a self-contained multimodal model stack: conversation formatting, multimodal utilities, model builders, language-model variants, vision encoders, projectors, and resamplers.
- It includes support for several LLM families under llava/model/language_model/ and multiple vision encoders under llava/model/multimodal_encoder/.
- The presence of projectors and resamplers shows the main architectural boundary inside LLaVA: raw visual embeddings are transformed before they are injected into the language model.
6. SAM3 subsystem
- sam3/ is the repository’s second major model stack and serves as the visual expert / segmentation engine used by CVSearch.
- It contains:
- model/ for the core SAM3 image/video/trackers, encoders, decoders, memory, and vision-language combiner components,
- agent/ for higher-level inference orchestration with LLM and SAM3 clients,
- eval/ for image/video segmentation and tracking benchmarks,
- train/ for dataset loading, losses, transforms, and distributed training.
- This subsystem is broader than just segmentation; it also supports tracking and video inference, which suggests CVSearch can rely on SAM3 for richer local-region discovery.
7. Runtime data flow
- Typical flow: a benchmark sample is loaded, the chosen MLLM backbone performs an initial assessment, and CVSearch decides whether the answer is confident enough or whether search is required.
- If search is triggered, the framework delegates to SAM3-based region proposal / expert assistance, crops or patches are generated, and the backbone is queried again with more focused visual evidence.
- The search loop continues with pruning and adaptive patch selection until the answer is produced or the search budget is exhausted.
8. Evaluation pipeline
- cvsearch/eval/ contains benchmark-specific result scripts for fines-bench, hr-bench, mme-realworld, treebench, and vstar.
- cvsearch/run_eval_cvsearch.sh is the main automation entrypoint for running the paper evaluations and generating answer files.
- The evaluation flow is file-based: model outputs are written as JSONL answer logs, then scored by benchmark-specific post-processing scripts.
9. Benchmark configuration and prompts
- The JSON files in cvsearch/ic_examples/ encode task-specific few-shot or reasoning templates for different benchmarks and modes.
- This makes prompt formatting part of the architecture, not just an external concern, because the search strategy depends on benchmark-specific instruction structure.
10. Training code is present but not the main CVSearch path
- CVSearch itself is described as training-free, but the repo still includes training stacks for the underlying models.
- llava/train/ contains LLaVA fine-tuning, DPO, memory-aware, and search-training entrypoints.
- sam3/train/ contains full training support for SAM3, including configs, datasets, losses, optimizers, and distributed utilities.
- These training subsystems are supporting infrastructure rather than the primary inference architecture.
11. Serving and deployment
- llava/serve/ provides controller/worker/gradio/CLI components for serving LLaVA-style models.
- sam3/agent/ provides agent-style inference and client abstractions for SAM3 and LLM integration.
- These are separate runtime surfaces from the CVSearch benchmark runner, useful for demos or interactive use rather than batch evaluation.
12. Model and asset dependencies
- The repo includes CLIP/EVA-related encoder code and vocab assets, indicating that visual encoding depends on pretrained vision backbones and their tokenization/configuration.
- The README also calls out external checkpoints for SAM3, LLaVA-OneVision, InternVL2.5, and Qwen2.5/3-VL, plus the evaluation dataset bundle under datasets/hr_data.
- Those external artifacts are important architectural dependencies because the repo mostly orchestrates pretrained models rather than defining them from scratch.
13. Key architectural takeaway
- The repo is a composition framework: CVSearch coordinates an MLLM backbone plus a visual expert, with benchmark-specific evaluation wrappers around that loop.
- The main diagram should show three boundaries: multimodal reasoning backbones, visual search/expert extraction, and evaluation/benchmark drivers.
Main entry points: models Model Adapters · llava_arch.py LLaVA Arch · CVSearch.py CVSearch API · model SAM3 Model
Components 17
CVSearch
Top-level assess-then-search orchestration and benchmark runners.
- CVSearch API · Main inference entrypoints for the assess-then-search loop.
cvsearch/CVSearch.py - Search Runner · Command-line flow for running CVSearch over benchmarks.
cvsearch/perform_CVSearch.py - Model Adapters · Compatibility layer for different multimodal backbones and search helpers.
cvsearch/models - Search Tree · Tree and utility logic for iterative bottom-up exploration and pruning.
cvsearch/models/tree.py - IC Prompts · Benchmark-conditioned few-shot and reasoning templates.
cvsearch/ic_examples
LLaVA
Multimodal language backbone stack used as one of the model runtimes.
- Model Builder · Builds and wires LLaVA multimodal models and components.
llava/model/builder.py - LLaVA Arch · Core interface for mixing visual features into the language model.
llava/model/llava_arch.py - Vision Encoders · CLIP/EVA/HF/OpenCLIP/SigLIP-style visual backbones.
llava/model/multimodal_encoder - Projectors · Transforms visual embeddings before they enter the language model.
llava/model/multimodal_projector - Resamplers · Compresses or reorganizes visual tokens for multimodal prompting.
llava/model/multimodal_resampler - LLM Variants · Supported language-model families used inside LLaVA.
llava/model/language_model
SAM3
Visual expert, segmentation, tracking, and agent runtime.
- SAM3 Model · Image/video segmentation, tracking, memory, and combiner components.
sam3/model - Agent Runtime · Higher-level LLM/SAM3 client integration and iterative region search assistance.
sam3/agent - SAM3 Eval · Benchmark and metric toolkits for image, video, and tracking evaluation.
sam3/eval - SAM3 Train · Datasets, losses, transforms, optimizers, and distributed training support.
sam3/train
Evaluation
Benchmark-specific scoring and automation around CVSearch.
- Bench Eval · Benchmark-specific result scripts for CVSearch outputs.
cvsearch/eval - Eval Script · Main shell entrypoint for running paper evaluations.
cvsearch/run_eval_cvsearch.sh
Connections 19
- CVSearch API → Model Adapters: dispatches to · Selects a backbone-specific wrapper and search mode.
- Search Runner → CVSearch API: invokes · Batch runner launches the core inference flow.
- Model Adapters → Model Builder: uses · LLaVA-compatible adapter can instantiate a LLaVA stack.
- Model Adapters → Search Tree: coordinates · Search wrappers manage tree state and adaptive patch selection.
- Model Adapters → SAM3 Model: calls · SAM3 adapter links search control to the visual expert.
- Model Adapters → IC Prompts: conditions on · Prompt templates vary by benchmark and reasoning mode.
- Model Builder → LLaVA Arch: assembles · Builds the multimodal model around the shared architecture.
- LLaVA Arch → Vision Encoders: ingests · Consumes visual features from supported encoders.
- LLaVA Arch → Projectors: routes through · Projects image features before language fusion.
- LLaVA Arch → Resamplers: optionally uses · Token compression/reformatting for multimodal inputs.
- LLaVA Arch → LLM Variants: pairs with · Multiple language-model families are supported behind the same interface.
- Agent Runtime → SAM3 Model: orchestrates · Agent layer drives SAM3 inference and expert queries.
- Agent Runtime → LLM Variants: pairs with · Agent runtime can combine LLM reasoning with SAM3 outputs.
- SAM3 Model → SAM3 Eval: feeds · Core model outputs are scored by evaluation tooling.
- SAM3 Model → SAM3 Train: trained by · Training stack supports the underlying SAM3 model family.
- CVSearch API → Agent Runtime: delegates search to · Search loop can request region proposals or expert assistance.
- CVSearch API → Bench Eval: produces outputs for · Inference emits answer logs consumed by benchmark scripts.
- Eval Script → Search Runner: automates · Shell wrapper launches evaluation runs.
- Bench Eval → IC Prompts: depends on · Benchmark post-processing assumes task-specific prompt/output formats.