NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

The Effect of Masking Strategies on Knowledge Retention by Language Models

Jonas Wallat, Tianyi Zhang, Avishek AnandarXiv 2023 · DOI

TL;DR

This paper investigates how different pre-training strategies affect the factual knowledge retained by language models. They found that masking entities or correlated spans is more effective than random masking for knowledge retention, and crucially, that this knowledge can be forgotten due to catastrophic forgetting during fine-tuning, but this can be mitigated with techniques like multi-task learning.

What Problem Does This Paper Address?

Large language models (LLMs) are incredibly powerful due to their ability to store vast amounts of world knowledge acquired during pre-training. This knowledge is essential for tasks like question answering and information retrieval. However, understanding how this knowledge is acquired, which specific pre-training tasks are most effective for retaining it, and whether it persists through subsequent fine-tuning remains an open question. Specifically, the authors aim to bridge the gap in understanding the impact of different pre-training masking strategies on factual knowledge acquisition and, importantly, to investigate the phenomenon of "catastrophic forgetting" – where knowledge learned during pre-training is lost when the model is fine-tuned on a new task.

Methods

The core of the paper involves a three-step experimental setup:

  1. Knowledge Infusion: The researchers used a T5-small model and infused it with factual knowledge by continuing its pre-training on Wikipedia passages. They experimented with three different masking strategies for this stage:
  2. Random Token Masking (RTM): The standard T5 approach where random tokens or spans are masked.
  3. Salient Span Masking (SSM): This strategy prioritizes masking named entities, hypothesizing that entities are crucial for factual recall in question answering.
  4. Pointwise Mutual Information (PMI) Masking: This method masks frequently co-occurring n-grams, aiming to capture more contextual information and reduce the masking of less informative tokens.
  5. CBQA Fine-tuning: After knowledge infusion, the models were fine-tuned on a closed-book question answering (CBQA) task using question-answer pairs derived from the same Wikipedia passages. This step simulates learning a downstream task.
  6. Knowledge Retention Testing: The models' ability to answer factual questions from a held-out set was evaluated using exact match and F1 scores. This measured how much of the infused knowledge was retained and usable.

To address catastrophic forgetting, they also experimented with Elastic Weight Consolidation (EWC) and Multi-Task Learning (MTL), applying these regularizers during the fine-tuning stage.

Datasets

The primary dataset used is the PAQ dataset (Lewis et al., 2021). This dataset consists of 65 million question-answer pairs automatically generated from Wikipedia passages, with each passage yielding 4-8 QA pairs. For their experiments, the authors selected 10,000 passages for the additional pre-training and then split the corresponding 49,000 QA pairs into training, development, and test sets for CBQA fine-tuning.

Key Insights and Ideas

  • Principled Masking Beats Randomness: Not all masking strategies are created equal. Masking entities (SSM) or correlated spans (PMI) is significantly more effective at embedding factual knowledge than simply masking random tokens. This suggests that models learn better when guided to focus on semantically important parts of the text.
  • Catastrophic Forgetting is Real: The study confirms that language models suffer from catastrophic forgetting. When fine-tuned on a new task (CBQA), a substantial portion of the factual knowledge acquired during the initial pre-training phase becomes inaccessible.
  • Regularization is Key to Retention: Techniques like EWC and MTL can effectively mitigate catastrophic forgetting. By either preserving important weights or training tasks in parallel, these methods allow models to retain more of their acquired factual knowledge.
  • PMI Masking Offers Stability: While SSM and PMI masking show similar performance gains, PMI masking exhibits notably less variance between experimental runs, making it a more stable and potentially preferable strategy for knowledge infusion.

Key Results

  • Knowledge Infusion Gains: SSM and PMI masking improved knowledge retention by approximately 9.4% and 8.9% respectively, compared to a baseline fine-tuned model. Random token masking (RTM) offered a smaller gain of 4.4%.
  • Catastrophic Forgetting Impact: Without regularization, the performance gains from pre-training were significantly diminished after fine-tuning.
  • Mitigation Effectiveness: Applying EWC led to an average increase of 23.4% in usable knowledge. MTL further improved performance, with an additional round of fine-tuning boosting results by 3.1% and showing the least variance.

Limitations and Future Work

The authors acknowledge that their study focuses on a specific model size (T5-small) and a particular dataset (PAQ). They suggest that future work could explore these masking strategies and forgetting mitigation techniques on larger models and a wider variety of knowledge-intensive tasks. The paper also implicitly highlights the need for more robust evaluation metrics that go beyond exact match to truly assess the depth of retained knowledge.

Summary updated

BibTeX
@misc{wallat2023effect,
  author = {Jonas Wallat and Tianyi Zhang and Avishek Anand},
  title = {{The Effect of Masking Strategies on Knowledge Retention by Language Models}},
  year = {2023},
  eprint = {2306.07185},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2306.07185},
}
Figure