Medical visual question answering systems often add facts from a knowledge graph, a database of relations such as <Heart, Function, Promote blood flow>, so the model can answer questions the image alone cannot settle. These systems decide how much to trust the injected facts by reading a gate or an attention weight. A high value is taken to mean "the model is using this knowledge." The attention-interpretability literature says that reading is unsafe. A token can receive large attention while its transformed vector is nearly zero. A highly attended feature can also push the prediction away from the answer it seems to support, and this happens more often deeper in the network. In a clinical model, the consequence is concrete: a retrieved triple linking an organ to a disease can quietly overrule a clear image while the gate value looks perfectly normal.
We propose to measure, at every layer and for every question, the signed contribution that knowledge-graph tokens and image tokens each make toward the model's answer. The measurement uses only forward passes. We then use it to control the knowledge stream at inference time. A layer that receives no real contribution from the knowledge graph has it removed. A layer where the knowledge graph strongly opposes strong visual evidence has the knowledge stream shrunk. A layer where vision is silent leaves the knowledge graph free to fill in. The method needs no retraining and no backward passes, and it yields a depth profile of where external knowledge actually enters the computation.
Core Claim
Gating external knowledge with a single scalar, as current systems do, conflates two things: how much the model looks at the knowledge, and what the knowledge does to the answer. A cheap forward-pass quantity separates them, and it differs sharply across depth. Concretely, we compute at layer $l$ the contribution of a token set $S$ (knowledge-graph tokens $K$ or image tokens $V$) projected onto the decision direction:
$$c_l(S) = \Big(\sum_{h}\sum_{i\in S}\alpha^{l}_{h,i}\,W^{l,h}_{O} f^{l}_{h}(x_i)\Big)\cdot u .$$
Here $\alpha^{l}_{h,i}$ is the attention weight of head $h$ on token $i$, $f^{l}_{h}(x_i)$ is that token's value vector, and $W^{l,h}_{O}$ is the head's output projection. The vector $u$ is the difference of the unembedding vectors of the model's top-two candidate answers, obtained from a first, uncontrolled pass.
The norm of the bracketed vector is the norm-based contribution of Attention is Not Only a Weight. That paper showed that scoring $\|\alpha_i f(x_i)\|$ instead of $\alpha_i$ lowers translation alignment error from 29.8 to 25.0, but the score carries no sign. Projecting onto $u$ adds the support-versus-suppression polarity that Rethinking Attention-Model Explainability through Faithfulness Violation Test shows is missing from raw attention. In that work, up to 38% of top-attended VQA regions were suppressors, and violations grew with depth. It recovered polarity with attention times gradient, which brought violations under 7% but requires a backward pass.
Our quantity only captures the direct path from a layer to the logits. Later layers can cancel or invert it, as Lopardo et al. argue. Whether this blind spot matters is an empirical question, and the proposal tests it directly instead of assuming it away.
Research Program
The first part is diagnostic. We use SLAKE's serialized triples as in-context knowledge for a frozen medical VLM: the released UniMedVL checkpoint, plus Qwen2.5-VL as a general backbone. SLAKE is the right testbed for three reasons. It ships more than 52,000 triples. It separates vision-only questions from knowledge-based ones. In its original stacked-attention model, knowledge integration gave only a modest gain of 2.0% on knowledge questions, which leaves room to ask where that knowledge goes.
For each layer we record three quantities for the knowledge-graph stream and for the image stream: raw attention mass, norm contribution, and signed contribution. We test whether these profiles follow the depth structure that the KV-cache literature reports for text models. D2O finds dense, low-variance attention in shallow layers and sparse, entity-focused attention in deep layers. Yilong Chen et al. find redundant middle layers. Our working hypothesis is that knowledge-graph contribution concentrates in a narrow middle-to-deep band. A second hypothesis is that the disagreement between attention mass and signed contribution grows with depth, mirroring Liu et al.'s depth trend.
The second part is the controller. A first pass yields the candidate pair, from which we form $u$. In a second pass, at each layer $l$, we take one of three actions. If $|c_l(K)|$ falls below a small fraction of that layer's total contribution, we mask the knowledge-graph keys at $l$. If $c_l(K)$ and $c_l(V)$ have opposite signs and $|c_l(V)|$ exceeds a threshold, we scale the knowledge-graph value vectors by the factor that makes the net knowledge contribution zero. Otherwise we leave the layer untouched. The rule encodes one clinical commitment: retrieved priors may fill in where the image says nothing, but may not overrule strong visual evidence at the layer where that evidence is formed. The two thresholds are tuned on SLAKE's validation split only.
Head-level conflict gating was introduced by Causal Route Gating, which suppresses textual routes that promote hallucinated tokens against visual routes, using gradients at about 2.27x per-token latency. We borrow its notion of route conflict. We differ in three ways: we add the knowledge graph as a third route, we resolve conflicts per layer, and our controller costs two forward passes with no backward pass.
A side effect is that the masking decision removes knowledge-graph keys and values from the cache at layers where they contribute nothing. Existing eviction policies do not address this. MiniKV protects tokens that are attended heavily at prefill, which serialized triples may not be. We report the memory saved but do not claim a cache system.
Baselines
The naive reference is the frozen VLM with no triples, alongside the same model with all retrieved triples concatenated at every layer. Together these bracket the effect of knowledge itself and the effect of knowledge pollution.
The strongest published knowledge-fusion method is AMiF. It applies a sigmoid-gated cross-attention module to decide per instance whether to fuse external knowledge, and it reports 86.71% accuracy on SLAKE, 80.49% on VQA-RAD and 65.33% on PathVQA. That result comes from a fine-tuned task model with its own alignment and hard-negative mining, so it is not directly comparable to a frozen backbone. We therefore re-implement AMiF's gate on our backbone, train it on SLAKE's training split with the same triples, and give it the same hyperparameter-search budget as our thresholds. We quote 86.71% only as the reference ceiling for fine-tuned systems. For general medical VLMs, UniMedVL reports 75.4% on SLAKE, which serves as the expected neighborhood for our frozen backbone.
The strongest attribution competitor is a gradient version of our controller. It replaces $c_l$ with attention times gradient, following Liu et al., and is run under identical thresholds. This measures exactly what the forward-only approximation loses. We also include a CRG-style head-level gradient gate extended to knowledge-graph tokens, to compare against its latency profile.
Three ablations isolate the key ingredients. A norm-only controller uses Kobayashi-style magnitude without sign. An attention-mass controller uses raw attention. A depth-uniform controller makes a single global decision from summed $c_l$.
Beating the baselines means two things. On the conflict set described below, we must exceed the trained AMiF-style gate and the attention-mass controller by a margin outside bootstrap confidence intervals. On standard SLAKE knowledge questions, we must stay within a point of the full-knowledge model, at under half CRG's reported overhead.
Why not just…?
Why not just train a per-layer gate end to end? This is the real threat. A learned gate per layer can, in principle, learn to close where knowledge hurts. The concern is that it learns the agreement statistics of the training split. On SLAKE, retrieved triples and images mostly agree, so a trained gate has little pressure to learn to reject knowledge that contradicts the image. Our controller makes that decision from the instance's own internal evidence. The conflict set and the cross-dataset transfer to VQA-RAD settle this question. If the trained per-layer gate matches us there, the contribution shrinks to the diagnostic depth profile plus a training-free alternative, and we will report it that way.
Why not just retrieve fewer, more relevant triples? Retrieval filtering scores a triple against the question, not against the image. A triple can be perfectly relevant to "Does this lung show a nodule?" and still be the source of a hallucinated "yes." We include a relevance-filtered top-k retrieval baseline. The prediction is that it reduces noise on ordinary questions but leaves the conflict-set error largely unchanged.
Why not just use gradients, which are known to be more faithful? Liu et al. report under 7% violations with attention times gradient, so gradients probably are more faithful per decision. The cost is a backward pass, and CRG's gradient approximation already runs at about 2.27x per token. The gradient controller is in our baseline set. If it beats the forward-only version by a wide margin, the direct-path blind spot is serious and the cheap measure is not worth it.
Why not just rely on the model's built-in medical knowledge? The no-triples baseline answers this directly. SLAKE's original 2.0% knowledge gain, and CRG's documentation of language priors overriding images (CHAIR sentence-level hallucination of 52.8% for LLaVA-1.5), suggest that internal knowledge is both incomplete and itself a source of overconfident priors.
Proposed Experiments
We evaluate on SLAKE, split into vision-only and knowledge-based questions, with VQA-RAD from the USB release as a transfer set that reuses SLAKE's knowledge graph. We do not use PathVQA for the main claim, because no matching graph is available in our materials.
The central new evaluation is a conflict set built from SLAKE closed questions whose gold answer is "no" for a finding. For each such question, we inject triples that associate the imaged organ with that finding. A model that is robust to knowledge pollution should not flip its answer. We report the flip rate alongside accuracy.
The first decisive check concerns the measurement itself. Using mean-value replacement of knowledge-graph tokens at a single layer rather than deletion, which avoids the out-of-distribution artifacts Liu et al. warn about, we measure how often the sign of $c_l(K)$ agrees with the actual change in answer margin. We then compare that agreement rate with the rates for attention mass and for gradient attribution. If forward-only sign agreement is not clearly better than attention mass, the method fails at its foundation.
The second check is the conflict-set flip rate against the trained per-layer gate and AMiF-style gate, which tests whether instance-internal evidence generalizes where learned gates do not.
The third check compares the depth profiles across UniMedVL and Qwen2.5-VL. If the band where the knowledge graph contributes is backbone-specific, any fixed-layer injection scheme is misguided. If it is stable across backbones, the profile directly informs where future models should inject knowledge.
We also report latency relative to a single forward pass, and the fraction of knowledge-graph cache entries removed.
References
- Attention is Not Only a Weight: Analyzing Transformers with Vector Norms
- Rethinking Attention-Model Explainability through Faithfulness Violation Test
- Attention Meets Post-hoc Interpretability: A Mathematical Perspective
- Slake: A Semantically-Labeled Knowledge-Enhanced Dataset For Medical Visual Question Answering
- D2O: Dynamic Discriminative Operations for Efficient Long-Context Inference of Large Language Models
- Mitigating Hallucinations in Large Vision-Language Models via Causal Route Gating
- MiniKV: Pushing the Limits of 2-Bit KV Cache via Compression and System Co-Design for Efficient Long Context Inference
- Alignment, Mining and Fusion: Representation Alignment with Hard Negative Mining and Selective Knowledge Fusion for Medical Visual Question Answering
- UniMedVL: Unifying Medical Multimodal Understanding and Generation through Observation-Knowledge-Analysis