Enhancing LLM Knowledge Learning through Generalization

Mingkang Zhu, Xi Chen, Zhongdao Wang, Bei Yu, Hengshuang Zhao, Jiaya Jia

TL;DR

Updating Large Language Models (LLMs) with new factual knowledge via continued pre-training often fails to generalize to question-answering tasks unless expensive, rewritten paraphrased data is used. This paper demonstrates that an LLM's question-answering capability is strongly correlated with its ability to predict knowledge tokens across varied contexts. To exploit this, the authors introduce formatting-based data augmentation and Sharpness-Aware Minimization (SAM), significantly boosting knowledge acquisition without the risks or costs of text rewriting.

What Problem Does This Paper Address?

As the world changes, LLMs need to be continuously updated with new factual knowledge. The standard approach—continued pre-training (CPT) on new documents—frequently fails because the model struggles to retrieve that knowledge when prompted with a question during inference.

Recent studies show that training on multiple paraphrased versions of a document helps the model generalize. However, generating these paraphrases via external LLMs or manual rewriting is computationally expensive, slow, and introduces a dangerous risk: the rewriting process might inadvertently alter or hallucinate the facts you are trying to teach the model. The authors of this paper set out to achieve the generalization benefits of paraphrasing without actually altering the text's semantic content.

Methods

The authors propose a two-pronged strategy to improve how LLMs generalize new knowledge to unseen contexts:

  1. Formatting-Based Data Augmentation: Instead of changing the words (semantic paraphrasing), they change the presentation of the text. They introduce three simple, zero-cost formatting modifications that preserve 100% factual integrity:
  2. Wrapping: Enclosing the text in quotes, asterisks, brackets, or parentheses (e.g., mimicking Markdown syntax).
  3. Left Padding: Adding spaces, tabs, or hashtags to the beginning of the text.
  4. Random Space Insertion: Randomly adding extra spaces between words to simulate different typing styles.
Examples of formatting-based data augmentations proposed in the paper.
  1. Sharpness-Aware Minimization (SAM): The authors replace standard optimizers with SAM during training. SAM looks for a "flat minimum" in the loss landscape rather than just a deep one, which directly encourages the model to generalize its knowledge predictions across different preceding contexts.

These methods are applied during both the continued pre-training (CPT) phase and the subsequent instruction tuning (IT) phase.

Datasets

The approach was validated using two distinct datasets:

  • Synthetic Biography Dataset: Modeled after recent literature, this dataset consists of 1,000 randomly generated profiles, each containing five attributes (birth date, college, major, hometown, and company). To rigorously test generalization, the evaluation uses five distinct question prompts per attribute.
  • Wiki2023-film Dataset: A real-world dataset consisting of recent movie information, specifically designed to minimize overlap with the models' original pre-training data to simulate the injection of genuinely new information.

Key Insights and Ideas

  • The Core Hypothesis: The authors discover a powerful, positive correlation between an LLM's ability to predict a factual knowledge token given an unseen paraphrased context and its ability to answer a question about that fact.
Figure 1: Conceptual illustration of our hypothesis. The red tokens represent knowledge tokens. Continued pre- training on raw knowledge documents leads to predic- tion accuracy increase of knowledge tokens conditioned on both preceding contexts of unseen paraphrased docu- ments containing the same knowledge and related ques- tions. Incorporating paraphrased training documents further improves both accuracies. Thus, their accuracies are positively correlated.
  • Format vs. Semantics: You don't need to change the meaning of a sentence to help an LLM generalize. Simply changing the formatting tokens forces the model to decouple the factual tokens from the exact sequence of preceding words, leading to better question-answering performance.
Figure 2: Average first knowledge token accuracy for each attribute conditioned on: (1) preceding tokens in unseen paraphrased documents, (2) preceding tokens in testing questions.
  • Traditional Augmentation Fails: Standard NLP data augmentations like EDA (Easy Data Augmentation, which deletes or swaps random words) completely destroy factual learning. Because EDA can alter or remove the actual knowledge tokens, it causes the model's exact match accuracy to drop to zero.

Key Results

The combination of formatting augmentation and SAM yielded massive performance gains across different model sizes (Qwen 2 1.5B and LLaMA 2 7B):

  • Biography Dataset: For Qwen 2 1.5B, standard CPT achieved a meager 7.1% Exact Match (EM) score on QA. Applying the proposed method boosted this to 43.2%. When combined with actual paraphrased data, the method pushed the EM score to 74.9% (up from 24.9% for baseline paraphrase CPT).
  • Instruction Tuning: The benefits carried over to the instruction tuning phase, showing that the model became significantly more robust against variations in how questions were phrased.
Table 2: Experiment results on the biography dataset with the base models continued pre-training and instruction- tuning by our method and baselines. Our method leads to substantial improvement in knowledge acquisition and extraction for both phases compared to baselines.
  • Real-World Data: On the Wiki2023-film dataset, the method consistently outperformed the baselines, demonstrating stable improvements of up to 7.3 points in EM and 9.6 points in Recall.

Limitations and Future Work

While the empirical results are robust and consistent across multiple models, the authors note that their findings lack a formal theoretical justification. They present the correlation between contextual token prediction and question-answering as an empirical discovery, leaving the mathematical proof for future work.

Additionally, because this method makes the model highly efficient at absorbing new facts, it also carries the risk of more effectively cementing misinformation or factual errors if they are present in the training data.

Summary updated

BibTeX
@misc{zhu2025enhancing,
  author = {Mingkang Zhu and Xi Chen and Zhongdao Wang and Bei Yu and Hengshuang Zhao and Jiaya Jia},
  title = {{Enhancing LLM Knowledge Learning through Generalization}},
  year = {2025},
  eprint = {2503.03705},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.03705},
}
Figure