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

Tianjie Ju,Weiwei Sun,Wei Du,Xinwei Yuan,Zhaochun Ren,Gongshen Liu
2024-01-01
Abstract:Previous work has showcased the intriguing capability of large languagemodels (LLMs) in retrieving facts and processing context knowledge. However,only limited research exists on the layer-wise capability of LLMs to encodeknowledge, which challenges our understanding of their internal mechanisms. Inthis paper, we devote the first attempt to investigate the layer-wisecapability of LLMs through probing tasks. We leverage the powerful generativecapability of ChatGPT to construct probing datasets, providing diverse andcoherent evidence corresponding to various facts. We employ 𝒱-usableinformation as the validation metric to better reflect the capability inencoding context knowledge across different layers. Our experiments onconflicting and newly acquired knowledge show that LLMs: (1) prefer to encodemore context knowledge in the upper layers; (2) primarily encode contextknowledge within knowledge-related entity tokens at lower layers whileprogressively expanding more knowledge within other tokens at upper layers; and(3) gradually forget the earlier context knowledge retained within theintermediate layers when provided with irrelevant evidence. Code is publiclyavailable at https://github.com/Jometeorie/probing_llama.
What problem does this paper attempt to address?