Continuous Retrieval Influence in Clinical RAG: A Mechanistic Interpretability Study Across Transformer Depth
Abstract
Retrieval-Augmented Generation (RAG) is widely adopted to ground clinical language model outputs in external evidence, yet the internal transformer dynamics through which retrieved context influences generation remain poorly understood. We study this problem by probing two clinical language models, BioMedLM 2.7B and BioMistral-7B, across all 32 transformer layers using the 759-sample PubMedQA corpus. The two models — BioMedLM (GPT-2 architecture, absolute positional embeddings) and BioMistral-7B (Mistral architecture, RoPE) — represent substantially different architectural families, enabling cross-architecture validation of retrieval influence patterns. We introduce the Evidence Adherence Analysis Framework (EAAF), which combines attention analysis, tuned-lens projection, irrelevant-context controls, and activation patching across paired retrieval-augmented and retrieval-suppressed forward passes. Contrary to a discrete-collapse hypothesis, PELT change-point detection applied across all 32 layers identifies no statistically supported phase transition in either model. Instead, retrieval influence evolves continuously across transformer depth. Our primary retrieval influence measure shows a replicated pattern across architectures with a nearly identical structure: no-label queries show stronger retrieval-conditioned distributional shift than yes-label queries, with both models peaking around layers 23--24. Irrelevant-context controls show that this signal reflects both generic context-conditioning and evidence-specific integration. Activation patching further demonstrates that late-layer retrieval-conditioned representations are causally sufficient to recover RAG-like output behavior from a suppressed baseline. Together, these results motivate a shift in clinical RAG hallucination analysis from discrete collapse detection toward continuous internal characterization of internal retrieval influence.