arXiv:2511.19232cs.CLcs.AI2025-11中稿 · AICS2025

用因果语言模型追踪语义错误的发现位置和编码机制。

In Machina N400: Pinpointing Where a Causal Language Model Detects Semantic Violations

  • 逐层分析隐藏状态,发现低层难辨语义异常
  • 中层检测准确率突增,顶层前达峰值
  • 语义异常先扩张后收缩,类似人类阅读处理

为探究Transformer如何察觉句子语义异常,我们使用精心构建的语料库对因果语言模型phi-2进行评估,句子结尾或合理或不合理。分析聚焦于每层的隐藏状态。通过两种互补探测方法:首先在各层使用线性探测器,发现低三层的线性解码器难以区分合理与不合理结尾,但中层准确率显著提升,在顶层前达到峰值;其次分析异常编码的有效维度,发现异常初期扩大表征子空间,随后在中层瓶颈处发生坍缩,可能反映从探索到快速整合的转变。结果暗示模型处理过程与经典心理语言学中人类阅读的语义异常检测时间一致,即在句法解析之后才出现。

原文摘要 · Abstract (English)

How and where does a transformer notice that a sentence has gone semantically off the rails? To explore this question, we evaluated the causal language model (phi-2) using a carefully curated corpus, with sentences that concluded plausibly or implausibly. Our analysis focused on the hidden states sampled at each model layer. To investigate how violations are encoded, we utilized two complementary probes. First, we conducted a per-layer detection using a linear probe. Our findings revealed that a simple linear decoder struggled to distinguish between plausible and implausible endings in the lowest third of the model's layers. However, its accuracy sharply increased in the middle blocks, reaching a peak just before the top layers. Second, we examined the effective dimensionality of the encoded violation. Initially, the violation widens the representational subspace, followed by a collapse after a mid-stack bottleneck. This might indicate an exploratory phase that transitions into rapid consolidation. Taken together, these results contemplate the idea of alignment with classical psycholinguistic findings in human reading, where semantic anomalies are detected only after syntactic resolution, occurring later in the online processing sequence.

语言模型语义检测可解释性

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。