Papers › How Large Language Models Encode Context Knowledge? A Layer-Wise Probing Study

How Large Language Models Encode Context Knowledge? A Layer-Wise Probing Study

25 Feb 2024arXiv:2402.16061archive 2025-07-28

Tianjie Ju, Weiwei Sun, Wei Du, Xinwei Yuan, Zhaochun Ren, Gongshen Liu

Previous work has showcased the intriguing capability of large language models (LLMs) in retrieving facts and processing context knowledge. However, only limited research exists on the layer-wise capability of LLMs to encode knowledge, which challenges our understanding of their internal mechanisms. In this paper, we devote the first attempt to investigate the layer-wise capability of LLMs through probing tasks. We leverage the powerful generative capability of ChatGPT to construct probing datasets, providing diverse and coherent evidence corresponding to various facts. We employ 𝒱-usable information as the validation metric to better reflect the capability in encoding context knowledge across different layers. Our experiments on conflicting and newly acquired knowledge show that LLMs: (1) prefer to encode more context knowledge in the upper layers; (2) primarily encode context knowledge within knowledge-related entity tokens at lower layers while progressively expanding more knowledge within other tokens at upper layers; and (3) gradually forget the earlier context knowledge retained within the intermediate layers when provided with irrelevant evidence. Code is publicly available at https://github.com/Jometeorie/probing_llama.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2402.16061")

Code

Syntology Ran 9 of 11 code samples harvested from 1 repository linked to this paper; 2 have no recorded run. Of those that ran: 2 ran · our draft was wrong; 3 ran · fixture could not drive it; 4 ran with no contract checked.

By repository: official repository: 11 samples from 1 repository, 9 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

jometeorie/probing_llama officialmentioned in paperpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

11 samples harvested; 9 ran; 0 honoured the contract we drafted; 2 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

2ran · our draft was wrong
3ran · fixture could not drive it
4ran
2unverified

Licence: 11 of the 11 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from jometeorie/probing_llama. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

repeat_kv jometeorie/probing_llama/code/llama/modeling_llama.py official repository ran · fixture could not drive it fingerprinted no licence file found · pointer only · 30d7eec482ebf6b1 · report
apply_rotary_pos_emb jometeorie/probing_llama/code/custom_llama/modeling_llama.py official repository ran · fixture could not drive it no licence file found · pointer only · f725bc2d76076485 · report
apply_rotary_pos_emb jometeorie/probing_llama/code/llama/modeling_llama.py official repository ran · fixture could not drive it no licence file found · pointer only · 37fc3129c3d06e0c · report
compute_intermediate_size jometeorie/probing_llama/code/llama/convert_llama_weights_to_hf.py official repository ran fingerprinted no licence file found · pointer only · 507f475feb734647 · report
compute_intermediate_size jometeorie/probing_llama/code/custom_llama/convert_llama_weights_to_hf.py official repository ran fingerprinted no licence file found · pointer only · 0c540da8d3df6b6e · report
import_protobuf jometeorie/probing_llama/code/llama/tokenization_llama.py official repository ran no licence file found · pointer only · dfbf610d72061eaf · report
read_json jometeorie/probing_llama/code/custom_llama/convert_llama_weights_to_hf.py official repository ran · our draft was wrong no licence file found · pointer only · c5bcf01d18bba63d · report
rotate_half jometeorie/probing_llama/code/custom_llama/modeling_llama.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · b99eea6376d1e212 · report
train jometeorie/probing_llama/code/probing_model.py official repository ran no licence file found · pointer only · 86fe730f11e67507 · report
write_model jometeorie/probing_llama/code/llama/convert_llama_weights_to_hf.py official repository unverified no licence file found · pointer only · 731285361b7dea0e · report
write_model jometeorie/probing_llama/code/custom_llama/convert_llama_weights_to_hf.py official repository unverified no licence file found · pointer only · cfeea96bf995824a · report

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections