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

TL;DR

This paper investigates the "how" of factual knowledge acquisition in LLMs, revealing that learning is a dynamic tug-of-war between small probability increases ("micro-acquisitions") and subsequent power-law forgetting. The authors find that while larger models are better at immediate learning, training for longer doesn't improve a model's ability to acquire new facts; instead, robustness to forgetting is driven by larger batch sizes and data deduplication.

What Problem Does This Paper Address?

We know that Large Language Models (LLMs) are incredibly good at storing factual knowledge, acting as massive, lossy databases. However, the actual mechanics of how a model picks up a fact during the chaotic pretraining process remain a "black box."

Do models learn facts suddenly in "grokking" moments, or is it a slow crawl? Why do they struggle with "long-tail" (rare) knowledge? This paper seeks to move beyond just measuring what a finished model knows and instead probes the fine-grained training dynamics to understand the relationship between data exposure, model scale, and the inevitable decay of memory.

Methods

The researchers used a "Knowledge Injection" approach. They took intermediate checkpoints of the open-source OLMo model (1B and 7B parameters) and continued their pretraining. During this continuation, they injected specific, never-before-seen facts into the training batches and monitored the model's internal state step-by-step.

To quantify this, they defined two key metrics:

  1. Effectivity ($\mathcal{E}$): The immediate jump in the log probability of a fact after the model sees it in a training batch.
  2. Retainability ($\mathcal{R}$): The fraction of that initial knowledge "jump" that remains after $t$ additional training steps.

They evaluated three "depths" of knowledge:

  • Memorization: Reciting the exact training sentence.
  • Semantic Generalization: Identifying the fact in a paraphrased sentence.
  • Compositional Generalization: Combining multiple injected facts to infer a new one.
Figure 1: An illustration of the change of log probability of the target span of a probe (∆ℓ(q)) measuring the memorization of factual knowledge on a short-term scale. At step 0 (marked as a dotted line), the model is trained with the injected knowledge which contains the factual knowledge evaluated by the probe q. The local acquisition maxima (marked as a red line) is the timestep where the log probability reaches its maximum within the window (shaded area), defined by tw. The measurement of effectivity and retainability at t = 30 is visualized, where retainability is obtained by measuring the fraction of the purple line compared to the gray line.

Datasets

The authors introduced the FICTIONAL KNOWLEDGE dataset.

  • Why Fictional? To ensure the model hadn't encountered the facts in its original pretraining corpus.
  • Structure: 120 detailed descriptions of fictional but realistic entities (e.g., a fake Martian government), generated using GPT-4 based on the template of the ECBD (Entity Cloze By Date) dataset.
  • Probes: 1,800 cloze-style questions (fill-in-the-blank) designed to test the three depths of knowledge mentioned above.

Key Insights and Ideas

  • The Sawtooth Pattern of Learning: Knowledge acquisition isn't a one-and-done event. It occurs through "micro-acquisitions"—tiny bumps in probability every time a fact is seen—which are immediately followed by gradual forgetting when the fact is absent from subsequent batches.
  • The Power-Law of Forgetting: Forgetting isn't linear; it follows a power-law relationship with the number of training steps. Interestingly, while compositional generalization is the hardest to acquire, it is actually more robust to forgetting than simple memorization.
  • Scaling Model Size vs. Training Time: Scaling the model size (1B to 7B) significantly improves the rate of acquisition (Effectivity). However, counterintuitively, a model at the end of pretraining (1.5T tokens) is no better at learning a new fact than a model at the beginning (170B tokens). The "emergent" performance of well-trained models likely comes from seeing more facts more often, not an improved learning mechanism.
  • The Batch Size Advantage: Training with larger batch sizes makes the model significantly more robust against forgetting. Smaller batches lead to a shorter "learnability threshold," meaning facts must appear much more frequently to stick.

Key Results

The study demonstrates that LLMs acquire knowledge by accumulating probability over multiple encounters. As shown in Figure 2, the log probability of a fact spikes upon injection but decays quickly.

Figure 2: Change in the average log probability of target spans of the probes plotted against training steps during the continuation of pretraining OLMo-7B mid checkpoint (trained on 500B tokens) with injecting the knowledge in the FICTIONAL KNOWLEDGE dataset. Results are shown for duplicate (Top), paraphrase (Center), and once (Bottom) injection scenarios. Note the immediate and distinctive increase of log probability after the model is updated with the injected knowledge, marked by dotted vertical lines.

Crucially, the authors found that data deduplication is vital because models trained on duplicated data actually forget generalizations faster. When a model sees the exact same string repeatedly, it prioritizes memorizing that specific sequence over learning the underlying factual relationship, widening the gap between memorization and generalization.

Quantitatively, the decay constant ($a$) for retainability was found to be lower for larger models and larger batch sizes, explaining why these models perform better on long-tail knowledge—they simply hold onto rare information longer before it fades away.

Limitations and Future Work

  • Log-Prob vs. Generation: The study relies on log probabilities of target spans. While this provides fine-grained data, it doesn't perfectly map to whether a model would actually generate the correct answer in a chat setting.
  • Early-Stage Dynamics: The researchers focused on intermediate and late-stage checkpoints. The very early stages of pretraining, where the model's internal representations are highly unstable, were not explored.
  • Hyperparameter Scope: The study only looked at a few batch sizes and model scales. Future work could map the "learnability threshold" across a wider range of architectures and training configurations.

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