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.
翻译:语法性和似然性是人类语言中不同的概念。预训练语言模型(LMs)是语言概率模型,旨在通过最大化语料库似然性进行拟合,它们能够生成语法正确的文本,并在严格控制的最小对中对语法与不合语法的句子进行良好区分。然而,其字符串概率总体上并不能显著区分语法与不合语法的句子。那么,LMs是否隐式地获取了独立于字符串概率的语法性区分?我们通过研究LMs的内部表征来探索这一问题,方法是在一个包含语法和(合成)不合语法句子的数据集上训练线性探针,这些句子通过对自然语料库文本应用扰动得到。我们发现,这一简单的语法性探针能够泛化到人工整理的语法性判断基准,并优于基于LM概率的语法性判断。然而,当应用于语义合理性基准时(其中最小对的两个成员均语法正确且仅在合理性上存在差异),该探针的表现逊于字符串概率。此外,用英语训练的探针还展现出非平凡的跨语言泛化能力,在多种其他语言的语法性基准上优于字符串概率。探针得分与字符串概率的相关性也较弱。这些结果共同表明,LMs在其隐藏层中在一定程度上获取了隐式的语法性区分。