Manuscript Offprint

arXiv:2609.11859

From Parameters to Answers: How LLMs Retrieve and Use Their Internal Knowledge

Wenkang Wei, Yuan Fang, Renhe Jiang, Hong Cheng, Xingtong Yu

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Wenkang Wei

University of Science and

Technology of China

Hefei, China

yizhilouyi@mail.ustc.edu.cn

Yuan Fang

Singapore Management

University

Singapore, Singapore

yfang@smu.edu.sg

Renhe Jiang

The University of Tokyo

Tokyo, Japan

jiangrh@csis.u-tokyo.ac.jp

Hong Cheng

The Chinese University of Hong Kong

Hong Kong, Hong Kong SAR, China

hcheng@se.cuhk.edu.hk

Xingtong Yu

The Chinese University of Hong Kong

Hong Kong, Hong Kong SAR, China

xtyu@se.cuhk.edu.hk

Abstract

How does a language model's dependence on query-routing information and target knowledge change as it answers a question? We study this question through layerwise interventions on the hidden state at the end of the question. Across Qwen, Llama, and Gemma, we compare country–continent questions with noun, adjective, and code answers while keeping several fitted measurements distinct. A pair-conditioned request direction describes which country is queried in natural single-country questions; a global request direction describes first- versus second-country requests in paired questions; separate selection candidates test control among contents already available in the hidden state. A diagnostic reanalysis of frozen Qwen natural-question states shows that the pair-conditioned direction grows stronger before interventions on it begin to alter later fitted knowledge, with this causal window opening while answer-supporting content is still forming. The paired three-model trajectories are not uniform: Gemma shows a partially overlapping mid-layer routing–content profile, whereas Llama has no sustained routing-effect window under the same gates. In the paired protocol, dependence on the global request direction decreases from fixed earlier to later layer sets while dependence on fitted content persists. A matched Qwen comparison shows that the pair-conditioned direction retains a late effect, so this operational hand-off concerns the global fitted direction rather than all request information. These results separate early readability, natural strength, causal steering, and later content dependence.

1 Introduction

Large language models (LLMs) (Bai et al., 2023; Brown et al., 2020) acquire extensive knowledge during pretraining and draw on it to answer questions. Yet how a query progressively accesses this internal knowledge and turns it into an answer across layers remains unclear. Prior work has investigated where knowledge is stored in model parameters (Geva et al., 2021; Meng et al., 2022; 2023) and identified layers or internal representations involved in its recall (Geva et al., 2023; Yu et al., 2023; Feng and Steinhardt, 2024). These studies provide important but largely separate views of knowledge storage and recall. Although Geva et al. (Geva et al., 2023) reveal the continuous computation that connects a query to the knowledge ultimately used for an answer, none of these studies separates the information specifying which knowledge to form from the knowledge that is ultimately formed, or measures how the answer's dependence shifts between the two across layers. We therefore ask: how do LLMs progressively retrieve and use their internal knowledge across layers?

Our analysis first reveals a functional separation between content and routing in the hidden state. A hidden state can contribute to the answer by carrying the knowledge used to produce it or by controlling where subsequent layers access knowledge. Through controlled interventions, we causally distinguish these two roles, which we call content and routing, respectively. Routing takes two functionally distinct forms, both represented in the hidden state but directed toward different knowledge substrates: parameter routing points to relevant knowledge in the model's parameters, whereas hidden-state routing points to retrieved content already represented in the hidden state.

Tracing these components across layers further reveals how answer-supporting content is progressively formed. In the early layers, hidden states progressively integrate query-relevant knowledge into answer-supporting content. At this stage, neither parameter routing nor hidden-state routing yet has a detectable effect on the answer. Parameter routing first grows stronger and, while answer-supporting content is still forming, begins to direct subsequent computation toward relevant knowledge in the model's parameters. As this knowledge is retrieved, it is progressively consolidated into answer-supporting content within the hidden state. Hidden-state routing becomes effective later, directing subsequent computation toward this newly formed content so that it can be further processed toward the answer.

Our analysis further reveals a routing–content handoff after answer-supporting content has formed. We redirect parameter routing toward content that supports a specific incorrect answer and compare this intervention with random changes. This intervention generally changes the output when applied at earlier layers, but becomes less effective at later layers, where the model increasingly retains the correct answer. In contrast, intervening on the answer-supporting content remains consequential, showing that the reduced dependence on routing does not reflect the loss of this content. Instead, the remaining computation shifts its causal dependence from the routing used to locate the content toward the content itself.

In summary, our contributions are threefold. (1) We causally separate content from routing and identify parameter and hidden-state routing. (2) We reveal their ordered emergence as answer-supporting content forms across layers. (3) We identify a routing–content handoff in which causal control shifts from routing to content.

References (100)

  • Understanding intermediate layers using linear classifier probes (opens arXiv in a new tab)
  • Qwen Technical Report
  • The Llama 3 Herd of Models
  • Bootstrap methods for standard errors, confidence intervals, and other measures of statistical accuracy (opens the publisher in a new tab)
  • How do language models bind entities in context? In ICLR, 2024
  • Gemma 3 Technical Report
  • Transformer feed-forward layers are key-value memories
  • Dissecting recall of factual associations in auto-regressive language models
  • Finding structure with randomness: Probabilistic algorithms for constructing approximate matrix decompositions (opens the publisher in a new tab)
  • Trevor Hastie. Ridge regularization: An essential concept in data science. arXiv preprint arXiv:2006.00371, 2020. URL https://arxiv.org/abs/2006.00371. (opens arXiv in a new tab)
  • Linearity of relation decoding in transformer language models
  • Factual retrieval in LLMs is a redundant, distributed and non-contiguous process
  • Locating and editing factual associations in GPT. In NeurIPS, volume 35, 2022
  • Mass-editing memory in a transformer
  • Qwen2.5 Technical Report
  • Neural machine translation of rare words with subword units (opens the publisher in a new tab)
  • Jonathon Shlens. A tutorial on principal component analysis. arXiv preprint arXiv:1404.1100, 2014. URL https://arxiv.org/abs/1404.1100. (opens arXiv in a new tab)
  • Attention is all you need
  • Functional abstraction of knowledge recall in large language models (opens arXiv in a new tab)
  • Locating and extracting relational concepts in large language models
  • Characterizing mechanisms for factual recall in language models
  • Root mean square layer normalization
  • The natural single-country experiment has its own pair-conditioned construction in Section 3
  • We vary how the same knowledge must be expressed: a continent name, its adjective, or an arbitrary code
  • It does not say which continent Kenya or China belongs to
  • The original data contain 24 countries from Africa, Asia, and Europe
  • The selection partition screens their effects
  • We use Qwen-2.5-3B-Instruct (Qwen Team, 2024), Llama-3.2-3B-Instruct (Dubey et al., 2024), and Gemma-3-4B-Instruct (Gemma Team, 2025)
  • We first fix this state and its task-specific coordinates, then define the content projection and the two request contrasts
  • The superscript global identifies a direction shared by all country pairs within this model and answer format
  • Let $b^{\ell}$ be the midpoint of the two main-task fit means for first- and second-country requests
  • We add the chosen vector to the specified decoder-layer output at the question-end position, then continue computation
  • It does not replace the entire hidden state with a random state or copy a component from another question
  • For each question $x$, the candidate set $\mathcal{A}_x = \{a_x^+, a_x^-\}$ contains the requested answer and the other country's answer in the required format
  • Let $\Delta\gamma_x^{\ell \to \ell', c}$ be the unmodified score minus the score after true deletion, and let $\Delta\gamma_x^{\ell \to \ell', c, j}$ be the analogous random-control loss
  • The denominator is the number of questions
  • A stable effect is positive in selection and both validation partitions
  • We average damages within each country pair and layer set before applying the random correction
  • The recorded-state location exception is distinguished from the intervention location, and the later subsections give the component formulas and controls
  • The archived contracts record the exact configuration, tokenizer, weight-index, and weight-shard hashes
  • It asks which marker belongs to the first or second record
  • Intervention is applied at the question-end position of the specified layer
  • All three peak entries are answer effects: parameter routing / transferred object selection / target content
  • All means below use the corresponding task’s fit partition
  • The balanced requests make these centers equal in exact arithmetic
  • Its center is $\boldsymbol{b}_x^{\ell,\mathrm{pair}} = \frac{1}{2}(\boldsymbol{h}_x^\ell + \boldsymbol{h}_{\bar{x}}^\ell)$
  • They are unrestricted random changes, not projections removed from a learned random subspace
  • The archived, more conservative alternative instead takes the maximum within each question:
  • Correctness is based on the two candidate strings’ length-averaged log probabilities, not on unrestricted generation accuracy
  • Lines average the two validation-partition values at each layer, and shaded ranges show their minimum and maximum
  • Figure 9 reports the original parameter-routing effects on later knowledge
  • They form 24 non-overlapping country pairs, each with countries from different continents
  • Qwen uses layers 29 and 31 versus 32 and 34; Gemma uses layer 24 versus layers 25 and 30; Llama uses layers 15 and 24 versus layer 28
  • Let Q contain the 24 country pairs and $X_q$ the eight questions for pair $q \in Q$
  • The pooled answer effect used in Equation 22 is
  • All eight variants and all compared conditions of a sampled pair stay together
  • Routing decline is the earlier-minus-later routing effect; knowledge advantage is the later knowledge effect minus the later routing effect
  • Examined separately, layer 29 has an interval spanning zero for both comparisons; layer 31 has positive intervals
  • The coefficient is recomputed from the state produced by all previous interventions
  • Let $\overline{m}_{q}^{0}$ be that pair's mean unmodified answer margin
  • It stopped before component fitting because the frozen candidate pool did not yield disjoint pairs spanning all three language combinations with every question variant correct
  • Their difference, Equation 20, is applied to the same-layer question-end state of noun, adjective, or code questions
  • Their later routing comparisons pass with 0/4 fits, while content passes with 4/4 fits at every listed comparison layer
  • Meanwhile, deletion length increases from 11.2052 to 12.0985
  • All 10,416 paired answer-margin records agree
  • Each model–format combination has six validation country pairs and 12 questions
  • Qwen supplies the clearest natural-question route-leading trajectory; Gemma supplies a more overlapping partial analogue in the paired protocol; Llama is a boundary case with dispersed routing effects and earlier sustained content dependence
  • We first define the direction and center choices and their aggregation, then give the direct-selection readouts and stopping rules used to test a different function: choosing between usable candidate facts
  • Which continent is the first country located in?
  • Both request constructions use the same two excluded objects:
  • Their four combinations define $c$ in Equation 23
  • For a fixed layer set L, define the pair-averaged loss and the corresponding random-corrected effect:
  • Thus the maximum is taken after, not before, averaging
  • Each bootstrap sample resamples 24 country pairs with replacement
  • Their direct difference is 2731.1 [1382.9, 3691.5]
  • For all 96 matched questions, baseline and edited answer margins and raw layer-32-to-36 deletion knowledge losses are identical between the two runs
  • The original six fitting countries form all 24 ordered cross-continent pairs, each with two requests under template A, giving $N_{\mathrm{fit}} = 48$ fitting questions
  • Country-identity targets concatenate the first five principal-component coordinates of each country's mean input-token embedding, fitted only on the six fitting countries
  • Write the standardized state as $\widetilde{\boldsymbol{h}}_x^{\ell} = (\boldsymbol{h}_x^{\ell} - \boldsymbol{\mu}^{\ell}) / \zeta^{\ell}$
  • The bias is unpenalized
  • \tag {43} $$
  • For selection, $\widehat{\boldsymbol{y}}_x^{\ell,\mathrm{sel},e}$ denotes the sole scalar coordinate
  • A wrong-position control applies the same swap vector at the first token of “continent” in the question
  • The directed selection-prediction change is
  • Positive changes move the prediction toward the opposite request
  • The superscript pointwise marks the maximum-before-averaging rule in Equation 46; it differs from Equation 41
  • Numerical qualification additionally requires at least 95% of active swap cases to meet the 5% target-write and random-length tolerances
  • Every load’s 1,584 actual writes passes the 5% numerical tolerance, including checks for a nonzero target collapsing to zero
  • Each prompt names two countries but supplies neither capital
  • What is the capital city of the first one?
  • The model must produce one of the two capitals from its weights
  • Eight matched random changes and an application of the same change at the wrong input position serve as controls
  • It changes later selection and answers, but restoring the original request at layers 15–19 recovers the original answer on at most 2/40 and 1/44 questions
  • Each model uses its own chat template and decoder depth, and all hidden-state calculations use float32
  • The targets are the concatenated identities of both countries, the first capital, the second capital, and the scalar first/second selection label
  • Its mean answer change is nevertheless 0.008 answer-margin units below the strongest pointwise control, and its best receiving-layer joint count is 5/14
  • The frozen receivers are layers 18, 19, and 20
  • The Gemma result therefore identifies a reproducible held-out internal selection candidate whose answer transmission is near the threshold; it does not establish that two capital facts remain separately usable from one modified state
  • Templates B and C supply the intervention-evaluation questions
  • Consequently, the full mean averages six vectors and each continent mean averages two

Couldn't load all references. Reload the page to try again.