Source-linked AI summary

Language Models as Knowledge Bases?

Fabio Petroni, Tim Rocktäschel, Patrick Lewis, Anton Bakhtin, Yuxiang Wu, Alexander H. Miller, Sebastian Riedel

arXiv:1909.01066v2cs.CL

TL;DR

The paper asks whether pretrained language models store relational knowledge that can be queried without the engineering and supervision required by traditional knowledge bases. Using the LAMA cloze probe, it finds BERT-large recalls factual and commonsense knowledge competitively with supervised and non-neural alternatives, though performance varies by relation.

  • Problem

    Traditional knowledge bases require complex, supervised, fixed-schema pipelines to extract relational data, motivating evidence about whether language models can provide an alternative.

  • Method

    The LAMA probe converts factual triples and question-answer pairs into cloze statements and evaluates pretrained models by ranking the ground-truth missing token.

  • Results

    57.1% precision@10: BERT-large approaches a supervised knowledge base’s 63.5% on open-domain question answering and generally outperforms other language models, but struggles on some relations.

  • Takeaways & Limitations

    Pretrained BERT-large can recall factual knowledge at a level competitive with non-neural and supervised alternatives, supporting its potential as an alternative to extracted knowledge bases.

  • Takeaways & Limitations

    Manually defined templates affect results, so the probe measures a lower bound on the knowledge language models may contain.

Abstract

from arXiv · show

Recent progress in pretraining language models on large textual corpora led to a surge of improvements for downstream NLP tasks. Whilst learning linguistic knowledge, these models may also be storing relational knowledge present in the training data, and may be able to answer queries structured as "fill-in-the-blank" cloze statements. Language models have many advantages over structured knowledge bases: they require no schema engineering, allow practitioners to query about an open class of relations, are easy to extend to more data, and require no human supervision to train. We present an in-depth analysis of the relational knowledge already present (without fine-tuning) in a wide range of state-of-the-art pretrained language models. We find that (i) without fine-tuning, BERT contains relational knowledge competitive with traditional NLP methods that have some access to oracle knowledge, (ii) BERT also does remarkably well on open-domain question answering against a supervised baseline, and (iii) certain types of factual knowledge are learned much more readily than others by standard language model pretraining approaches. The surprisingly strong ability of these models to recall factual knowledge without any fine-tuning demonstrates their potential as unsupervised open-domain QA systems. The code to reproduce our analysis is available at https://github.com/facebookresearch/LAMA.

1 Introduction

The paper investigates whether pretrained language models store relational knowledge that can be retrieved through masked-token cloze queries, avoiding several requirements of conventional knowledge bases. Using the LAMA probe, it evaluates this knowledge across factual, commonsense, and question-answering settings without fine-tuning.

  • Motivation: Language models can be queried for relational facts by predicting masked objects in cloze sentences, without schema engineering or human annotations.This approach supports an open set of queries and avoids complex pipelines for populating knowledge bases from text.
  • Method: The LAMA probe tests whether pretrained models know subject-relation-object facts by evaluating masked-object prediction across multiple knowledge sources.The probe covers entity relations from Wikidata and other knowledge types, including commonsense and general question answering.
  • Results: BERT-large captures accurate relational knowledge comparable to a knowledge base built with an off-the-shelf relation extractor and oracle-based entity linker.The comparison uses a corpus known to express the relevant knowledge.
  • Results: Factual knowledge is recovered surprisingly well from pretrained models, but performance is very poor for some relations, particularly N-to-M relations.These findings show that standard language-model pretraining does not make all factual relation types equally accessible.
  • Results: BERT-large consistently outperforms other language models on factual and commonsense knowledge recovery and is more robust to query phrasing.The comparison concerns pretrained language models evaluated without fine-tuning.
  • Results: 57.1% precision@10 is achieved by BERT-large on open-domain question answering, compared to 63.5% for a knowledge base built with supervised relation extraction.The supervised baseline uses a task-specific relation extraction system.

2 Background

The section introduces language models through autoregressive next-word prediction and contextual representations. Neural models estimate token probabilities with a softmax over learned vocabulary scores, while architectures differ in how they compute hidden states and may model longer context.

  • Autoregressive language models: Unidirectional language models factorize the probability of a token sequence into conditional next-token probabilities given preceding words.For w = [w_1, w_2, ..., w_N], the model assigns p(w) through this factorization.
  • Neural probability estimation: Neural language models estimate each conditional probability with a softmax over W h_t + b.Here h_t is the neural network output at position t, and W maps it to unnormalized scores for every vocabulary word.
  • Architectural variation: Language-model architectures mainly differ in how they compute h_t from word history, using methods such as multilayer perceptrons, convolutional layers, or recurrent networks.The passage gives Bengio et al., Mikolov and Zweig, Dauphin et al., Zaremba et al., and Merity et al. as examples.
  • Long-context modeling: Transformer-XL extends history through cached previous outputs and relative positional encoding, achieving 18.3 test perplexity on WikiText-103.It is described as a large-scale language model based on the Transformer.
  • Contextual representations: Contextual representation models seek word representations conditioned on the entire sentence or paragraph rather than only on preceding words.The objective is expressed for a position i in an input sequence as estimating p(w_i) from the full context.

3 Related Work

Prior work primarily studies the linguistic, semantic, syntactic, and transfer properties of pretrained representations and language models. This paper instead examines whether pretrained language models store factual and commonsense knowledge comparable to symbolic knowledge bases.

  • Research focus: This work contrasts with research on linguistic and semantic properties by testing whether pretrained language models store factual and commonsense knowledge.The investigation compares pretrained language models with symbolic knowledge bases.
  • Word representations: Neural word representations outperform count-based distributional methods on most evaluated lexical-semantics tasks.Baroni et al. compare the methods on semantic relatedness and concept categorization.
  • Transfer and linguistic knowledge: Pretrained-model studies assess linguistic transfer and syntax, but transfer evaluations provide little insight into competition with symbolic knowledge bases.Related work includes downstream natural-language-understanding transfer and analyses of grammaticality, syntactic heuristics, and layer specialization.
  • Generative pretraining: GPTv1 introduced Transformer-based generative pretraining, while GPTv2 was evaluated for zero-shot transfer across downstream tasks.GPTv1 was trained on the Book Corpus, which contains 7000 books.

4 The LAMA Probe

The LAMA probe evaluates factual and commonsense knowledge in language models by converting structured facts into cloze queries. Models are assessed by how highly they rank the ground-truth token among words in a fixed candidate set.

  • Probe design: LAMA tests factual and commonsense knowledge in language models using a corpus of structured facts.Facts are represented as subject-relation-object triples or question-answer pairs.
  • Probe design: Each fact is converted into a cloze statement that queries the model for a missing token.
  • Evaluation: Models are evaluated by ranking the ground-truth token against every other word in a fixed candidate set.

4.1 Knowledge Sources

The evaluation draws on factual, commonsense, and question-answering sources, converting their facts or pairs into cloze templates. Wikipedia alignment information supports supervised baselines, but alignment quality differs across sources.

  • Evaluation design: The study compares language models across sources of factual and commonsense knowledge, transforming facts or question-answer pairs into cloze templates and recording Wikipedia alignment.Alignment information is used by supervised baselines to extract knowledge representations from aligned text.
  • Structured knowledge sources: Google-RE contains ∼60K manually extracted Wikipedia facts, with evaluation restricted to place of birth, date of birth, and place of death.The excluded relations mainly contain multi-token objects unsupported by the evaluation, and each considered relation receives a manually defined template.
  • Structured knowledge sources: T-REx is a larger Wikidata-derived source covering 41 relations, with at most 1000 facts subsampled per relation and manually defined templates.Its Wikipedia alignments are automatic and potentially noisy, although reported alignment accuracy is 97.8%.
  • Commonsense knowledge: ConceptNet contributes English commonsense triples with single-token objects across 16 relations, using OMCS sentences containing both entities as masked-object templates.The source originates from multilingual ConceptNet, initially built on Open Mind Common Sense sentences.
  • Question answering: SQuAD contributes 305 context-insensitive development-set questions with single-token answers, manually rewritten as cloze-style questions.Because SQuAD was created from Wikipedia, each question-answer fact is known to be expressed there.

4.2 Models

The study evaluates six pretrained, case-sensitive language models and generates token probabilities according to each model’s training objective.

  • Models: Six pretrained case-sensitive models are studied: fairseq-fconv, Transformer-XL large, ELMo original, ELMo 5.5B, BERT-base, and BERT-large.The models are abbreviated Fs, Txl, Eb, E5B, Bb, and Bl, respectively.
  • Models: Token generation follows each model’s training objective, using preceding outputs for unidirectional models, bidirectional probabilities for ELMo, and masking for BERT.ELMo averages forward and backward softmax probabilities from the corresponding positions.

4.3 Baselines

The section defines baselines for comparing language models with established approaches to symbolic knowledge extraction and open-domain question answering. These include frequency-based object ranking, relation extraction, and DrQA’s retrieval-based QA pipeline.

  • Baselines: Freq ranks words by their frequency as objects for a subject–relation pair in the test data, representing a model that always predicts relation-specific frequent objects.It indicates the upper-bound performance of this constant-object prediction strategy.
  • Baselines: RE returns the correct object when any extracted relation instance has the right type, even if its subject or object is wrong.Extracted subjects and objects are linked to the query subject and object during evaluation.
  • Baselines: DrQA answers natural-language questions with a two-step pipeline beginning with TF/IDF retrieval of relevant articles from a large document store.The passage introduces DrQA as a popular open-domain question-answering system.

4.4 Metrics

The evaluation uses rank-based metrics computed per relation and averaged across relations, with filtered candidate rankings for multiple valid objects. Mean precision at k (P@k) measures whether the correct object appears among the top k results.

  • Metrics: The evaluation reports rank-based metrics per relation and mean values across all relations.This provides both relation-level and aggregate performance views.
  • Metrics: For N-M relations, other valid training objects are removed from test-time candidate rankings.Only the tested valid object remains among candidates from the training data.
  • Metrics: Mean precision at k (P@k) equals 1 when the object ranks among the top k results and 0 otherwise.The score is computed for each fact and then averaged.

4.5 Considerations

The LAMA probe’s design choices constrain what it measures: manually defined templates are treated as a lower bound, while targets and vocabularies are standardized to reduce technical and comparability issues. It predicts object slots, with reverse relations enabling subject-slot queries, but excludes relation-slot queries.

  • Manually Defined Templates: Manual templates can produce better or worse results for the same relation, so the probe measures a lower bound on language-model knowledge.Template choice affects performance for some relations and models.
  • Single Token: The probe restricts prediction targets to single-token objects because multi-token decoding introduces tunable parameters that can obscure the knowledge being measured.These parameters include beam size, candidate-scoring weights, length normalization, and n-gram repetition penalties.
  • Object Slots: The probe queries object slots, while reverse relations such as contains and contained-by also permit subject-slot queries; relation slots are not queried.Relation-slot realizations span several tokens, creating a technical challenge outside the work’s scope.
  • Intersection of Vocabularies: The probe uses a common vocabulary of approximately 21K case-sensitive tokens because models use different vocabularies and larger vocabularies make top-ranking the gold token harder.The compared vocabularies include approximately 800K tokens for ELMo and 30K for BERT.

5 Results

Across Google-RE, T-REx, ConceptNet, and SQuAD, BERT—especially BERT-large—retrieves factual, commonsense, and open-domain QA answers strongly without fine-tuning. Results also indicate that performance may reflect training-data exposure and co-occurrence associations rather than understanding.

  • Google-RE: BERT-base and BERT-large substantially outperform all other models on Google-RE, exceeding the oracle-based relation-extraction baseline by 2.2 and 2.9 average-accuracy points, respectively.The oracle baseline had seen at least one sentence expressing every test fact and received entity-linking assistance.
  • Interpretation and limitations: BERT-large’s strong results may arise from memorized training sentences or subject–object co-occurrence associations rather than genuine understanding.BERT and ELMo 5.5B also show low query-framing variability, potentially because they saw more relevant Wikipedia sentences during training.
  • T-REx: On the larger T-REx benchmark, BERT’s factual-knowledge retrieval remains close to automatically constructed knowledge bases using relation extraction and oracle entity linking.The correct object appears in BERT’s top ten in around 60% of cases and top 100 in 80% of cases.
  • ConceptNet: BERT-large consistently performs best on ConceptNet and retrieves commonsense knowledge at a level similar to factual knowledge.Its generated concepts are often syntactically correct and surprisingly reasonable.
  • SQuAD: On cloze-style open-domain SQuAD, unsupervised, non-fine-tuned BERT-large trails supervised DrQA, but the P@10 performance gap is remarkably small.BERT-large has no dedicated information-retrieval system.

6 Discussion and Conclusion

The analysis finds that pretrained language models, especially BERT-large, recall factual and commonsense knowledge competitively with traditional alternatives, while exposing challenges for extracted knowledge bases and evaluation. It also identifies template variation and multi-token answers as open directions.

  • Findings: BERT-large recalls factual and commonsense knowledge better than competing pretrained models and competitively with non-neural and supervised alternatives.The comparison concerns knowledge stored in existing pretrained-model weights, not the inherent knowledge-capture ability of architectures or objectives.
  • Findings: Extracting a knowledge base from text that matches directly using pretrained BERT-large remains non-trivial despite target-fact data and generous entity-linking supervision.The relation-extraction baseline received data likely to express target facts, reducing false negatives, and an entity-linking oracle.
  • Implications: Language models trained on increasingly large corpora may become a viable alternative to traditional knowledge bases extracted from text.This is presented as a future implication of the difficulty of matching pretrained BERT-large through relation extraction.
  • Limitations and Future Work: Future work should quantify recall variance across natural-language templates and address multi-token answers, which remain an open evaluation challenge.The LAMA probe is proposed for testing future pretrained language models, alongside analyses of template sensitivity.
Loading 1909.01066v2…