Language Models as Knowledge Bases: On Entity Representations, Storage Capacity, and Paraphrased Queries

Benjamin Heinzerling, Kentaro Inui

Abstract

This study investigates the potential of Large Language Models (LLMs) to serve as structured knowledge bases by scaling their capacity to millions of entities. We examine entity representation methods, parameter-to-fact storage efficiency, and the robustness of models to paraphrased queries. Results indicate that storage capacity scales linearly with model size and that pretrained models are significantly better at generalizing to linguistically diverse queries than models trained from scratch. While LLMs can store millions of facts with high accuracy, their ability to answer paraphrased queries depends heavily on pretraining and the linguistic similarity of the query to the original memorized statement.

Introduction

Traditional Knowledge Bases (KBs) like Wikidata are structured, storing information as "triples" (e.g., Barack Obama — born in — Hawaii). While precise, they are difficult to query using natural language. Recently, researchers proposed using LLMs as "soft" KBs because they appear to memorize facts during training.

The process of querying a Language Model as a Knowledge Base.

However, early "LM-as-KB" experiments were limited to entities that were single tokens in the model's vocabulary. This paper addresses how to represent millions of multi-word entities, the actual storage capacity of model parameters, and the robustness of recall when questions are paraphrased.

Methods and Representations

The authors compared three primary methods for representing entities within LLMs:

  1. Symbolic Representation: Extending the model's vocabulary so every entity has its own unique token. This is highly accurate but computationally expensive.
  2. Surface Form Representation: Treating entity names as sequences of subwords (e.g., "Sesame Street"). This is efficient but struggles with long, rare names.
  3. Continuous Representation: Representing each entity as a fixed d-dimensional embedding. This proved to be the most parameter-efficient method.

To measure capacity, the researchers used LSTMs and Transformers (RoBERTa) trained on synthetic data generated from Wikidata, including a 6-million entity set and templates for the 100 most frequent predicates.

Key Insights: Linear Scaling and Capacity

A significant finding of the study is that storage capacity scales linearly with model size. For the models tested, a 160M parameter Transformer could store roughly 7 million facts at 80% accuracy. This suggests that trillion-parameter models could theoretically house massive portions of human knowledge.

Memorization accuracy across different model architectures as the number of statements increases.

As shown in the figure above, models like RoBERTa-base maintain extremely high memorization accuracy (near 97%) even when tasked with storing 5 million statements. The study introduced a "Storage Efficiency" metric to normalize these results: $$\text{Storage efficiency} = \frac{\#\text{statements} \times \text{accuracy}}{\#\text{parameters}}$$

Robustness and the Role of Pretraining

The research highlights a critical distinction between rote memorization and functional knowledge. A model trained from scratch can memorize facts perfectly but fails if the query format changes even slightly (e.g., adding an ellipsis).

In contrast, pretrained models like RoBERTa possess an underlying understanding of language that allows them to "transfer" a memorized fact to a paraphrased query. While zero-shot transfer remains difficult—accuracy can plummet for diverse paraphrases—the models are "quick learners." Finetuning on just 5 to 100 examples of a new query format allowed models to successfully recall previously memorized facts in that new format.

Limitations and Future Work

While promising, the study focused on simple 1-to-1 relations. Real-world KBs involve 1-to-N relations, multi-hop reasoning, and facts qualified by time or location. Furthermore, the paper does not address "knowledge editing"—the ability to update specific facts without retraining the entire model. Future work may explore "adaptive pretraining," where entity supervision is integrated directly into the initial LM training phase.

Summary updated

BibTeX
@inproceedings{heinzerling2021language,
  author = {Benjamin Heinzerling and Kentaro Inui},
  title = {{Language Models as Knowledge Bases: On Entity Representations, Storage Capacity, and Paraphrased Queries}},
  booktitle = {EACL},
  year = {2021},
  doi = {10.18653/v1/2021.eacl-main.153},
}
Figure