arXiv:2610.34553cs.AIOct 2026

Manuscript Offprint

arXiv:2610.34553

How Much Information Can We Fit inside a Transformer?

Amirhossein Basareh, Rishabh Sanjay, Daniel de Mello, Abulhair Saparov

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

How efficiently can transformers store factual knowledge? The answer to this question has implications for both model design and understanding the limits of transformer-based systems. Prior studies observe a linear relationship between the number of facts memorized and the number of model parameters required, substantially worse than what theoretical analyses predict is achievable. We re-examine empirical scaling: through rigorous and systematic experiments, including extensive hyperparameter search via Bayesian optimization, we determine the smallest model that can perfectly memorize a given set of facts, and measure how this minimum size scales with the number of facts. On synthetic datasets of random, independent (subject, relation, object) triples—e.g., (Paris, capital_of, France)—drawn at random with no exploitable structure, we find that memorization capacity, the size of the largest dataset that a model memorizes completely, grows exponentially with the transformer dimension. Equivalently, the minimum transformer dimension dmin⁡d_{\min} required to memorize N facts grows logarithmically in N. Across 11 dataset sizes spanning N = 45 to 49,920, a lack-of-fit F-test does not reject the logarithmic fit (with an offset), but it does reject all other tested alternatives including power-law. Along the depth axis, however, at fixed width, the maximum memorizable dataset size grows sublinearly with the number of layers over the measured range. We further extend our exploration to structured data containing symmetric relations or two-hop composition. In this setting, we find that transformers exploit these regularities to further improve capacity. All code to reproduce our results is available at https://github.com/Magronox/transformer_information_capacity.

1 INTRODUCTION

Large language models (LLMs) exhibit a remarkable ability to memorize facts and associations, sometimes to the point of verbatim recall (Carlini et al., 2021; 2023; Petroni et al., 2019). As transformer models scale to trillions of parameters, critical questions arise: What is the maximum number of associations a model of given size can memorize? How does this capacity scale with model size? Answering these questions enables practitioners to select appropriate architectures/hyperparameters for knowledge-intensive tasks and predict when transformers will successfully memorize versus fail to learn training data due to insufficient capacity (Li et al., 2025). Our central research questions are: (1) how does the minimum transformer model dimension required to perfectly memorize N facts scale with N? and (2) at fixed model dimension, how does the maximum number of memorizable facts scale with the number of layers L?

Prior empirical studies of transformer memorization measure how many bits of factual knowledge are learned per parameter. Allen-Zhu & Li (2025) train GPT-2, LLaMA, and Mistral models on synthetic biographies composed of (name, attribute, value) tuples and establish, through an information-theoretic bit-complexity analysis of their trained model, that sufficiently trained transformers store ∼\sim2 bits of information per parameter (i.e., linear scaling). Morris et al. (2026) train GPT-style models on synthetic random sequences and report ∼\sim3.6 bits per parameter. Lu et al. (2024), training Qwen-style LLMs directly on relational triples, report approximately linear scaling between fact

∗^{*}Equal contribution.

capacity and number of parameters, estimating that memorizing Wikidata would require ∼\sim1000 billion parameters; however, their measurements use 50–200 training epochs while their own analysis indicates that capacity saturates only at around 1000 epochs and hyperparameters are only partially tuned at different model sizes.

Theoretical work has established bounds on transformer memorization capacity. The result most directly relevant to our work is Kajitsuka & Sato (2025), who study the next-token prediction setting (a single label per input sequence, equivalent to ours) and prove that O~(N)\tilde{O}(\sqrt{N}) parameters are sufficient for a transformer to memorize N facts, and that Ω(N)\Omega(\sqrt{N}) parameters are necessary for memorizing every {0,1}\{0,1\}-labeling of N facts; these upper and lower bounds are the same up to log factors and are much better than the linear scaling observed in empirical studies. Other upper-bound constructions for related settings give larger parameter counts (Kajitsuka & Sato, 2024; Madden et al., 2025; Mahdavi et al., 2024; Kim et al., 2023) while Hopfield-network and Johnson–Lindenstrauss theoretical results predict transformer dimension needs to scale logarithmically with N for memorization in idealized settings; we discuss both in Section 2. Our results show that the standard fixed-depth softmax transformer can memorize N facts with the transformer dimension scaling as log⁡N\log N.

We believe that the gap with prior empirical work has two main sources. Prior studies that report a linear relationship between parameter count and the number of memorized facts (Lu et al., 2024; Morris et al., 2026) use limited hyperparameter search and limited training compute, both of which prevent the model from reaching its maximum information capacity at larger dataset sizes (Section 2). Allen-Zhu & Li (2025) demonstrate that the number of times each fact is seen during training (i.e., exposure) directly governs measured capacity, confirming that insufficient training duration causes underestimation of the model's information capacity.

In this work we show that standard transformers empirically achieve substantially better scaling than the linear relationship between number of parameters and number of facts reported in prior empirical work (Allen-Zhu & Li, 2025; Lu et al., 2024). We train transformers on synthetic relational triples (Bordes et al., 2013) with uniformly random structure, since we aim to test the model's memorization capability while controlling for generalization. We find that the number of facts N that a transformer can memorize 1^{1} grows exponentially with transformer dimension. Equivalently, the minimum transformer dimension dmin⁡d_{\min} required to memorize N facts grows logarithmically in N. In this setting, the logarithmic form is the only form that is not rejected by a lack-of-fit F-test (Section 4.1). At fixed width (i.e., transformer dimension) d=8d = 8 and a fixed training budget, the maximum memorizable dataset size grows with depth (i.e., number of layers), but sublinearly; a lack-of-fit F-test rejects linear, N=aLN = aL ( p=7.8×10−6p = 7.8 \times 10^{-6}), affine, N=aL+bN = aL + b ( p=0.0025p = 0.0025), and superlinear forms ( p≤1.2×10−5p \leq 1.2 \times 10^{-5}), while a logarithm and a power-law with exponent 0.65 are not rejected, and our data do not distinguish between them (Section 4.2).

In addition, we extend our analysis beyond unstructured uniformly-distributed data. For data with logical structure, such as data containing symmetric relations (r is symmetric if (s,r,o)(s, r, o) then (o,r,s)(o, r, s) for any o,so, s) and two-hop compositional relations (if (a,r1,b)(a, r_1, b) and (b,r2,c)(b, r_2, c) then (a,r3,c)(a, r_3, c) for any a,b,ca, b, c), we find that transformers exploit these regularities to achieve improved scaling. To probe whether distribution skew alone affects capacity—a relevant question because real-world fact distributions are typically Zipf-like rather than uniform—we additionally test power-law-distributed data, finding that they show similar scaling behavior to uniformly-distributed data.

Our key contributions are:

• We demonstrate that memorization capacity grows exponentially with the transformer dimension: at fixed depth L = 1, the minimum transformer dimension d needed to memorize N facts grows logarithmically in N, and a lack-of-fit F-test rejects the power-law and other alternatives (Section 4.1, Table 1).

  • At fixed width and a fixed training budget, capacity grows sublinearly with the number of layers: linear and superlinear growth are rejected, and the sublinear forms we tested are not distinguished (Section 4.2, Table 5).

• We show that the gap with prior empirical work stems from training methodology: both insufficient training duration and limited hyperparameter optimization lead to suboptimal scaling trends (Section 4.3).

1^{1}I.e., the model achieves 100% training accuracy in predicting the object given the subject and relation.

• We characterize how relational structure in the data and the shape of the data distribution affect memorization. Structured data (symmetric relations and two-hop compositions, defined in Section 3.6) leads to improved scaling by exploiting regularities, and power-law-distributed data shows a similar scaling behavior to uniformly distributed data (Section 4.1, Figure 1).

These findings suggest that LLMs may have substantially greater knowledge capacity than previous empirical estimates indicate, with implications for understanding how transformers store knowledge (Geva et al., 2021) and for predicting capacity requirements at scale.