TL;DR
Large language models often behave like vast libraries without a card catalog: they absorb millions of facts during pre-training, yet frequently fail to retrieve them when asked a direct question. This paper mathematically proves when and how fine-tuning builds that catalog. By analyzing a simplified transformer, the authors show that fine-tuning doesn't need to re-teach every single fact—it just needs to cover enough of the underlying phrasing templates ("relation directions") used to store those facts in the first place.
What Problem Does This Paper Address?
It is a familiar frustration in modern AI: a model reads "Alice was born in California" during pre-training, yet draws a blank or hallucinates when prompted with "Question: Where is Alice's hometown? Answer:". There is a fundamental gap between knowledge storage and knowledge extraction.
While empirical studies have shown that MLP layers act like key-value memories for facts and that fine-tuning helps unlock them, we lack a unified theoretical understanding of how this actually happens during training. Prior theoretical work usually isolates just one piece of the puzzle—studying attention-only models, looking only at pre-training, or using simplified supervised objectives. To truly see how stored knowledge becomes extractable, you have to analyze the messy dance between self-attention, MLPs, autoregressive next-token prediction, and the format shift from pre-training text to fine-tuning Q&A prompts.
Methods
To make the math of training dynamics tractable without losing the essence of the problem, the authors construct a stylized one-layer transformer featuring both a self-attention module and a ReLU MLP, omitting positional encodings and fixing the output projection layers.
They track gradient descent dynamics across two distinct phases:
- Pre-training via Next-Token Prediction (NTP): Using a three-stage learning-rate schedule, the model learns from short sentences containing noisy background context, a subject, a relation phrase, and an answer. Self-attention learns to filter out the high-norm background noise, while the MLP encodes the subject-relation-answer connections.
- Fine-tuning (Full and Low-Rank): The model is adapted on a subset of frequent facts reformatted as Q&A prompts. Notably, the authors analyze both standard full gradient descent and an idealized low-rank fine-tuning (replacing the gradient with its best rank-1 approximation, akin to LoRA/AdaLoRA).
Datasets
- Synthetic 5-Token Data: A custom setup modeling $N$ subject-answer pairs split into "frequent" pairs (seen across $K$ paraphrased relation templates, like "was born in" or "is a native of", drawn from a total universe of $|\mathcal{R}|$ templates) and "rare" pairs (seen with only 1 template). Token embeddings are assumed to be mutually orthogonal to cleanly isolate feature directions.
- Curated PopQA Subsets: Real-world factual benchmarks used to test whether the theoretical predictions hold up in standard multi-layer architectures:
- A movies-and-directors subset (augmented with $K$ multiple phrasings per fact) used to pre-train and fine-tune a 12-layer GPT-2 from scratch.
- A capitals-of-locations subset (split into "frequent" vs. "rare" facts based on Wikipedia page views) used to fine-tune a pre-trained Llama-3.2-1B model.
Key Insights and Ideas
- The "Relation-Covering" Mechanism: Facts aren't just memorized as direct subject-to-answer links; they are routed through specific relation-template directions during pre-training. Fine-tuning generalizes to unseen facts by turning the Q&A prompt format into a global trigger that aligns with these pre-trained relation features and suppresses competing relation outputs.
- The Coupon-Collector Intuition: Why does paraphrasing data during pre-training help so much? Think of the $|\mathcal{R}|$ possible phrasings of a relation as coupons. Fine-tuning on $\beta N_f$ examples, each associated with $K$ phrasings, gives you roughly $\beta N_f K / |\mathcal{R}|$ chances to "collect" and activate every relation template. Once a template is covered during fine-tuning, any pre-trained fact stored via that template becomes extractable—even rare facts never revisited during fine-tuning!
- A Mathematical Regime for Hallucination: When relation coverage is sparse ($\beta N_f K / |\mathcal{R}| < 1$), uncovered relation templates retain a competitive advantage over the true answer. The fact remains intact inside the MLP weights, but the Q&A prompt fails to unlock it—yielding a provable, stylized mechanism for factual hallucination.
- Why Low-Rank Adaptation Works Here: During Q&A fine-tuning, the gradient updates are naturally dominated by a low-rank component aligned with the new Q&A format token. Consequently, rank-1 updates are just as capable of wiring the Q&A prompt to stored relation features as full fine-tuning.
Key Results
- Theoretical Bounds: When relation coverage is sufficient, post-fine-tuning extraction error drops exponentially: $\mathcal{L}_e \le |\mathcal{R}| \exp\left(-\frac{\beta N_f K}{150|\mathcal{R}|}\right)$. Conversely, when coverage falls below a threshold ($C_3 < 1$), misclassification error is provably lower-bounded away from zero ($\mathcal{L}_e \ge c_1$).
- Synthetic Validation: Across both the simplified 1-layer model and a 12-layer GPT-2, generalization accuracy on unseen Q&A pairs consistently climbs as pre-training multiplicity ($K$) and fine-tuning dataset size ($\beta N_f$) increase, and drops as the universe of relation phrases ($|\mathcal{R}|$) expands.
- Real-World LLM Trends: On PopQA, GPT-2 exact-match accuracy scales steadily from near 0% up toward ~30% as fine-tuning proportion $\beta$ increases from $0$ to $0.75$, with $K=5$ phrasings outperforming $K=3$ and $K=1$. On Llama-3.2-1B, fine-tuning on frequent facts (higher pre-training multiplicity) yields 26.36% Exact Match (28.68 F1), beating fine-tuning on rare facts at 20.93% Exact Match (22.74 F1).
Limitations and Future Work
Because theoretical tractability requires heavy simplification, the mathematical model assumes mutually orthogonal token embeddings, omits positional encodings, and restricts itself to a single layer. Most importantly, the theory only models a single underlying relation expressed through multiple paraphrases (meaning every subject has one unique answer). Extending this framework to multiple distinct relations—where asking for Alice's birthplace vs. Alice's employer requires routing based on both subject and relation—alongside multi-head, multi-layer architectures, remains open for future work.
Summary updated