Implicit Representations of Grammaticality in Language Models

📄 arXiv: 2605.05197v1 📥 PDF

作者: Yingshan Susan Wang, Linlu Qiu, Zhaofeng Wu, Roger P. Levy, Yoon Kim

分类: cs.CL

发布日期: 2026-05-06


💡 一句话要点

提出隐式语法性表示以提升语言模型的判断能力

🎯 匹配领域: 支柱三:空间感知与语义 (Perception & Semantics)

关键词: 语言模型 语法性判断 线性探针 跨语言泛化 自然语言处理

📋 核心要点

  1. 现有的语言模型在生成文本时,虽然能生成语法正确的句子,但在整体上无法有效区分语法和非语法句子。
  2. 本文提出通过训练线性探针来研究语言模型内部的隐式表示,以探讨其是否具备独立于字符串概率的语法性区分能力。
  3. 实验结果显示,该探针在语法性判断基准上超越了基于LM概率的判断,并在多语言环境中表现出良好的泛化能力。

📝 摘要(中文)

语法性和可能性是人类语言中的两个不同概念。预训练的语言模型(LMs)虽然能够生成语法正确的文本,但在整体上并不能有效区分语法和非语法句子。本文探讨了语言模型是否在隐含层中获得了独立于字符串概率的语法性区分。通过对自然文本语料进行扰动,构建了语法和非语法句子的线性探针,结果表明该探针在语法性判断基准上表现优于基于LM概率的判断,并在多种语言中展现出良好的跨语言泛化能力。这些结果表明,语言模型在一定程度上确实获得了隐式的语法性区分。

🔬 方法详解

问题定义:本文旨在解决语言模型在整体上无法有效区分语法和非语法句子的问题。现有方法主要依赖于字符串概率,但未能充分捕捉语法性。

核心思路:通过训练线性探针,分析语言模型的内部表示,探讨其是否隐含地获得了语法性区分能力。这样的设计旨在揭示语言模型在语法判断上的潜力。

技术框架:整体流程包括数据集构建、线性探针训练和评估。数据集由自然文本语料经过扰动生成的语法和非语法句子组成,探针则用于评估模型对语法性的判断能力。

关键创新:最重要的创新在于通过线性探针的方式揭示语言模型在隐含层中对语法性的理解,这与传统依赖字符串概率的判断方法本质上不同。

关键设计:在训练过程中,探针的损失函数设计为最小化语法性判断错误,网络结构为简单的线性模型,确保其能够有效捕捉到语法性特征。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果表明,线性探针在语法性判断基准上超越了基于LM概率的判断,且在多种语言中表现出良好的跨语言泛化能力。探针得分与字符串概率的相关性较弱,表明其捕捉到了独立的语法性特征。

🎯 应用场景

该研究的潜在应用领域包括自然语言处理中的语法检查、机器翻译和对话系统等。通过提升语言模型的语法性判断能力,可以显著提高文本生成的质量和准确性,未来可能对人机交互和自动化文本处理产生深远影响。

📄 摘要(原文)

Grammaticality and likelihood are distinct notions in human language. Pretrained language models (LMs), which are probabilistic models of language fitted to maximize corpus likelihood, generate grammatically well-formed text and discriminate well between grammatical and ungrammatical sentences in tightly controlled minimal pairs. However, their string probabilities do not sharply discriminate between grammatical and ungrammatical sentences overall. But do LMs implicitly acquire a grammaticality distinction distinct from string probability? We explore this question through studying internal representations of LMs, by training a linear probe on a dataset of grammatical and (synthetic) ungrammatical sentences obtained by applying perturbations to a naturalistic text corpus. We find that this simple grammaticality probe generalizes to human-curated grammaticality judgment benchmarks and outperforms LM probability-based grammaticality judgments. When applied to semantic plausibility benchmarks, in which both members of a minimal pair are grammatical and differ in only plausibility, the probe however performs worse than string probability. The English-trained probe also exhibits nontrivial cross-lingual generalization, outperforming string probabilities on grammaticality benchmarks in numerous other languages. Additionally, probe scores correlate only weakly with string probabilities. These results collectively suggest that LMs acquire to some extent an implicit grammaticality distinction within their hidden layers.