Abstract
Large language models are able to exploit in-context learning to accessexternal knowledge beyond their training data through retrieval-augmentation.While promising, its inner workings remain unclear. In this work, we shed lighton the mechanism of in-context retrieval augmentation for question answering byviewing a prompt as a composition of informational components. We propose anattribution-based method to identify specialized attention heads, revealingin-context heads that comprehend instructions and retrieve relevant contextualinformation, and parametric heads that store entities' relational knowledge. Tobetter understand their roles, we extract function vectors and modify theirattention weights to show how they can influence the answer generation process.Finally, we leverage the gained insights to trace the sources of knowledge usedduring inference, paving the way towards more safe and transparent languagemodels.