---
title: 'TCP-LLaVA: Token Compression for WSI-VQA'
url: https://www.emergentmind.com/topics/token-compression-pathology-llava-tcp-llava
type: topic
---

# TCP-LLaVA: Token Compression for WSI-VQA

Token Compression Pathology LLaVA (TCP-LLaVA) is a LLaVA-style multimodal large language model architecture for whole-slide image visual question answering that introduces an explicit token compression stage between patch encoding and language-model decoding. In "Efficient Whole Slide Pathology VQA via Token Compression" [2507.14497], TCP-LLaVA is presented as the first MLLM architecture to perform WSI VQA via token compression: a frozen pretrained visual encoder embeds thousands to tens of thousands of WSI patches, a modality compression module distills the resulting visual tokens together with textual context into a compact set of trainable compression tokens, and only the compressed tokens are forwarded to the LLM for answer generation. The acronym also intersects with a broader LLaVA literature on token-compression-induced degradation, where aggressive reduction of visual tokens can impair perception, OCR, grounding, and reasoning [2412.08771].

## 1. Problem setting: whole-slide image VQA and sequence-length pressure

Whole-slide images in pathology can reach up to \(10{,}000 \times 10{,}000\) pixels, and WSI-VQA pairs a gigapixel WSI with a natural-language question, sometimes with multiple-choice answers (A–D). A WSI is tiled into non-overlapping \(224 \times 224\) patches, yielding thousands to tens of thousands of patches per slide. If each patch contributes a visual token to an LLM, the sequence length can easily exceed 10,000 tokens per slide, which stresses context-length limits and induces quadratic attention costs in both memory and compute [2507.14497].

The long-sequence bottleneck is formalized by letting \(L = L_v + L_t\), where \(L_v\) denotes visual tokens and \(L_t\) denotes text tokens. Standard decoder self-attention then scales as \(O(L^2)\) in time and \(O(L^2)\) in memory. In WSI-VQA, \(L_v > 10{,}000\) and typical \(L_t \ll L_v\), so the visual side dominates the computational profile. This is the central systems problem that TCP-LLaVA addresses [2507.14497].

Prior pathology pipelines illustrate the trade-off. CLIP+MIL models compress patch features into a single slide descriptor and work well for classification, but they lack the generative capacity and dialog-style reasoning required for VQA. WSI-level MLLMs such as SlideChat directly feed thousands of patch tokens to an LLM to enable VQA, but this is resource-heavy and scales poorly with WSI size. TCP-LLaVA is positioned between these regimes: it preserves the generative advantages of MLLMs while replacing the raw visual-token stream with a compact learned representation [2507.14497].

## 2. Architecture and modality compression mechanism

TCP-LLaVA consists of four stages: WSI preprocessing and patch encoding, text tokenization, modality compression, and LLM decoding. A frozen pretrained visual encoder initialized from CONCH embeds each patch, and a linear projection aligns visual features to the LLM hidden size \(d\), producing visual tokens \(X \in \mathbb{R}^{L_v \times d}\). The question, and optionally multiple-choice options, are tokenized by the LLM tokenizer to produce textual embeddings \(T \in \mathbb{R}^{L_t \times d}\). The language backbone is instantiated from Qwen2.5-7B-Instruct in a LLaVA-style integration [2507.14497].

The compression stage maintains \(K\) trainable compression tokens \(C \in \mathbb{R}^{K \times d}\), with \(K = 100\) as the recommended default. These tokens jointly attend over the concatenated multimodal sequence \([X; T]\). In the paper’s single-head formulation,
\[
Q_c = C W_q, \qquad K_{\text{all}} = [X; T] W_k, \qquad V_{\text{all}} = [X; T] W_v,
\]
\[
A = \operatorname{softmax}\!\left(\frac{Q_c K_{\text{all}}^\top}{\sqrt{d}}\right) \in \mathbb{R}^{K \times (L_v + L_t)},
\]
\[
Z = A V_{\text{all}} \in \mathbb{R}^{K \times d}.
\]
With residual, normalization, and feed-forward structure, one compression layer is written as
\[
\tilde{Z} = \operatorname{LN}(C + Z), \qquad \hat{Z} = \operatorname{LN}(\tilde{Z} + \operatorname{MLP}(\tilde{Z})).
\]
In practice, the modality compression module is initialized from the early layers of the target LLM, so its blocks already contain multi-head attention, residual connections, layer norms, and MLPs [2507.14497].

Conceptually, each compression token functions as a learnable \([CLS]\)-like query over visual and textual context. Only the compressed tokens are forwarded as the “image-side” evidence to the LLM, while the question prompt itself is still provided to the LLM as ordinary text tokens for generation. The model therefore replaces thousands of visual tokens with approximately 100 compressed tokens while keeping the question text intact [2507.14497].

This joint compression is text-conditioned rather than purely visual. Appendix t-SNE visualizations show that the compressed tokens cluster tightly and lie close to the text token cluster, while the uncompressed visual tokens are spread. The paper interprets this as evidence that compression is heavily text-guided: the module distills image evidence most relevant to the question, rather than producing a generic slide summary [2507.14497].

## 3. Complexity, efficiency, and training protocol

TCP-LLaVA changes the computational profile of WSI-VQA in two places. First, the compression module performs cross-attention from \(K\) queries to \(L_v + L_t\) keys and values, which costs \(O(K(L_v + L_t))\) per layer when suppressing constant factors. Second, the LLM no longer receives \(L_v\) raw visual tokens; instead, its effective sequence is \(L_t + K\), so the per-layer self-attention cost becomes \(O((L_t + K)^2)\) instead of \(O((L_t + L_v)^2)\). The dominant complexity therefore switches from
\[
O((L_t + L_v)^2)
\]
to
\[
O(K(L_v + L_t)) + O((L_t + K)^2).
\]
With \(L_v \gg L_t\) and \(K \ll L_v\), this yields large savings [2507.14497].

The reported empirical gains are consistent with that analysis. Replacing \(L_v \approx 10{,}000\) with \(K = 100\) reduces the visual-token dimension by more than 99%. The paper reports a \(>99\%\) reduction in LLM input length on the visual side; training TFLOPS increases from 2.35 for SlideChat to 10.87 for TCP-LLaVA on a single NVIDIA A6000 (48 GB) under batch size 1 and no gradient accumulation; training throughput improves from 0.42 to 179.46 samples/s; inference throughput improves from 0.58 to 3.33 samples/s; and end-to-end wall-clock for 10,000 samples is 0.67 hours for TCP-LLaVA versus 1 hour for SlideChat under partial fine-tuning, a \(\approx 33\%\) reduction in training time [2507.14497].

The training setup is deliberately narrow in scope. The visual encoder and LLM are frozen; only the projector and the compression module are trained. Optimization uses AdamW, linear warmup plus cosine decay, learning rate \(1.5 \times 10^{-5}\), 2 epochs, batch size 1, 8 gradient-accumulation steps, and FP16 mixed precision. The objective is standard autoregressive language modeling over the answer tokens \(A = (a_1, \ldots, a_T)\):
\[
\mathcal{L}_{\text{VQA}} = -\sum_{t=1}^{T} \log P(a_t \mid a_{<t}, \hat{Z}, Q),
\]
where \(\hat{Z}\) denotes the final compressed tokens and \(Q\) the question prompt [2507.14497].

## 4. Benchmark results on TCGA-derived WSI-VQA

The evaluation dataset is a TCGA-derived WSI-VQA benchmark with ten tumor subtypes: BLCA, BRCA, COAD, GBM, HNSC, LGG, LUAD, LUSC, READ, and SKCM. At the QA level, the dataset contains tens of thousands of pairs per subtype, including BRCA 37,564; LGG 30,074; GBM 21,009; LUAD 17,969; LUSC 16,438; BLCA 15,294; COAD 14,481; HNSC 13,615; READ 5,287; and SKCM 4,066. The WSI split is 8:1:1 train/val/test per tumor, with no slide overlap across splits. Questions are multiple-choice with four options, and the model generates a free-form answer string that includes the chosen letter, which is parsed to compute accuracy [2507.14497].

Average accuracy favors TCP-LLaVA over both generic MLLMs and WSI-oriented baselines.

| Model | Setting | Average accuracy |
|---|---|---:|
| LLaVA-v1.6-Vicuna-7B | 30-patch setting per slide | 34.63% |
| LLaVA-Med | 30-patch setting per slide | 44.35% |
| Quilt-LLaVA | 30-patch setting per slide | 38.99% |
| SlideChat | WSI-level MLLM | 77.23% |
| SlideChat + DivPrune | token pruning | 77.18% |
| TCP-LLaVA | token compression | 78.57% |

Representative per-subtype comparisons show mixed but generally favorable behavior relative to SlideChat. TCP-LLaVA reaches BLCA 83.54 vs 81.65, COAD 76.43 vs 74.52, GBM 80.00 vs 75.00, LUAD 76.44 vs 74.87, READ 87.84 vs 85.14, and SKCM 82.35 vs 79.41. It ties on HNSC at 78.79 and LGG at 79.34, while BRCA is 67.56 vs 69.57 and LUSC is 73.45 vs 74.01. The paper’s stated takeaways are that MLLMs specialized for WSI outperform generic LLaVA variants on this task, direct token pruning preserves SlideChat’s performance but does not improve it, and compression-based TCP-LLaVA slightly improves accuracy over the strongest WSI baseline while cutting cost [2507.14497].

Ablation studies further constrain the interpretation. Replacing token compression with ACMIL inside the SlideChat pipeline yields comparable or lower accuracy: on BRCA, both methods achieve 67.56%; on LUAD, TCP-LLaVA improves from 74.35% for ACMIL+SlideChat to 75.39%. Varying the number of compression tokens from 100 to 4,000 produces small performance variation on BRCA, approximately 67.1–67.8%, and modest gains on LUAD, 74.35% to 75.92%. This indicates diminishing returns beyond a few hundred tokens, with \(K = 100\) already capturing most of the benefit at a fraction of the cost [2507.14497].

## 5. Relation to token compression pathology in the broader LLaVA literature

The name TCP-LLaVA belongs to a pathology-domain model in [2507.14497], but the broader LLaVA literature uses closely related analyses to describe failure modes that occur when visual tokens are compressed too aggressively. "LLaVA-Zip: Adaptive Visual Token Compression with Intrinsic Image Information" [2412.08771] diagnoses visual token overload and performance degradation under fixed or naive compression; "LLaVA-PruMerge: Adaptive Token Reduction for Efficient Large Multimodal Models" [2403.15388] frames the issue in terms of detail loss, semantic drift, hallucination, degraded spatial reasoning, and instability across inputs; and "LLaVA-Mini: Efficient Image and Video Large Multimodal Models with One Vision Token" [2501.03895] attributes the brittleness of direct compression to the fact that many vision tokens are crucial in the early layers of the LLM backbone.

The quantitative pattern in general-purpose LLaVA is severe. In LLaVA-Zip, static compression at inference degrades LLaVA-1.5 from 576 to 144 to 64 visual tokens with benchmark drops such as GQA 62.78 \(\rightarrow\) 56.63 \(\rightarrow\) 52.55, MM-Vet 33.62 \(\rightarrow\) 24.77 \(\rightarrow\) 19.49, and TextVQA 46.82 \(\rightarrow\) 27.08 \(\rightarrow\) 16.38. The paper describes this as strong empirical evidence that static compression harms tasks that depend on spatial detail and textual grounding, with TextVQA suffering most [2412.08771].

Different mitigation strategies follow different diagnoses.

| Paper | Core mechanism | Representative evidence |
|---|---|---|
| LLaVA-Zip [2412.08771] | Dynamic Feature Map Reduction using \(\overline{\sigma}\) and threshold \(\tau\) | At 64 tokens, DFMR gives TextVQA 32.03 vs 16.38 for static LLaVA-1.5 |
| LLaVA-PruMerge [2403.15388] | IQR-based adaptive token selection from \([CLS] \rightarrow\) patch attention plus key-based KNN merging | \(\approx 18\times\) average compression; FP16 prefill FLOPs 9.3 \(\rightarrow\) 0.91 |
| LLaVA-Mini [2501.03895] | Modality pre-fusion outside the LLM plus query-based compression to one token | 1 vision token instead of 576; FLOPs reduced by 77% |

In LLaVA-Zip, DFMR is inserted between the CLIP vision encoder and the projector, computes the mean of patch standard deviations \(\overline{\sigma}\), selects a compression factor \(s \in \{1,2,3\}\) according to threshold \(\tau\), and then applies \(s \times s\) average pooling. Its 64-token results improve substantially over static compression: GQA 59.72 vs 52.55, LLaVA-Bench 62.30 vs 47.50, and TextVQA 32.03 vs 16.38 [2412.08771].

In PruMerge, token importance is derived from sparse attention between the class token and visual tokens. Outliers are selected by interquartile-range rules, retained tokens become cluster centers, and pruned information is merged back into them via key-similarity KNN and attention-weighted averaging. The paper reports 18× average compression in the abstract, 5.5% tokens retained across six tasks in the detailed analysis, FP16 prefill FLOPs 9.3 \(\rightarrow\) 0.91, prefill time 88.6 ms \(\rightarrow\) 15.3 ms, and activation memory 4.60 GB \(\rightarrow\) 0.28 GB on V100 with Vicuna-7B [2403.15388].

In LLaVA-Mini, the central claim is that most vision tokens only play a crucial role in the early layers of the LLM backbone, where they mainly fuse visual information into text tokens. The model therefore moves this fusion stage outside the LLM with \(N_{\text{fusion}}\) Transformer blocks and then compresses the visual stream with learnable queries. Under the extreme setting \(C=1\), one image is represented by a single token. The paper reports that LLaVA-Mini outperforms LLaVA-v1.5 with just 1 vision token instead of 576, reduces FLOPs by 77%, delivers low-latency responses within 40 milliseconds, and can process over 10,000 frames of video on 24 GB of GPU memory [2501.03895].

Taken together, these works indicate that token compression in LLaVA-like MLLMs is not a single technique but a design space. TCP-LLaVA in pathology uses trainable compression tokens over \([X; T]\); DFMR uses intrinsic image variability; PruMerge uses attention sparsity plus merging; and LLaVA-Mini uses pre-fusion plus query-based compression. A plausible implication is that the pathology-domain TCP-LLaVA belongs to the same broader family of attempts to replace naive visual-token reduction with adaptive, information-preserving compression.

## 6. Limitations, failure modes, and open directions

TCP-LLaVA remains a lossy compression system. The pathology paper explicitly notes potential information loss: subtle but diagnostically crucial signals, such as rare tumor features occupying few patches, may be discarded. Although average accuracy is strong and GBM improves by 5.00 percentage points relative to SlideChat, BRCA and LUSC show small regressions, which is consistent with possible over-compression or sampling sensitivity. The model also depends on non-overlapping \(224 \times 224\) tiling, so fine-grained or boundary features may be missed, and results depend on the tiling scale and number of extracted patches [2507.14497].

The current empirical scope is limited to TCGA-derived slides and question templates refined from SlideBench and WSI-VQA. External generalization, domain shifts such as scanner and staining variation, and artifact robustness were not reported. The supervision target is VQA rather than long-form pathology report generation, and the paper identifies extension to report generation and rationale extraction as future work [2507.14497].

Related LLaVA studies show that compression pathologies are mitigated rather than eliminated. LLaVA-Zip reports that extreme compression still hurts detail-sensitive tasks even when DFMR is used, for example TextVQA 47.13 at 576 tokens versus 32.03 at 64 tokens. LLaVA-Mini likewise reports residual deficits on some metrics relative to LLaVA-v1.5, including POPE \(-1.5\), TextVQA \(-1.3\), and MME \(-44.7\), despite strong overall averages [2412.08771; 2501.03895]. This suggests that aggressively shortened visual prefixes remain vulnerable when tasks require OCR, counting, or highly localized evidence.

The future directions listed for TCP-LLaVA follow naturally from those limits: adaptive or hierarchical compression, multi-scale WSIs, pathology priors such as nuclei or tissue segmentation cues, retrieval-augmented patch selection, and extensions beyond QA. In the broader LLaVA compression literature, corresponding open questions concern how to choose compression ratios dynamically, how to preserve rare but important signals, and how to distribute compute between fusion and compression stages without reintroducing the quadratic cost that token compression is intended to avoid [2507.14497; 2501.03895].

Source: https://www.emergentmind.com/topics/token-compression-pathology-llava-tcp-llava