[论文解读] How Large Language Models Encode Context Knowledge? A Layer-Wise Probing Study
本文提出一种逐层探测框架,用于研究大型语言模型(LLMs)如何编码上下文知识,采用ChatGPT生成的证据和$Σ$-可用信息作为度量指标。研究发现,LLMs在深层网络中编码更多上下文知识,随深度推进,知识从实体标记传递至更广泛上下文,且在接触无关证据时表现出干扰现象,揭示了其内部知识保留的关键动态机制。
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 $\mathcal V$-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.
研究动机与目标
- 探究大型语言模型在其隐藏层中如何编码上下文知识,以填补对其内部机制理解的空白。
- 开发一种可靠的探测框架,利用ChatGPT生成的多样化、连贯的证据,评估逐层知识编码能力。
- 使用$Σ$-可用信息作为判别性度量,衡量并比较不同LLM层编码冲突或新获取知识的能力。
- 通过测试在不断增加无关证据条件下的上下文知识保留能力,探究LLMs的长期记忆容量。
- 揭示自注意力机制和位置编码在跨层塑造知识表征中的作用。
提出的方法
- 利用ChatGPT生成事实和反事实的多样化、连贯证据,构建探测数据集。
- 将证据和问题输入LLaMA 2模型,提取隐藏层表征以进行探测。
- 使用$Σ$-可用信息作为主要度量指标,评估层表征中上下文知识的可区分程度。
- 设计针对冲突知识(如更正参数化事实)和新获取知识(如密码)的探测任务,以评估编码行为。
- 系统性地改变证据的相关性和位置编码,测试中间层的鲁棒性与干扰效应。
- 通过热力图可视化逐层探测结果,识别知识编码在不同层和标记类型中的模式。
实验结果
研究问题
- RQ1LLMs如何在其隐藏层中分布上下文知识的编码?
- RQ2上下文知识主要编码在实体标记上,还是在更广泛的上下文中?
- RQ3无关证据的存在如何影响中间层中新获取知识的保留?
- RQ4自注意力在多大程度上促进知识从实体标记向其他标记在跨层间的传递?
- RQ5位置编码是否显著影响层表征中上下文知识的可检测性?
主要发现
- LLMs倾向于在上层编码上下文知识,在冲突知识场景中,深层网络表现出最高的$Σ$-可用信息。
- 与相关实体标记在低层编码更多上下文知识,但该优势随层数加深而减弱,并在高层被其他标记超越。
- 自注意力机制推动知识从实体标记向周围上下文标记逐步转移,且随网络深度增加而增强。
- 当暴露于无关证据时,LLMs在中间层表现出显著性能下降,表明存在干扰,且新获取知识的保留能力降低。
- 位置编码(如添加换行符)对探测结果影响微乎其微,表明其在知识编码检测中可视为可忽略的噪声。
- 即使对于新获取的事实(如密码),模型编码上下文知识的能力依然稳健,尽管随着无关上下文的增加,性能有所下降。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。