Can Language Models Act as Knowledge Bases at Scale?

Qiyuan He, Yizhong Wang, Wenya WangarXiv 2024

Abstract

This study investigates whether Large Language Models (LLMs) can be explicitly trained to function as massive, flexible Knowledge Bases (KBs) by memorizing 46 million triplets from Wikidata. The researchers find that while LLMs are surprisingly efficient at storing and flexibly retrieving large-scale factual data, they suffer from a "reasoning gap"—particularly struggling with inverse relationships. This paper introduces importance sampling to handle scale and evaluates models like LLaMA-2 and T5 on their ability to act as "Neural KBs."

Introduction

Traditional Knowledge Bases (KBs) like Wikidata are structured and accurate but rigid, requiring complex semantic parsing for queries. Conversely, LLMs excel at natural language but often hallucinate or miss "long-tail" knowledge due to their unstructured pre-training. This research asks: can we explicitly train an LLM on a massive, cleaned KB to create a "Neural KB" that combines the accuracy of a database with the flexibility of a chatbot?

Methods: Injecting Knowledge at Scale

The authors propose a systematic approach to "injecting" a KB into an LLM by converting (subject, relation, object) triplets into simple strings for prediction. To handle the scale of 46 million triplets, they employ Importance Sampling. This algorithm prioritizes "hard-to-memorize" samples based on current prediction loss, significantly accelerating convergence compared to uniform sampling.

Impact of Importance Sampling on training efficiency and score convergence.

Experimental Setup and Datasets

The primary training set, $D_0$, consists of 46 million triplets from Wikidata involving 10.5 million entities. Evaluation is conducted across several dimensions:

  • Fixed-form recall: Triplet completion.
  • Free-form recall: Natural language question answering using the PopQA dataset.
  • Reasoning: Inference of missing facts using inverse or compositional logic.

Key Insights: Scaling and the Reasoning Gap

The study reveals several critical properties of Neural KBs:

The Memorization Scaling Law

Larger models are not just higher in capacity; they are more efficient learners. LLaMA-2-13b memorized facts significantly faster and more accurately than the 7b version or T5 models. As shown in the performance plots, larger models consistently achieve higher Exact Match (EM) and F1 scores across various subsets of the data.

Performance of T5 and LLaMA-2 models across different data subsets, highlighting the scaling of memorization capacity.

Popularity Bias and Directionality

Even with a balanced KB, models find "popular" entities easier to memorize than "long-tail" ones. Furthermore, LLMs exhibit a "directionality" issue: learning "A is the sibling of B" does not imply the model knows "B is the sibling of A." This suggests facts are stored as one-way associations rather than holistic concepts.

Key Results

  • Capacity: LLaMA-2-13b achieved an 81.64% F1 score in recalling facts from the 46M triplet dataset.
  • Efficiency: Importance sampling produced a significantly steeper learning curve, reaching high accuracy in fewer steps.
  • Reasoning Threshold: While KB training aids compositional reasoning, there is an upper limit where more memorization no longer improves logical deduction. Inverse reasoning remained a significant weakness across all models.

Conclusion and Future Work

While LLMs show promise as Neural KBs, the "reasoning gap" remains a hurdle. Memorization does not equate to understanding relational properties like symmetry. Future research must address how to force models to learn these properties and how to efficiently update or "edit" facts in a static neural memory.

Summary updated

BibTeX
@misc{he2024can,
  author = {Qiyuan He and Yizhong Wang and Wenya Wang},
  title = {{Can Language Models Act as Knowledge Bases at Scale?}},
  year = {2024},
  eprint = {2402.14273},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.14273},
}
Figure