cs.CLFeb 23, 2026

How Retrieved Context Shapes Internal Representations in RAG

Authors: Samuel Yeh, Sharon Li

Organizations: Department of Computer Science, University of Wisconsin-Madison

Abstract

Retrieval-augmented generation (RAG) enhances large language models (LLMs) by conditioning generation on retrieved external documents, but the effect of retrieved context is often non-trivial. In realistic retrieval settings, the retrieved document set often contains a mixture of documents that vary in relevance and usefulness. While prior work has largely examined these phenomena through output behavior, little is known about how retrieved context shapes the internal representations that mediate information integration in RAG. In this work, we study RAG through the lens of latent representations. We systematically analyze how different types of retrieved documents affect the hidden states of LLMs, and how these internal representation shifts relate to downstream generation behavior. Across four question-answering datasets and three LLMs, we analyze internal representations under controlled single- and multi-document settings. Our results reveal how context relevancy and layer-wise processing influence internal representations, providing explanations of LLMs' output behaviors and insights for RAG system design.

Figures & tables

Appendix figures & tables15 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. On the impact of retrieved content representations in RAG Pipelines

    May 29, 2026Jonathan J Ross, Bevan Koopman, Anton van der Vegt +1Retrieval-Augmented GenerationRAG Evaluation

  2. Latent Abstraction for Retrieval-Augmented Generation

    Apr 20, 2026Ha Lan N. T, Minh-Anh Nguyen, Dung D. LeRetrieval-Augmented GenerationAdaptive RAG

  3. Guaranteeing Knowledge Integration with Joint Decoding for Retrieval-Augmented Generation

    Apr 9, 2026Zhengyi Zhao, Shubo Zhang, Zezhong Wang +7Hallucination in RAGRetrieval-Augmented Generation