Manuscript Offprint
arXiv:2611.23093What's in a Tree ? Hierarchical -gram models as controlled approximators of language
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
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.
1 Introduction
Language is hypothesized to be hierarchically structured (Chomsky, 1956; Chomsky, 1957; Everaert et al., 2015; Hauser et al., 2002; Goodfellow et al., 2016). Its statistical structure has been studied using classical and modern language models, including Markov-chain and -gram models (Shannon, 1951; Brown et al., 1992; Bengio et al., 2003a). Synthetic datasets inspired by context-free gramars (Chomsky, 1956; Hopcroft and Ullman, 1979; Klein and Manning, 2004; Kim et al., 2019) have also been proposed as tractable testbeds to understand language modeling. In particular, (Cagnetta et al., 2024) 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 (Dyer et al., 2016; Kuncoro et al., 2018); however, learning linguistically meaningful tree structures directly from data remains difficult (Klein and Manning, 2004; Kim et al., 2019; Hewitt and Manning, 2019). 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 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.
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.

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- merges (), blue edges denote order- 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.
1.1 Background and Motivation
Hierarchical models have been used to study synthetic datasets resembling language. (Chomsky, 1956; Chomsky and Schützenberger, 1963; Yao et al., 2021; Cagnetta et al., 2024). Justification for such hierarchical modelling comes from statistical property analysis (Thurner et al., 2015), information theory (Futrell and Hahn, 2026; Yang et al., 2026) and cognitive representations (Crain and Nakayama, 1987; Pallier et al., 2011; Ding et al., 2016; Hale et al., 2018). 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 (Cagnetta et al., 2026). Such approximations have been made by using traditional and smoothed -gram counts (Chen and Goodman, 1996; Parikh et al., 2014a; Liu et al., 2025), hidden Markov models (Balle et al., 2014) or tensor-trains (Miller et al., 2021; Su et al., 2024). 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 B.
2 The tree-gram architecture
We implement tree-grams as a hierarchical architecture (see Fig. 1), with layers indexed by . After an initial shared token embedding ,
the new layer is formed via local order-2 ( ) and order-3 () merges. is a (learnable) positional encoding. The operation is defined as
h^{(\ell)}_{i}=\operatorname{Merge}_{\text{up}}(z)=\begin{cases}W^{(\ell-1)}_{i}z^{(\ell-1)}_{i}&(\hbox to13.18pt{\vbox to10.33pt{\pgfpicture\makeatletter\hbox{\hskip 2.32133pt\lower-2.32133pt\hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#000000} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.4pt} \lx@inpgf@ignorespaces\nullfont\hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} { {{}}\lx@inpgf@ignorespaces\hbox{\hbox{{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {{}{{{}}}{{}}{}{}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{}{}{}{}{}{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {}\lxSVG@fillstroke\lxSVG@drawpath@unclipped{M 2.94 0 C 2.94 1.62 1.62 2.94 0 2.94 C -1.62 2.94 -2.94 1.62 -2.94 0 C -2.94 -1.62 -1.62 -2.94 0 -2.94 C 1.62 -2.94 2.94 -1.62 2.94 0 Z M 0 0}{} \lx@inpgf@ignorespaces \lxSVG@closescope }{{{{\lx@inpgf@ignorespaces}}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@transformcm{1.0}{0.0}{0.0}{1.0}{0.0pt}{0.0pt}\lxSVG@begingroup@{transform=matrix(1.0 0.0 0.0 1.0 0 0)} \pgfsys@hbox{60}\lxSVG@closescope }}} \lxSVG@closescope }}} {{}}\lx@inpgf@ignorespaces\hbox{\hbox{{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {{}{{{}}}{{}}{}{}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{}{}{}{}{}{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {}\lxSVG@fillstroke\lxSVG@drawpath@unclipped{M 14.75 7.87 C 14.75 9.5 13.43 10.81 11.81 10.81 C 10.19 10.81 8.88 9.5 8.88 7.87 C 8.88 6.25 10.19 4.94 11.81 4.94 C 13.43 4.94 14.75 6.25 14.75 7.87 Z M 11.81 7.87}{} \lx@inpgf@ignorespaces \lxSVG@closescope }{{{{\lx@inpgf@ignorespaces}}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@transformcm{1.0}{0.0}{0.0}{1.0}{8.5359pt}{5.69046pt}\lxSVG@begingroup@{transform=matrix(1.0 0.0 0.0 1.0 11.81 7.87)} \pgfsys@hbox{60}\lxSVG@closescope }}} \lxSVG@closescope }}} {{}}{}{{}} {{{{{}}{}{}{}{}{{}}}}}{}{{{{{}}{}{}{}{}{{}}}}}{{}}{}{}{}\lxSVG@begingroup@{_scopebegin=1} \color[rgb]{0,0,1}\lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=1.6pt} \lx@inpgf@ignorespaces{}\lxSVG@stroke\lxSVG@drawpath@unclipped{M 2.67 1.78 L 9.14 6.09}{fill:none} \lx@inpgf@ignorespaces \lxSVG@closescope } \lxSVG@closescope {\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}\hss}\lxSVG@discardpath\lxSVG@closescope \hss}}\lxSVG@closescope\endpgfpicture}}\text{ connection}),\\[4.0pt] W^{(\ell-1)}_{i}\left(z^{(\ell-1)}_{i}\odot z^{(\ell-1)}_{i\,{+}\,1}\right)&(\hbox to21.71pt{\vbox to10.33pt{\pgfpicture\makeatletter\hbox{\hskip 2.32133pt\lower-2.32133pt\hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#000000} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.4pt} \lx@inpgf@ignorespaces\nullfont\hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} { {}{{\lx@inpgf@ignorespaces}}\lx@inpgf@ignorespaces\hbox{\hbox{{\lxSVG@begingroup@{_scopebegin=1} {{}{{}}{}{}} \lxSVG@closescope }}} {}{{\lx@inpgf@ignorespaces}}\lx@inpgf@ignorespaces\hbox{\hbox{{\lxSVG@begingroup@{_scopebegin=1} {{}{{}}{}{}} \lxSVG@closescope }}} {}{{\lx@inpgf@ignorespaces}}\lx@inpgf@ignorespaces\hbox{\hbox{{\lxSVG@begingroup@{_scopebegin=1} {{}{{}}{}{}} \lxSVG@closescope }}} \par{{}}{}{{}}{}{{}}{{{\lx@inpgf@ignorespaces}}{{}}} {}{}\lxSVG@begingroup@{_scopebegin=1} \color[rgb]{1,0,0}\lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=1.6pt} \lx@inpgf@ignorespaces{}\lxSVG@stroke\lxSVG@drawpath@unclipped{M 0 0 L 11.81 6.21}{fill:none} \lx@inpgf@ignorespaces \lxSVG@closescope {{}}{}{{}}{}{{}}{{{\lx@inpgf@ignorespaces}}{{}}} {}{}\lxSVG@begingroup@{_scopebegin=1} \color[rgb]{1,0,0}\lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=1.6pt} \lx@inpgf@ignorespaces{}\lxSVG@stroke\lxSVG@drawpath@unclipped{M 23.62 0 L 11.81 6.21}{fill:none} \lx@inpgf@ignorespaces \lxSVG@closescope \par{{}}{{}}\lx@inpgf@ignorespaces\hbox{\hbox{{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {{}{{{}}}{{}}{}{}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{}{}{}{}{}{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {}\lxSVG@fillstroke\lxSVG@drawpath@unclipped{M 2.94 0 C 2.94 1.62 1.62 2.94 0 2.94 C -1.62 2.94 -2.94 1.62 -2.94 0 C -2.94 -1.62 -1.62 -2.94 0 -2.94 C 1.62 -2.94 2.94 -1.62 2.94 0 Z M 0 0}{} \lx@inpgf@ignorespaces \lxSVG@closescope }{{{{\lx@inpgf@ignorespaces}}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@transformcm{1.0}{0.0}{0.0}{1.0}{0.0pt}{0.0pt}\lxSVG@begingroup@{transform=matrix(1.0 0.0 0.0 1.0 0 0)} \pgfsys@hbox{60}\lxSVG@closescope }}} \lxSVG@closescope }}} {{}}{{}}\lx@inpgf@ignorespaces\hbox{\hbox{{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {{}{{{}}}{{}}{}{}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{}{}{}{}{}{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {}\lxSVG@fillstroke\lxSVG@drawpath@unclipped{M 14.75 7.87 C 14.75 9.5 13.43 10.81 11.81 10.81 C 10.19 10.81 8.88 9.5 8.88 7.87 C 8.88 6.25 10.19 4.94 11.81 4.94 C 13.43 4.94 14.75 6.25 14.75 7.87 Z M 11.81 7.87}{} \lx@inpgf@ignorespaces \lxSVG@closescope }{{{{\lx@inpgf@ignorespaces}}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@transformcm{1.0}{0.0}{0.0}{1.0}{8.5359pt}{5.69046pt}\lxSVG@begingroup@{transform=matrix(1.0 0.0 0.0 1.0 11.81 7.87)} \pgfsys@hbox{60}\lxSVG@closescope }}} \lxSVG@closescope }}} {{}}{{}}\lx@inpgf@ignorespaces\hbox{\hbox{{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {{}{{{}}}{{}}{}{}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{}{}{}{}{}{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {}\lxSVG@fillstroke\lxSVG@drawpath@unclipped{M 26.56 0 C 26.56 1.62 25.24 2.94 23.62 2.94 C 22 2.94 20.69 1.62 20.69 0 C 20.69 -1.62 22 -2.94 23.62 -2.94 C 25.24 -2.94 26.56 -1.62 26.56 0 Z M 23.62 0}{} \lx@inpgf@ignorespaces \lxSVG@closescope }{{{{\lx@inpgf@ignorespaces}}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@transformcm{1.0}{0.0}{0.0}{1.0}{17.07182pt}{0.0pt}\lxSVG@begingroup@{transform=matrix(1.0 0.0 0.0 1.0 23.62 0)} \pgfsys@hbox{60}\lxSVG@closescope }}} \lxSVG@closescope }}} } \lxSVG@closescope {\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}\hss}\lxSVG@discardpath\lxSVG@closescope \hss}}\lxSVG@closescope\endpgfpicture}}\text{ connection}),\end{cases}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. Tree-grams belong to a more general class of hierarchical tensor decompositions with latent nodes Song et al. (2013); Razin et al. (2022); Furman et al. (2026). 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 () 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 operation is modified as
h^{(\ell)}_{i}=\operatorname{Merge}_{\text{down}}(z)=\begin{cases}(W^{(\ell+1)}_{i})^{T}z^{(\ell+1)}_{c^{\ell}_{i}}&(\hbox to13.18pt{\vbox to10.33pt{\pgfpicture\makeatletter\hbox{\hskip 2.32133pt\lower-2.32133pt\hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#000000} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.4pt} \lx@inpgf@ignorespaces\nullfont\hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} { {{}}\lx@inpgf@ignorespaces\hbox{\hbox{{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {{}{{{}}}{{}}{}{}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{}{}{}{}{}{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {}\lxSVG@fillstroke\lxSVG@drawpath@unclipped{M 2.94 0 C 2.94 1.62 1.62 2.94 0 2.94 C -1.62 2.94 -2.94 1.62 -2.94 0 C -2.94 -1.62 -1.62 -2.94 0 -2.94 C 1.62 -2.94 2.94 -1.62 2.94 0 Z M 0 0}{} \lx@inpgf@ignorespaces \lxSVG@closescope }{{{{\lx@inpgf@ignorespaces}}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@transformcm{1.0}{0.0}{0.0}{1.0}{0.0pt}{0.0pt}\lxSVG@begingroup@{transform=matrix(1.0 0.0 0.0 1.0 0 0)} \pgfsys@hbox{60}\lxSVG@closescope }}} \lxSVG@closescope }}} {{}}\lx@inpgf@ignorespaces\hbox{\hbox{{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {{}{{{}}}{{}}{}{}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{}{}{}{}{}{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {}\lxSVG@fillstroke\lxSVG@drawpath@unclipped{M 14.75 7.87 C 14.75 9.5 13.43 10.81 11.81 10.81 C 10.19 10.81 8.88 9.5 8.88 7.87 C 8.88 6.25 10.19 4.94 11.81 4.94 C 13.43 4.94 14.75 6.25 14.75 7.87 Z M 11.81 7.87}{} \lx@inpgf@ignorespaces \lxSVG@closescope }{{{{\lx@inpgf@ignorespaces}}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@transformcm{1.0}{0.0}{0.0}{1.0}{8.5359pt}{5.69046pt}\lxSVG@begingroup@{transform=matrix(1.0 0.0 0.0 1.0 11.81 7.87)} \pgfsys@hbox{60}\lxSVG@closescope }}} \lxSVG@closescope }}} {{}}{}{{}} {{{{{}}{}{}{}{}{{}}}}}{}{{{{{}}{}{}{}{}{{}}}}}{{}}{}{}{}\lxSVG@begingroup@{_scopebegin=1} \color[rgb]{0,0,1}\lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=1.6pt} \lx@inpgf@ignorespaces{}\lxSVG@stroke\lxSVG@drawpath@unclipped{M 2.67 1.78 L 9.14 6.09}{fill:none} \lx@inpgf@ignorespaces \lxSVG@closescope } \lxSVG@closescope {\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}\hss}\lxSVG@discardpath\lxSVG@closescope \hss}}\lxSVG@closescope\endpgfpicture}}\text{ connection}),\\[4.0pt] \left(z^{(\ell+1)}_{c^{\ell}_{i,L}}\odot(W^{(\ell+1)}_{i})^{T}z^{(\ell+1)}_{c^{\ell}_{i,R}}\right)&(\hbox to21.71pt{\vbox to10.33pt{\pgfpicture\makeatletter\hbox{\hskip 2.32133pt\lower-2.32133pt\hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#000000} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.4pt} \lx@inpgf@ignorespaces\nullfont\hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} { {}{{\lx@inpgf@ignorespaces}}\lx@inpgf@ignorespaces\hbox{\hbox{{\lxSVG@begingroup@{_scopebegin=1} {{}{{}}{}{}} \lxSVG@closescope }}} {}{{\lx@inpgf@ignorespaces}}\lx@inpgf@ignorespaces\hbox{\hbox{{\lxSVG@begingroup@{_scopebegin=1} {{}{{}}{}{}} \lxSVG@closescope }}} {}{{\lx@inpgf@ignorespaces}}\lx@inpgf@ignorespaces\hbox{\hbox{{\lxSVG@begingroup@{_scopebegin=1} {{}{{}}{}{}} \lxSVG@closescope }}} \par{{}}{}{{}}{}{{}}{{{\lx@inpgf@ignorespaces}}{{}}} {}{}\lxSVG@begingroup@{_scopebegin=1} \color[rgb]{1,0,0}\lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=1.6pt} \lx@inpgf@ignorespaces{}\lxSVG@stroke\lxSVG@drawpath@unclipped{M 0 0 L 11.81 6.21}{fill:none} \lx@inpgf@ignorespaces \lxSVG@closescope {{}}{}{{}}{}{{}}{{{\lx@inpgf@ignorespaces}}{{}}} {}{}\lxSVG@begingroup@{_scopebegin=1} \color[rgb]{1,0,0}\lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=1.6pt} \lx@inpgf@ignorespaces{}\lxSVG@stroke\lxSVG@drawpath@unclipped{M 23.62 0 L 11.81 6.21}{fill:none} \lx@inpgf@ignorespaces \lxSVG@closescope \par{{}}{{}}\lx@inpgf@ignorespaces\hbox{\hbox{{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {{}{{{}}}{{}}{}{}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{}{}{}{}{}{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {}\lxSVG@fillstroke\lxSVG@drawpath@unclipped{M 2.94 0 C 2.94 1.62 1.62 2.94 0 2.94 C -1.62 2.94 -2.94 1.62 -2.94 0 C -2.94 -1.62 -1.62 -2.94 0 -2.94 C 1.62 -2.94 2.94 -1.62 2.94 0 Z M 0 0}{} \lx@inpgf@ignorespaces \lxSVG@closescope }{{{{\lx@inpgf@ignorespaces}}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@transformcm{1.0}{0.0}{0.0}{1.0}{0.0pt}{0.0pt}\lxSVG@begingroup@{transform=matrix(1.0 0.0 0.0 1.0 0 0)} \pgfsys@hbox{60}\lxSVG@closescope }}} \lxSVG@closescope }}} {{}}{{}}\lx@inpgf@ignorespaces\hbox{\hbox{{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {{}{{{}}}{{}}{}{}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{}{}{}{}{}{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {}\lxSVG@fillstroke\lxSVG@drawpath@unclipped{M 14.75 7.87 C 14.75 9.5 13.43 10.81 11.81 10.81 C 10.19 10.81 8.88 9.5 8.88 7.87 C 8.88 6.25 10.19 4.94 11.81 4.94 C 13.43 4.94 14.75 6.25 14.75 7.87 Z M 11.81 7.87}{} \lx@inpgf@ignorespaces \lxSVG@closescope }{{{{\lx@inpgf@ignorespaces}}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@transformcm{1.0}{0.0}{0.0}{1.0}{8.5359pt}{5.69046pt}\lxSVG@begingroup@{transform=matrix(1.0 0.0 0.0 1.0 11.81 7.87)} \pgfsys@hbox{60}\lxSVG@closescope }}} \lxSVG@closescope }}} {{}}{{}}\lx@inpgf@ignorespaces\hbox{\hbox{{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {{}{{{}}}{{}}{}{}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{}{}{}{}{}{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#FFBFBF} {}\lxSVG@fillstroke\lxSVG@drawpath@unclipped{M 26.56 0 C 26.56 1.62 25.24 2.94 23.62 2.94 C 22 2.94 20.69 1.62 20.69 0 C 20.69 -1.62 22 -2.94 23.62 -2.94 C 25.24 -2.94 26.56 -1.62 26.56 0 Z M 23.62 0}{} \lx@inpgf@ignorespaces \lxSVG@closescope }{{{{\lx@inpgf@ignorespaces}}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@transformcm{1.0}{0.0}{0.0}{1.0}{17.07182pt}{0.0pt}\lxSVG@begingroup@{transform=matrix(1.0 0.0 0.0 1.0 23.62 0)} \pgfsys@hbox{60}\lxSVG@closescope }}} \lxSVG@closescope }}} } \lxSVG@closescope {\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}\hss}\lxSVG@discardpath\lxSVG@closescope \hss}}\lxSVG@closescope\endpgfpicture}}\text{ connection}),.\end{cases}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 (Eldan and Li, 2023), using a custom BPE tokenizer with vocabulary size (Cagnetta et al., 2026). Details on optimization are in Appendix F. We train on two additional datasets : (1) a 130MT WikiText-103 Merity et al. (2017) dataset, obtained by designing a custom BPE tokenizer with vocabulary size and (2) a 1.05BT FineWeb-Edu Penedo et al. (2024) dataset, tokenized with the GPT-2 tokenizer and vocabulary size .
3 Results
3.1 Comparison to existing baselines

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) n-gram entropy.
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) (Chen and Goodman, 1996; Parikh et al., 2014b), unbounded suffix array calculations (infinigram) (Liu et al., 2025), weighted finite-automaton approximations obtained via spectral methods (spectral WFA) (Balle et al., 2014), tensor train approximations (tree TN, u-MPS, TTLM) (Miller et al., 2021; Su et al., 2024), MLP-based neural models (MLP, neural LM, neural LM + unigram) (Castro et al., 1999; Bengio et al., 2003b; Blat et al., 2005), 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 (Cagnetta et al., 2026) (black dashed line in Figure 1b and c). The model-independence is a strong indication that this is close to the true -gram entropy. (Nguyen, 2024; Krishnan et al., 2023; Cagnetta et al., 2026) 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)
3.2 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 Fig. 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 Fig. 1.
4 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 M 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 P and effect of pre-training and fine-tuning distribution shifts on fine-tuning performance.
4.1 Hyperparameter transfer under Maximal Update Parametrization
The standard recipe for hyperparameter (HP) transfer under the P (Maximal Update) parametrization Yang et al. (2022) involves two stages: tuning and transfer. The tuning stage involves training a small model, initialized according to P 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 Bjorck et al. (2025); Li et al. (2025), data deduplication Lee et al. (2022); Abbas et al. (2023) or high-quality data pruning Sorscher et al. (2023).
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.
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 P 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 Kosson et al. (2026); Ishikawa et al. (2026); Filatov et al. (2025). 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.
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 (Cagnetta et al., 2024) and of multiscale Gaussian signal models (Wornell and Oppenheim, 1992b). 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 define unit-norm vectors , then the next-token logits are
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 (LeCun et al., 1991) 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 E. We emphasize that the toy model presented is not intended to provide a causal mechanism for our empirical observations.
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.
4.2 Pre-training and finetuning
The value of a pre-training distribution depends on how well it aligns with the fine-tuning distribution. (Isik et al., 2025) 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 (Papadimitriou and Jurafsky, 2020), artificial languages with controlled dependency structure (Ri and Tsuruoka, 2022; Chiang and Lee, 2022), and formal languages with hierarchical dependencies (Hu et al., 2025) 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. (2021); Hu et al. (2025). Unlike a narrower downstream task, a target here can be more complex than its source, so we avoid low-rank adapters Biderman et al. (2024). We re-warm and cosine re-decay the learning rate from a fresh optimizer state Ibrahim et al. (2024); Gupta et al. (2023), but without the replay that Ibrahim et al. (2024) 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: 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.
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. (2026). 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.
5 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 Section 6. There is some difference in the training dynamics, which is reported in Fig. 6. The anti-aligned topologies start at a higher loss but converge to a lower loss and vice versa for the algined 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 ()† | 1.946 () | 1.970 () |
| anti-aligned | 1.805 | 2.025 () | 3.142 () | 1.935 () |
Table 1: Best validation loss for tree-gram on TinyStories. Parameter-matched ablations on various components of tree-grams. †Diverges late in training.
6 Emergent sparsity through topology routing

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.
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., 2017):
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, 2025). 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- (out of 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 Fig. 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., 2018).
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. Fig. 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.
7 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 operation. We implement a particular choice of tensor factorization in 5, inspired from Loconte and others (2024). 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.
References
A. Abbas, K. Tirumala, D. Simig, S. Ganguli, and A. S. Morcos SemDeDup: data-efficient learning at web-scale through semantic deduplication. External Links: 2303.09540, Link Cited by: §4.1.
M. Assran and M. Rabbat On the convergence of Nesterov’s accelerated gradient method in stochastic settings. In Proceedings of the 37th International Conference on Machine Learning, Proceedings of Machine Learning Research, Vol. 119, pp. 410–420. Cited by: §E.5.
B. Balle, A. Quattoni, and X. Carreras Spectral learning techniques for weighted automata, transducers, and grammars. Note: Tutorial at the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)Accessed: 2026-08-29 External Links: Link Cited by: Appendix D, §1.1, §3.1.
Y. Bengio, R. Ducharme, P. Vincent, and C. Jauvin A neural probabilistic language model. Journal of Machine Learning Research 3, pp. 1137–1155. Cited by: §1.
Y. Bengio, R. Ducharme, P. Vincent, and C. Jauvin A neural probabilistic language model. Journal of Machine Learning Research 3, pp. 1137–1155. External Links: Link Cited by: Appendix B, Appendix D, §3.1.
T. Berg Branching direction in recursive structures. English Language and Linguistics 16 (3), pp. 385–401. External Links: Document Cited by: footnote 8.
D. Biderman, J. Portes, J. J. Gonzalez Ortiz, M. Paul, P. Greengard, C. Jennings, D. King, S. Havens, V. Chiley, J. Frankle, C. Blakeney, and J. P. Cunningham LoRA learns less and forgets less. Transactions on Machine Learning Research. External Links: Link Cited by: §4.2.
J. Bjorck, A. Benhaim, V. Chaudhary, F. Wei, and X. Song Scaling optimal lr across token horizons. External Links: 2409.19913, Link Cited by: §4.1.
F. Blat, M. J. Castro, S. Tortajada, and J. A. 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. External Links: Document Cited by: Appendix B, Appendix D, §3.1.
T. L. Booth Probabilistic representation of formal languages. In 10th Annual Symposium on Switching and Automata Theory, pp. 74–81. External Links: Document Cited by: Appendix B.
T. Brants, A. Popat, P. Xu, F. J. Och, and J. Dean Large language models in machine translation. In Conference on Empirical Methods in Natural Language Processing, External Links: Link Cited by: Appendix B.
P. F. Brown, V. J. D. Pietra, P. V. deSouza, J. C. Lai, and R. L. Mercer Class-based -gram models of natural language. Computational Linguistics 18 (4), pp. 467–479. Cited by: §1.
F. Cagnetta, A. Favero, A. Sclocchi, and M. Wyart Scaling laws and representation learning in simple hierarchical languages: transformers vs. convolutional architectures. External Links: 2505.07070, Link Cited by: Appendix B.
F. Cagnetta, L. Petrini, U. M. Tomasini, A. Favero, and M. Wyart How deep neural networks learn compositional data: the random hierarchy model. Phys. Rev. X 14, pp. 031001. External Links: Document, Link Cited by: Appendix B, Appendix E, §1.1, §1, §4.1.
F. Cagnetta, A. Raventós, S. Ganguli, and M. Wyart Deriving neural scaling laws from the statistics of natural language. Note: arXiv:2602.07488https://github.com/fracagnetta/small-language-modelling Cited by: Appendix B, Appendix D, Appendix F, §H.1, §1.1, §2, §3.1, §4.2.
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), Vol. 2, pp. 910–915 vol.2. External Links: Document Cited by: Appendix B, Appendix D, §3.1.
S. F. Chen and J. 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. External Links: Document, Link Cited by: Appendix B, Appendix D, §1.1, §3.1.
S. Cheng, L. Wang, T. Xiang, and P. Zhang Tree tensor networks for generative modeling. Physical Review B 99 (15), pp. 155131. External Links: Document Cited by: Appendix D.
C. Chiang and H. Lee On the transferability of pre-trained language models: a study from artificial datasets. In Proceedings of the AAAI Conference on Artificial Intelligence, Vol. 36. Cited by: §4.2.
J. Choi, K. M. Yoo, and S. Lee Learning to compose task-specific tree structures. In AAAI, Cited by: Appendix B.
N. Chomsky and M. Schützenberger The algebraic theory of context-free languages. In Computer Programming and Formal Systems, Studies in Logic and the Foundations of Mathematics, Vol. 35, pp. 118–161. External Links: Document Cited by: Appendix B, §1.1.
N. Chomsky Three models for the description of language. IRE Transactions on Information Theory 2 (3), pp. 113–124. External Links: Document Cited by: Appendix B, §1.1, §1.
N. Chomsky Syntactic structures. Mouton, The Hague. Cited by: Appendix B, §1.
N. Chomsky On certain formal properties of grammars. Information and Control 2 (2), pp. 137–167. External Links: Document Cited by: Appendix B.
S. Crain and M. Nakayama Structure dependence in grammar formation. Language 63 (3), pp. 522–543. External Links: Document Cited by: Appendix B, §1.1.
M. Danilova and G. Malinovsky Averaged heavy-ball method. Computer Research and Modeling 14 (2), pp. 277–308. External Links: Document Cited by: §E.5.
DeepSeek-AI DeepSeek-V3 technical report. External Links: 2412.19437, Link Cited by: §6.
E. DeGiuli Random language model. Phys. Rev. Lett. 122, pp. 128301. External Links: Document, Link Cited by: Appendix B.
F. Denis, M. Gybels, and A. Habrard Dimension-free concentration bounds on Hankel matrices for spectral learning. Journal of Machine Learning Research 17 (31), pp. 1–32. External Links: Link Cited by: Appendix B.
N. Ding, L. Melloni, H. Zhang, X. Tian, and D. Poeppel Cortical tracking of hierarchical linguistic structures in connected speech. Nature Neuroscience 19 (1), pp. 158–164. External Links: Document Cited by: Appendix B, §1.1.
C. Dyer, A. Kuncoro, M. Ballesteros, and N. A. Smith Recurrent neural network grammars. In Proceedings of NAACL-HLT, pp. 199–209. External Links: Document Cited by: §1.
R. Eldan and Y. Li TinyStories: how small can language models be and still speak coherent English?. External Links: 2305.07759, Link Cited by: 1st item, §2.
J. L. Elman Distributed representations, simple recurrent networks, and grammatical structure. Machine Learning 7, pp. 195–225. External Links: Document Cited by: Appendix B.
M. B. H. Everaert, M. A. C. Huybregts, N. Chomsky, R. C. Berwick, and J. J. Bolhuis Structures, not strings: linguistics as part of the cognitive sciences. Trends in Cognitive Sciences 19 (12), pp. 729–743. External Links: Document Cited by: §1.
O. Filatov, J. Ebert, J. Wang, and S. Kesselheim Time transfer: on optimal learning rate and batch size in the infinite data limit. External Links: Link Cited by: §4.1.
Z. Furman, S. Wäldchen, Y. Bei, and L. Hodgkinson Benign loss landscapes can coexist with worst-case hardness. External Links: 2609.13057, Link Cited by: §2.
R. Futrell and M. Hahn Linguistic structure from a bottleneck on sequential information processing. Nature Human Behaviour 10, pp. 589–600. External Links: Document Cited by: Appendix B, §1.1.
M. Ganardi, A. Jeż, and M. Lohrey Balancing straight-line programs. External Links: 1902.03568, Link Cited by: footnote 7.
I. Goodfellow, Y. Bengio, and A. Courville Deep learning. MIT Press. Cited by: Appendix B, §1.
J. Goodman A bit of progress in language modeling. External Links: cs/0108005, Link Cited by: Appendix B.
K. Gupta, B. Thérien, A. Ibrahim, M. L. Richter, Q. Anthony, E. Belilovsky, I. Rish, and T. Lesort Continual pre-training of large language models: how to (re)warm your model?. In ES-FoMo Workshop, International Conference on Machine Learning, External Links: Link Cited by: §H.1, §4.2.
J. Hale, C. Dyer, A. Kuncoro, and J. Brennan Finding syntax in human encephalography with beam search. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), I. Gurevych and Y. Miyao (Eds.), Melbourne, Australia, pp. 2727–2736. External Links: Link, Document Cited by: Appendix B, §1.1.
M. D. Hauser, N. Chomsky, and W. T. Fitch The faculty of language: what is it, who has it, and how did it evolve?. Science 298 (5598), pp. 1569–1579. External Links: Document Cited by: §1.
D. Hernandez, J. Kaplan, T. Henighan, and S. McCandlish Scaling laws for transfer. arXiv preprint arXiv:2102.01293. External Links: 2102.01293, Link Cited by: §4.2.
J. Hewitt and C. D. Manning A structural probe for finding syntax in word representations. In Proceedings of NAACL-HLT, pp. 4129–4138. External Links: Document Cited by: §1.
J. E. Hopcroft and J. D. Ullman Introduction to automata theory, languages, and computation. Addison-Wesley. Cited by: §1.
M. Y. Hu, J. Petty, C. Shi, W. Merrill, and T. Linzen Between circuits and Chomsky: pre-pretraining on formal languages imparts linguistic biases. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), Cited by: §4.2, §4.2.
A. Ibrahim, B. Thérien, K. Gupta, M. L. Richter, Q. Anthony, T. Lesort, E. Belilovsky, and I. Rish Simple and scalable strategies to continually pre-train large language models. Transactions on Machine Learning Research (TMLR). External Links: 2403.08763, Link Cited by: §H.1, §4.2.
S. Ishikawa, R. Yokota, and R. Karakida Measuring the local shape of learning-rate transfer curves. External Links: 2610.21814, Link Cited by: §4.1.
B. Isik, N. Ponomareva, H. Hazimeh, D. Paparas, S. Vassilvitskii, and S. Koyejo Scaling laws for downstream task performance in machine translation. In International Conference on Learning Representations (ICLR), External Links: 2402.04177, Link Cited by: §H.1, §4.2.
D. S. Kalra and M. Barkeshli Quantifying hyperparameter transfer and the importance of embedding layer learning rate. External Links: 2605.21486, Link Cited by: §G.2.
D. S. Kalra nanoGPT-mup. Note: https://github.com/dayal-kalra/nanoGPT-mup(Slight modifications made by authors) Cited by: Appendix F.
Y. Kim, C. Dyer, and A. M. Rush Compound probabilistic context-free grammars for grammar induction. In Proceedings of ACL, pp. 2369–2385. External Links: Document Cited by: §1.
D. Klein and C. 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, External Links: Document Cited by: §1.
A. Kosson, J. Welborn, Y. Liu, M. Jaggi, and X. Chen Weight decay may matter more than µp for learning rate transfer in practice. In The Fourteenth International Conference on Learning Representations, External Links: Link Cited by: §4.1.
A. Krishnan, J. Alabi, and D. Klakow On the n-gram approximation of pre-trained language models. External Links: 2306.06892, Link Cited by: Appendix B, Appendix D, §3.1.
A. Kuncoro, C. Dyer, L. Rimell, S. Clark, and P. Blunsom LSTMs can learn syntax-sensitive dependencies well, but modeling structure makes them better. In Proceedings of ACL, pp. 1426–1436. External Links: Document Cited by: §1.
K. Lari and S. J. Young The estimation of stochastic context-free grammars using the inside-outside algorithm. Computer Speech & Language 4 (1), pp. 35–56. External Links: Document Cited by: Appendix B.
Y. LeCun, I. Kanter, and S. A. Solla Eigenvalues of covariance matrices: application to neural-network learning. Phys. Rev. Lett. 66, pp. 2396–2399. External Links: Document, Link Cited by: §4.1.
K. Lee, D. Ippolito, A. Nystrom, C. Zhang, D. Eck, C. Callison-Burch, and N. Carlini Deduplicating training data makes language models better. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), S. Muresan, P. Nakov, and A. Villavicencio (Eds.), Dublin, Ireland, pp. 8424–8445. External Links: Link, Document Cited by: §4.1.
H. Li, W. Zheng, Q. Wang, H. Zhang, Z. Wang, S. Xuyang, Y. Fan, Z. Ding, H. Wang, N. Ding, S. Zhou, X. Zhang, and D. Jiang Predictable scale: part i, step law – optimal hyperparameter scaling law in large language model pretraining. External Links: 2503.04715, Link Cited by: §4.1.
H. Li, L. Liu, G. Huang, and S. Shi On the branching bias of syntax extracted from pre-trained language models. External Links: 2010.02448, Link Cited by: Appendix K.
H. W. Lin and M. Tegmark Critical behavior in physics and probabilistic formal languages. Entropy 19 (7), pp. 299. External Links: Document Cited by: §E.2.
J. Liu, S. Min, L. Zettlemoyer, Y. Choi, and H. Hajishirzi Infini-gram: scaling unbounded n-gram language models to a trillion tokens. External Links: 2401.17377, Link Cited by: Appendix B, Appendix D, §1.1, §3.1.
L. Loconte, A. Mari, G. Gala, R. Peharz, C. de Campos, E. Quaeghebeur, G. Vessio, and A. Vergari What is the relationship between tensor factorizations and circuits (and how can we exploit it)?. External Links: 2409.07953, Link Cited by: Appendix B, §2.
L. Loconte et al. Multiplicative interactions and low-rank tensor approximations. arXiv preprint arXiv:2409.07953. Cited by: §7.
L. Madaan, S. Bhojanapalli, H. Jain, and P. Jain Treeformer: dense gradient trees for efficient attention computation. In ICLR, Cited by: Appendix B.
S. G. Mallat A theory for multiresolution signal decomposition: the wavelet representation. IEEE Transactions on Pattern Analysis and Machine Intelligence 11 (7), pp. 674–693. External Links: Document Cited by: §E.1, Appendix E.
S. Merity, C. Xiong, J. Bradbury, and R. Socher Pointer sentinel mixture models. In International Conference on Learning Representations, External Links: Link Cited by: §2.
J. Miller, G. Rabusseau, and J. Terilla Tensor networks for probabilistic sequence modeling. In AISTATS, Cited by: Appendix B, Appendix B, Appendix D, §1.1, §3.1.
M. Nakamura and K. 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), Glasgow, Scotland, pp. 731–734. Cited by: Appendix B.
G. G. Naumis and G. 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), pp. 286. External Links: Document, Link Cited by: Table 4, Appendix L.
T. Nguyen Understanding transformers via n-gram statistics. In Advances in Neural Information Processing Systems, A. Globerson, L. Mackey, D. Belgrave, A. Fan, U. Paquet, J. Tomczak, and C. Zhang (Eds.), Vol. 37, pp. 98049–98082. External Links: Document, Link Cited by: Appendix B, Appendix D, §3.1.
C. Pallier, A. Devauchelle, and S. Dehaene Cortical representation of the constituent structure of sentences. Proceedings of the National Academy of Sciences 108 (6), pp. 2522–2527. External Links: Document, Link, https://www.pnas.org/doi/pdf/10.1073/pnas.1018711108 Cited by: Appendix B, §1.1.
I. Papadimitriou and D. 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), Cited by: §4.2.
A. P. Parikh, A. Saluja, C. Dyer, and E. Xing Language modeling with power low rank ensembles. In Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), Doha, Qatar, pp. 1487–1498. External Links: Document, Link Cited by: Appendix B, Appendix B, §1.1.
A. P. Parikh, A. Saluja, C. Dyer, and E. Xing Language modeling with power low rank ensembles. In Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing, pp. 1487–1498. External Links: Document, Link Cited by: Appendix D, §3.1.
G. Penedo, H. Kydlíček, L. B. allal, A. Lozhkov, M. Mitchell, C. Raffel, L. V. Werra, and T. Wolf The fineweb datasets: decanting the web for the finest text data at scale. In The Thirty-eight Conference on Neural Information Processing Systems Datasets and Benchmarks Track, External Links: Link Cited by: §2.
V. Pestun and Y. Vlassopoulos Tensor network language model. arXiv preprint arXiv:1710.10248. Cited by: Appendix B, Appendix B.
B. T. Polyak Some methods of speeding up the convergence of iteration methods. USSR Computational Mathematics and Mathematical Physics 4 (5), pp. 1–17. External Links: Document Cited by: §E.5.
N. Razin, A. Maman, and N. Cohen Implicit regularization in hierarchical tensor factorization and deep convolutional neural networks. External Links: 2201.11729, Link Cited by: §2.
R. Ri and Y. 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), Cited by: §4.2.
C. E. Shannon Prediction and entropy of printed English. Bell System Technical Journal 30 (1), pp. 50–64. External Links: Document Cited by: §1.
Y. Shen, S. Tan, A. Sordoni, and A. Courville Ordered neurons: integrating tree structures into recurrent neural networks. In ICLR, Cited by: Appendix B.
L. Song, M. Ishteva, A. Parikh, E. Xing, and H. Park Hierarchical tensor decomposition of latent tree graphical models. In Proceedings of the 30th International Conference on Machine Learning, S. Dasgupta and D. McAllester (Eds.), Proceedings of Machine Learning Research, Vol. 28, Atlanta, Georgia, USA, pp. 334–342. External Links: Link Cited by: §2.
B. Sorscher, R. Geirhos, S. Shekhar, S. Ganguli, and A. S. Morcos Beyond neural scaling laws: beating power law scaling via data pruning. External Links: 2206.14486, Link Cited by: §4.1.
Z. Su, Y. Zhou, F. Mo, and J. G. Simonsen Language modeling using tensor trains. arXiv preprint arXiv:2405.04590. Cited by: Appendix B, Appendix B, Appendix D, §1.1, §3.1.
A. Svete, N. Borenstein, M. Zhou, I. Augenstein, and R. Cotterell Can transformers learn -gram language models?. In Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, Y. Al-Onaizan, M. Bansal, and Y. Chen (Eds.), Miami, Florida, USA, pp. 9851–9867. External Links: Link, Document Cited by: Appendix B.
K. S. Tai, R. Socher, and C. D. Manning Improved semantic representations from tree-structured long short-term memory networks. In ACL, Cited by: Appendix B.
S. Thurner, R. Hanel, B. Liu, and B. Corominas-Murtra Understanding Zipf’s law of word frequencies through sample-space collapse in sentence formation. Journal of the Royal Society Interface 12 (108), pp. 20150330. External Links: Document Cited by: Appendix B, §1.1.
A. Varre, G. Yüce, and N. Flammarion Learning in-context -grams with transformers: sub--grams are near-stationary points. In Proceedings of the 42nd International Conference on Machine Learning, Proceedings of Machine Learning Research, Vol. 267, pp. 60924–60963. Cited by: Appendix B.
A. Williams, A. Drozdov, and S. R. Bowman Do latent tree learning models identify meaningful structure in sentences?. Transactions of the Association for Computational Linguistics 6, pp. 253–267. Cited by: Appendix B, §6.
G.W. Wornell and A.V. Oppenheim Estimation of fractal signals from noisy measurements using wavelets. IEEE Transactions on Signal Processing 40 (3), pp. 611–623. External Links: Document Cited by: Appendix E.
G. W. Wornell and A. V. Oppenheim Estimation of fractal signals from noisy measurements using wavelets. IEEE Transactions on Signal Processing 40 (3), pp. 611–623. External Links: Document Cited by: §4.1.
G. Yang, E. J. Hu, I. Babuschkin, S. Sidor, X. Liu, D. Farhi, N. Ryder, J. Pachocki, W. Chen, and J. Gao Tensor programs V: tuning large neural networks via zero-shot hyperparameter transfer. External Links: 2203.03466, Link Cited by: §4.1.
S. Yang, Y. Zhao, and K. 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, Online, pp. 1487–1498. External Links: Document, Link Cited by: Appendix B.
X. Yang, H. Getz, and E. G. Wilcox Function words as statistical cues for language learning. External Links: 2601.21191, Link Cited by: Appendix B, §1.1.
S. Yao, B. Peng, C. Papadimitriou, and K. 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), Online, pp. 3770–3785. External Links: Document, Link Cited by: §1.1.
O. K. Yüksel, R. A. Lucendo, and N. Flammarion Incremental learning of sparse attention patterns in transformers. External Links: 2602.19143, Link Cited by: Appendix B.
M. Zaheer, S. Kottur, S. Ravanbakhsh, B. Poczos, R. Salakhutdinov, and A. Smola Deep sets. In Advances in Neural Information Processing Systems, Cited by: §6.
Appendix A 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.
Appendix B 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, 1956) used finite-state Markov models, phrase-structure grammars and transformational grammars. The theory of formal languages classifies grammars by their generative capacity (Chomsky, 1959). 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 and Schützenberger, 1963). Later work extended context-free grammars into stochastic models by assigning probabilities to production rules (Booth, 1969; Lari and Young, 1990), while synthetic grammatical data became a controlled setting for studying whether neural networks can learn hierarchical structure (Elman, 1991). More recently, there has been a growing interest in understanding models of data with randomly chosen underlying rules, eg. the Random Language Model (DeGiuli, 2019) and the Random Hierarchy Model (Cagnetta et al., 2024). The justification for such hierarchical structures comes from theoretical studies (Chomsky, 1957), statistical analysis (Thurner et al., 2015; Goodfellow et al., 2016), information theory (Futrell and Hahn, 2026; Yang et al., 2026) and cognitive representations (Crain and Nakayama, 1987; Pallier et al., 2011; Ding et al., 2016; Hale et al., 2018). 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 and Goodman, 1996); PLRE takes advantages of conditional factorization into lower-rank tensors (Parikh et al., 2014a); Some algorithms use backoff (Goodman, 2001; Nakamura and Shikano, 1989) or scales by brute force (Brants et al., 2007) up to the unbounded suffix-array construction of infini-gram (Liu et al., 2025)
A different method is to approximate this with factorized tensor sequence models, MPS and tensor-train models. (Pestun and Vlassopoulos, 2017; Miller et al., 2021; Su et al., 2024) We use (Loconte et al., 2025) as a primary motivation for our rank- tensor factorization.
Neural networks can also be used for a parametric estimation. This has been tried by (Castro et al., 1999) with MLPs and one-hot encodings, (Bengio et al., 2003b) with MLPs and learnable encodings, (Blat et al., 2005) 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, 2024; Krishnan et al., 2023; Cagnetta et al., 2026; Cagnetta et al., 2025)
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., 2016). MPS uses bond dimension (Pestun and Vlassopoulos, 2017; Miller et al., 2021; Su et al., 2024) (Yang et al., 2021) uses latent state size, while (Parikh et al., 2014a) 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., 2024) and (Varre et al., 2025) in an in-context setting. (Yüksel et al., 2026) 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., 2015) while (Choi et al., 2018) learns the composition order (tree) with a Gümbel relaxation. (Shen et al., 2019) forces a soft hierarchy into a recurrent net’s gates. A key tension arises with (Williams et al., 2018), 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., 2023) uses a decision-tree index over keys.
Appendix C Details of the architecture
C.1 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 .
Appendix D Description of -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 (Chen and Goodman, 1996; Parikh et al., 2014b). 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 (Liu et al., 2025). 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 (Balle et al., 2014). 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 (Miller et al., 2021) is a Born machine, , with a single core shared across positions. The tree tensor network (tree TN) of (Cheng et al., 2019) 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., 2024) 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 ( nats) and falls to near the unigram level from on. Tree-grams outperform all three at every shared order, by nats at and 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., 1999) (MLP) or through learnable embedding structure (Bengio et al., 2003b) (neural LM). Later works combined MLP with a unigram model (Blat et al., 2005) 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, 2024; Krishnan et al., 2023; Cagnetta et al., 2026). 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 Fig. 1b, tree-grams track these estimators through approximately , while the deep references remain lower at larger . However, in Fig. 1(c), cross-entropy decreases monotonically as the rank increases over the tested range.
Appendix E 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., 2024) and the wavelet analysis of (Wornell and Oppenheim, 1992a; Mallat, 1989). 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 .
E.1 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, 1989). 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.
E.2 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 (Lin and Tegmark, 2017). 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 .
E.3 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.
E.4 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 . Equation 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 random draws of the , we use Gaussian feature draws and minimize the sample-average cross-entropy plus the ridge penalty. At the numerical optimum, the median of is , , and at , , and , 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 then .
E.5 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 (Polyak, 1964; Danilova and Malinovsky, 2022). Nesterov’s method, and , commonly uses and (Assran and Rabbat, 2020). 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 .
E.6 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.
Appendix F 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 M-token training split of TinyStories, tokenized with a custom BPE tokenizer (Cagnetta et al., 2026), and validate on a M-token subset of its M-token validation split.
Every run trains for a single epoch over the M training tokens, cut into non-overlapping windows of tokens with 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 of steps and then follows a cosine decay to 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 nats (), and at most nats for the other - and -sweep cells; it reaches 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 , 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 for one epoch on the same windows as the tree-grams, with the same warmup from , decaying to of the peak, and with dropout . The transformers were based on (Kalra, 2025).
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 Wiki-Text and TinyStories, and is equal to one and a half days for FineWeb-Edu (which has a larger vocabulary size).
WT (130 MT) TS (529 MT) FWE (1.05 BT) Cores Model 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.
F.1 Parameter-matched transformer configurations
Table 3 gives the transformer width used for each tree-gram and transformer depth in Fig. 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.
Table 3: Exact parameter-matched transformer widths. Tree parameters include embeddings.
tree-gram Tree params Transformer width by depth 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
Appendix G HP transfer experiment details
G.1 Learning rate sweeps
For the hyper-parameter-transfer study in Fig. 3, all transformers use eight heads, , GELU, RoPE, tied embeddings, no dropout, sequence length and batch ( tokens per step). Every proxy and every target trains for one epoch over the full M-token training split of its corpus ( steps), so a proxy trained on real data differs from its target only in width. We use AdamW with , and weight decay , a linear warmup from over the first of steps, and a cosine decay to of the peak.
Proxy widths are at , each trained on all eleven corpora of Fig. 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 spans at and at the wider widths, and seeds and 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.
G.2 Continuous from a smoothing spline
In order to get a more precise estimate of we use a cubic smoothing spline as discussed in (Kalra and Barkeshli, 2026). Writing , we discard points with , fit a cubic smoothing spline to with smoothing parameter , evaluate it at 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 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 sweeps no descending increment exceeds nats while the smallest increment the rule flags is , so it separates basin from cliff without ever truncating a basin, and the median residual falls to 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 – at and – at , against a rung of .
Appendix H Finetuning experiment details
H.1 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 M-token subset of the target’s validation split.
Pre-training. Each source is pre-trained for one epoch over its segment ( 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 Gupta et al. (2023); Ibrahim et al. (2024), with no replay of source data. The fine-tuning peak rate is set per (source, target) pair: , snapped to the lattice, where comes from a one-seed sweep over a shared 22-point window. Tuning the rate per model follows Isik et al. (2025) ; re-warming to the pre-training peak instead trades adaptation against forgetting Gupta et al. (2023), and we score only the target.
Budgets and references. The matrix is read after the full M fine-tuning tokens ( steps). For a synthetic target, the floor is its generator’s entropy rate (Eq. 9). For real TinyStories we use nats, the converged loss of the 12-layer, GPT-2 of (Cagnetta et al., 2026) 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 M real tokens, at (within one lattice step of their own optimum on this budget), reach nats at and nats at (medians of three seeds), that is and on the scale of Fig. 5(c,d).
Appendix I 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 (Fig. 9).
- A per-position cross-entropy comparison of every tree-gram in the sweep against itsparameter-matched transformers, at every depth (Fig. 10).
- The HP tuning results on FineWeb-Edu (Fig. 11).
- The transfer phase diagram over every (proxy width, target width) pair, contrasting the median-over-synthetics rule with tuning on the real corpus (Fig. 12).
- The raw loss-versus-learning-rate curves for different widths on different datasets, with the spline-function interpolated values. (Fig. 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 (Fig 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 (Fig. 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 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 (M to M). The tree-gram tracks the transformer family exactly for the first few positions in every panel and peels away only at long context.
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.
Appendix J 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 (Fig. 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 (Fig. 18, bottom). The range term has the same sign and nearly the same size in all four settings.
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.
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.
Appendix K 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 (Fig. 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 (Li et al., 2020). In addition, we contrast this token recovery pattern in four different network ablations: trained and untrained tree-grams with or without residual connections (Fig. 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 (solid) and (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 Fig. 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).
Appendix L 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 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.
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 (Naumis and Cocho, 2007).
log-RMSE AICc KS KL Model s0 s1 s0 s1 s0 s1 s0 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
For the power law with a generalized exponential cutoff is best on every measure for both seeds, with log-scale and . For the broken power law has the lowest log-RMSE and AICc for both seeds ( and ), 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 for against and for , while (–) and (–) vary about as much between the two seeds of one router as between routers. The most probable paths carry and of the mass for and and for , but their identity does not reproduce: the two seeds of a router share none of their most probable paths, and only () and () of their top , against about 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 (Naumis and Cocho, 2007).
Appendix M Examples of generated text
Samples from fixed tree-grams on TinyStories (BPE-) at temperature , 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.
I. Width sweep — varies at
, ( 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. H ina’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
, ( 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
, ( 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
, ( 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?”
, ( 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
II. Context sweep — varies at
, ( 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
, ( 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
, ( 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
, ( 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
, ( 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