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

Abstract

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 utilizing a lightweight mapping network called map-tuning, the authors demonstrate that frozen, already-fine-tuned downstream models can be enhanced with new knowledge bases as easily as plugging a flash drive into a computer. This approach decouples knowledge from model parameters, allowing for efficient domain adaptation and resource-saving knowledge updates across multiple specialized models.

Introduction: The Coupling Problem

Traditionally, integrating specific facts from external databases (e.g., Wikidata) into a language model requires injection during the pre-training or fine-tuning phases. This creates a significant efficiency bottleneck: if multiple specialized models require the same new knowledge base, each must be retrained from scratch. The authors identify this as a "coupling" problem where knowledge and model parameters are inextricably linked.

The plug-and-play paradigm allows injecting linguistic or factual knowledge into frozen models for various downstream tasks.

To address this, they propose a decoupled approach where the base model remains frozen, and a tiny "plugin" module bridges the gap between external knowledge embeddings and the model’s internal representation space. This allows for a modular architecture where knowledge can be swapped or updated without modifying the underlying model weights.

Methodology: Map-tuning

The core contribution is Map-tuning, a method to train a lightweight mapping network ($M$) that projects external knowledge into the model's latent space.

The Plugin Architecture

Instead of altering the model, map-tuning takes entity embeddings (e.g., from TransE) and passes them through a simple affine transformation ($We + b$) to project them into the same dimension as the PLM’s token embeddings. When an entity is identified in the input text, its mapped embedding is inserted alongside the original tokens as an additional input.

Comparison between previous knowledge injection methods and the proposed plug-and-play paradigm, including details on General and Task-specific Map-tuning.

Training Settings

The authors propose two primary ways to train these mapping networks:

  1. General Map-tuning: The mapping network is trained using Mention-Masked Language Modeling (MMLM). By masking only entity mentions and forcing the model to predict them using the injected embeddings, the network learns to provide "readable" information to the frozen PLM.
  2. Task-specific Map-tuning: The mapping network is tuned directly on a specific downstream task (like relation classification) while the main model remains frozen.

Because the mapping network is extremely small (~0.1M parameters), it can be trained quickly and "plugged" into any model derived from the same backbone (e.g., any BERT-base model).

Evaluation and Results

The approach was evaluated across several knowledge-driven NLP tasks, including Relation Classification (FewRel, Wiki80), Entity Typing (Wiki-ET), and Question Answering (EntityQuestions), using knowledge bases like Wikidata5M and UMLS.

Key Performance Gains

Map-tuning improved performance across all tested downstream models, regardless of whether they were trained via full fine-tuning or parameter-efficient methods like LoRA or Adapters. For instance, on the FewRel 1.0 (10-way 1-shot) task, map-tuning improved a fine-tuned BERT model's accuracy from 85.4% to 88.1%.

Efficiency and Domain Adaptation

  • Computational Efficiency: Training a general mapping network takes approximately 12 hours on a single GPU, compared to thousands of hours for traditional knowledge-enhanced pre-training.
  • Domain Adaptation: A model trained on Wikipedia can be adapted to the medical domain (PubMed) simply by swapping the mapping network for one trained on UMLS, suggesting that the model's underlying reasoning capabilities are preserved and transferable.

Discussion and Limitations

The authors found that existing methods like E-BERT often degrade performance when applied to frozen models because they introduce noise the model cannot adapt to. Map-tuning avoids this by ensuring the injected information is "readable" to the frozen backbone.

However, the current study focuses on BERT-base; future work should explore larger LLMs and causal architectures. Additionally, the impact on complex multi-hop reasoning and the potential for "plugin fusion" (combining multiple knowledge sources like text, images, and structured KBs) remain open areas for research.

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