Learning Curve Theory

Marcus Hutter

Introduction

Power laws in large-scale machine learning. The ‘mantra’ of modern machine learning is ‘bigger is better’. The larger and deeper Neural Networks (NNs) are, the more data they are fed, the longer they are trained, the better they perform. Apart from the problem of overfitting [BHM18] and the associated recent phenomenon of double-descent [BHMM19], this in itself is rather unsurprising. But recently ‘bigger is better’ has been experimentally quantified, most notably by Baidu [HNA+17] and OpenAI [HKK+20, KMH+20, HKHM21]. They observe that the error or test loss decreases as a power law, with the data size, with the model size (number of NN parameters), as well as with the compute budget used for training, assuming one factor is not “bottlenecked” by the other two factors. If all three factors are increased appropriately in tandem, the loss has power-law scaling over a very wide range of data/model size and compute budget.

If there is intrinsic noise in the data (or a non-vanishing model mis-specification), the loss can never reach zero, but at best can converge to the intrinsic entropy of the data (or the intrinsic representation=approximation error). When we talk about error, we mean test loss with this potential offset subtracted, similar to regret in online learning.

Ubiquity/universality of power laws. Power laws have been observed for many problem types (supervised, unsupervised, transfer learning) and data types (images, video, text, even math) and many NN architectures (Transformers, ConvNets, …) [HNA+17, RRBS19, HKK+20, KMH+20]. This has led some to the belief that power laws might be universal: Whatever the problem, data, model, or learning algorithm, learning curves follow power laws. To which extent this conjecture is true, we do not know, since theoretical understanding of this phenomenon is largely lacking. Below we review some (proto)theory we are aware of.

Theory: Scaling with model size. Consider a function f:[0;1]d\textrightarrowRf:[0;1]^{d}\textrightarrow ℝ which we wish to approximate. A naive approximation is to discretize the hyper-cube to an εε-grid. This constitutes a model with m=(1/ε)dm=(1/ε)^{d} parameters, and if ff is LL-Lipschitz, can approximate ff to accuracy L⋅ε=L⋅m−1/dL⋅ε=L⋅m^{-1/d}, i.e. the (absolute) error scales with model size mm as a power law with exponent −1/d-1/d. More generally, there exist (actually linear) models with mm parameters that can approximate all functions ff whose first kk derivatives are bounded to accuracy O(m−k/d)O(m^{-k/d}) [Mha96], again a power law, and without further assumptions, no reasonable model can do better [DHM89]; see [Pin99] for reformulations and discussions of these results in the context of NNs. Not being aware of this early theoretical work, this scaling law has very recently been empirically verified and extended by [SK20]. Instead of naively using the input dimension dd, they determine and use the (fractal) dimension of the data distribution in the penultimate layer of the NN.

Theory: Scaling with compute. Most NNs are trained by some form of stochastic gradient descent, efficiently implemented in the form of back-propagation. Hence compute is proportional to number of iterations ii times batch-size times model size. So studying the scaling of error with the number of iterations tells us how error scales with compute. The loss landscape of NNs is highly irregular, which makes theoretical analyses cumbersome at best. At least asymptotically, the loss is locally convex, hence the well-understood stochastic (and online) convex optimization could be a first (but possibly misleading) path to search for theoretical understanding of scaling with compute. The error of most stochastic/online optimization algorithms scales as a power law i−1/2i^{-1/2} or i−1i^{-1} for convex functions [Bub15, Haz16].

Theory: Scaling with data size. Even less is theoretically known about scaling with data size. [Cho20] and [HNA+17] consider a very simple Bernoulli model: Essentially they observe that the Bernoulli parameter can be estimated to accuracy 1/n1/\sqrt{n} from nn i.i.d samples, i.e. the absolute loss (also) scales with 1/n1/\sqrt{n} [HNA+17] and the log-loss or KL-divergence scales with 1/n1/n [Cho20]. Indeed, the latter holds for any loss, locally quadratic at the minimum, so is not at all due to special properties of KL as [Cho20] suggests. These observations trivially follow from the central limit theorem for virtually any finitely-parameterized model in the under-parameterized regime of more-data-than-parameters. This is of course always the case for their Bernoulli model, which only has one parameter, but not necessarily for the over-parameterized regime some modern NNs work in. Anyway, the scaling laws identified by OpenAI et al. are n−βn^{-β}, for various β<1/2β<1/2, which neither the Bernoulli nor any finite-dimensional model can explain.

Data size vs iterations vs compute. Above we have used the fact that compute is (usually in deep learning) proportional to number of learning iterations, provided batch and model size are kept fixed. In addition,

in online learning, every data item is used only once, hence the size of data used up to iteration nn is proportional to nn.

This is also true for stochastic learning algorithms for some recent networks, such as GPT-3, trained on massive data sets, where every data item is used at most once (with high probability).

When generating artificial data, it is natural to generate a new data item for each iteration.

Hence in all of these 3 settings, the learning curves, error-with-data-size, error-with-iterations, and error-with-compute, are scaled versions of each other. For this reason, scaling of error with iterations, also tells us how error scales with data size and even with compute, but scaling with model size is different.

This work. In this work we focus on scaling with data size nn. As explained above, any reasonable finitely-parameterized model and reasonable loss function leads to a scaling law n−βn^{-β} with β=12β={\textstyle\frac{1}{2}} or β=1β=1, but not the observed β<12β<{\textstyle\frac{1}{2}}. We therefore conjecture that any theoretical explanation of power laws for a variety ββ (beyond 0-1 and absolute error implying β=12β={\textstyle\frac{1}{2}} and locally-quadratic loss implying β=1β=1) requires real-world data of unbounded complexity, that is, no finite-dimensional model can “explain” all information in the data.

Possible modelling choices are (a) scaling up the model with data, or (b) consider non-parametric models (e.g. kNN or Gaussian processes), or (c) a model with (countably-)infinitely-many parameters. We choose (c) for mathematical simplicity compared to (b), and because (c) clearly separates scaling with data from scaling with model size, unlike (a). In future, (a) and (b) should definitely also be pursued, in particular, since we have no indication that our findings transfer.

Within our toy model, we show that for domains of unbounded complexity, a large variety of learning curves are possible, including non-power-laws. It is plausible that this remains true for most infinite models. Real data is often Zipf distributed (e.g. the frequency of words in text), which is itself a power law. We show that this, in our toy model, implies power law learning curves with “interesting” ββ, though most (even non-Zipf) distributions also lead to power laws but with “uninteresting” ββ.

Contents. In Section 2 we introduce our setup: classification with countable “feature” space and a memorizing algorithm, the simplest model and algorithm we could come up with that exhibits interesting/relevant scaling behavior. In Section 3 we derive and discuss general expressions for expected learning curves and for various specific data distributions: finite, Zipf, exponential, and beyond, many but not all lead to power laws. In Section 4 we estimate the uncertainty in empirical learning curves. We show that the signal-to-noise ratio deteriorates with nn, which implies that many (costly) runs need to be averaged in practice to get a smooth learning curve. On the other hand, the signal-to-noise ratio of the time-averaged learning curves tends to infinity, hence even a single run suffices for large nn. In Section 5 we perform some simple control experiments to confirm and illustrate the theory and claims, and the accuracy of the theoretical expressions. In Section 6 we discuss (potential) extensions of our toy model towards a more comprehensive and realistic theory of scaling laws: noisy labels, other loss functions, continuous features, models that generalize, and deep learning. Section 7 concludes with limitations and potential applications. Appendix A discusses losses beyond 0-1 loss. Appendix B contains derivations of the expected error, and in particular exact and approximate expressions for the time-averaged variance. Appendix C considers noisy labels. Appendix D derives an approximation of sums by integrals, tailored to our purpose. Appendix E lists notation. Appendix F contains some mores plots.

Setup

We formally introduce our setup, model, algorithm, and loss function in this section: We consider classification problems with 0-1 loss and countable feature space. A natural practical example application would be classifying words w.r.t. some criterion. Our toy model is a deterministic classifier for features/words sampled i.i.d. w.r.t. to some distribution. Our toy algorithm predicts/recalls the class for a new feature from a previously observed (feature,class) pair, or acts randomly on a novel feature. The probability of an erroneous prediction is hence proportional to the probability of observing a new feature, which formally is equivalent to the model in [Cha81]. The usage and analyses of the model and resulting expressions are totally different though. While [Cha81]’s aim is to develop estimators for the probability of discovering a new species from data whatever the unknown true underlying probabilities, we are interested in the relationship between the true probability distribution of the data and the resulting learning curves, i.e. the scaling of expected (averaged) error with sample size. In Appendix A we show that, within a for our purpose irrelevant multiplicative constant, the results also apply to most other loss functions.

The toy algorithm. We consider a simple tabulation learning algorithm A:N×(N×Y)∗\textrightarrowYA:ℕ×(ℕ×{\cal Y})^{*}\textrightarrow{\cal Y} that stores all past labelled features Dn{\cal D}_{n} and on next feature in+1=ii_{n+1}=i recalls yty_{t} if it=ii_{t}=i, i.e. feature ii has appeared in the past, or outputs, in its simplest instantiation, undefined if i∉i1:ni\not\in i_{1:n} i.e. is new. Formally:

Error. Algorithm AA only makes an error predicting label yn+1y_{n+1} if i∉i1:ni\not\in i_{1:n}. We say AA makes 1 unit of error in this case. Formally, the (instantaneous) error En\text{\sf E}_{n} of algorithm AA when predicting yn+1y_{n+1} from Dn{\cal D}_{n} is defined as

The expectation of this w.r.t. to the random choice of Dn{\cal D}_{n} and in+1i_{n+1} gives the expected (instantaneous) error

A formal derivation is given in Appendix B, but the result is also intuitive: If feature ii has not been observed so far (which happens with probability (1−θi)n(1-θ_{i})^{n}), and then feature ii is observed (which happens with probability θiθ_{i}), the algorithm makes an error. \text{\sf E\!\!\!\!\;E}_{n} as a function of nn constitutes an (expected) learning curve, which we will henceforth study. In Appendix A we show that expression (2) remains valid within an irrelevant multiplicative constant for most other loss functions.

Expected Learning Curves

We now derive theoretical expected learning curves for various underlying data distributions. We derive exact and approximate, general and specific expressions for the scaling of expected error with sample size. Specifically we consider finite models, which lead to exponential error decay, and infinite Zipf distributions, which lead to interesting power laws with power β<1β<1. Interestingly even highly skewed data distributions lead to power laws, albeit with “uninteresting” power β=1β=1.

Exponential decay. In the simplest case of mm of the θiθ_{i} being equal and the rest being , the error \text{\sf E\!\!\!\!\;E}_{n}=(1-{\textstyle\frac{1}{m}})^{n}≈e^{-n/m} decays exponentially with nn. This is not too interesting to us, since (a) this case corresponds to a finite model (see above), (b) exponential decay is an “artifact” of the deterministic label and discontinuous 0-1 error, and (c) will become a power law 1/n1/n after time-averaging (Section 4).

Superposition of exponentials. Since (2) is invariant under bijective renumbering of features i∈Ni∈ℕ, we can w.l.g. assume θ1≥θ2≥θ3≥...θ_{1}≥θ_{2}≥θ_{3}≥.... Some θθs may be equal. If we group equal θθs together into θˉˉj\bar{\bar{θ}}_{j} with multiplicity mj>0m_{j}>0 and define ϑˉˉj:=−ln⁡(1−θˉˉj)\bar{\bar{ϑ}}_{j}:=-\ln(1-\bar{\bar{θ}}_{j}), then

where M∈N∪{∞}M∈ℕ∪\{∞\} is the number of different θi>0θ_{i}>0. This is a superposition of exponentials in nn (note that ∑j=1Mmjθˉˉj=1∑_{j=1}^{M}m_{j}\bar{\bar{θ}}_{j}=1) with different decay rates ϑˉˉj\bar{\bar{ϑ}}_{j}. If different θˉˉj\bar{\bar{θ}}_{j} have widely different magnitudes and/or for suitable multiplicities mjm_{j}, the sum will be dominated by different terms at different “times” nn. So there will be different phases of exponential decay, starting with fast decay e−nϑˉˉ1e^{-n\bar{\bar{ϑ}}_{1}} for small nn, taken over by slower decay e−nϑˉˉ2e^{-n\bar{\bar{ϑ}}_{2}} for larger nn, and e−nϑˉˉ3e^{-n\bar{\bar{ϑ}}_{3}} for even larger nn, etc. though some terms may never (exclusively) dominate, or phases may be unidentifiably muddled together (see figure above). In any case, if M=∞M=∞, the dominant terms shift indefinitely to ever smaller θθ for ever larger nn. For M<∞M<∞ eventually e−nϑˉˉMe^{-n\bar{\bar{ϑ}}_{M}} for the smallest ϑˉˉ\bar{\bar{ϑ}} will dominate \text{\sf E\!\!\!\!\;E}_{n}. The same caveats (a)-(c) apply as for M=1M=1 in the previous paragraph.

Approximations. First, in our subsequent analysis we (can) approximate (1−θi)n=:e−nϑi≈e−nθi(1-θ_{i})^{n}=:e^{-nϑ_{i}}≈e^{-nθ_{i}}, justified as follows: (i) For nθi≪1nθ_{i}\ll 1 this is an excellent approximation. (ii) For θi≪1θ_{i}\ll 1, ϑi≈θiϑ_{i}≈θ_{i}, while numerically e−nϑi/e−nθi≉1e^{-nϑ_{i}}/e^{-nθ_{i}}\not≈1 for nθi≫1nθ_{i}\gg 1, but the exponential scaling of e−nϑie^{-nϑ_{i}} and e−nθie^{-nθ_{i}} we care about is sufficiently similar. (iii) There can only be a finite number of θi≪̸1θ_{i}\not\ll 1, say, θiθ_{i} for i≤i0i≤i_{0} are not small, then already for moderately large n≫1/θi0n\gg 1/θ_{i_{0}}, all features i≤i0i≤i_{0} are observed with high probability and hence do not contribute (much) to the expected error (formally e−nθi≪1e^{-nθ_{{}_{i}}}\ll 1 for i≤i0i≤i_{0}) hence can safely be ignored in any asymptotic analysis.

Second, let f:R\textrightarrowRf:ℝ\textrightarrow ℝ be a smooth and monotone decreasing interpolation of θ:N\textrightarrowR{\bm{θ}}:ℕ\textrightarrow ℝ, i.e. f(i):=θif(i):=θ_{i} and f′(x)≤0f^{\prime}(x)≤0. We can then approximate the error as follows:

The first ≈≈ uses the two approximations introduced above. The equality follows from a reparametrization u=f(x)u=f(x) and f(1)=θ1f(1)=θ_{1} and f(∞)=0f(∞)=0 and dx=du/f′(x)dx=du/f^{\prime}(x) and f′<0f^{\prime}<0. The numerator ue−nuue^{-nu} is maximal and (strongly) concentrated around u=1/nu=1/n, hence u≈1/nu≈1/n gives most of the integral’s contribution. Therefore replacing uu by 1/n1/n in the denominator can be a reasonable approximation. The last ≈≈ follows from this and ∫0θ1ue−nudu≈∫0∞ue−nudu=1/n2∫_{0}^{θ_{1}}ue^{-nu}du≈∫_{0}^{∞}ue^{-nu}du=1/n^{2} for nθ1≫1nθ_{1}\gg 1.

Intuitively, the expected error (2) is dominated by samples i0i_{0} for which θi0≈1nθ_{i_{0}}≈{\textstyle\frac{1}{n}}. Estimating the number of such i0i_{0} multiplied by θi0(1−θi0)n≈θi0e−1θ_{i_{0}}(1-θ_{i_{0}})^{n}≈θ_{i_{0}}e^{-1} leads to approximation (3). In Appendix B we show that the approximation error of the integral representation is bounded by 1/en+o(1/n)1/en+o(1/n).

Zipf-distributed data. Empirically many data have been observed to have a power-law distribution, called Zipf distribution in this context, that is, for a countable domain the frequency of the iith most frequent item is approximately proportional to i−(α+1)i^{-(α+1)} for some α>0α>0. In our model this will be the case if θi∝i−(α+1)θ_{i}\propto i^{-(α+1)}, so let u=f(x)=α⋅x−(α+1)u=f(x)=α⋅x^{-(α+1)}. This implies x=f−1(u)=(u/α)−1/(1+α)x=f^{-1}(u)=(u/α)^{-1/(1+α)} and f′(x)=−α(α+1)x−(α+2)=−α(α+1)(u/α)(α+2)/(α+1)f^{\prime}(x)=-α(α+1)x^{-(α+2)}=-α(α+1)(u/α)^{(α+2)/(α+1)}, hence

That is, Zipf-distributed data (with power α+1α+1) lead to a power-law learning curve (with power β=α1+α<1β={α\over 1+α}<1). The more accurate integral representation leads to the same power law but with correct coefficient \text{\sf E\!\!\!\!\;E}_{n}≈c_{α}n^{-β} with cα=α1/(α+1)Γ(α1+α)/(α+1)c_{α}=α^{1/(α+1)}Γ({α\over 1+α})/(α+1). c1=12π =˙ 0.886c_{1}={\textstyle\frac{1}{2}}\sqrt{\pi}~{}\dot{=}~{}0.886 and c0.1=1.177c_{0.1}=1.177 in excellent agreement with the fit curves in Figure 2.

Exponentially-distributed data. An exponential data distribution θi∝e−γiθ_{i}\propto e^{-γi} is more skewed than any power law. For u=f(x)=γ⋅e−γxu=f(x)=γ⋅e^{-γx} we have x=f−1(u)=1γln⁡γux=f^{-1}(u)={\textstyle\frac{1}{γ}}\ln{\textstyle\frac{γ}{u}} and f′(x)=−γ2e−γx=−γuf^{\prime}(x)=-γ^{2}e^{-γx}=-γu, hence both approximations in (3) give 1/γn1/γn. A rigorous upper bound \text{\sf E\!\!\!\!\;E}_{n}≤({\textstyle\frac{1}{e}}+{\textstyle\frac{1}{γ}}){\textstyle\frac{1}{n}} follows from (11) in Appendix B, and a rigorous lower bound \text{\sf E\!\!\!\!\;E}_{n}\smash{\stackrel{{\scriptstyle×}}{{≥}}}{\textstyle\frac{1}{n}} from the next paragraph. So even an exponential data distribution leads to a power law learning curve, though the exponent 11 is much larger than observed in (most) experiments, which hints at that data are not exponentially distributed, assuming this toy model has any real-world relevance.

Beyond exponentially-distributed data. For (quite unrealistic) decay faster than exponentially, e.g. θi∝e−γi2θ_{i}\propto e^{-γi^{2}}, the approximations (3) are too crude, but somewhat surprisingly we always get a (sort of) power law as long as θi>0θ_{i}>0 for infinitely many ii. First, the previous paragraph implies that \text{\sf E\!\!\!\!\;E}_{n}\smash{\stackrel{{\scriptstyle×}}{{≤}}}n^{-1} for any θi≤×e−γiθ_{i}\smash{\stackrel{{\scriptstyle×}}{{≤}}}e^{-γi} for any γ>0γ>0, i.e. the error decreases at least with n−1n^{-1} if the iith item has at most exponentially small probability in ii. For a (partial) converse, define ni:=⌈1/ϑi⌉≤1/ϑi+1n_{i}:=\lceil 1/ϑ_{i}\rceil≤1/ϑ_{i}+1. Plugging ϑi:=−ln⁡(1−θi)≥θiϑ_{i}:=-\ln(1-θ_{i})≥θ_{i} and 2θi≥ϑi≥1/ni2θ_{i}≥ϑ_{i}≥1/n_{i} for θi<0.79θ_{i}<0.79 into \text{\sf E\!\!\!\!\;E}_{n}≥θ_{i}(1-θ_{i})^{n}=θ_{i}e^{-nϑ_{i}} we get

Hence, if θi>0θ_{i}>0 for infinitely many ii, then there are infinitely many nn for which \text{\sf E\!\!\!\!\;E}_{n}\smash{\stackrel{{\scriptstyle×}}{{≥}}}n^{-1}. For θiθ_{i} going to zero exponentially or slower, the spacing between ni+1n_{i+1} and nin_{i} has bounded ratio ni+1/ni≤eγn_{i+1}/n_{i}≤e^{γ}, which implies \text{\sf E\!\!\!\!\;E}_{n}\smash{\stackrel{{\scriptstyle×}}{{≥}}}n^{-1} for all nn. For faster decaying θiθ_{i}, e.g. θi=e−γi2θ_{i}=e^{-γi^{2}} this is no longer the case. So in some weak sense, power law learning curves are universal, but it’s mostly 1/n1/n, so not useful to explain observed power laws.

Learning Curve Variance

Instantaneous Variance. En∈{0,1}\text{\sf E}_{n}∈\{0,1\}, hence En2=En\text{\sf E}_{n}^{2}=\text{\sf E}_{n}, hence

Since μn\textrightarrow0μ_{n}\textrightarrow 0 for n\textrightarrow∞n\textrightarrow∞, the standard deviation

That is, the standard deviation is much larger than then mean for large nn. Indeed, for a single run, there is no proper learning curve at all, since En∈{0,1}\text{\sf E}_{n}∈\{0,1\} (see Figures 4&5 top left). In order to get a good signal-to-noise ratio one would need to average a large (and indeed increasing with nn) number k≫1/μnk\gg 1/μ_{n} of runs (see Figures 1&4&5).

Time-averaged Mean and Variance. In practice, beyond averaging over runs, other averages are performed to reduce noise.One alternative is to report the time-averaged error E‾\overline{\text{\sf E}}, rather than the instantaneous error E. We can calculate its mean and variance as follows

where (a)(a) is simple algebra, (b)(b) follows from inserting the definition of E‾N\overline{\text{\sf E}}_{N} and some rather tedious algebraic manipulations (see Appendix B), and (c)(c) from inserting (a)(a) and (b)(b) into the definition of variance and simple algebraic manipulation. We now revisit the exponential and Zipf case studied earlier, after a trivial but note-worthy observation.

Case θi=1m[ ⁣[i≤m] ⁣]θ_{i}={\textstyle\frac{1}{m}}[\![i≤m]\!]. In this case, while \text{\sf E\!\!\!\!\;E}_{n}=(1-{\textstyle\frac{1}{m}})^{n}≈e^{-n/m} decays exponentially, the average quantities decay with 1/N1/N (or 1/N21/N^{2}):

Case θi∝i−(α+1)θ_{i}\propto i^{-(α+1)}. Recall that for Zipf-distribution θi∝i−(α+1)θ_{i}\propto i^{-(α+1)}, the expected error followed power law \text{\sf E\!\!\!\!\;E}_{n}≈c_{α}n^{-β}, where 0<β=α1+α<10<β={α\over 1+α}<1. The time-averaged error

follows the same power law with the emphsame exponent ββ, which is a generic property as foreshadowed earlier. As for the variance, we show in Appendix B that

That is, the standard deviation is much smaller than then mean. A single run suffices to get a good (and excellent for n≳500n\gtrsim 500) signal-to-noise ratio for the averaged and cumulative error (see Figures 2&3&6 (right) and Figures 4&5 (top left)). Still, the infinite Zipf model leads to a more noisy learning curve than the finite uniform model. Intuitively, for every NN, new iN+1∉i1:Ni_{N+1}\not\in i_{1:N} have small but sufficient chance, contributing to the error and variance, decreasing exponentially in the uniform model, but only as a power law in the Zipf model.

To prove the limit \textrightarrow0\textrightarrow 0 we have to distinguish two cases: First note that \text{\sf E\!\!\!\!\;E}_{n} is monotone decreasing (\text{\sf E\!\!\!\!\;E}_{n}\!\!\!\searrow). (i) For bounded total error ∑_{n=0}^{∞}\text{\sf E\!\!\!\!\;E}_{n}≤c (e.g. exponential error decay in finite models), \text{\sf E\!\!\!\!\;E}_{n}\!\!\!\searrow implies \text{\sf E\!\!\!\!\;E}_{N}=o(1/N), which implies that the numerator tends to 0; the denominator is lower-bound by \text{\sf E\!\!\!\!\;E}_{0}=1. (ii) For unbounded total error ∑_{n=0}^{N-1}\text{\sf E\!\!\!\!\;E}_{n}\textrightarrow∞ (most infinite models, e.g. Zipf and even exponential θiθ_{i}), we factor the denominator as \sum_{n=0}^{N-1}\text{\sf E\!\!\!\!\;E}_{n}≡\sqrt{\smash{Σ_{n=0}^{N-1}}\text{\sf E\!\!\!\!\;E}_{n}}⋅\sqrt{\smash{Σ_{n=0}^{N-1}}\text{\sf E\!\!\!\!\;E}_{n}} and lower-bound one term by \sum_{n=0}^{N-1}\text{\sf E\!\!\!\!\;E}_{n}≥N\text{\sf E\!\!\!\!\;E}_{N}, which is true since \text{\sf E\!\!\!\!\;E}_{n}\!\!\!\searrow.

Experiments

We performed some control experiments to verify the correctness of the theory and claims, and the accuracy of the theoretical expressions.

Fitting power laws to learning curves. We now fit power laws to the learning curves of (exactly) Zipf distributed data. Figure 2 shows fits for synthetic data with Zipf-exponents α=1α=1 and α=0.1α=0.1. The fit is “perfect” except for very small values of nn. This is consistent with our approximation, which is good for nθ1≫1nθ_{1}\gg 1. Theoretically we expect and empirically we found the approximation (3) to be good for nθ1≳2nθ_{1}\gtrsim 2. For α=1α=1 we have θ1=0.5θ_{1}=0.5, hence the approximation should be good for n≳4n\gtrsim 4, while for α=0.1α=0.1 we have θ1 =˙ 0.067θ_{1}~{}\dot{=}~{}0.067, hence the approximation should be good for n≳30n\gtrsim 30; both are consistent with the plots. To avoid clutter we only present expected curves. They perfectly match the averaged curves over infinitely many runs anyway (see Figures 1&5). The fitted power law exponents β^\hat{β} are also close to the theoretical predictions β=α1+αβ={\textstyle\frac{α}{1+α}} (12=0.5{\textstyle\frac{1}{2}}=0.5 for α=1α=1 and 111 =˙ 0.091{\textstyle\frac{1}{11}}~{}\dot{=}~{}0.091 for α=0.1α=0.1).

Text data. It is well-known that the frequency of a word in typical texts is about inversely proportional to its rank in the frequency table: The most frequent word (‘the’) occurs about twice as often as the second most frequent word (‘a’), about three times as often as the third most frequent word, and so on. That is, word frequency follows a Zipf distribution with α≈0α≈0. Figures 3&6 (left) show the frequency distributions of the first 20469 words in file ‘book1’ of the Calgary Corpus. Apart from the steps, caused by word frequencies being integers, the distribution is very close to Zipf. Note that more than half of the words only appear once. Figures 3 (right) shows the learning curves for any word classification task. The power-law fit is reasonably good, but not perfect. The reason is the step structure of especially rare words. Indeed, many θθs are equal, and only finitely many are non-zero, so the learning curve is a finite superposition of exponentials as in (3). For moderate nn this mixture amalgamates to an approximately power law. For large nn, the error decays exponentially as exp⁡(−θminn)\exp(-θ_{min}n). Indeed, for larger nn, Figures 6 shows that the power fit becomes worse, and the true error decays faster than the fit power law. Note that for α≤0α≤0, i−(α+1)i^{-(α+1)} is not summable, hence any such distribution must break down after some ii, our approximation becomes invalid, and β≤0β≤0 makes no sense in any case.

Extensions

In the following we discuss some potential extensions of the toy model. Some look feasible, others are hard or wishful thinking. We discuss the more realistic case of noisy labels, other loss functions, continuous features, and more realistic models that generalize, e.g. deep learning algorithms.

Noisy labels. In most machine learning applications, labels (or more general targets) are themselves noisy, not just the feature vector x∈Xx∈{\cal X}, e.g. y=h(x)+y=h(x)+Noise. The major implications are as follows:

The learning algorithms need to be a bit smarter than just memorization, e.g. predicting the average or by majority.

Due to the label noise, the error cannot converge to anymore but to the intrinsic “entropy”, which should be subtracted before studying scaling.

For absolute (locally quadratic) loss there will be an extra n−1/2n^{-1/2} (n−1n^{-1}) additive error term due to parameter estimation error, hence

the instantaneous loss will not decay exponentially anymore even if the model is finite.

Otherwise the scaling laws for Zipf data are unchanged.

In summary, the error/loss should be a sum of 3 terms, at least conceptually:

the parameter learning rate n−1/2n^{-1/2} for absolute loss, squared, i.e. n−1n^{-1} for (locally) quadratic loss,

the same power law n−βn^{-β} as in the deterministic case.

Other loss functions. For our deterministic toy model, the loss function has little to no influence on the results as discussed in Appendix A. For noisy labels, this also seems to be the case, except that n−β0n^{-β_{0}} is now the fastest possible decay, with β0β_{0} depending on the loss-function: β0=12β_{0}={\textstyle\frac{1}{2}} for absolute loss and β0=1β_{0}=1 for locally quadratic loss such as KL and square. Loss functions with any (other) value of β0>0β_{0}>0 are possible but rare. This is another potential universality of scaling laws, their independence from the loss function for large models.

Continuous features. Countable feature spaces have some applications, e.g. in NLP, words can be identified with integer features i∈Ni∈ℕ. In most applications, feature spaces are (effectively) continuous, often vector spaces Rdℝ^{d}, and no feature ever repeats exactly (xn≠xmx_{n}≠x_{m} for n≠mn≠m). A simple model with a continuous domain is the Dirichlet Process, or the essentially equivalent Chinese Restaurant Process (CRP) and Stick-Breaking process. In the CRP, the continuous domain is essentially reduced to an exponentially distributed countable number of sticks=features, leading to power law learning curves n−βn^{-β}, but the exponent is restricted to β=1β=1, which is too limiting. But even the CRP is not exactly a special case of our toy model and much harder to analyse. In some form of “mean-field” approximation it reduces to a special case of our model. The generalized 2-parameter Poison Dirichlet Process [BH10] also only leads to β=1β=1. Finding analytically tractable models with continuous features that exhibit interesting learning curves remains an open problem.

Generalizing algorithms. Proper models/algorithms for continuous features need to generalize from observed inputs to similar future not-yet-observed inputs, which is at the heart of virtually all interesting machine learning model/algorithms. Such models are much more varied and harder to analyze. If the domain could be partitioned into countably many cells, each cell containing only sufficiently similar features, and this can be done a-priori and is fixed independent of the actually realized data Dn{\cal D}_{n} and most importantly independent of the data size nn, we arrive back at our countable toy model (usually with noisy labels) and our analysis (nearly) applies. But it is more plausible that a suitable partitioning, e.g. clustering of data, is in itself data (size) dependent, and hence will affect the scaling. A more interesting non-parametric model, potentially amenable to theoretical analysis, is kk-Nearest-Neighbors (kNN), likely with interesting learning curves. The ‘perfect prediction for exact repetition’ in our toy model can be viewed as an abstraction of ‘classify features in the same cell alike’ which itself is a toy model for ‘classify similar observations alike or similarly’, so maybe some of our findings or analysis tools approximately transfer.

Deep learning. (Deep) neural networks are a particularly powerful class of models/algorithms that can generalize, but are also notoriously difficult to theoretically analyse. It may be a long way from our toy model to a similar analysis of NNs. Furthermore we have not at all considered the equally interesting questions of scaling with model size and compute.

Discussion

Summary. We introduced a very simple model that can exhibit power laws (decrease of error with data size) consistent with recent findings in deep learning. The model is plausibly the simplest such model, and that choice was deliberate to not get bogged down with intractable math or forced into crude approximations or bounds at this early stage of investigation. Many but not all data distributions lead to power laws. We do not know whether the discovered specific relation between the Zipf exponent αα and the power law exponent β=α/(1+α)β=α/(1+α) is an artifact of the model, or has wider validity beyond this model. The signal-to-noise ratio for the time-averaged error tend to zero, which implies that a single experimental run suffices for stable results.

Limitations. The toy model studied in this work is admittedly totally unrealistic as a Deep Learning model, but we believe it captures the (or at least a) true reason for the observed scaling laws w.r.t. data. Whether it has any predictive power, or can be generalized to NNs and/or scaling laws for model size and/or compute, is beyond the scope of this paper. We hope that this initial investigation spurs more advanced theoretical investigations, and ultimately lead to predictive models. We have outlined some ideas in Section 6, some (more) are hopefully feasible. In any case, finding the simplest model which captures the essence is a necessary first step, and we believe our toy model fits this bill.

Applications. Besides providing scientific insight, a good theoretical understanding of scaling laws could ultimately help tune network and algorithm parameters in a more principled way, and thus save significant compute for finding good large NNs by reducing hyper-parameter sweeps. The cost of training recent models has reached millions of dollars and can exhaust and exceed even FAANGs computational resources.

Acknowledgements. I thank David Budden and Jörg Bornschein for encouraging me to look into the topic of scaling laws, and for interesting discussions.

References

Appendix A Other Loss Functions

We can (slightly) generalize the learning algorithm AA to other loss functions and behaviors on in+1∉i1:ni_{n+1}\not\in i_{1:n}. We continue to assume that A′A^{\prime} suffers Lossn=0\text{\sf Loss}_{n}=0 if i∈i1:ni∈i_{1:n} by using stored Dn{\cal D}_{n}. Assume A′A^{\prime} suffers Lossn\text{\sf Loss}_{n} if in+1∉i1:ni_{n+1}\not\in i_{1:n}, then

and this fact holds even more generally. Since a multiplicative constant in the loss is irrelevant from a scaling perspective, all scaling results for \text{\sf E\!\!\!\!\;E}_{n} also apply to this (slightly) more general setting.

Appendix B Derivation of Expectation and Variance

Expectation. Recall the error of (the basic form of) Algorithm AA is En=[ ⁣[in+1∉i1:n] ⁣]\text{\sf E}_{n}=[\![i_{n+1}\not\in i_{1:n}]\!]. Hence the probability that Algorithm AA makes an error under distribution θ{\bm{θ}} given data Dn{\cal D}_{n} is

The expectaion of this w.r.t. Dn{\cal D}_{n} is

The result can actually more easily be derived as

but the former derivation is more suitable for generalization to other loss functions and noisy labels.

Approximation. Let f:(0;∞)\textrightarrow(0;∞)f:(0;∞)\textrightarrow(0;∞) be a continuously differentiable and decreasing extension of θ:N\textrightarrowR{\bm{θ}}:ℕ\textrightarrow ℝ, i.e. f(i):=θif(i):=θ_{i} and f′(x)<0f^{\prime}(x)<0. Let g(x):=f(x)e−nf(x)g(x):=f(x)e^{-nf(x)}. Since u↦ue−nuu\mapsto ue^{-nu} is unimodal with maximum 1/en1/en and at u=1/nu=1/n and ff is monotone, g(x)g(x) is unimodal with maximum gmax=1/eng_{max}=1/en at xmax=f−1(1n)x_{max}=f^{-1}({\textstyle\frac{1}{n}}). We hence can use (18) (any a∈[0;1]a∈[0;1]) to upper bound the sum in (10) by an integral as follows:

where the last equality follows from a reparametrization u=f(x)u=f(x) and f(∞)=0f(∞)=0 and dx=du/f′(x)dx=du/f^{\prime}(x) and f′<0f^{\prime}<0.

For a lower bound, we need a lower bound on (1−θi)n(1-θ_{i})^{n}. For 0≤x≤2ε0≤x≤2ε we have

Let us choose i0i_{0} such that θi0≥ε(1−ε)θ_{i_{0}}≥ε(1-ε), which is possible as long as θi≥12θi−1θ_{i}≥{\textstyle\frac{1}{2}}θ_{i-1}. This finally leads to

Since we can choose εε arbitrarily small, combining both bounds, and choosing a\textrightarrow0a\textrightarrow 0 and ff such that f(x)\textrightarrow∞f(x)\textrightarrow∞ for x\textrightarrow0x\textrightarrow 0, we have

The integral is dominated by u≲1nu\lesssim{\textstyle\frac{1}{n}}, so for large nn is determined by the asymptotics of f′(f−1(u))f^{\prime}(f^{-1}(u)) for u\textrightarrow0u\textrightarrow 0. Assume

Zipf distribution. For Zipf-distributed θi=αi−(α+1)θ_{i}=αi^{-(α+1)}, let u=f(x)=α⋅x−(α+1)u=f(x)=α⋅x^{-(α+1)}. This implies

hence approximation (12) is actually exact with δ=α+2α+1δ={\textstyle\frac{α+2}{α+1}} and c′=α(α+1)/α(α+2)/(α+1)c^{\prime}=α(α+1)/α^{(α+2)/(α+1)} leading to

Time-averaged expectation and variance. We now consider the time-averaged error

where (b)(b) breaks up the double sum into lower=upper and diagonal terms. Since m<nm<n we have

Putting everything together, non-diagonal i≠ji≠j and diagonal i=ji=j expressions we get our final expression

In order to get the variance of E‾N\overline{\text{\sf E}}_{N} we have to subtract the squared expected error

where we expanded the product and separated the i≠ji≠j from the i=ji=j terms, which now easily leads to

Approximation. We can approximate the variance similarly to the expectation \text{\sf E\!\!\!\!\;E}_{n}. We only provide a heuristic derivation analogous to (3):

Appendix C Noisy Labels

Here we generalize our model to noisy labels. We first derive generic expression expressions for (somewhat) general algorithm and loss. We then instantiate them for frequency estimation and square loss. Finally we outline how to derive similar expressions for the absolute loss.

The most naive learning algorithm would predict γiγ_{i} from observed frequencies: Ai=ki/niA_{i}=k_{i}/n_{i} if feature ii occurred ni:=#{t≤n:it=i}n_{i}:=\#\{t≤n:i_{t}=i\} times and has label 11 for ki:=#{t≤n:it=i,yt=1}k_{i}:=\#\{t≤n:i_{t}=i,y_{t}=1\} times. Obviously ki/ni\textrightarrowγik_{i}/n_{i}\textrightarrow γ_{i} provided ni\textrightarrow∞n_{i}\textrightarrow∞, hence Lossn(A∣Dn,in+1=i)\text{\sf Loss}_{n}(A|{\cal D}_{n},i_{n+1}=i) converges to the intrinsic label “entropy” γi(1−γi)γ_{i}(1-γ_{i}), rather than to , which has to be subtracted for a power law analysis to make sense. Similarly the expectation of log-loss −yln⁡Ai−(1−y)ln⁡(1−Ai)-y\ln A_{i}-(1-y)\ln(1-A_{i}) w.r.t. γiγ_{i} leads to Kullback-Leibler loss KL(γi∣∣Ai)\text{KL}(γ_{i}||A_{i}) + Entropy H(γi)H(γ_{i}). More generally let us assume A(i,Dn)A(i,{\cal D}_{n}) depends (somehow) only on kik_{i} and nin_{i} (e.g. Laplace rule), and hence

where ∑Dn:ki,ni\sum_{{\cal D}_{n}:k_{i},n_{i}} means that the sum is restricted to Dn{\cal D}_{n} for which ii ((i,1)(i,1)) appears nin_{i} (kik_{i}) times. The probability of each of this happening is binomial:

This is obvious or follows by explicit calculation of the sums and some algebra. Putting everything together and finally taking the expectation over ii we get

where (a) follows from substituting ni=k−1n_{i}=k-1 and rearranging terms, and (b) from adding and subtracting the missing k=0k=0 contribution, and the fact that a complete binomial sums to 1. If we assume that the noise level is the same for all features, i.e. γi=γγ_{i}=γ or γi=1−γγ_{i}=1-γ, then

Again, in the deterministic case γ∈{0,1}γ∈\{0,1\}, we get back \text{\sf Loss}_{n}(A)=\text{\sf E\!\!\!\!\;E}_{n}. If we assume that γiγ_{i} are bounded away from 0 and 1, then still within a multiplicative constant

Appendix D Approximating Sums by Integrals

Sums ∑i=1∞g(i)∑_{i=1}^{∞}g(i) can be approximated by integrals ∫1∞g(x)dx∫_{1}^{∞}g(x)dx. To upper bound the approximation error classically requires computing a cumbersome integral (Euler-Maclaurin remainder) or only works for finite sums (Trapezoid rule). In the following we derive an upper bound on the approximation accuracy, suitable for our purpose. First, note that for a monotone increasing function

with inequalities reversed for monotone decreasing functions. Consider now any measurable function g:[0;∞)\textrightarrow[0;∞)g:[0;∞)\textrightarrow[0;∞) increasing up to gmax=g(xmax)g_{max}=g(x_{max}) and thereafter decreasing (In our application g(x)=f(x)e−nf(x)g(x)=f(x)e^{-nf(x)}). Let im−1≤xmax≤imi_{m-1}≤x_{max}≤i_{m}. We split the integral into the increasing and decreasing part and use (17) to lower-bound the error:

To obtain an upper bound we have to exclude im−1i_{m-1} and imi_{m} from the sums:

Together this leads to the following bound on the approximation error:

for any=every choice of a∈[0;1]a∈[0;1]. Without further assumptions on gg, this bound is tight. For the lower bound consider g(x)=gmaxg(x)=g_{max} for im−1<x<imi_{m-1}<x<i_{m} and otherwise. For the upper bound consider g(im)=gmaxg(i_{m})=g_{max} and otherwise.

Appendix E List of Notation

Appendix F More Figures