揭示大模型在隐马尔可夫模型中执行上下文学习的内部算法机制
Extracting Algorithms in Pre-trained LLMs: A Case on Hidden Markov Models

- 通过行为对比与理论推导,锁定三种可能的算法类
- 发现模型激活中存在低维线性信号,决定预测结果
- 揭示不同计算阶段分布在不同网络层,适配模型解释研究者
大语言模型(LLMs)在上下文学习(ICL)下展现出对隐马尔可夫模型(HMM)下一观测值的强大预测能力,但其背后的具体算法仍不明确。现有研究提出多个候选算法,却缺乏对模型内部激活的实证支持。本文提出三阶段方法:首先通过实验比较模型行为与多类候选算法,将可能范围缩小至三类;其次建立这三类算法与Transformer结构间的理论联系,并在小型训练模型中验证其可实现性;最后引入主激活探测器(PAP),一种分层探针与干预方法,用于识别模型激活中的算法信号。PAP揭示出驱动预测的低维线性表示,且这些表示随底层HMM特性动态变化,不同计算阶段分别对应不同网络层。研究首次将预训练大模型在HMM上的上下文学习行为与内部机制相连接,深化了对大模型如何执行上下文学习的理解。
原文摘要 · Abstract (English)
Large language models (LLMs) display a striking ability to predict next observations from Hidden Markov Models (HMMs) via in-context learning (ICL), but the algorithm underlying this capability remains undetermined: prior work has proposed several candidates without consensus, and none has been grounded in the model's internal activations. We close this gap with a three-stage pipeline. First, we empirically compare LLM behavior against a suite of candidate algorithms and narrow the space to three classes -- though no single class explains LLM behavior across all HMM settings and sequence lengths. Second, we derive theoretical connections between the three classes and show how each can be implemented in-context by a Transformer, validating the construction in a small trained Transformer. Third, returning to pre-trained LLMs, we introduce the Principal Activations Probe (PAP), a layer-wise probing and intervention method that isolates algorithmic signals in model activations. PAP reveals low-dimensional linear representations that causally drive model predictions and track empirical ICL performance. PAP further reveals how these representations shift with properties of the underlying HMM regime; distinct computational stages are localized to different layers. Together, our results connect the in-context behavior of pre-trained LLMs to the underlying internal mechanisms and advance our understanding of how LLMs perform ICL on HMMs.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。