In Machina N400: Pinpointing Where a Causal Language Model Detects Semantic Violations
Christos-Nikolaos Zacharopoulos, Revekka Kyriakoglou

TL;DR
This paper investigates where and how a causal language model detects semantic violations, revealing that detection accuracy peaks in middle layers and that violations initially expand then condense the representational space.
Contribution
It introduces a layered analysis of semantic violation detection in transformer models, highlighting the dynamic encoding process across layers.
Findings
Detection accuracy peaks in middle layers
Violation encoding involves initial expansion then collapse of representational space
Semantic anomalies are detected after syntactic resolution, similar to human reading
Abstract
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…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsNeurobiology of Language and Bilingualism · Language Development and Disorders · Syntax, Semantics, Linguistic Variation
