How Do Large Language Models Acquire Factual Knowledge During Pretraining?

Hoyeon Chang, Jinho Park, Seonghyeon Ye, Sohee Yang, Youngkyung Seo, Du-Seong Chang, Minjoon Seo

Introduction

This paper pulls back the curtain on how Large Language Models (LLMs) learn facts during pretraining, revealing that knowledge acquisition is a constant tug-of-war between "micro-acquisitions" and rapid forgetting. The researchers found that while larger models are better at absorbing information, training for longer doesn't actually improve a model's ability to learn new facts. Instead, the "secret sauce" of massive datasets is simply giving the model enough chances to see a fact before it fades away entirely.

The Mystery of Pretraining

We know LLMs are incredible encyclopedias, but we don't really know how they read the book. Most research looks at what a model knows after training is finished. This paper asks: what is happening step-by-step during the pretraining process?

Specifically, the authors tackle three mysteries:

  1. The Dynamics: How does the probability of a fact change as the model sees it and then continues training on other data?
  2. The Conditions: Does a model get "smarter" at learning as it sees more tokens, or does model size matter more?
  3. The Forgetting: Why do models struggle with "long-tail" (rare) knowledge, and why does deduplicating data help?

Methodology: Controlled Knowledge Injection

To study this without the interference of knowledge the model might have already seen, the authors created a "controlled injection" experiment. They took intermediate checkpoints of the OLMo model (at 1B and 7B scales) and injected brand-new, fictional factual knowledge into the training stream.

They introduced the FICTIONAL KNOWLEDGE dataset, containing 120 descriptions of fictional but realistic entities (e.g., a fake Martian government) generated via GPT-4. By using fictional data, the researchers ensured the model had a "zero" baseline probability for the facts, allowing them to measure the exact impact of the training steps.

They measured two key metrics:

  • Effectivity: The immediate boost in log-probability for a fact after the model sees it in a training batch.
  • Retainability: How much of that probability boost remains after the model moves on to thousands of subsequent training steps.
Illustration of Effectivity and Retainability after a knowledge injection.

They tested three "depths" of knowledge: memorization (exact string match), semantic generalization (paraphrased versions), and compositional generalization (combining multiple injected facts to answer a question).

Key Findings: The Tug-of-War of Learning

  • Learning is Granular: Factual knowledge isn't "learned" in one go. It’s a series of "micro-acquisitions" where the model's confidence in a fact ticks up slightly each time it's seen, only to be slowly diluted by subsequent training on unrelated data.
  • The Effectivity Plateau: Surprisingly, a model doesn't get better at learning new facts as it sees more tokens. A 7B model that has seen 1.5 trillion tokens is no more "effective" at immediate learning than one that has seen only 500 billion. However, scaling model size does help—the 7B model is significantly more effective than the 1B model.
  • The Power-Law of Forgetting: Forgetting isn't random; it follows a predictable power-law relationship with the number of training steps. The researchers found that the trend of retainability against the log of training steps fits a linear function ($R^2 > 0.80$).
  • The "Learnability Threshold": By calculating the x-intercept of these forgetting curves, the authors identified a threshold. If a fact appears in the training data less frequently than this threshold (the "long-tail"), the model will forget it faster than it can accumulate it, making it impossible for the model to "know" that fact at the end of training.
  • The Duplication Trap: While repeating a fact (duplication) helps with immediate memorization, it actually causes the model to forget generalizations faster. This provides a theoretical backbone for why the community has found that deduplicating training sets leads to better-performing models.
  • Batch Size as a Shield: Training with larger batch sizes makes the acquired knowledge more robust against forgetting, likely because the gradients are more stable.
  • Compositional Robustness: While compositional generalization (connecting the dots between facts) is the hardest to acquire, it is actually more robust to forgetting than simple memorization.

Limitations and Future Work

The authors acknowledge a few key boundaries to their study. First, the study focuses on the internal probability the model assigns to tokens, not whether the model would actually output the correct answer in a chat interface. The relationship between "probability" and "decodable knowledge" needs more exploration. Second, the study looked at "Early," "Mid," and "Late" stages of pretraining, but skipped the very beginning of training, where behaviors might be more erratic. Finally, while they tested batch size and model scale, they didn't perform an exhaustive sweep of learning rates or different optimizer configurations.

Overall, this work provides a vital framework for understanding the "metabolism" of LLMs—how they ingest, digest, and occasionally lose the facts that make them so useful.

Summary updated

BibTeX
@inproceedings{chang2024how,
  author = {Hoyeon Chang and Jinho Park and Seonghyeon Ye and Sohee Yang and Youngkyung Seo and Du-Seong Chang and Minjoon Seo},
  title = {{How Do Large Language Models Acquire Factual Knowledge During Pretraining?}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=TYdzj1EvBP},
}
Figure