WorksComputer Science
What's in a Tree ? Hierarchical -gram models as controlled approximators of language
Abstract
Hierarchical models have been proposed as synthetic settings for studying language. However, their relevance to realistic language corpora remains underexplored. In this work, we introduce tree-grams, autoregressive generative -gram models that build the conditional probability tensor through a hierarchical composition of order-2 and order-3 tensors. controls the maximal context window, whereas a rank hyperparameter controls model capacity, yielding an interpretable and systematically scalable family of approximators of language. We show how tree-grams outperform existing -gram baselines, while remaining competitive with deep transformer-based language models. We demonstrate the utility of such controlled approximations by using tree-grams as generative models. In particular, we show that hyperparameter transfer under P can be made more robust when narrower models are tuned on simpler data, generated by tree-grams with moderate and . In addition, we show that entropy and effective range of correlations control performance gap after fine-tuning. This is because tree-grams allow us to explicitly control horizon and capacity. When allowed to route across candidate topologies, we observe emergent sparsity in tree-grams. Such concentrated routing permits pruning upto 95% of topologies without significant change in performance.
Introduction
Language is hypothesized to be hierarchically structured ([21, 22, 33, 42, 38]). Its statistical structure has been studied using classical and modern language models, including Markov-chain and -gram models ([80, 12, 4]). Synthetic datasets inspired by context-free grammars ([21, 45, 53, 52]) have also been proposed as tractable testbeds to understand language modeling. In particular, ([13]) propose a family of tree-like generative models where a hierarchy of latent nodes determines the probability distribution of the leaves. Tree-like generative models can successfully represent compositional dependencies and improve language modeling ([56] (Dyer et al. 2016)); however, learning linguistically meaningful tree structures directly from data remains difficult ([53, 52, 44]). It is also important to understand what tree-like properties are present in real data, which can be accomplished by creating trainable versions of such models.
In this work, we propose such a trainable model. In particular, we propose tree-grams, which are hybrid -gram models based on hierarchy and local connectivity. Tree-grams combine order-2/order-3
[†]: The code is released on Github. Saved models are released on Hugging Face, while generated datasets are released as Hugging Face datasets. tensor approximation with normalization layers, residual connections, and MLPs to approximate the order- transition tensor . The two hyper-parameters and are independent controls on tree-grams, while controls the horizon of the model, controls model capacity. A summary of our contributions is provided below.
Summary of contributions
We present tree-grams as generative models for controlled approximation of language. The approximation is controlled through a horizon parameter and a rank parameter . In contrast with context-free grammars, tree-grams learn the latent features from data. We train tree-grams on TinyStories [31] as a proof of concept, for which we demonstrate how tree-grams out-perform existing -gram estimators and remain competitive with deep neural references.
We demonstrate the utility of such controlled approximations by analyzing hyperparameter (HP) transfer and fine-tuning performance. In particular, we show that HP transfer is more robust when the smaller proxy is trained on lower-complexity synthetic data. We also investigate the effect of alignment between pre-training and finetuning data, where we show that performance has a stronger dependence on the finetuning distribution.
We observe concentrated topology-routing distributions when tree-grams are allowed to choose topologies at each layer through linear routers. We observe that the predictive performance changes very little even when we prune upto 95 % of topologies at each level.
We emphasize that the value of tree-grams is experimental. It allows us to rigorously test ideas about the structure of (language) data and learning. This is in contrast with empirical value as a model class that out-performs SOTA neural networks. Thus the focus in this work was to set up a basic version of tree-like models that scale better than existing -gram baselines.
Background and Motivation
Hierarchical models have been used to study synthetic datasets resembling language. [21, 24, 94, 13]. Justification for such hierarchical modelling comes from statistical property analysis [87], information theory [36, 93] and cognitive representations [25, 72, 30, 41]. However, all such models fix hidden features based on semantic or syntactic structures. Tree-grams are introduced as generative models where the hidden node features are directly learnt from data. In addition, it is useful to have independent knobs that control the complexity of the full corpus. Such an approximation can be made by either controlling the capacity or the horizon of the generative model [15]. Such approximations have been made by using traditional and smoothed -gram counts [17, 74, 63], hidden Markov models [3] or tensor-trains [68, 84]. However, these methods are difficult to scale beyond few words. On the other hand, the effect of various architectural hyper-parameters in transformers on model capacity is poorly understood. We introduce tree-grams in light of the above considerations. Detailed background and related works are presented in Appendix § 13.
The tree-gram architecture
We implement tree-grams as a hierarchical architecture (see Figure 1), with layers indexed by . After an initial shared token embedding Emb,
Figure 1. (a) The tree-gram architecture. Tree-grams consist of hybrid blocks which are used to merge intermediate nodes, progressively reducing the number of nodes at each layer. Red edges are order-3 merges, blue edges denote order-2 merges. All upward merges (denoted with an upward-pointing arrow) are followed by LayerNorm and an MLP, shared across the first nodes of the layer. Autoregressive prediction is done by masking (*) previous tokens. The last node outputs logits for next-token prediction. (b) Scaling with the horizon . cross-entropy of the next-token probability given exactly tokens of context. Tree-grams (in red) outperform tested -gram estimators for large but fall short of deep transformers. (c) Scaling with the rank . Per-token loss as a function of the rank . We observe a smooth approach towards the empirical lower envelope of the available references as increases. The corresponding plots for Wiki-Text and FineWebEdu are presented in the Appendix I.
the new layer is formed via local order-2 and order-3 merges. is a (learnable) positional encoding. The Merge operation is defined as
where , , and denotes elementwise multiplication. The order-3 merge is a CP-type (Hadamard) factorisation of an order-3 tensor, as in the tensor circuits introduced by (Loconte et al., 2025). The factorization above is a non-unique choice. It restricts the class of topologies, although the number of topologies is super-polynomial . Moreover, it fixes the depth to be , which we call the principle of minimal depth. 8 Tree-grams belong to a more general class of hierarchical tensor decompositions with latent nodes [82, 78, 35]. Any factorization of the nodes represents a valid tree-gram architecture.
Given the horizon, or maximal context window, , the number of nodes in each layer is defined via a recursive relation
fixing the depth of the network is . For each layer, and constrain the total number of order-3 merges, but their position along the sequence can vary. The choice of positions at each layer determines the topology of the tree-gram.
The merge operation is preceded by LayerNorm, and followed by the residual+MLP composition typical of transformer layers,
where if has a single connection, and if it has a double connection. The LayerNorm (LN) and MLP are shared across nodes in a layer, while the tree-gram weight depends on the parent position. Unless stated otherwise, , the MLP uses GELU and hidden width , and all reported tree-gram runs use learned positional embeddings to break the commutativity of the merge.
The downward pass occurs along the terminal nodes at each layer, with the same residual/MLP pattern as Eq. (4). The only difference is that Merge operation is modified as
The terminal node in the bottom layer serves as the predictive node, where an embedding-weight-tied softmax head maps it to next-token probabilities. Tree-grams perform autoregressive prediction by unfolding each sequence into its left-padded prefixes, which activate different subtrees. The model was trained with the usual autoregressive cross-entropy loss. Appendix C provides further details on the architecture.
For the primary experiments reported in the main text, we train on a 529M-token subset of TinyStories, a synthetic language corpus [31], using a custom BPE tokenizer with vocabulary size [15]. Details on optimization are in Appendix F. We train on two additional datasets: (1) a 130M-token WikiText-103 [67] dataset, obtained by designing a custom BPE tokenizer with vocabulary size and (2) a 1.05B-token FineWeb-Edu [76] dataset, tokenized with the GPT-2 tokenizer and vocabulary size .
Results
Comparison to existing baselines
Figure 1 b) compares tree-grams to different classes of -gram estimators, from raw counts to transformer-based LLMs. In particular, we consider classical smoothed counting models (raw count) [17, 75], unbounded suffix array calculations (infinigram) [63], weighted finite-automaton approximations obtained via spectral methods (spectral WFA) [3], tensor train approximations (tree TN, u-MPS, TTLM) [68, 84], MLP-based neural models (MLP, neural LM, neural LM + unigram) [16, 5, 9], transformer-based (GPT-2 (APE), GPT-2 (RoPE), Llama) and Selective-State-Space-Models-based (Mamba) language models. A detailed description of these baselines is found in Appendix D.
In the range of horizons probed, , the LLM baselines converge to the model-independent asymptotic conditional entropy of the true next-token distribution [15] (black dashed line in Figure 1b and Figure 1c). The model-independence is a strong indication that this is close to the true -gram entropy. [71, 55, 15] This will be referred to as the empirical entropy in what follows. Tree-grams match the empirical -gram reference up to , vastly outperforming all other baselines except LLMs (Figure 1b). Furthermore, increasing the capacity parameter reduces the performance gap to LLMs (Figure 1c)
Comparison with transformers
In order to understand the performance gap of tree-grams to LLMs more carefully, we compare tree-grams with transformers of different depth with the same parameter count, the same context length and trained with the same number of optimization steps, thereby highlighting the difference in their architectural biases. For each tree-gram target, we take a decoder-only transformer of depth . Tree-grams perform better than the shallow matched transformers. This pattern holds until approximately . At longer contexts, the tree-gram is unable to match deep transformers. The right panel shows that the excess loss monotonically decreases with . While shallow transformers plateau quickly, tree-grams monotonically decrease with a power-law curve, showing that they are more scalable than shallow transformers. In addition, the slope is not drastically different from the deepest transformers tested. It is worth emphasizing that this performance gap could simply be due to sub-optimal optimization routines for tree-grams. Developing better principles for optimizing tree-grams is left for future work. The per-position curves behind these endpoints are in Figure 10 (Appendix I), where the tree-gram tracks the transformer family for the first few positions and drifts away at long context, the same signature as in Figure 1.
Figure 10. Per-position cross-entropy for every tree-gram in the sweep against its parameter-matched transformers, for various depths . (top) varies at ; (bottom) varies at . Grey annotations give the parameter count of the tree-gram in that panel (1M to 140M). The tree-gram tracks the transformer family exactly for the first few positions in every panel and peels away only at long context.
Tree-grams as Controlled Approximation of Language
We use the tree-grams as a source of synthetic data, with and independently controlling distinct modes of approximation of the synthetic corpus to the original training corpus. We emphasize that, unlike transformers, a single hyper-parameter controls the model capacity. In Appendix § 24 we present a qualitative analysis of the decoded text generated by tree-grams from the same prompt. Increasing (at sufficiently large ) increases coherence from word-level () to sentence-level (). On the other hand, increasing increases both coherence and quality of the generated text. We demonstrate the scientific utility of such finite-window and finite-capacity approximations by experimenting on hyper-parameter transfer under and effect of pre-training and fine-tuning distribution shifts on fine-tuning performance.
Hyperparameter transfer under Maximal Update Parametrization
The standard recipe for hyperparameter (HP) transfer under the (Maximal Update) parametrization Yang et al. (2022) involves two stages: tuning and transfer. The tuning stage involves training a small model, initialized according to to find the optimal HP combination This optimal HPs are then transferred to a larger model through appropriate scaling. However, the complexity of the datasets in the tuning phase is only controlled implicitly, for example through the amount of pre-training data Björck et al. [8]; Li et al. [60], data deduplication Lee et al. [59]; Abbas et al. [1] or high-quality data pruning Sorscher et al. [83].
Using tree-grams as a generative model, we can control the data complexity explicitly. We observe that tuning HPs on a controlled-complexity approximation of the original dataset yields better transfer. Specifically, we tune the learning rate of 2- and 4-layer decoder-only proxy transformers with widths , then analyze the transfer to target transformers with various widths. We judge the transfer by the excess loss of the target model with transferred learning rate with respect to its own HP-tuned minimum. As shown in Figure 3, tuning on the original data almost always yields the highest excess loss (black square). The converged loss has an asymmetric dependence around the optimal learning rate [54, 48, 34]. Thus, a drift in the optimal learning rate can lead to a higher excess loss. We show empirical evidence for this drift in Figure 3. The from tuning on the real dataset however shows a non-monotonic effect with width, as shown by the black dashed line which sits lower than the optimal learning rate obtained from tuning on the real data. While a formal characterization of which proxy distribution to tune on, remains an open question - choosing the median learning rate over different proxy distributions can give robust transfer. It is worth emphasizing that the undershooting the learning rate is better only if the optimal learning rate at a narrower width is higher than that at larger width. In the Appendix, we show that this does not hold for FineWeb-Edu. The monotonic drift in optimal learning rate as a function of data complexity however still holds, which is the relevant phenomena.
Figure 3. Hyper-parameter (HP) transfer from narrow proxies trained on controlled synthetic approximations of the target corpus. The excess loss is the difference between the loss of a wide model ( at and at ) in at the proxy’s optimal learning rate and the wide model’s own HP-tuned minimum. Tuning on different distributions gives different optimal learning rate. Almost all tuning with simpler proxy data gives a lower excess loss than if tuned on real data. In addition, we see a monotonic drift of the optimal learning rate with data complexity. The drift explains the excess loss because of the asymmetric loss curves around the optimal learning rate. Relative complexity is defined as , where stands for the entropy of a particular distribution.
A complete mechanistic understanding of this observation is beyond the scope of the present work. However, we present a simple toy model of data from tree-grams, which we show can give rise to a mechanism for the drift in the optimal learning rate . To keep notation simple, we will work in log-space . The model is a Gaussian surrogate of hierarchical features, in the spirit of the Random Hierarchy Model ([13]) and of multiscale Gaussian signal models ([90]). We start with a left-branching binary tree over the context tokens. The node at level summarizes a block of tokens, so there is one node per level, . This sets the number of levels to be . The power at level is for some constant , where fixes the total power to one for every . The importance of a node is controlled by the variance of its coefficient, . We assume that the power of each node is diluted evenly over coordinates. If we get unit-norm vectors , then the next-token logits are
Figure 4. (a) The toy model for tree-gram data. (b), (c) We show that the dependence of the optimal learning rate on the measured allocated power share matches closely with the prediction from the toy model. Note that the bigram model is not a tree-gram and hence excluded from the fit.
We also assume that the observed features are noisy versions of the true features
where the noise term is independent of . The quality factor sets the signal-to-noise ratio .
Solving a minimal quadratic model like that of [58] with aligned features, the single-step optimal learning rate has the following dependence:
Here is a quantity that characterizes the complexity of the synthetic data. is a term that depends solely on the approximation parameters and . increases monotonically with and , which provides a mechanism for a drift in the optimal learning rate. The full derivation is presented in Appendix § 16. We emphasize that the toy model presented is not intended to provide a causal mechanism for our empirical observations.
Pre-training and finetuning
The value of a pre-training distribution depends on how well it aligns with the fine-tuning distribution. [49] find that downstream quality improves monotonically with more pre-training data only when the two distributions are well aligned. Synthetic corpora have been used to ask which structure transfers to natural language: music and code [73], artificial languages with controlled dependency structure [79, 19], and formal languages with hierarchical dependencies [46] can all transfer, depending on the structure they carry. Tree-grams provide a structured manner to introduce, and to measure, misalignment between the pre-training and finetuning data, through either the context horizon or the model capacity .
We clarify that by fine-tuning we mean continued next-token training of all parameters on the target corpus, as in studies of transfer between text distributions Hernandez et al. [43]; Hu et al. [46]. Unlike a narrower downstream task, a target here can be more complex than its source, so we avoid low-rank adapters Biderman et al. [7]. We re-warm and cosine re-decay the learning rate from a fresh optimizer state Ibrahim et al. [47]; Gupta et al. [40], but without the replay that Ibrahim et al. [47] recommend. This is because replaying source data would mix the source into every target run and remove the same-distribution control on the diagonal. For a generator , we estimate its Bayes floor on the sampled path as
The conditional entropy at each sampled context is computed from the generator’s full softmax during generation — it is not inferred from the downstream model’s validation loss. Appendix H specifies the model ladder, data split and optimization schedule.
Figure 5 reports the result of this experiment. The final finetuning performance depends monotonically on the complexity of the finetuning distribution. The dependence on the pre-training distribution is more nuanced. If the pre-training data is too simple, we notice a monotonic worsening of performance with decreasing complexity. However, when fine-tuning distributions are simple, finetuning performance is almost independent of the pre-training distribution. Note that we separate the capacity-limited and horizon-limited modes Figure 5. This is because the monotonicity is a function of the entropy of the distribution within the same approximation mode (the figure sorted by entropy alone is reported in Appendix I, where the clean trend shown disappears.) Most of the gap is set by the target, through two properties that can be measured directly from its token statistics: its entropy rate and the effective range of correlations, measured by how quickly the mutual information between tokens decays with their separation, beyond the horizon. Entropy has the larger effect, but at comparable entropy a target with a longer effective range is consistently harder to reach. The joint effect of entropy and effective range of correlations was discussed in Cagnetta et al. [15]. We propose an ad hoc four-parameter law in these two quantities, plus a penalty when the source carries less information than the target, which accounts for 82–99% of the variance across all source–target pairs in every setting, and predicts the gap for held-out targets. Details are delegated to Appendix J.
Figure 5. Finetuning on controlled distributions after pre-training. We plot the relative difference between the final validation loss achieved after finetuning and the target Bayes floor of the target distribution. There is a monotonic worsening of performance as the fine-tuning target complexity increases. In addition, the performance monotonically worsens if we pre-train on too simple of a data. For brevity, we display the results of a 2-layer transformer only for TinyStories. The other plots are included in Appendix I.
Ablations
Role of topologies. We focus on three kinds of topologies: aligned, balanced, and anti-aligned. The aligned topologies contain all 🔗 connections on the left-hand side (topologies labelled , , in Figure 6, while the anti-aligned topologies contain all connections on the right-hand side (labelled , ). Balanced topologies have the connections in the middle (labelled , ). With proper hyper-parameter tuning, all seven converge to nearly the same loss at the end of training. The difference in their per-token losses occurs only in the last few positions. We notice that the balanced and aligned topologies typically have a higher loss, while the anti-aligned topologies converge to a lower last-token loss. However, we perform experiments with since it is an interpretable model, as outlined in § 6. There is some difference in the training dynamics, which is reported in Figure 6. The anti-aligned topologies start at a higher loss but converge to a lower loss and vice versa for the aligned topologies.
Figure 6. (a) Role of topologies. (Left) At convergence, the topologies show slight difference at long . (Right) The seven different topologies we experimented on. The anti-aligned topologies seem to significantly out-perform other topologies only for last-token prediction (losses in nats mentioned). (b) Role of MLPs. MLPs have a significant effect in reducing the loss even at matched parameter count. (c) MLPs help control the drift in the losses for different topologies, giving more stable training.
Role of MLPs MLPs have a significant effect on performance gap to transformers. We compare a tree-gram with MLPs to a parameter-matched tree-gram without MLPs. For either topology, removing the MLP worsens performance. This effect is more pronounced at higher values of the logit index. However, the comparison changes both the MLP/nonlinearity and the contraction rank to maintain parameter parity, so it does not isolate which factor causes the gap. We also observe that MLPs control the variation between different tree-gram topologies during training. We leave an in-depth investigation of the role of MLPs to future work. However, we would like to emphasize that even without MLPs, tree-grams can learn language structure.
Role of LayerNorm and Residual Connections LayerNorm and skip connections both help stabilize training. Removing either gave a worse loss (increase of 0.1 to 1.3 nats) for two topologies and , see Table 1. Without either components, the initial gradients are essentially zero (median of order or below, against about for the full model). Even the bare tree-gram (without normalization, residual streams or MLPs) have a median gradient of the order or less. Therefore, we did not run the latter two combinations at full scale.
| Topology | Full | No LayerNorm | No residual | No MLP |
| aligned | 1.847 | 2.567 (+0.72) | 1.946 (+0.10) | 1.970 (+0.12) |
| anti-aligned | 1.805 | 2.025 (+0.22) | 3.142 (+1.34) | 1.935 (+0.13) |
Table 1. Best validation loss for , tree-gram on TinyStories. Parameter-matched ablations on various components of tree-grams. Diverges late in training.
Emergent sparsity through topology routing
To test whether the network develops a preference among topologies, we implement a dynamic tree-gram with one linear router at each merge layer. The routing decision is sequence-level, unlike token-level choice as in Mixture-of-Experts routing. At layer , the router applies the same linear map to every active node state and then averages across active positions, in the style of Zaheer et al. [96]:
Here is the active-node set, indexes the valid grouping patterns at that layer, and is a non-gradient bias trick adapted from DeepSeek-AI [27]. During training, is updated toward a slightly perturbed uniform selection target to reduce route collapse, which we switch off after 5% of training time for better performance. We select the hard top- indices under and mix their outputs using the corresponding differentiable softmax weights. Gradients flow through the selected weights. We report the path probabilities where denotes the topology chosen at a layer .
We observe that the network has a sharp cutoff in the probabilities, indicating that it has a strong preference for a few topologies. For the specific case of , the top-100 (out of 36,720 topologies) carry a substantial fraction of the probability mass. This can also be seen through the fact that the tail is steeper than the head for both . Raising flattens both exponents together, and spreads the mass. These results are shown in Figure 7a. Although the concentration persists despite the balancing bias, current experiments are insufficient to rule out initialization or router-optimization effects as compared to learnt-language preference. The exact preferred topologies chosen is an effect of the random seed. We emphasize that we treat topology as an architectural prior. We do not infer linguistic meaning from the studied topologies, as cautioned by Williams et al. [89].
Figure 7. Emergent sparsity in tree-grams. Left. Tree-grams that are allowed to choose sequences through routing, demonstrate a preference for few topologies. The paths follow a power-law with a generalized exponential cutoff, with the tail showing a steeper decay. Right. Pruning merges at each level can preserve predictive performance even with significant fraction of merges removed.
We test the practical relevance of routing by pruning different fractions of the Merge operations at each level. As one would expect from the concentration of paths, we see that we can remove close to 95% of the Merge operations, without the tree-grams showing any meaningful change in performance, cf. Figure 7b. This experiment suggests that we can increase tree-gram capacity by training only sparse subsets of all topologies. We leave this to future work.
Conclusion, Limitations, Future Work
In this work, we present tree-grams, trainable and controllable -gram approximators of language. They match optimal -gram estimates at small . A noticeable gap from deep models remains at longer contexts. We find that controlled data approximations can aid hyper-parameter transfer under P. We also use them to study performance gaps after finetuning by distinguishing pre-training and fine-tuning distributions.
Since the focus in this work was experimental rather than empirical, our work consequently suffers from many limitations. It is not obvious whether our choice of architecture is optimal. We consider a narrow class of topologies, which is fixed by the layer recurrence relation 3 and the maximal order of the Merge operation. We implement a particular choice of tensor factorization in 5, inspired from Loconte et al. [64]. Computational constraints prevent scaling to longer context windows, particularly to , which is the typical length of paragraphs in TinyStories. The activation cost of prefix unfolding is a primary bottleneck, which could be reduced by sharing prefix states. In addition, the scope and scale of the models and data is limited. Understanding of different individual components of the tree-gram architecture also remains limited. In addition, a careful comparison of alternate HP tuning strategies was not performed.
Developing faster, stabler and robust optimization routines for tree-grams remains an open engineering problem. It would also be interesting to train tree-grams on distributions very different from language. We leave these and other directions mentioned in the text for future work.
Declaration of AI Usage
In this work, we used generative AI tools to design or provide feedback on research methodology or experiments, propose or refine hypotheses, help develop theoretical models or conceptual frameworks, formulate mathematical claims, provide critical ingredients for proving mathematical claims, assist in the writing of proofs, and to implement several baseline methods. We have not used generative AI tools to generate synthetic data sets. Additionally, we used generative AI tools to create or modify scientific figures or images, create or edit software code, draft parts of a research paper, summarize or analyse existing literature, discover research topics or identify gaps, suggest a structure for a research paper, and to propose a keywords for a research paper. All content, claims, and conclusions have been reviewed and verified by the authors to ensure accuracy and originality. In particular, we checked LLM-generated research ideas for potential plagiarism through a manual literature survey. LM-generated code was verified and tested for correctness by one author. LM-generated proofs were checked by one author. The key idea of developing tree-grams were originated by the authors, and AI was mainly used to implement it from scratch. We take responsibility for the final content of this work, including text, claims or artifacts produced with the aid of generative AI.
Ethics Statement
The authors pledge to adhere to the Code of Ethics. No human subjects were used in this project. All experiments are conducted exclusively on publicly available, standard benchmark datasets. Specifically, we trained on TinyStories, which is a GPT-generated text dataset WikiText (derived from verified Wikipedia articles) and FineWeb-Edu (an educational subset filtered from Common Crawl). No human subjects were involved, and no private, sensitive, or personally identifiable information (PII) was collected or processed beyond what exists in these public corpora.
Reproducibility Statement
Code to train tree-grams and reproduce the plots in the main text will be released publicly. Any unlawful or unethical use or distribution of the code is strictly prohibited.
Acknowledgements
A.D. acknowledges support from NSF DMR-2429246. F.C. acknowledges support by the European Union’s Horizon Europe program under the Marie Skłodowska-Curie grant agreement No. 101154584. D.D. acknowledges financial support from the Johns Hopkins University Data Science and AI Institute Fellowship. We acknowledge the University of Maryland supercomputing resources (http://hpcc.umd.edu) made available for conducting the research reported in this paper. Certain products, commercial and otherwise, are mentioned in this publication. These mentions are for informational purposes only, and do not imply recommendation or endorsement by NIST. Contributions to this work by NIST, an agency of the US government, are not subject to US copyright.
Model, Code and Data release
The tree-gram architecture and pre-trained models will be released under the Creative Commons Attribution 4.0 International (CC BY 4.0) license, allowing use, modification and redistribution with proper attribution.
The models will be released through a public Github or HuggingFace repository. As presented in the Supplementary Material, scripts describing the architecture and use will be uploaded, with clear instructions for reproducibility.
The Github repo will be additionally tracked to allow users to report and fix bugs. We will further invite the community to contribute to existing models through bug reports, suggestions for improvement and new dataset and feature suggestions. Each update will be accompanied by well-documented release notes, detailing changes and new requirements.
Detailed Background and Related Works
We provide a detailed description of previous and related works, to motivate tree-grams presented in this work.
Synthetic models of data Modelling language has been an area of study for a long time. The classic work of Chomsky, [21] used finite-state Markov models, phrase-structure grammars and transformational grammars. The theory of formal languages classifies grammars by their generative capacity Chomsky, [23]. In particular, context-free grammars use recursive production rules to generate hierarchical and nested structures, such as Dyck languages, that finite-state Markov models cannot represent Chomsky & Schützenberger, [24]. Later work extended context-free grammars into stochastic models by assigning probabilities to production rules Booth, [10]; Lari & Young [57], while synthetic grammatical data became a controlled setting for studying whether neural networks can learn hierarchical structure Elman, [32]. More recently, there has been a growing interest in understanding models of data with randomly chosen underlying rules, eg. the Random Language Model DeGiuli, [28] and the Random Hierarchy Model Cagnetta et al., [13]. The justification for such hierarchical structures comes from theoretical studies (Chomsky, [22]), statistical analysis (Thurner et al., [87]; Goodfellow et al. [38]), information theory (Futrell & Hahn, [36]; Yang et al. [93]) and cognitive representations (Crain & Nakayama, [25]; Pallier et al. [72]; Ding et al. [30]; Hale et al. [41]). Tree-grams are a natural extension of such hierarchical and exponentially expressive models of language-like data. By making these models trainable, we allow tree-grams to capture necessary features from the data, without explicit interpretation of hidden nodes.
-gram estimators Language modeling is essentially an -gram estimation task. Recall that the -gram estimation amounts to estimating the conditional probability tensor . The frequentist method quickly becomes infeasible due to an exponential dependence on sample complexity and memory requirements. However, numerous empirical studies indicate that this tensor is extremely sparse, which gives rise to different algorithms. Smoothing re-distributes the probability mass through a linear interpolation (Chen & Goodman, [17]); PLRE takes advantages of conditional factorization into lower-rank tensors (Parikh et al., [74]); Some algorithms use back-off (Goodman, [39]; Nakamura & Shikano [69]) or scales by brute force (Brants et al., [11]) up to the unbounded suffix-array construction of infini-gram (Liu et al., [63])
A different method is to approximate this with factorized tensor sequence models, MPS and tensor-train models. (Pestun & Vlassopoulos, (2017); Miller et al. [68]; Su et al. [84]) We use (Loconte et al., 2025) as a primary motivation for our rank-3 tensor factorization.
Neural networks can also be used for a parametric estimation. This has been tried by (Castro et al., [16]) with MLPs and one-hot encodings, (Bengio et al., [5]) with MLPs and learnable encodings, (Blat et al., [9]) with interpolation with unigrams.
Modern recurrent networks or sequence-to-sequence models take advantage of implicit biases or statistical or nested properties of language to directly model the -gram probabilities. (Nguyen, [71]; Krishnan et al. [55]; Cagnetta et al. [15, 14])
Controlled approximation of languages -gram estimators provide a truncated-horizon approximation of language data. In addition, several model families introduce monotonic measures of capacity. Weighted automata uses finite Hankel rank (Denis et al., [29]). MPS uses bond dimension (Pestun & Vlassopoulos, (2017); Miller et al. [68]; Su et al. [84]) (Yang et al., [92]) uses latent state size, while (Parikh et al., [74]) use matrix and tensor ranks to represent intermediate levels of dependence between successive -gram orders.
Studying transformers on such controlled languages / n-grams There have been attempts to study transformers on synthetic formal grammars. In addition, -gram models of data has also been formulated as a learning problem by (Svete et al., [85]) and (Varre et al., [88]) in an in-context setting. (Yüksel et al., [95]) show that transformer incremental learn higher order Markov structure. However, to the best of our knowledge, such controlled approximations have never been applied for understanding practical situations like HP transfer, due to the limitation posed by scalability and fidelity to a realistic text corpora.
Trainable tree-structured models Differentiable tree structures exist. In particular, Tree-LSTMs consume a given parse (Tai et al., [86]) while (Choi et al., [20]) learns the composition order (tree) with a Gumbel relaxation. (Shen et al., [81]) forces a soft hierarchy into a recurrent net’s gates. A key tension arises with (Williams et al., [89]), who caution that the structures such models learn need not be the linguistically meaningful ones. Transformer architectures also take advantage of trees, eg. (Madaan et al., [65]) uses a decision-tree index over keys.
Details of the architecture
Analytic expressions for various properties of the network
Write for the number of nodes at level , so that and . Unrolling the recursion gives the closed form
The expressions for the depth , number of nodes and the number of different topologies are as follows
Only the levels above the leaves carry weight matrices, so the total number of parameters is
If MLPs are not included then .
Description of n-gram baselines used for comparison
Raw count A raw count -gram model estimates by normalizing counts for each observed -tuple of tokens. Smoothed raw count models redistribute probability mass to unseen events and shorter histories through interpolation and absolute discounting, while low-rank ensembles control the correlation of -grams through low-rank matrices [17, 75]. We report classical raw-count, smoothed-count, and low-rank count baselines only for to . This is because at , we already observe that 60% of the -grams appear only once. Tree-grams match these tested count baselines at small and out-perform them for larger .
Infini-gram Infini-gram uses a suffix array to retrieve continuation counts for the longest matching suffix of the available history and backs off when longer matches are unavailable [63]. In our finite-context comparison, we cap this search at tokens and interpolate with a smoothed unigram (infinigram + unigram) or a neural LM (infinigram + neural LM). On TinyStories, infinigram + unigram improves through , but its loss worsens and then plateaus at larger as long exact suffix matches become rare. Infinigram + neural LM improves but plateaus by . In contrast, tree-grams improve throughout the tested range and outperform infinigram at every shared value of .
Spectral automaton models A spectral weighted-finite-automaton (spectral WFA) estimator constructs empirical Hankel blocks of substring probabilities and uses a truncated singular-value decomposition to recover a finite-dimensional state and token-transition operators [3]. After tuning the rank and Hankel window , the resulting curve remains nearly flat as increases and performs worse even compared to the raw trigram. Tree-grams outperform the spectral estimator at every shared order, with the gap increasing toward larger .
Tensor train approximations We compare to three tensor-network language models. The uniform matrix product state (u-MPS) of [68] is a Born machine, , with a single core shared across positions. The tree tensor network (tree TN) of [18] is a Born machine on a balanced binary tree over the context, with a learned feature map at the leaves and one order-3 tensor at each internal node; we train it end to end by gradient descent rather than by DMRG sweeps. TTLM-Large (TTLM) (Su et al., [84]) is a tensor-train recurrence in which a token-dependent factor updates the state multiplicatively, followed by a softmax readout tied to the input embedding tensor. At every , the bond dimension , the tree width and the rank are set to match the parameter count of the tree-gram (–, –, –). The tree TN is best at (3.36 nats) and falls to near the unigram level from on. Tree-grams outperform all three at every shared order, by 0.19 nats at and 0.95 nats at against the strongest of them, TTLM.
Neural network approximation of -grams A neural -gram model embeds a fixed window of preceding tokens and uses an MLP with a softmax output to estimate the next-token distribution. This may be done with one-hot encodings (Castro et al., [16]) (MLP) or through learnable embedding structure (Bengio et al., [5]) (neural LM). Later works combined MLP with a unigram model (Blat et al., [9]) which we adapt here as the MLP + unigram model with the learnable embedding MLP. The parameter-matched neural baseline improves through but worsens at . However, it has consistently higher cross-entropy than tree-grams. Thus, tree-grams outperform all tested finite-window neural -gram estimators at every shared order.
Deep neural sequence models Well-trained deep sequence models provide a stronger estimate of -gram statistics at large (Nguyen, [71]; Krishnan et al., [55]; Cagnetta et al., [15]). In this case, we compare tree-grams to GPT-2 with absolute positional embeddings (GPT-2 (APE)) and rotary positional embeddings (GPT-2 (RoPE)), Llama-3.2 (Llama), and Mamba (Mamba). These are converged multi-epoch runs, which use approximately six times the token budget. In Figure 1b, tree-grams track these estimators through approximately , while the deep references remain lower at larger . However, in Figure 1(c), cross-entropy decreases monotonically as the rank increases over the tested range.
A Toy Model for Tree-gram data
We provide details of the toy model that we defined in the main text, which suggests a plausible mechanism for the HP transfer experiment results we observe empirically.
This model is based primarily on the random hierarchy model (Cagnetta et al., [13]) and the wavelet analysis of (Wornell & Oppenheim, [91]; Mallat, [66]). The toy model for the data has two layers. A finite dyadic hierarchy allocates predictive power across look-back scales. A Gaussian channel limits how well each latent feature can be recovered. Each of these layers are used to implement a different mode of control that tree-grams offer. We discuss this in more detail below. We make an attempt to highlight every assumption that a conclusion depends on through the labels (A1) – (A10). Figure 8 gives an intuitive picture.
Figure 8. Why does the optimal step size drift with the context length and the channel count ? The figure follows one next-token example through the toy model and then reads off the curvature that a quadratic learner would see. (a) Each doubling of the look-back window reveals one new block of context (colour), and each block becomes one level that carries independent channels. Each channel has variance , shown by the Gaussian spread. The level powers decay geometrically and sum to one. Adding a level redistributes this fixed budget. The label depends on the clean features alone; the learner sees only the noisy copy . No arrow joins different levels or channels, so each channel is estimated on its own. Drawn for , , . (b) One channel in rescaled coordinates, with equal fixed lengths for and . Their angle satisfies . The projection is , with power . (c) The Hessian eigenvalue of each channel, stacked by multiplicity, for , , , (grey: ridge-only directions). Under the toy model, adding a level or adding channels moves the stiffest eigenvalue to the left, and rises; the shift from is much larger than the shift from .
:::
Scales and signal strength
Let be a context of tokens, and let be its centered Bayes logit vector. We assume and . The dyadic suffix window holds the most recent tokens, so . Passing from to reveals the tokens at distances ; for , it reveals . This is the coarse-to-fine organization of multiresolution analysis (Mallat, [66]). Let be the -algebra generated by , and let be the trivial one. The level- increment and its signal strength are
where is the categorical Fisher matrix at the uniform distribution . It is positive definite on centered vectors, and we write . The increments are martingale differences. For a constant metric they are therefore orthogonal, for , and their powers add: . The strength is signal power, not a Hessian eigenvalue.
(A1) Modelling the effect of horizon and capacity equivalents The horizon and the channel count are hyperparameters of the data distribution. In our experiments, they stand for the
context window and the width of the tree-gram that generated a corpus. Here, we attempt to model the dependence of the distribution on these hyper-parameters through the toy model that we describe above. sets a finite context window by an abrupt cutoff on the lookback distance . controls the fidelity of the different modes through a quality factor which we define later.
(A2) Suffix windows, one summary per level. The model keeps one -channel summary per level and ignores the internal organization of each new block.
Scale powers
A hierarchy alone does not determine . Suppose that the level- increment has amplitude , with .
(A3) Self-similar branch law. The factors , , , are mutually independent, and for every .
Then . Such a power law was also obtained in [62]. The empirically relevant case is . Only the levels whose window fits in the context are active:
This sets the context approximation in (A1). Hence is constant for , and the tokens at distances are dropped.
(A4) Fixed total budget. For every , the total clean power is one: .
With , the level powers are
The largest level power is for and for . It decreases strictly with and tends to , , and for , , and . Assumption (A4) deserves care. For one fixed source, the increments 16 do not depend on , so a longer context adds levels without weakening the old ones. The normalization therefore describes a family of teachers, one for each , each scaled to unit predictable power. It is also the only source of -dependence in the spectral edge below. Without it, is independent of for and grows with for .
The feature–label generator
For each sample, each active level , and each channel , draw
Choose centered logit directions that are orthonormal in the metric, which requires . Generate
The dataset contains , not or . The index labels the level and labels its channels. Each channel has its own direction , so the features of a level stay distinguishable in their effect on the prediction, and is the number of resolved features per level. The latent summaries play the role of the context in Section E.1: and . The base logit is zero, so is uniform. A non-uniform unigram distribution would enter as a fixed logit offset.
(A5) Independent, balanced Gaussian channels. All and are jointly Gaussian and independent, and the channels of a level share its power equally.
(A6) Scale-uniform recovery. The recovery fraction is the same at every level and does not depend on . Its deficit satisfies as .
The per-channel signal-to-noise ratio is . Because the channel is Gaussian, , and by independence . The posterior mean and its power are
The recoverable covariance is , with trace . More capacity recovers more total signal, but each channel carries less of it: falls with while rises. The total recoverable power tends to zero as . The normalized spectrum is known in closed form, and no corpus statistic enters it.
A matched quadratic learner
We now provide a minimal quadratic model to set up the learner for the data distribution above.
The learner has one coordinate for every channel it can represent, including channels that are inactive at the current . It predicts . Take a fixed regression target , such as . The population objective and its Hessian are
The off-diagonal entries vanish because the output directions are -orthonormal, even if the features are correlated. Inactive coordinates have and curvature . Data features and optimization modes therefore align by construction. The target moves the optimum but not the Hessian.
(A7) Matched features. The learner reads , not . This is a strong assumption. We justify it here by assuming that the warmup phase of learning aligns the model’s features with the data features, so that the optimal learning rate is driven in this pseudo-constant phase where the learner model has aligned features.
(A8) Weak signal. Because is linear in , the regularized cross-entropy objective has the exact Hessian , with and . (22) replaces by . This assumes that predictions stay near the reference distribution, that is, that the total clean power is small in units. Assumption (A4) sets , and a smaller is absorbed into .
The replacement is exact at . At any , the correction that is first order in the logits vanishes in expectation, because it is odd under . The error is therefore of relative order . Numerically, use the square-root recovery law with , , , , , , and . For each of 24 random draws of the , we use 60,000 Gaussian feature draws and minimize the sample-average cross-entropy plus the ridge penalty. At the numerical optimum, the median of is 1.00%, 10.61%, and 25.98% at , 1, and 4, respectively. Both Hessians are evaluated on the same samples. The unit budget corresponds to about half a nat of divergence from the uniform distribution, since . The quadratic model is exact for a Gaussian regression target with independent centered noise, since the .
Spectral edges and the optimal learning rate
(A9) Ridge-only directions. At least one learner coordinate has no data curvature, for example an inactive channel, so . Otherwise, also moves with .
(A10) Deterministic, non-adaptive optimizer. The optimizer takes full-batch steps on with constant parameters. Minibatch noise, schedules, and Adam-type preconditioning are outside the model.
The upper edge is
For a spectrum in , gradient descent has the minimax step . This step equalizes and contracts at rate . The heavy-ball update has and [77, 26]. Nesterov’s method, and , commonly uses and [2]. With , the gradient-descent rate decomposes exactly as
The capacity term decreases strictly in and stepwise in . It vanishes as and saturates in for . When and , Eq. (24) becomes . More generally, , with , , and . The heavy-ball correction is only . The stability threshold has the same scaling, so the prediction concerns the dependence on rather than the optimality criterion.
The monotone drift uses (A1), (A4), (A5), and (A9), together with two facts: new levels receive positive power, and recovery grows sublinearly, so that decreases and dilution beats recovery. The drift can fail if the total power grows with depth, if recovery improves faster than linearly over some range of , or if an unrelated direction sets .
From the solvable learner to a transformer
Equation 22 makes the data features and the Hessian eigenvectors coincide by design. Applying Eq. (24) to a transformer requires a hypothesis in three parts. (H1) The dominant Hessian eigendirections align approximately with the multiscale predictive features. (H2) The top eigenvalue belongs to such a direction and equals an -independent gain times its recoverable power. (H3) The lower spectral edge does not depend on .
For a well-specified softmax model at a population optimum, the cross-entropy Hessian reduces to its Gauss–Newton part,
because the residual term vanishes there. The strengths determine neither the singular vectors nor the singular values of the learned logit Jacobian . A transformer can rotate the features, mix scales, and add unrelated high-curvature directions. The Fisher factor adds a corpus dependence of its own: shrinks as predictions sharpen, so the gain in (H2) can itself depend on . The learned Jacobian is the unresolved first-principles bottleneck.
Tree-gram experimental details and comparison to transformers
We performed experiments with 4 NVIDIA A100 GPUs. The 529.2M-token run for the , model (with MLP) takes 5 hours of wall-clock time. A total of 11,000 A100 GPU hours were used for all pre-training experiments on tree-grams reported in this paper.
We train on the 529.2M-token training split of TinyStories, tokenized with a custom BPE tokenizer [15], and validate on a 1.05M-token subset of its 5.34M-token validation split.
Every run trains for a single epoch over the 529.2M training tokens, cut into non-overlapping windows of tokens with 1024 windows per batch, using AdamW at its default moments. The learning rate warms up linearly from the initial to the peak value over the first 1% of steps and then follows a cosine decay to 1% of the peak. Unless stated otherwise the architecture uses LayerNorm, a residual stream of unit strength, GELU, and tied embeddings. We used a 1.05M validation set.
We tuned the peak learning rate and the weight decay for every cell. The -sweep used and , and the -sweep added ; the , cell pools this grid with an earlier one that reaches and . The initial learning rate was except for and . The topology ablations used smaller grids to test for learning rate transfer: , with for , and for , . The anti-aligned and need smaller rates and were swept over initial rates , and (: , ). Without MLPs only and were swept; the other five topologies were run at a single setting (, ). Cells were scored by the minimum validation loss over the run, averaged over two seeds. At the selected settings of the cells with MLPs, the seed-to-seed standard deviation is at most 0.0025 nats (), and at most 0.0004 nats for the other - and -sweep cells; it reaches 0.06 nats for the untuned topologies without MLPs. We ran 2 random seeds for each HP configuration of the - and -sweeps and then ran a total of 4 random seeds for the model with the best HP configuration. Data generation took 200 GPU hours.
For P transformers comparison, we scanned 10 peak learning rates while holding the weight decay fixed at 0.01, and kept the rate with the lowest validation loss on a single seed. We ran a total of 3 seeds for the transformers with the best value of the hyper-parameter combination. These were also trained with AdamW at batch 1024 for one epoch on the same windows as the tree-grams, with the same 1% warmup from , decaying to 10% of the peak, and with dropout 0.0. The transformers were based on Kalra [50].
Tree-grams were trained on WikiText-103 (130 MT) and FineWeb-Edu (1.05BT subset) as well. The training was done by choosing the best hyper-parameter for the relevant models for the TinyStories corpus, without additional hyper-parameter tuning. Training time was approximately linear in total token count, except for the , tree-gram model which could not be fit into 4 A100 GPUs. As a result we used gradient accumulation, which made the total wall-clock time to be closer to 20 hours, rather than the expected 10 hours. The additional experiments reported for these datasets needed an additional 8,000 GPU hours. At the time of writing, the pre-training, fine-tuning results on FineWeb-Edu are yet to run, and they need an estimated 2,000 GPU hours more.
Cost of generating a corpus. We timed the generation costs for the largest generators in the paper: 139.5 million parameters over an 8,192-token vocabulary (TinyStories and WikiText) and 182.6 million parameters over a 50,257-token vocabulary (FineWeb-Edu). On four threads of a single CPU (an Apple M4 Pro), sampling 512 sequences in parallel, they produce about 1.15 thousand and 0.65 thousand tokens per second. Generating WikiText (131.8 million tokens), TinyStories (529.2 million) and FineWeb-Edu (1.05 billion) therefore takes about 32, 128 and 448 hours on one worker. The deepest KV-cached transformers typically take around 2x less time for generation.
We also measured the estimated generation times on a cluster with dual AMD 7763 CPUs. The times are mentioned below in Table 2. As can be observed, the maximum time for generation even for the 1.05BT subset is roughly 90 hours. The mean times are well within a day for WikiText and TinyStories, and is equal to one and a half days for FineWeb-Edu (which has a larger vocabulary size).
| Cores | Model | WT (130 MT) | TS (529 MT) | FWE (1.05 BT) | ||||||
| median | mean | max | median | mean | max | median | mean | max | ||
| 1 | Tree-gram | 58.3 | 91.5 | 320 | 232 | 362 | 1,253 | 956 | 1,097 | 2,985 |
| Transformer | 40.4 | 50.4 | 125 | 163 | 203 | 499 | 779 | 778 | 1,543 | |
| 16 | Tree-gram | 3.9 | 6.2 | 21.2 | 15.7 | 24.3 | 83.6 | 70.2 | 80.2 | 205 |
| Transformer | 2.8 | 3.4 | 8.3 | 12.0 | 14.6 | 35.1 | 58.2 | 58.0 | 104 | |
| 32 | Tree-gram | 2.3 | 3.7 | 12.3 | 9.4 | 14.0 | 46.4 | 41.2 | 48.9 | 124 |
| Transformer | 1.7 | 2.0 | 4.6 | 6.6 | 7.7 | 18.0 | 33.2 | 33.3 | 58.4 | |
| 64 | Tree-gram | 1.7 | 2.9 | 9.2 | 6.8 | 10.3 | 32.5 | 31.3 | 36.2 | 88.7 |
| Transformer | 1.4 | 1.5 | 3.3 | 4.2 | 4.9 | 11.1 | 24.3 | 24.6 | 40.0 |
Table 2. Wall-clock time for corpus generation on dual AMD 7763 CPU cores. Times are in units of hours. Transformers are typically around 1.5–2x faster.
Parameter-matched transformer configurations
Table 3 gives the transformer width used for each tree-gram and transformer depth in Figure 2. All transformers use eight heads, MLP width , GELU, RoPE, tied embeddings, and the same context and token budget as the corresponding tree-gram. Parameter counts are matched to the nearest available width. Thus, width varies with depth and the sweep does not isolate depth.
Figure 2. Last-token loss of a fixed tree-gram (red) against matched transformers of varying depth , matched to the tree-gram in parameter count, context and optimization steps. (left) Scaling with horizon at : tree-grams perform better at small , but are outperformed by the deeper transformers at longer contexts. (right) Scaling with tree-gram rank at . Transformers plateau earlier at smaller depth. Tree-gram loss continues to decrease with over the tested range, while shallow transformers plateau. Thus tree-grams appear to be scalable. is the (empirical) -gram entropy.
| tree-gram | Tree params | Transformer width by depth | ||||||||
| 1 | 2 | 3 | 4 | 5 | 6 | 10 | 12 | |||
| 3 | 1024 | 36,709,376 | 1440 | 1072 | 896 | 800 | 720 | 656 | 512 | 480 |
| 4 | 1024 | 56,637,440 | 1856 | 1376 | 1152 | 1008 | 912 | 832 | 656 | 592 |
| 8 | 1024 | 78,665,728 | 2240 | 1648 | 1376 | 1200 | 1072 | 992 | 784 | 704 |
| 16 | 1024 | 104,892,416 | 2640 | 1920 | 1600 | 1392 | 1248 | 1152 | 896 | 832 |
| 32 | 64 | 1,039,744 | 112 | 96 | 96 | 80 | 80 | 80 | 64 | 64 |
| 32 | 128 | 3,103,488 | 272 | 224 | 208 | 176 | 176 | 160 | 128 | 128 |
| 32 | 256 | 10,302,976 | 640 | 512 | 432 | 384 | 352 | 320 | 256 | 240 |
| 32 | 512 | 36,989,952 | 1440 | 1088 | 912 | 800 | 720 | 656 | 528 | 480 |
| 32 | 1024 | 139,515,904 | 3088 | 2240 | 1856 | 1616 | 1456 | 1344 | 1040 | 960 |
Table 3. Exact parameter-matched transformer widths. Tree parameters include embeddings.
HP transfer experiment details
Learning rate sweeps
For the hyper-parameter-transfer study in Figure 3, all transformers use eight heads, , GELU, RoPE, tied embeddings, no dropout, sequence length 128 and batch 256 (32,768 tokens per step). Every proxy and every target trains for one epoch over the full 529.2M-token training split of its corpus (16,024 steps), so a proxy trained on real data differs from its target only in width. We use AdamW with , and weight decay 0.01, a linear warmup from over the first 1% of steps, and a cosine decay to 10% of the peak.
Proxy widths are at , each trained on all eleven corpora of Figure 5. Targets are trained on real TinyStories only, at for and for ; the main text reports () and (). Peak rates lie on the lattice . For the proxies, seed 0 spans at and at the wider widths, and seeds 1 and 2 span . This was done to ensure that the optimal learning rate is obtained at the basin of the loss vs learning rate curve. Targets use three seeds on , or on for the two widest targets at each depth, plus two to four off-lattice rates per target inserted near its divergence onset.
Continuous from a smoothing spline
In order to get a more precise estimate of we use a cubic smoothing spline as discussed in [51]. Writing , we discard points with , fit a cubic smoothing spline to with smoothing parameter , evaluate it at 400 uniformly spaced in the retained range, and take its minimizer.
Two adaptations are needed here. First, the window was calibrated on sweeps with a different loss scale; with nats the bar sits near 2.0 and admits points already far up the divergence cliff. A single such point inflates , hence , and the cubic cannot turn fast enough to follow the cliff, so it smears it back across the basin. We therefore truncate the window at the divergence onset, cutting at the first increment above nats, where is the median along the descending branch; across all 412 sweeps no descending increment exceeds 0.045 nats while the smallest increment the rule flags is 0.062, so it separates basin from cliff without ever truncating a basin, and the median residual falls to 0.0009 nats. Second, we use the spline only to locate optima. A proxy may recommend an far up the target’s cliff — tuning on the real corpus does exactly that — and there the measured loss is precisely the quantity of interest, so we score the target with a shape-preserving (PCHIP) interpolant of its full curve rather than with the spline. That interpolant cannot itself locate an optimum, since it sets a zero derivative at every data extremum and its minimiser is the grid argmin again; only a smoothing spline moves off the lattice.
The re-estimate leaves our conclusions unchanged and sharpens two of them. The median-over-synthetics rule stays within one grid point of each target’s own optimum with no grid involved: is 0.87–1.05 at and 1.11–1.22 at , against a rung of 4/3.
Finetuning experiment details
Methodology and optimization
For the finetuning experiment the downstream models are and . We evaluate every ordered pair among the bigram corpus, the five horizon-sweep corpora , the five capacity-sweep corpora , and real TinyStories: an matrix for each depth and three seeds. Fine-tuned models are validated on a 1.05M-token subset of the target’s validation split.
Pre-training. Each source is pre-trained for one epoch over its 80% segment (12,819 steps). Its peak rate is the argmin, on one seed, over seven lattice rates centred on that corpus’s optimum at in the HP-transfer sweep, a window; no selected rate lies on the edge of its window. This gives pre-trained checkpoints.
Fine-tuning. All parameters are updated from the pre-trained weights with a fresh AdamW state; the learning rate is re-warmed from over the first 1% of steps and cosine-decayed to 10% of its peak [40 ); {citep}]Ibrahim et al. [47], with no replay of source data. The fine-tuning peak rate is set per (source, target) pair: $\eta_{\mathrm{FT}}(s \to t)=\eta^\star_{\mathrm{PT}}(t)\cdot\eta^\star_{\mathrm{FT}(s\to\mathrm{real})}/\eta^\star_{\mathrm{FT}(\mathrm{real})}$, snapped to the lattice, where $\eta^\star_{\mathrm{FT}(s\to\mathrm{real})}$ comes from a one-seed sweep over a shared 22-point window. Tuning the rate per model follows {citet}Isik et al. [49]; re-warming to the pre-training peak instead trades adaptation against forgetting {citep}Gupta et al. [40]`, and we score only the target.
Budgets and references. The matrix is read after the full 105.8M fine-tuning tokens (3,205 steps). For a synthetic target, the floor is its generator’s entropy rate (Eq. (9)). For real TinyStories we use 1.242 nats, the converged loss of the 12-layer, GPT-2 of Cagnetta et al., [15] at , which is an empirical reference rather than a Bayes floor. Each cell reports the median over the three seeds of the final validation loss. As a no-pre-training reference, the same models trained from scratch on the same 105.8M real tokens, at 0.52 (within one lattice step of their own optimum on this budget), reach 1.688 nats at and 1.600 nats at (medians of three seeds), that is 0.36 and 0.29 on the scale of Figure 5(c,Figure 5d).
Additional plots
We provide additional plots alluded to in the main text. In order:
Comparison of tree-grams ran on Wiki-Text and FineWebEdu, with deep neural baselines (Figure 9).
A per-position cross-entropy comparison of every tree-gram in the sweep against its parameter-matched transformers, at every depth (Figure 10).
The HP tuning results on FineWeb-Edu (Figure 11).
The transfer phase diagram over every (proxy width, target width) pair, contrasting the median-over-synthetics rule with tuning on the real corpus (Figure 12).
The raw loss-versus-learning-rate curves for different widths on different datasets, with the spline-function interpolated values. (Figure 13).
Plots of the optimal learning rate for proxy widths as a function of the entropy of the distribution is presented in Figure 14. The non-monotonic behavior of the optimal learning rate as a function of the width for the real dataset is presented in Figure 15.
The pre-training and fine-tuning transfer matrices for both TinyStories and Wiki-Text dataset (Figure 16).
The pre-training transfer matrix with both axes re-sorted by entropy rates, which is where the two synthetic sweeps are seen to interleave (Figure 17).
Figure 9. Comparison of tree-grams with transformers on Wiki-Text and FineWeb-Edu. We notice that tree-grams are competitive with these deep neural architectures, like TinyStories discussed in the main text. We use a deep well-trained transformer as a proxy for the true empirical -gram entropy.
Figure 11. The HP transfer plot for FineWeb-Edu. We notice that in this case, the synthetic corpora do not provide a better approximation of the target.
Figure 12. The HP transfer phase diagram. (Left) We plot the excess loss obtained when transferring the median optimal learning rate from a source width to a target width . (Right) The same plot when we tune a proxy on the real data. Rows are depth (top) and (bottom). The synthetic rule is more robust as compared to tuning on the real data (the standard recipe).
Figure 13. Converged losses as a function of the peak learning rates. The solid dots represent the actual runs while the dashed lines represent the interpolated losses using a spline function.
Figure 14. Optimal learning rate as a function of the entropy of the generated distributions. We see a monotonic decrease with increase in entropy. However the width-dependence is extremely weak.
Figure 15. Optimal learning rate for the real dataset as a function of width. We observe a non-monotonic trend.
Figure 16. The pre-training transfer matrix for transformer on WikiText and transformers on WikiText and TinyStories respectively. We see the same qualitative trend as that of the main-text figure.
Figure 17. The pre-training transfer matrices with both axes re-sorted by entropy rate of the synthetic corpus, instead of grouped by mode of approximation. The green boxes are the same-distribution diagonal. We observe that the monotonic trend we observed in the main text, is no longer present. In addition, horizon-limited modes perform worse than capacity-limited modes, even when they have similar entropy rate.
Pre-training Fine-tuning Performance Gap
Which source–target pairs are hard to fine-tune is decided almost entirely by the target, through two properties measured directly on its token statistics. The first is its entropy rate: targets with a lower Bayes floor are harder to reach relative to that floor. The second is its effective range, which is how far apart two tokens can be and still carry information about each other. Entropy has the larger effect, but at comparable entropy a target with a longer effective range is consistently harder to reach. Generators that change the width at a fixed window sit above generators that change the window, at the same entropy (Figure 18, top). The source matters mainly when it carries less information than the target. A four-parameter law in these quantities, linear in the target’s entropy and in the logarithm of its range, plus a penalty for a source whose entropy rate exceeds the target’s, accounts for 82–99% of the variance across all 81 source–target pairs in each setting. It predicts the gap for held-out targets with comparable error (Figure 18, bottom). The range term has the same sign and nearly the same size in all four settings.
Figure 18. Do targets with longer-range correlations have a larger fine-tuning gap at the same entropy? The gap is the final validation loss divided by the target’s Bayes floor, minus one. Top: median gap over sources against the target’s Bayes floor, for generators that vary the context window at (blue) and generators that vary the width at (orange); numbers give each target’s mean lag . If range matters beyond entropy, the orange curve lies above the blue one at matched entropy, which it does in every panel. Bottom: observed against fitted gap for all 81 source–target pairs under the law shown, coloured by target; stars mark source = target, where the penalty term vanishes. Held-out error is computed by leaving out each target in turn. Points on the diagonal mean the law captures the pair. The one clear miss (WikiText-103, , the narrowest-width target trained on itself) is a run that became unstable late in training.
To measure the effective range, we estimate the mutual information between two tokens positions apart in text sampled from each generator. We use a bias-corrected plug-in estimator and subtract a null computed on shuffled pairs. Beyond the generator’s context window (), the logarithm of this mutual information falls linearly with , so the information decays exponentially. We take the slope of that line, , as the decay rate, so a small means a long range. Each curve is fitted only up to the lag where the mutual information first falls into the noise floor of the estimator. For display, the top row labels each target with its mean lag , the lag averaged with weights given by the mutual information, which orders the targets the same way.
Effective Receptive Fields for Tree-grams
The aligned topology labelled (Figure 6) has the unique property that terminal nodes in different layers ”focus” on different parts of the context. On the other hand, the anti-aligned topology mixes information from the whole context. We use a linear probe to uncover input tokens from latent activations of the terminal nodes in tree-grams. We observe that for , different terminal nodes in different layers recover each input token in its scope. The accuracy rises as we move down the layers, which indicates the difficulty of reconstruction increases as we pass through multiple non-linear passes. In contrast, for and transformers, recovery peaks at the last token, given the full context. This highlights that the aligned topology has effective receptive fields for each node in the downward pass, in contrast with anti-aligned topologies and transformers. Activation patching also confirms this causally (Figure 19). Restoring a single node recovers the prediction exactly when the swapped token lies in its scope and not at all otherwise. We emphasize that we do not claim that transformers are implementing a topology. Recovery of trees from transformers needs careful investigation due to known biasing effects from the parsing algorithm, feature definition as well as inherent architectural biases ([61]). In addition, we contrast this token recovery pattern in four different network ablations: trained and untrained tree-grams with or without residual connections (Figure 20). The windowed receptive fields of are already present in an untrained tree-gram with residual connections: each terminal node recovers the tokens in its scope above the majority-class baseline at initialization, so the windows come from the wiring of the topology rather than from training. Training sharpens these windows and removes the leakage of the earliest tokens into the lower nodes. Residual connections are what carry token identity through depth. Without them, an untrained tree-gram loses the tokens that pass through more than a few merges, and a trained one keeps the narrow windows near the end of the context but loses most of the wide early ones. shows no windows in any of the four conditions: untrained, its nodes hold a weak, nearly uniform trace of the whole context, and trained, all of them peak at the last token. We emphasize that the purpose of these experiments were to show that and provide alternate mechanisms for model computation. The corresponding experiments with transformers show that this is distinct from the usual model computation, which are closer to the anti-aligned topology as opposed to .
Figure 19. Effective receptive fields. Columns: tree-gram with the aligned topology , tree-gram with the anti-aligned topology , and a 12-layer transformer. Top: the architecture, with the probed terminal nodes (trees) or last-position layers (transformer) marked in the colors used below; the tree leaves are aligned to the token axis. Middle: we train linear probes to predict input tokens from latent activations of these nodes (top-1 accuracy; dotted: majority-class baseline). Accuracy for peaks at different intermediate context windows for different tree-gram layers, while the accuracy peaks at the last context position for all layers for and transformers. This suggests that different layers in an aligned topology preserve information about different context windows, while the anti-aligned topology and transformers mix features for last-token prediction. Bottom: receptive fields of individual nodes, recovered by activation patching. The token at each position is swapped, one position at a time, for the token another validation sequence holds there (1024 sequences), and every activation is compared with the unswapped run. We plot the mean squared change of each node’s Merge (solid) and MLP (dashed) activation (attention and MLP for the transformer), normalized by twice the activation’s variance (Jansen total-effect index, log scale). Outside a node’s scope its activations are exactly unchanged (no line). Triangles mark where the linear probe of the middle row peaks; shaded bands mark the disjoint context windows of . For , each node responds only to tokens up to the end of its window and most to the window it adds, peaking in the same windows as the probe; reaches the down nodes only below , outside the plotted range. In , no individual context windows are observed: every node’s change rises smoothly towards the last token. The transformer behaves the same way at every layer.
Figure 20. Do the effective receptive fields of come from training, from the topology, or from the residual connections? Linear-probe token recovery (as in Figure 19, middle row) for the six terminal nodes of (top row) and (bottom row), in trained and untrained tree-grams with and without residual connections; dotted: majority-class baseline; shaded bands: the disjoint context windows of . If the windows come from the wiring, they appear in the untrained but never in . They do: with residual connections, the untrained already recovers each window at its own node, and training sharpens the windows and removes the leakage of the first token into the lower nodes. Without residual connections, the untrained tree-gram loses tokens that pass through more than a few merges, and the trained one keeps only the narrow late windows. peaks at the last token, or nowhere, in every condition. Panels show the mean of two seeds for untrained tree-grams with residual connections and trained tree-grams without them, and a single model otherwise. The trained without residual connections is only partly trained (final losses of 3.44 and 2.85 nats for the two seeds).
Goodness of fit for ranked path probabilities
We sort the exact path probabilities and normalize each candidate on the finite rank support, . The probability of a path is the token average of its per-token joint probability, , over 192,448 validation tokens. We fit each router and seed separately, by least squares on . This gives equal weight to each rank and resolves the low-probability tail. The primary measures are log-RMSE and AICc. AICc assumes Gaussian log residuals. KS and are secondary descriptive checks.
For the power law with a generalized exponential cutoff is best on every measure for both seeds, with log-squared and 0.9948. For , the broken power law has the lowest log-RMSE and AICc for both seeds ( and 0.9929), while the generalized cutoff has the lowest KS and KL. Both place the bend at –, one as a sharp break and one smoothly. Under the generalized cutoff, , the cutoff scale separates the two routers, and 777 for against 6,860 and 8,170 for , while (1.16–1.33) and (0.53–0.81) vary about as much between the two seeds of one router as between routers. The 100 most probable paths carry 88% and 85% of the mass for and 70% and 91% for , but their identity does not reproduce: the two seeds of a router share none of their 100 most probable paths, and only 3 () and 0 () of their top 500, against about 7 expected by chance. Pareto and power law are the same finite rank model here. Double Pareto and sharp broken power law are also the same rank curve. The smooth cutoff agrees with the transition from power-law-like ranks to faster tails discussed by [70].
| Model | log-RMSE s0 | log-RMSE s1 | AICc s0 | AICc s1 | KS s0 | KS s1 | KL s0 | KL s1 |
| Exponential | 2.965 | 2.972 | 191424.8 | 175489.6 | 0.839 | 0.809 | 3.597 | 3.513 |
| Generalized exponential | 0.433 | 0.393 | 50186.3 | 26910.6 | 0.373 | 0.340 | 0.580 | 0.590 |
| Power law / Pareto | 1.622 | 1.940 | 147131.1 | 144180.5 | 0.431 | 0.459 | 0.682 | 0.880 |
| PL with exponential cutoff | 0.351 | 0.371 | 34644.7 | 22679.1 | 0.266 | 0.279 | 0.200 | 0.259 |
| PL with GEC | 0.219 | 0.272 | 0.0 | 0.0 | 0.087 | 0.120 | 0.068 | 0.128 |
| Broken PL / double Pareto | 0.281 | 0.467 | 18371.9 | 39542.0 | 0.271 | 0.286 | 0.211 | 0.272 |
| DGBD / beta-rank | 0.939 | 1.007 | 106993.4 | 96049.9 | 0.375 | 0.398 | 0.443 | 0.559 |
| Exponential | 1.736 | 2.288 | 179757.3 | 192998.3 | 0.743 | 0.879 | 2.797 | 4.086 |
| Generalized exponential | 0.369 | 0.735 | 66086.3 | 109589.8 | 0.341 | 0.565 | 0.417 | 0.956 |
| Power law / Pareto | 0.852 | 0.554 | 127501.0 | 88814.8 | 0.317 | 0.244 | 0.333 | 0.161 |
| PL with exponential cutoff | 0.208 | 0.255 | 24092.6 | 31735.5 | 0.127 | 0.155 | 0.066 | 0.090 |
| PL with GEC | 0.201 | 0.242 | 21497.1 | 27930.4 | 0.095 | 0.120 | 0.044 | 0.074 |
| Broken PL / double Pareto | 0.150 | 0.165 | 0.0 | 0.0 | 0.178 | 0.154 | 0.114 | 0.090 |
| DGBD / beta-rank | 0.512 | 0.392 | 90046.1 | 63404.0 | 0.241 | 0.209 | 0.193 | 0.125 |
Table 4. Goodness of fit for the ranked path-probability curves, fitted separately to the two seeds (s0, s1) of each router. Lower is better in every column, and the best value in each column of a block is in bold. PL denotes power law. GEC denotes generalized exponential cutoff. DGBD denotes the discrete generalized Beta distribution discussed in [70].
Examples of generated text
Samples from fixed tree-grams on TinyStories (BPE-8192) at temperature 1, with a fixed context and generation seed. Within each block every model receives the same validation prompt, truncated to its own context length ; the token stream is lightly de-tokenised (punctuation re-attached) for readability, and [EOS] marks the end-of-story token.
Width sweep — varies at
, (31 context tokens, nats/token)
Prompt. camp. [EOS] One day, a little girl named Lucy found a shoe in her room. It was a big shoe, much too big for her foot.
Continuation. Mia tried to climb up, but she couldn’t. She felt so cold and strong. She did not shiver anymore. Her music made her. It made her bow back on the ground. The lemonade tasted like Mr. Hina’s face turned into a small sc run. The fit and introduced all her was out to dry and decided to show it to her, making a pile castle. She had some money from
, (31 context tokens, nats/token)
Prompt. camp. [EOS] One day, a little girl named Lucy found a shoe in her room. It was a big shoe, much too big for her foot.
Continuation. Mia wanted to comfort Fluffy, but she was scared. She did not know what to play with. Kitty’s mom saw her feeling sad and did not want to help. So, she hid the medicine in the kitchen. [EOS] One day, a colorful bird named Bob flew in a big tree. March was a happy place to be. He was very happy to find the sun. Bobo flew to a big park where people
, (31 context tokens, nats/token)
Prompt. camp. [EOS] One day, a little girl named Lucy found a shoe in her room. It was a big shoe, much too big for her foot.
Continuation. Lucy tried to fix the shoe, but it couldn’t pinch her dress. Amy asked her mom, “Mom, what is this jacket?” Her mom said, “I don’t know, Sue. Maybe they can use a glove to talk to someone.” Finally, Tim’s mom mentioned the coin to Tim. But when they went back home, Tim forgot about Spot. She gave it back to Tim and said
, (31 context tokens, nats/token)
Prompt. camp. [EOS] One day, a little girl named Lucy found a shoe in her room. It was a big shoe, much too big for her foot.
Continuation. She tried to pull it, but she couldn’t. She felt frustrated. Amy asked her mom, “Mom, what is this round thing?” Her mom smiled and said, “This is a special seat, Amy. It tells us things A test is when we drive around the front to the whole world. We can learn this and learn how to count to 10, to the beauty end. How does that sound?”
, (31 context tokens, nats/token) Prompt. camp. [EOS] One day, a little girl named Lucy found a shoe in her room. It was a big shoe, much too big for her foot.
Continuation. She wanted to repair it, but she did not know how. “Mom, can I reverse our shoe?” Sam requested. His mom smiled and said, “Of course we can! I’ll hold it for you.” [EOS] One day, a colorful bird named Bob flew to a big tree. He wanted to settle there to rest and rest. While he was sitting, he heard a loud laugh. Rob opened his eyes
Context Sweep — varies at
, (2 context tokens, nats/token)
Prompt. too big
Continuation. for you. Do you want to buy the blue ball. One sunny day, a boy named Tom came to the war and be friends and her white dress. She ran back home. They played together and had fun. Would you like.“Bob wanted to bake with her toys and games. They agreed and they both loved the doll.” You can’t need to sleep. [EOS] Once upon a time, there was a
, (3 context tokens, nats/token)
Prompt. much too big
Continuation. for you. Do you want to buy the blue ball. One sunny day, a boy named Tom came to Sam’s orange collar and her white boots. She ran back home to play together. [EOS] Once upon a time, there was a rabbit. She had seen the wind’s joy and introduced himself. The cat was busy and decided to show it to all her friends. She gave Lily a big hug and said
, (7 context tokens, nats/token)
Prompt. a big shoe, much too big
Continuation. and old. John felt frustrated. He yelled,’But the parrot wouldn’t listen. He came closer and saw what was happening. She did not want to be rude. Tom looked at Sam and said, “Would you like some more?” But Tom could not hear Tim’s voice and shake the hole. A big dog came to the castle. The dog did not like the decorations. He wanted some money from
, (15 context tokens, nats/token)
Prompt. in her room. It was a big shoe, much too big for her
Continuation. mouth. Sue didn’t want her spaghetti, but her mom said, “Don’t worry, we can make another one later.” After that, they played a game where Tom squeezed the bowl and made a loud noise. “Boo!” A sound came out. “Wow, you fit us! You are good at hiding. You can escape through the hole to sleep.” Tim followed Max to a big park where there
, (31 context tokens, nats/token)
Prompt. camp. [EOS] One day, a little girl named Lucy found a shoe in her room. It was a big shoe, much too big for her foot. Continuation. She wanted to repair it, but she did not know how. “Mom, can I reverse our shoe?” Sam requested. His mom smiled and said, “Of course we can! I’ll hold it for you.” [EOS] One day, a colorful bird named Bob flew to a big tree. He wanted to settle there to rest and rest. While he was sitting, he heard a loud laugh. Rob opened his eyes
References
- [1]Amro Abbas, Kushal Tirumala, Dániel Simig, Surya Ganguli, and Ari S. Morcos. Semdedup: Data-efficient learning at web-scale through semantic deduplication, 2023. URL https://arxiv.org/abs/2303.09540.
- [2]Mahmoud Assran and Mike Rabbat. On the convergence of Nesterov’s accelerated gradient method in stochastic settings. In Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pp. 410–420, 2020.arxiv.org/abs/2002.12414
- [3]Borja Balle, Ariadna Quattoni, and Xavier Carreras. Spectral learning techniques for weighted automata, transducers, and grammars. Tutorial at the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), 2014. URL https://borjaballe.github.io/emnlp14-tutorial/. Accessed: 2026-08-29.
- [4]Yoshua Bengio, Réjean Ducharme, Pascal Vincent, and Christian Jauvin. A neural probabilistic language model. Journal of Machine Learning Research, 3:1137–1155, 2003a.
- [5]Yoshua Bengio, Réjean Ducharme, Pascal Vincent, and Christian Jauvin. A neural probabilistic language model. Journal of Machine Learning Research, 3:1137–1155, 2003b. URL https://www.jmlr.org/papers/v3/bengio03a.html.
- [6]Thomas Berg. Branching direction in recursive structures. English Language and Linguistics, 16 (3):385–401, 2012. doi: 10.1017/S1360674312000160.DOI
- [7]Dan Biderman, Jacob Portes, Jose Javier Gonzalez Ortiz, Mansheej Paul, Philip Greengard, Connor Jennings, Daniel King, Sam Havens, Vitaliy Chiley, Jonathan Frankle, Cody Blakeney, and John P. Cunningham. LoRA learns less and forgets less. Transactions on Machine Learning Research, 2024. URL https://arxiv.org/abs/2405.09673.
- [8]Johan Bjorck, Alon Benhaim, Vishray Chaudhary, Furu Wei, and Xia Song. Scaling optimal lr across token horizons, 2025. URL https://arxiv.org/abs/2409.19913.
- [9]Fernando Blat, María José Castro, Salvador Tortajada, and Joan Andreu Sánchez. A hybrid approach to statistical language modeling with multilayer perceptrons and unigrams. In Proceedings of the 8th International Conference on Text, Speech and Dialogue (TSD 2005), pp. 195–202. Springer, 2005. doi: 10.1007/11551874_25.DOI
- [10]Taylor L. Booth. Probabilistic representation of formal languages. In 10th Annual Symposium on Switching and Automata Theory, pp. 74–81. IEEE, 1969. doi: 10.1109/SWAT.1969.7.
- [11]T. Brants, Ashok Popat, Peng Xu, Franz Josef Och, and Jeffrey Dean. Large language models in machine translation. In Conference on Empirical Methods in Natural Language Processing, 2007. URL https://api.semanticscholar.org/CorpusID:633992.
- [12]Peter F. Brown, Vincent J. Della Pietra, Peter V. deSouza, Jennifer C. Lai, and Robert L. Mercer. Class-based n-gram models of natural language. Computational Linguistics, 18(4):467–479, 1992. Preprint. Under review.DOI
- [13]Francesco Cagnetta, Leonardo Petrini, Umberto M. Tomasini, Alessandro Favero, and Matthieu Wyart. How deep neural networks learn compositional data: The random hierarchy model. Phys. Rev. X, 14:031001, Jul 2024. doi: 10.1103/PhysRevX.14.031001. URL https://link.aps.org/doi/10.1103/PhysRevX.14.031001.DOI
- [14]Francesco Cagnetta, Alessandro Favero, Antonio Sclocchi, and Matthieu Wyart. Scaling laws and representation learning in simple hierarchical languages: Transformers vs. convolutional architectures, 2025. URL https://arxiv.org/abs/2505.07070.
- [15]Francesco Cagnetta, Allan Raventós, Surya Ganguli, and Matthieu Wyart. Deriving neural scaling laws from the statistics of natural language. https://github.com/fracagnetta/small-language-modelling, 2026. arXiv:2602.07488.arxiv.org/abs/2602.07488
- [16]M.J. Castro, F. Prat, and F. Casacuberta. MLP emulation of n-gram models as a first step to connectionist language modeling. In 1999 Ninth International Conference on Artificial Neural Networks ICANN 99. (Conf. Publ. No. 470), volume 2, pp. 910–915 vol.2, 1999. doi: 10.1049/cp:19991228.DOI
- [17]Stanley F. Chen and Joshua Goodman. An empirical study of smoothing techniques for language modeling. In Proceedings of the 34th Annual Meeting of the Association for Computational Linguistics, pp. 310–318. Association for Computational Linguistics, 1996. doi: 10.3115/981863.981904. URL https://aclanthology.org/P96-1041/.DOI
- [18]Song Cheng, Lei Wang, Tao Xiang, and Pan Zhang. Tree tensor networks for generative modeling. Physical Review B, 99(15):155131, 2019. doi: 10.1103/PhysRevB.99.155131.DOI
- [19]Cheng-Han Chiang and Hung-yi Lee. On the transferability of pre-trained language models: A study from artificial datasets. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 36, 2022.arxiv.org/abs/2109.03537
- [20]Jihun Choi, Kang Min Yoo, and Sang-goo Lee. Learning to compose task-specific tree structures. In AAAI, 2018.arxiv.org/abs/1707.02786
- [21]Noam Chomsky. Three models for the description of language. IRE Transactions on Information Theory, 2(3):113–124, 1956. doi: 10.1109/TIT.1956.1056813.
- [22]Noam Chomsky. Syntactic Structures. Mouton, The Hague, 1957.
- [23]Noam Chomsky. On certain formal properties of grammars. Information and Control, 2(2):137–167, 1959. doi: 10.1016/S0019-9958(59)90362-6.
- [24]Noam Chomsky and Marcel-Paul Schützenberger. The algebraic theory of context-free languages. In Computer Programming and Formal Systems, volume 35 of Studies in Logic and the Foundations of Mathematics, pp. 118–161. North-Holland, 1963. doi: 10.1016/S0049-237X(08)72023-8.
- [25]Stephen Crain and Mineharu Nakayama. Structure dependence in grammar formation. Language, 63(3):522–543, 1987. doi: 10.2307/415004.DOI
- [26]Marina Danilova and Grigory Malinovsky. Averaged heavy-ball method. Computer Research and Modeling, 14(2):277–308, 2022. doi: 10.20537/2076-7633-2022-14-2-277-308.DOI
- [27]DeepSeek-AI. DeepSeek-V3 technical report, 2025. URL https://arxiv.org/abs/2412.19437.
- [28]E. DeGiuli. Random language model. Phys. Rev. Lett., 122:128301, Mar 2019. doi: 10.1103/PhysRevLett.122.128301. URL https://link.aps.org/doi/10.1103/PhysRevLett.122.128301.DOI
- [29]François Denis, Mattias Gybels, and Amaury Habrard. Dimension-free concentration bounds on Hankel matrices for spectral learning. Journal of Machine Learning Research, 17(31):1–32, 2016. URL https://www.jmlr.org/papers/v17/14-501.html.
- [30]Nai Ding, Lucia Melloni, Hang Zhang, Xing Tian, and David Poeppel. Cortical tracking of hierarchical linguistic structures in connected speech. Nature Neuroscience, 19(1):158–164, 2016. doi: 10.1038/nn.4186. Chris Dyer, Adhiguna Kuncoro, Miguel Ballesteros, and Noah A. Smith. Recurrent neural network grammars. In Proceedings of NAACL-HLT, pp. 199–209, 2016. doi: 10.18653/v1/N16-1024.
- [31]Ronen Eldan and Yuanzhi Li. TinyStories: How small can language models be and still speak coherent English?, 2023. URL https://arxiv.org/abs/2305.07759.
- [32]Jeffrey L. Elman. Distributed representations, simple recurrent networks, and grammatical structure. Machine Learning, 7:195–225, 1991. doi: 10.1007/BF00114844.DOI
- [33]Martin B. H. Everaert, Marinus A. C. Huybregts, Noam Chomsky, Robert C. Berwick, and Johan J. Bolhuis. Structures, not strings: Linguistics as part of the cognitive sciences. Trends in Cognitive Sciences, 19(12):729–743, 2015. doi: 10.1016/j.tics.2015.09.008.DOI
- [34]Oleg Filatov, Jan Ebert, Jiangtao Wang, and Stefan Kesselheim. Time transfer: On optimal learning rate and batch size in the infinite data limit, 2025. URL https://openreview.net/forum?id=MLhquJb1qN.arxiv.org/abs/2410.05838
- [35]Zach Furman, Stephan Wäldchen, Yangda Bei, and Liam Hodgkinson. Benign loss landscapes can coexist with worst-case hardness, 2026. URL https://arxiv.org/abs/2609.13057.
- [36]Richard Futrell and Michael Hahn. Linguistic structure from a bottleneck on sequential information processing. Nature Human Behaviour, 10:589–600, 2026. doi: 10.1038/s41562-025-02336-w.DOI
- [38]Ian Goodfellow, Yoshua Bengio, and Aaron Courville. Deep Learning. MIT Press, 2016.
- [39]Joshua Goodman. A bit of progress in language modeling, 2001. URL https://arxiv.org/abs/cs/0108005.
- [40]Kshitij Gupta, Benjamin Thérien, Adam Ibrahim, Mats L. Richter, Quentin Anthony, Eugene Belilovsky, Irina Rish, and Timothée Lesort. Continual pre-training of large language models: How to (re)warm your model? In ES-FoMo Workshop, International Conference on Machine Learning, 2023. URL https://arxiv.org/abs/2308.04014.
- [41]John Hale, Chris Dyer, Adhiguna Kuncoro, and Jonathan Brennan. Finding syntax in human encephalography with beam search. In Iryna Gurevych and Yusuke Miyao (eds.), Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 2727–2736, Melbourne, Australia, July 2018. Association for Computational Linguistics. doi: 10.18653/v1/P18-1254. URL https://aclanthology.org/P18-1254/.DOI
- [42]Marc D. Hauser, Noam Chomsky, and W. Tecumseh Fitch. The faculty of language: What is it, who has it, and how did it evolve? Science, 298(5598):1569–1579, 2002. doi: 10.1126/science.298.5598.1569.DOI
- [43]Danny Hernandez, Jared Kaplan, Tom Henighan, and Sam McCandlish. Scaling laws for transfer. arXiv preprint arXiv:2102.01293, 2021. URL https://arxiv.org/abs/2102.01293.
- [44]John Hewitt and Christopher D. Manning. A structural probe for finding syntax in word representations. In Proceedings of NAACL-HLT, pp. 4129–4138, 2019. doi: 10.18653/v1/N19-1419.DOI
- [45]John E. Hopcroft and Jeffrey D. Ullman. Introduction to Automata Theory, Languages, and Computation. Addison-Wesley, 1979.
- [46]Michael Y. Hu, Jackson Petty, Chuan Shi, William Merrill, and Tal Linzen. Between circuits and Chomsky: Pre-training on formal languages imparts linguistic biases. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), 2025.arxiv.org/abs/2502.19249
- [47]Adam Ibrahim, Benjamin Thérien, Kshitij Gupta, Mats L. Richter, Quentin Anthony, Timothée Lesort, Eugene Belilovsky, and Irina Rish. Simple and scalable strategies to continually pre-train large language models. Transactions on Machine Learning Research (TMLR), 2024. URL https://openreview.net/forum?id=DimPeeCxK0. Preprint. Under review.arxiv.org/abs/2403.08763
- [48]Satoki Ishikawa, Rio Yokota, and Ryo Karakida. Measuring the local shape of learning-rate transfer curves, 2026. URL https://arxiv.org/abs/2610.21814.
- [49]Berivan Isik, Natalia Ponomareva, Hussein Hazimeh, Dimitris Paparas, Sergei Vassilvitskii, and Sanmi Koyeyo. Scaling laws for downstream task performance in machine translation. In International Conference on Learning Representations (ICLR), 2025. URL https://arxiv.org/abs/2402.04177.
- [50]Dayal Singh Kalra. nanoGPT-mup. https://github.com/dayal-kalra/nanoGPT-mup, 2025. (Slight modifications made by authors).
- [51]Dayal Singh Kalra and Maissam Barkeshli. Quantifying hyperparameter transfer and the importance of embedding layer learning rate, 2026. URL https://arxiv.org/abs/2605.21486.
- [52]Yoon Kim, Chris Dyer, and Alexander M. Rush. Compound probabilistic context-free grammars for grammar induction. In Proceedings of ACL, pp. 2369–2385, 2019. doi: 10.18653/v1/P19-1228.DOI
- [53]Dan Klein and Christopher D. Manning. Corpus-based induction of syntactic structure: Models of dependency and constituency. In Proceedings of the 42nd Annual Meeting of the Association for Computational Linguistics, 2004. doi: 10.3115/1218955.1219019.
- [54]Atli Kosson, Jeremy Welborn, Yang Liu, Martin Jaggi, and Xi Chen. Weight decay may matter more than μp for learning rate transfer in practice. In The Fourteenth International Conference on Learning Representations, 2026. URL https://openreview.net/forum?id=PvTxIdZc1E.arxiv.org/abs/2510.19093
- [55]Aravind Krishnan, Jesujoba Alabi, and Dietrich Klakow. On the n-gram approximation of pre-trained language models, 2023. URL https://arxiv.org/abs/2306.06892.
- [56]Adhiguna Kuncoro, Chris Dyer, Laura Rimell, Stephen Clark, and Phil Blunsom. LSTMs can learn syntax-sensitive dependencies well, but modeling structure makes them better. In Proceedings of ACL, pp. 1426–1436, 2018. doi: 10.18653/v1/P18-1132.DOI
- [57]Karim Lari and Steve J. Young. The estimation of stochastic context-free grammars using the inside-outside algorithm. Computer Speech & Language, 4(1):35–56, 1990. doi: 10.1016/0885-2308(90)90022-X.
- [58]Yann LeCun, Ido Kanter, and Sara A. Solla. Eigenvalues of covariance matrices: Application to neural-network learning. Phys. Rev. Lett., 66:2396–2399, May 1991. doi: 10.1103/PhysRevLett.66.2396. URL https://link.aps.org/doi/10.1103/PhysRevLett.66.2396.DOI
- [59]Katherine Lee, Daphne Ippolito, Andrew Nystrom, Chiyuan Zhang, Douglas Eck, Chris Callison-Burch, and Nicholas Carlini. Deduplicating training data makes language models better. In Smaranda Muresan, Preslav Nakov, and Aline Villavicencio (eds.), Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 8424–8445, Dublin, Ireland, May 2022. Association for Computational Linguistics. doi: 10.18653/v1/2022.acl-long.577. URL https://aclanthology.org/2022.acl-long.577/.DOI
- [60]Houyi Li, Wenzhen Zheng, Qiufeng Wang, Hanshan Zhang, Zili Wang, Shijie Xuyang, Yuantao Fan, Zhenyu Ding, Haoying Wang, Ning Ding, Shuigeng Zhou, Xiangyu Zhang, and Daxin Jiang. Predictable scale: Part i, step law – optimal hyperparameter scaling law in large language model pretraining, 2025. URL https://arxiv.org/abs/2503.04715.
- [61]Huayang Li, Lemao Liu, Guoping Huang, and Shuming Shi. On the branching bias of syntax extracted from pre-trained language models, 2020. URL https://arxiv.org/abs/2010.02448.
- [62]Henry W. Lin and Max Tegmark. Critical behavior in physics and probabilistic formal languages. Entropy, 19(7):299, 2017. doi: 10.3390/e19070299.DOI
- [63]Jiacheng Liu, Sewon Min, Luke Zettlemoyer, Yejin Choi, and Hannah Hajishirzi. Infini-gram: Scaling unbounded n-gram language models to a trillion tokens, 2025. URL https://arxiv.org/abs/2401.17377. Preprint. Under review. Lorenzo Loconte, Antonio Mari, Gennaro Gala, Robert Peharz, Cassio de Campos, Erik Quaeghebeur, Gennaro Vessio, and Antonio Vergari. What is the relationship between tensor factorizations and circuits (and how can we exploit it?), 2025. URL https://arxiv.org/abs/2409.07953.
- [64]Lorenzo Loconte et al. Multiplicative interactions and low-rank tensor approximations. arXiv preprint arXiv:2409.07953, 2024.
- [65]Lovish Madaan, Srinadh Bhojanapalli, Himanshu Jain, and Prateek Jain. Treeformer: Dense gradient trees for efficient attention computation. In ICLR, 2023.arxiv.org/abs/2208.09015
- [66]Stéphane G. Mallat. A theory for multiresolution signal decomposition: The wavelet representation. IEEE Transactions on Pattern Analysis and Machine Intelligence, 11(7):674–693, 1989. doi: 10.1109/34.192463.DOI
- [67]Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. Pointer sentinel mixture models. In International Conference on Learning Representations, 2017. URL https://openreview.net/forum?id=Byj72udxe.arxiv.org/abs/1609.07843
- [68]Jacob Miller, Guillaume Rabusseau, and John Terilla. Tensor networks for probabilistic sequence modeling. In AISTATS, 2021.arxiv.org/abs/2003.01039
- [69]Masaaki Nakamura and Kiyoshi Shikano. A study of English word category prediction based on neural networks. In Proceedings of the International Conference on Acoustics, Speech, and Signal Processing (ICASSP), pp. 731–734, Glasgow, Scotland, 1989.DOI
- [70]Gerardo G. Naumis and Germinal Cocho. The tails of rank-size distributions due to multiplicative processes: from power laws to stretched exponentials and beta-like functions. New Journal of Physics, 9(8):286, 2007. doi: 10.1088/1367-2630/9/8/286. URL https://doi.org/10.1088/1367-2630/9/8/286.
- [71]Timothy Nguyen. Understanding transformers via n-gram statistics. In A. Globerson, L. Mackey, D. Belgrave, A. Fan, U. Paquet, J. Tomczak, and C. Zhang (eds.), Advances in Neural Information Processing Systems, volume 37, pp. 98049–98082. Curran Associates, Inc., 2024. doi: 10.52202/079017-3112. URL https://proceedings.neurips.cc/paper_files/paper/2024/file/b1c446eebd9a317dd0e96b1690c821a-Paper-Conference.pdf.DOI
- [72]Christophe Pallier, Anne-Dominique Devauchelle, and Stanislas Dehaene. Cortical representation of the constituent structure of sentences. Proceedings of the National Academy of Sciences, 108(6):2522–2527, 2011. doi: 10.1073/pnas.1018711108. URL https://www.pnas.org/doi/abs/10.1073/pnas.1018711108.DOI
- [73]Isabel Papadimitriou and Dan Jurafsky. Learning music helps you read: Using transfer to study linguistic structure in language models. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), 2020.arxiv.org/abs/2004.14601
- [74]Ankur P. Parikh, Avneesh Saluja, Chris Dyer, and Eric Xing. Language modeling with power low rank ensembles. In Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 1487–1498, Doha, Qatar, 2014a. Association for Computational Linguistics. doi: 10.3115/v1/D14-1158. URL https://aclanthology.org/D14-1158/.DOI
- [75]Ankur P. Parikh, Avneesh Saluja, Chris Dyer, and Eric Xing. Language modeling with power low rank ensembles. In Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 1487–1498. Association for Computational Linguistics, 2014b. doi: 10.3115/v1/D14-1158. URL https://aclanthology.org/D14-1158/.DOI
- [76]Guilherme Penedo, Hynek Kydlíček, Loubna Ben allal, Anton Lozhkov, Margaret Mitchell, Colin Raffel, Leandro Von Werra, and Thomas Wolf. The fineweb datasets: Decanting the web for the finest text data at scale. In The Thirty-eighth Conference on Neural Information Processing Systems Datasets and Benchmarks Track, 2024. URL https://openreview.net/forum?id=n6SCkn2QaG. Preprint. Under review.
- [77]Boris T. Polyak. Some methods of speeding up the convergence of iteration methods. USSR Computational Mathematics and Mathematical Physics, 4(5):1–17, 1964. doi: 10.1016/0041-5553(64)90137-5.DOI
- [78]Noam Razin, Asaf Maman, and Nadav Cohen. Implicit regularization in hierarchical tensor factorization and deep convolutional neural networks, 2022. URL https://arxiv.org/abs/2201.11729.
- [79]Ryokan Ri and Yoshimasa Tsuruoka. Pretraining with artificial language: Studying transferable knowledge in language models. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), 2022.arxiv.org/abs/2203.10326
- [80]Claude E. Shannon. Prediction and entropy of printed English. Bell System Technical Journal, 30 (1):50–64, 1951. doi: 10.1002/j.1538-7305.1951.tb01366.x.DOI
- [81]Yikang Shen, Shawn Tan, Alessandro Sordoni, and Aaron Courville. Ordered neurons: Integrating tree structures into recurrent neural networks. In ICLR, 2019.arxiv.org/abs/1810.09536
- [82]Le Song, Mariya Ishteva, Ankur Parikh, Eric Xing, and Haesun Park. Hierarchical tensor decomposition of latent tree graphical models. In Sanjoy Dasgupta and David McAllester (eds.), Proceedings of the 30th International Conference on Machine Learning, volume 28 of Proceedings of Machine Learning Research, pp. 334–342, Atlanta, Georgia, USA, 17–19 2013. PMLR. URL https://proceedings.mlr.press/v28/song13.html.
- [83]Ben Sorscher, Robert Geirhos, Shashank Shekhar, Surya Ganguli, and Ari S. Morcos. Beyond neural scaling laws: beating power law scaling via data pruning, 2023. URL https://arxiv.org/abs/2206.14486.
- [84]Zhan Su, Yuqin Zhou, Fengran Mo, and Jakob Grue Simonsen. Language modeling using tensor trains. arXiv preprint arXiv:2405.04590, 2024.arxiv.org/abs/2405.04590
- [85]Anej Svete, Nadav Borenshtein, Mike Zhou, Isabelle Augenstein, and Ryan Cotterell. Can transformers learn n-gram language models? In Yaser Al-Onaizan, Mohit Bansal, and Yun-Nung Chen (eds.), Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, pp. 9851–9867, Miami, Florida, USA, November 2024. Association for Computational Linguistics. doi: 10.18653/v1/2024.emnlp-main.550. URL https://aclanthology.org/2024.emnlp-main.550/.DOI
- [86]Kai Sheng Tai, Richard Socher, and Christopher D. Manning. Improved semantic representations from tree-structured long short-term memory networks. In ACL, 2015.arxiv.org/abs/1503.00075
- [87]Stefan Thurner, Rudolf Hanel, Bo Liu, and Bernat Corominas-Murtra. Understanding Zipf’s law of word frequencies through sample-space collapse in sentence formation. Journal of the Royal Society Interface, 12(108):20150330, 2015. doi: 10.1098/rsif.2015.0330.
- [88]Aditya Varre, Gizem Yüce, and Nicolas Flammarion. Learning in-context n-grams with transformers: Sub-n-grams are near-stationary points. In Proceedings of the 42nd International Conference on Machine Learning, volume 267 of Proceedings of Machine Learning Research, pp. 60924–60963. PMLR, 2025.arxiv.org/abs/2508.12837
- [89]Adina Williams, Andrew Drozdov, and Samuel R. Bowman. Do latent tree learning models identify meaningful structure in sentences? Transactions of the Association for Computational Linguistics, 6:253–267, 2018.arxiv.org/abs/1709.01121
- [90]Gregory W. Wornell and Alan V. Oppenheim. Estimation of fractal signals from noisy measurements using wavelets. IEEE Transactions on Signal Processing, 40(3):611–623, 1992a. doi: 10.1109/78.120804.DOI
- [91]G.W. Wornell and A.V. Oppenheim. Estimation of fractal signals from noisy measurements using wavelets. IEEE Transactions on Signal Processing, 40(3):611–623, 1992b. doi: 10.1109/78.120804. Preprint. Under review.
- [92]Songlin Yang, Yanpeng Zhao, and Kewei Tu. PCFGs can do better: Inducing probabilistic context-free grammars with many symbols. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 1487–1498, Online, 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.naacl-main.117. URL https://aclanthology.org/2021.naacl-main.117/.DOI
- [93]Xiulin Yang, Heidi Getz, and Ethan Gotlieb Wilcox. Function words as statistical cues for language learning, 2026. URL https://arxiv.org/abs/2601.21191.
- [94]Shunyu Yao, Binghui Peng, Christos Papadimitriou, and Karthik Narasimhan. Self-attention networks can process bounded hierarchical languages. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pp. 3770–3785, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.292. URL https://aclanthology.org/2021.acl-long.292/.DOI
- [95]Oğuz Kaan Yüksel, Rodrigo Alvarez Lucendo, and Nicolas Flammarion. Incremental learning of sparse attention patterns in transformers, 2026. URL https://arxiv.org/abs/2602.19143.
- [96]Manzil Zaheer, Satwik Kottur, Siamak Ravanbakhsh, Barnabas Poczos, Ruslan Salakhutdinov, and Alexander Smola. Deep sets. In Advances in Neural Information Processing Systems, 2017. Preprint. Under review.



















