Relational Memory Augmented Language Models

Qi Liu, Dani Yogatama, Phil Blunsom

Introduction

Modern autoregressive language models, such as GPT-4 or Transformer-XL, exhibit remarkable fluency but frequently struggle with factual consistency and logical reasoning. Because these models store knowledge implicitly within their parameters, they often rely on statistical word correlations rather than structured facts. This limitation leads to "hallucinations"—for example, incorrectly associating entities simply because they frequently co-occur in training data.

To address this, researchers from DeepMind and Oxford have introduced RELATIONLM. This model explicitly conditions text generation on a "relational memory" of knowledge graph triples. By retrieving relevant (head, relation, tail) facts from both local context and external data, RELATIONLM improves logical coherence and reduces factual errors.

Methodology

RELATIONLM augments a Transformer-XL base with a structured relational memory component. The architecture follows a multi-step process to integrate symbolic knowledge into the neural generation pipeline.

The RELATIONLM architecture integrates knowledge graph triples into the language modeling process via a gated mechanism.
  1. Knowledge Source: Instead of relying solely on static, often incomplete knowledge bases, the model utilizes Open Information Extraction (OpenIE). It extracts triples—$(head\ entity, relation, tail\ entity)$—directly from the training and evaluation datasets.
  2. Dynamic OpenIE: During evaluation, the model extracts relations from previously seen text segments. This allows it to "learn" and utilize new facts specific to the document currently being processed.
  3. Retrieval & Scoring: Given a context, the model identifies salient entities using an entity tagger and tf-idf scoring, then retrieves associated triples from its relational memory.
  4. Integration: Retrieved triples are serialized (e.g., "Obama, alma mater, Columbia University") and encoded into vectors using an LSTM. A learned gating mechanism then determines the relative influence of the standard textual context versus the retrieved relational facts when predicting the next token.

Experimental Setup

The model was evaluated on three standard English benchmarks representing different linguistic challenges:

  • WikiText-103: A knowledge-heavy collection of featured Wikipedia articles.
  • WMT19: Dynamic English news data, which is more temporal than Wikipedia.
  • enwik8: A character-level dataset consisting of the first $10^8$ bytes of English Wikipedia.

Key Results

RELATIONLM consistently outperformed the Transformer-XL baseline across all datasets. The improvements are particularly notable in "Knowledge Perplexity"—the model's ability to accurately predict entity names.

Quantitative results showing RELATIONLM's performance (Perplexity for WikiText/WMT19 and BPC for enwik8) compared to baselines.

On WikiText-103, RELATIONLM achieved a test perplexity of 19.2, compared to 19.9 for the baseline. Furthermore, human evaluations of 1,000 contexts favored RELATIONLM's generations, finding them more coherent (612 vs. 388) and knowledgeable (584 vs. 416) than those of the baseline.

Discussion and Insights

The authors highlight several key findings:

  • OpenIE vs. Static KBs: Relations extracted via OpenIE from the dataset itself proved more useful than those from general-purpose bases like Freebase, as they capture the specific nuances of the corpus.
  • Complementarity: Relational memory is complementary to token-based memory (like SPALM). While token memory handles style and local patterns, relational memory provides a factual "scaffolding."
  • Interpretability: The explicit memory allows for "causal interventions." By manually swapping a triple in memory, researchers can force the model to change its output, demonstrating a level of control absent in standard LMs.

Limitations

Despite its successes, RELATIONLM introduces computational overhead, running approximately 1.5x to 2.1x slower than Transformer-XL due to the retrieval and encoding steps. Future work may explore "dense retrieval" using neural embeddings to replace the current tf-idf approach and investigate how these relational gating mechanisms scale to models with billions of parameters.

Summary updated

BibTeX
@article{liu2022relational,
  author = {Qi Liu and Dani Yogatama and Phil Blunsom},
  title = {{Relational Memory Augmented Language Models}},
  journal = {Trans. Assoc. Comput. Linguistics},
  year = {2022},
  doi = {10.1162/tacl\_a\_00476},
}
Figure