Plug-and-Play Knowledge Injection for Pre-trained Language Models

Zhengyan Zhang, Zhiyuan Zeng, Yankai Lin, Huadong Wang, Deming Ye, Chaojun Xiao, Xu Han, Zhiyuan Liu, Peng Li, Maosong Sun, Jie Zhou

TL;DR

This paper introduces a "plug-and-play" paradigm for injecting external knowledge into pre-trained language models (PLMs) without the need for expensive retraining. By using a lightweight mapping network called map-tuning, researchers can inject facts into frozen downstream models, achieving significant performance gains with only 0.1% additional parameters and a fraction of the traditional training time.

What Problem Does This Paper Address?

While pre-trained language models like BERT are powerful, they often lack specific, up-to-date factual knowledge. The standard way to fix this is "knowledge injection"—incorporating external knowledge bases (KBs) into the model. However, existing methods are "highly coupled": the knowledge is baked into the model during pre-training or fine-tuning.

This creates a massive efficiency bottleneck. If you want to update the knowledge base or apply a new injection method to an existing task-specific model, you usually have to discard your model and start the expensive retraining process from scratch. The authors propose a decoupled approach where models and knowledge bases are treated like computers and flash disks: you should be able to "plug in" new knowledge to a frozen, already-deployed model.

Figure 1: Illustration of plug-and-play knowledge injec- tion, where knowledge bases and models are decoupled.

Methods

The authors propose Map-tuning, a method that trains a small mapping network ($M$) to bridge the gap between structured knowledge embeddings (like TransE) and the PLM’s internal representation space.

They explore two primary settings:

  1. General Plug-and-Play Injection: A single mapping network is trained once using a variant of Masked Language Modeling called Mention-Masked Language Modeling (MMLM). In MMLM, the model learns to predict masked entity mentions in a text by leveraging the "plugged-in" knowledge embeddings. This general plugin can then be used across any downstream model derived from that PLM.
  2. Task-specific Plug-and-Play Injection: The mapping network is trained (or fine-tuned from the general version) using the specific objective of a downstream task (e.g., relation classification) while keeping the main model parameters frozen.
Figure 2: Left: Comparisons between previous paradigms and our proposed plug-and-play paradigm. Right: Two ways for map-tuning. The input text is “Hamsters love peanut butter.”. “DM” refers to “downstream model”.

Datasets

The researchers evaluated their approach on several knowledge-intensive NLP tasks:

  • Relation Classification: FewRel 1.0, FewRel 2.0 (few-shot), and Wiki80 (full-data).
  • Entity Typing: Wiki-ET (68 entity types from Freebase).
  • Question Answering: EntityQuestions (an open-domain, entity-centric QA dataset).
  • Knowledge Bases: Wikidata (for general domains) and UMLS (for the medical domain).

Key Insights and Ideas

  • Existing Methods Fail the "Plug-and-Play" Test: Traditional injection methods like E-BERT or PELT actually degrade performance when applied to frozen downstream models. They act as "disruptive noise" because the models weren't trained to interpret those specific external signals.
  • Generality through Dropout: To ensure the mapping network works on various downstream models it has never seen, the authors used high dropout rates (around 0.25) during training. This simulates model variance and forces the mapping network to be more robust.
  • Domain Adaptation without Retraining: One of the most striking findings is that map-tuning allows for seamless domain transfer. A model trained on Wikipedia can be adapted to the medical domain (PubMed) simply by swapping the "knowledge plugin" from Wikidata to UMLS, outperforming models that were fully fine-tuned on the target domain.

Key Results

  • Performance: Map-tuning achieved consistent improvements across almost all tested models and tasks. For example, on the EntityQuestions task, it improved BERT-base accuracy from 41.7% to 49.0% in the general setting.
  • Efficiency: The mapping network is incredibly lightweight, containing fewer than 0.1 million parameters (less than 0.1% of a standard BERT-base model).
  • Speed: Training the mapping network takes only about 12 GPU hours on an NVIDIA Tesla V100. In contrast, traditional pre-training-based injection methods like LUKE or KEPLER require over 3,000 GPU hours.
Time cost vs. Accuracy for different knowledge injection methods.

Limitations and Future Work

The authors acknowledge a few key limitations:

  • Fine-tuning Assumption: The current paradigm assumes the PLM has been fine-tuned for a downstream task. It hasn't yet been tested on the zero-shot or in-context learning capabilities of massive LLMs (like GPT-4).
  • Scope of Knowledge: The study focused on structured factual knowledge (triples). Future work could extend this to "plugging in" text corpora, images, or even other language models.
  • Reasoning: It remains to be seen if these plugins can support complex, multi-hop reasoning beyond simple fact retrieval.

Summary updated

BibTeX
@inproceedings{zhang2023plug,
  author = {Zhengyan Zhang and Zhiyuan Zeng and Yankai Lin and Huadong Wang and Deming Ye and Chaojun Xiao and Xu Han and Zhiyuan Liu and Peng Li and Maosong Sun and Jie Zhou},
  title = {{Plug-and-Play Knowledge Injection for Pre-trained Language Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-long.594},
}
Figure