Decouple knowledge from paramters for plug-and-play language modeling

Xin Cheng, Yankai Lin, Xiuying Chen, Dongyan Zhao, Rui Yan

Introduction

Standard Pre-trained Language Models (PLMs) like BERT or GPT function as "knowledge sponges," implicitly storing factual information within their millions of parameters during training. While effective, this architecture leads to two significant challenges: staleness and opacity. Once trained, a model's knowledge is frozen, requiring expensive retraining or fine-tuning to update facts. Furthermore, the "black box" nature of these parameters makes it nearly impossible to trace the provenance of a specific prediction.

To address these issues, this paper proposes PlugLM, a framework that decouples the "reasoning engine" (model parameters) from the "knowledge base" (external data). By moving factual knowledge into an editable, external "plug-in memory," the model can adapt to new domains or update its facts instantly without retraining.

Methodology: Differentiable Plug-in Memory (DPM)

The core innovation of PlugLM is the Differentiable Plug-in Memory (DPM). This approach leverages the observation that Feed-Forward Network (FFN) layers in Transformers—which account for roughly two-thirds of total parameters—act as unnormalized key-value memories.

The PlugLM architecture featuring Differentiable Plug-in Memory (DPM) and the Knowledge Attention mechanism.

PlugLM replaces the FFN layers in the upper levels of the Transformer with the DPM. The process involves:

  1. Knowledge Encoding: A dedicated encoder transforms raw text snippets (e.g., from Wikipedia or PubMed) into vector-based keys and values.
  2. Retrieval & Fusion: For a given input, the model employs Maximum Inner Product Search (MIPS) to retrieve the most relevant snippets. A "Knowledge Attention" mechanism then fuses this external information into the model's hidden states.
  3. End-to-End Training: Unlike traditional retrieval-augmented models, PlugLM is trained end-to-end using a standard Masked Language Modeling (MLM) objective, ensuring the retriever and the language model are tightly integrated.

Experimental Setup

PlugLM was evaluated across a diverse range of datasets and tasks:

  • General Domain: Wikipedia for initial pre-training.
  • Domain Adaptation: Four unlabeled corpora including BIOMED (S2ORC), CS (Computer Science), NEWS (REALNEWS), and REVIEWS (Amazon).
  • Benchmarks: The GLUE suite for general understanding, SQuAD for question answering, and eight specialized Biomedical Named Entity Recognition (NER) datasets.

Key Results and Insights

PlugLM demonstrates superior flexibility and efficiency compared to standard models.

Zero-Shot Domain Adaptation

The "plug-and-play" nature allows for instant domain adaptation. By simply swapping the Wikipedia memory plug for a PubMed or CS-specific plug, the model adapts to specialized fields without further training. PlugLM achieved domain adaptation results 254x faster than standard Domain Adaptive Post-Training (DAPT).

Heatmaps illustrating how attention patterns shift between Wikipedia and Computer Science (CS) domains under different adaptation strategies.

Performance Gains

On average, PlugLM showed a 3.95 F1 point improvement across four domains without in-domain pre-training. Notably, it saw an 11.55 F1 jump on the ACL-ARC citation intent dataset. In biomedical NER tasks, PlugLM outperformed WikiBERT on 8 out of 8 tasks simply by switching its external memory source.

Interpretability and Updates

Because the model explicitly retrieves text snippets, predictions are inherently more interpretable. Users can inspect the specific PubMed abstract or Wikipedia entry that informed a model's output. Additionally, the model can "absorb" new information training-free by adding new slots to the DPM, as evidenced by significant performance improvements on the LINNAEUS NER dataset as memory size increases.

Limitations and Future Work

While promising, PlugLM faces challenges regarding inference latency. Incorporating MIPS retrieval into the forward pass makes the model approximately 2.5x slower than a standard BERT model. Future research will focus on extending this architecture to large-scale decoder-only models (like GPT-4) and exploring more granular or hierarchical memory structures to optimize search efficiency.

Summary updated

BibTeX
@inproceedings{cheng2023decouple,
  author = {Xin Cheng and Yankai Lin and Xiuying Chen and Dongyan Zhao and Rui Yan},
  title = {{Decouple knowledge from paramters for plug-and-play language modeling}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.findings-acl.901},
}
Figure