Understanding Contextual Recall in Transformers: How Finetuning Enables In-Context Reasoning over Pretraining Knowledge

arXiv cs.LG / 3/24/2026

💬 OpinionSignals & Early TrendsIdeas & Deep AnalysisModels & Research

Key Points

  • The paper studies “contextual recall,” a variant of in-context learning where pretrained transformers can retrieve specific facts in new prompt formats using paired examples, rather than updating parameters.
  • It finds that pretraining alone can produce factual knowledge but is insufficient to support contextual recall once key grammar/statistical cues are removed from prompts, indicating missing implicit attribute-type inference.
  • The authors show that finetuning on separate tasks that require implicit inference (using a subset of subjects) is enough to trigger contextual recall across all subjects, implying a training-induced capability rather than an emergent pretraining artifact.
  • They report a mechanistic link: the transition to contextual recall is accompanied by the formation of low-dimensional latent encodings corresponding to shared attribute types.
  • To validate causality and provide interpretability, the paper derives an attention-only transformer construction that replicates the factual-to-contextual recall transition and confirms it empirically in a controlled setup.

Abstract

Transformer-based language models excel at in-context learning (ICL), where they can adapt to new tasks based on contextual examples, without parameter updates. In a specific form of ICL, which we refer to as \textit{contextual recall}, models pretrained on open-ended text leverage pairwise examples to recall specific facts in novel prompt formats. We investigate whether contextual recall emerges from pretraining alone, what finetuning is required, and what mechanisms drive the necessary representations. For this, we introduce a controlled synthetic framework where pretraining sequences consist of subject-grammar-attribute tuples, with attribute types tied to grammar statistics. We demonstrate that while such pretraining successfully yields factual knowledge, it is insufficient for contextual recall: models fail to implicitly infer attribute types when the grammar statistics are removed in ICL prompts. However, we show that finetuning on tasks requiring implicit inference, distinct from the ICL evaluation, using a subset of subjects, triggers the emergence of contextual recall across all subjects. This transition is accompanied by the formation of low-dimensional latent encodings of the shared attribute type. For mechanistic insight, we derive a construction for an attention-only transformer that replicates the transition from factual to contextual recall, corroborated by empirical validation.