Manuscript Offprint
arXiv:2610.35965Generalization in Learning: Eyring Formula and Predator-prey Model
Abstract
In this work, generalization in machine learning is investigated using a predator-prey model. We overview biological and chemical interpretation of the stochastic gradient Langevin dynamics and generative adversarial network. For a particular example of recovering an unknown function by a polynomial of fixed degree from a set of noisy data, the predator-prey model provides better approximation compared to the gradient descent method. Further, thermodynamical arguments, in particular Eyring formula, are used to explain grokking (delayed generalization) phenomenon in machine learning.
Keywords: overfitting, predator–prey model, stochastic gradient descent
1 Introduction
In this work, we provide, following the general physical and biological approaches to overfitting control in machine learning developed in [1], a more detailed study of the abilities of the predator-prey model to control overfitting using the example of reconstruction of an unknown function from noisy data, and outline possible application of thermodynamical arguments to grokking. The standard approach to machine learning is based on the optimization by the stochastic gradient descent [2]. In [1] and here, following [3, 4], we consider stochastic gradient descent in the form of the stochastic gradient Langevin dynamics with random walk in the potential which is given by the risk functional. This approach allows to apply known methods of thermodynamics theory to machine learning. In particular, the Eyring formula in kinetic theory [5] describes selection of wide minima in optimization by stochastic gradient Langevin dynamics and therefore explains better generalization ability for stochastic gradient optimization. Here we consider overfitting control in the framework of the algorithmic stability approach, more precisely, by suppressing narrow minima of the empirical risk functional. We also consider the generative adversarial network (GAN) model [6] as a mathematical predator-prey model in biology, where the discriminator and
*kozyrev@mi-ras.ru, Steklov Mathematical Institute of Russian Academy of Sciences, Moscow, Russia
ilya.lopatin2606@gmail.com, Steklov Mathematical Institute of Russian Academy of Sciences, Moscow, Russia
apechen@gmail.com, Steklov Mathematical Institute of Russian Academy of Sciences, Moscow, Russia, and Ivannikov Institute for System Programming of the Russian Academy of Sciences, Moscow, Russia generator in GAN play the roles of the prey and predator, respectively. This allows to explain better generalization in GAN model by the predator pushing the prey out of narrow minima [1].
In Section 2, the stochastic gradient Langevin dynamics is described by a stochastic differential equation (SDE). The Eyring formula of chemical kinetics allows to explain the ability of better generalization for stochastic gradient optimization in the presence of noise [1].
In Section 3, we explain the grokking phenomenon [7] of delayed generalization using ideas of statistical physics. In particular fast memorization is described by a Brownian motion in potential (i.e., stochastic Langevin gradient descent) while delayed generalization is explained by a Brownian motion with zero potential.
In Section 4, the GAN model is described by a system of two stochastic differential equations which possess a biological interpretation as interaction between a predator and a prey. Learning for GANs by solving a system of ordinary differential equations was considered in [8, 9, 10].
In Section 5, we show for a particular problem of recovering an unknown function by a polynomial of fixed degree from a set of noisy data, that the predator-prey provides better approximation compared to the gradient descent method.
Section 6 (the Conclusion) summarizes the results.
2.1 Stochastic gradient Langevin dynamics
The statement of the learning problem is as follows. Let be given a sample , , a loss function , and a parameter called hypothesis (we assume that the hypothesis space is ). If , then the loss is absent. Minimization of the empirical risk is the following problem
If not important, we will omit the sample variable in the following.
Gradient descent algorithm for this problem (if the loss function is continuously differentiable) is given by the differential equation , which is numerically described by the iterative process with gradient step starting from some ,
We describe the stochastic gradient descent by the stochastic gradient Langevin dynamics
where are small independent Gaussian random vectors. In the continuous limit such evolution reduces to the stochastic differential equation
where is vector of Brownian motion coordinates , is the Wiener stochastic differential and is the temperature.
The stochastic gradient Langevin dynamics was discussed in [3, 4, 11, 12].
The Fokker–Planck equation for the Langevin dynamics (2) is the diffusion equation for the distribution function in the potential ,
where . This diffusion equation equivalently can be rewritten as
where is the inverse temperature. The Gibbs distribution, which is up to normalization proportional to , is a stationary solution of Eq. (3).
2.2 Generalization and Eyring formula
The lack of the ability to generalize for a solution of the learning problem (i.e., to have low risk on the training sample and high risk on the validation sample) is called overfitting. Overfitting is related to memorization instead of generalization for a given training sample. We exploit the approach of wide (flat) minima to generalization [13] which is related to the algorithmic stability [14, 15, 16].
It is known that adding noise to the gradient descent procedure improves the ability to generalization [2]. We will discuss this as follows. Eyring formula of kinetic theory states that the reaction rate [which is defined as the rate of transition between two potential wells due to diffusion of the form (3)] is proportional to the exponent
where is the free energy of the transition state (the saddle between the two potential wells) and is the free energy of the initial state of the reaction (the potential well from which the transition starts). The free energy of a state is , where E is the energy and S is the entropy of the state. In the general case, free energy of a set U (say a potential well) is defined as
The Eyring formula (4) implies that the transition rate will be lower (the free energy of the initial state will be lower) for potential wells with higher entropy (wider ones). Thus, a stochastic gradient Langevin dynamics (2) corresponds to a regime in which wider wells more effectively capture the learning system, i.e., algorithmically stable solutions to the learning problem should be most likely selected during the stochastic gradient optimization.
3 Grokking, thermodynamics and Eyring formula
In [7], the phenomenon of grokking (delayed generalization) in learning theory was discovered and discussed in [17, 18]. In [7], training of a neural network (a transformer consisting of a single-layer decoder) to perform the algorithm of modular arithmetic – addition of residues modulo a prime number (the prime number was chosen as ) was studied, other operations in the corresponding number field were also studied (multiplication, division, calculation of quadratic and cubic polynomials), and operations in the group of permutations of five elements were considered. For such problems the maximum size of the training sample is limited (in particular, for addition of two residues modulo the maximum sample size is ). It is also significant that the considered learning tasks had a solution in the form of a "structure", i.e., a simple algorithm (for example, an algorithm for addition modulo a prime number). The network was chosen to be overparameterized, i.e., the number of parameters was large, exceeding the size of the training sample.
The grokking effect was discovered, which includes two phenomena:
-
Training the neural network to achieve zero risk on the training sample (memorizing the training set) took about iterations of stochastic gradient descent. In this case, for the control sample total overfitting was observed. But after continuing running the stochastic gradient descent, after about iterations the effect of generalization (grokking) was achieved – almost zero risk was achieved on the control sample and overfitting disappeared. Regularization also found to have a positive effect on grokking.
-
The dependence of training time on the sample size was studied, a sharp increase in training time with a decrease in the sample size was found. In this case, the points representing the training time before achieving grokking approximately lie on a straight line in logarithmic coordinates. On one axis, the logarithm of the time to achieve 99% accuracy on the control sample, i.e., grokking, on the other axis, the sample size (the ratio of the size of the training sample to the size of the maximum possible sample for a given training problem). Therefore, the grokking time exponentially decreases with increasing sample.
Thus, in grokking, at first there was a relatively fast memorization of the training sample, and then a significantly slower disappearance of overfitting occurs. Let us explain the phenomenon of grokking from the point of view of thermodynamics and statistical physics.
Overparameterized networks are characterized by the presence of a whole region of parameters with zero risk for (1), in which and local minima merge into a manifold. Thus, in the region of zero risk we have . In order for the zero-risk region to contain the desired solution in the form of an algorithm (e.g., modular arithmetic), the entropy of the zero-risk manifold in practical situations should be high enough.
The first phase of grokking – memorization, i.e., achieving zero risk on the training sample, consists of achieving the zero-risk manifold . Stochastic gradient descent in this case consists of diffusion with drift in the region of non-zero gradient of the risk functional, i.e., the distance traveled in the parameter space towards the zero-risk manifold is approximately proportional to the training time (the number of steps of the stochastic gradient).
The second phase of grokking is described by moving the system along the zero-risk manifold towards the region of this manifold with high entropy. This process occurs according to the second law of thermodynamics (increase in the entropy). This movement has the form of a Brownian motion along the zero-risk manifold with zero gradient, hence the traveled distance is proportional to (the root of the number of steps of the stochastic gradient). It is worth noting that in [7] the first phase of grokking took about steps of the stochastic gradient, and the next one about steps (i.e., square of the memorization time).
As the size of the training sample increases, the zero-risk manifold decreases (since additional conditions are imposed for additional ). At the same time, a solution in the form of an algorithm ("structure") exists for any training sample. Thus, as the training sample grows, the zero-risk manifold shrinks toward a region with high entropy containing the desired solution in the form of an algorithm.
Suppose that the entropy of the zero-risk region decreases linearly with increasing sample size, i.e., the volume of such a region decreases exponentially. It can be assumed that imposing each additional condition for a new removes approximately the same percentage of the volume of the zero-risk manifold as the sample size increases. Such behavior will occur, for example, in the case where the zero-risk manifold is (initially) a multidimensional cube , and imposing the condition for some will mean imposing the constraint , on one of the cube coordinates. Then, by choosing independently at each step and imposing a constraint on the corresponding coordinate, we obtain an exponential decrease in the volume of the zero-risk region during the iteration of such a procedure.
Eyring’s formula gives an approximation of the dependence of the reciprocal of the grokking time on the sample size. Here is the free energy of the initial grokking region (part of the zero-risk manifold where the Brownian motion of grokking begins, i.e., we assume that entropy decreases and grows linearly with the growth of the training sample size) and is the transition state, i.e., the final grokking region (the neighborhood of the solution to the learning problem, this free energy changes weakly with the growth of the sample), in both cases only the entropic parts of the free energy are important. Recall that the free energy is , i.e., with the growth of the entropy of the initial state (i.e., the decrease in the sample) the transition time increases exponentially, which is observed in the experiment [7].
4 The GAN Model and generalization
The Generative Adversarial Network (GAN) model is a minimax problem [6]
Here , is a sample; and , called the discriminator and the generator, are parametric families of probability distributions on the space , and (we assume and to be real vector spaces) are parameters (hypotheses) for the discriminator and the generator, correspondingly. In [6], the generator was considered as a parametric family of mappings from some auxiliary space to , these mappings transferred the probability distribution on the auxiliary space to .
The functional V in Eqs. (5) and (6) has the form
The first contribution is the log-likelihood function. The second contribution behaves qualitatively as , where
and the Kullback–Leibler distance between probability distributions p and q is given by the formula
The stochastic gradient Langevin dynamics optimization procedure for the problem (5), (6) reduces to the system of SDEs for random walks on the spaces of the parameters of the discriminator and generator
Here and are Wiener processes on the parameter spaces of the discriminator and generator correspondingly; and are derivatives of V with respect to the first and second arguments, respectively.
In [8, 9, 10], oscillations of the parameters for the gradient descent optimization of the GAN model were discussed. In particular, for one-dimensional parameters x and y and functional the above system of equations (for zero noise) reduces to
and the solution oscillates around the minimax
Arguments on overfitting reduction for stochastic gradient descent are also applicable to the system (7) and (8) of SDEs for GAN [1].
The presence of the generator will suppress overfitting more effectively. By (7) discriminator will tend to reach local maximum of and by (8) generator will follow discriminator. This may be interpreted as a biological prey (discriminator) and predator (generator) model, where the predator pushes the prey out of narrow maxima of to reduce overfitting.
5 Reduction of overfitting for function recovery with a predator-prey model
In this section, we numerically show the reduction of overfitting by the "prey-predator" method introduced in [1] for a problem of reconstruction of an unknown function from a set of noisy data (i.e., regression). Let f be a hidden function, for which as a particular example for simulations we consider
Let be a training dataset, where with being independent normally distributed random variables with zero expectation and fixed dispersion. A test dataset is introduced analogously. Sampling examples of the training and test datasets of the hidden function with , produced by , with standard deviation 0.2 are shown on Fig. 1.
We are looking for an approximation of the hidden function f by polynomials of the degree d,
Train Data

Figure 1: Sampling examples of training and test datasets for the function .
which can be interpreted as a single-layer neural network. To find the coefficients , we consider the problem of minimizing the mean squared error (MSE) loss on the training sample,
The quality of the model is determined by the MSE on the test sample.
In the overfitting regime, loss on training samples decreases while loss on test samples increases. Let us consider the set of approximating polynomials (9) with degrees . For each degree, we run the same number of steps of gradient descent with the same learning rate
The results of the simulations are provided in Table 1 and Fig. 2.
The case corresponds to underfitting, i.e., the model with is unable to capture patterns in the data. The case corresponds to normal learning – the model captures the patterns. The cases correspond to overfitting, i.e., the model is too complex and is affected by the noise in the data.
In [1], we considered in learning a prey-predator model given by a system of stochastic differential equations. The prey u and the predator z with initial conditions were considered and their dynamics is given by
| Degree | 1 | 3 | 5 | 7 |
|---|---|---|---|---|
| Loss on train | 0.171 | 0.072 | 0.027 | 0.026 |
| Loss on test | 0.400 | 0.033 | 0.161 | 0.159 |
| Deviation from | 0.227 | 0.007 | 0.059 | 0.080 |
Table 1: Learning results for different degrees of polynomials. The last line of the table shows the MSE of the model predictions for the hidden function on a uniform grid on [-1, 1] with 1000 points.


Figure 2: Solid lines show approximations to the function (dashed lines) found by gradient descent after iterations for in (9). The train points are marked by 'x'.
where and are constant learning rates, the term provides repulsion of the prey from the predator
The following repulsion was considered
where , and are the parameters of the optimization. The first term is an approximation (at ) of the step function with shift , where is the characteristic interaction distance, the second term is the Yukawa potential providing the repulsion for short distances.
On Fig. 3 the final of totally iterations of the predator-prey model simulation are shown.

Distance between Prey and Predator
Distances between Average and Current
Figure 3: Simulation results for: (a) loss on train; (b) loss on test; (c) distance between the predator and the prey; (d) distance between the current state and the averaged state for the prey.
Here we use weighted moving average
After that, it is possible to select the best model by the minimum of the loss on test for the last N iterations for training by ordinary gradient descent and predator-prey method. We obtain the following results.
• The smallest MSE on the test sample at N last iterations decreased from 0.161 to 0.106.
• Deviation from the hidden function decreased from 0.0594 to 0.0334.
Figure 3 shows the process of oscillation corresponding to transitions between several minima. Moreover, as shown on Fig. 4 the deviation from the hidden function behaves in a similar way.
A possible interpretation of this behavior is as follows. The graph of the loss on train, besides extrema or "wells", also contains wide "lacunas" containing several closely located minima. For narrow minima instead of oscillations in one "well" we will observe jumps between the neighboring minima. Different minima in the same "lacuna" can have different loss on the test sample (up to 1.5–2 times difference). The applied algorithm allows to search several different nearby extrema and select the best ones. This kind of behavior is observed for all runs of the "predator–prey" model on other samples and with the same potential V.
In simulations it was observed that the trajectory of the (standard) gradient descent goes near the minimum of the loss function. Similar behavior is observed for the predator–prey model if the predator is sufficiently distant from the prey. The experiments show a significant improvement only for a sufficiently large number of iterations of the procedure.
Possible explanations for this effect are as follows. In this particular regression problem, we consider as the initial , which is close enough to the optimal that can be obtained when training the model for . Therefore, it is possible that the model first converges to the data "in general" (i.e., the situation of normal fitting), and then, with an oversize number of parameters, begins to be fitted to specific, noise features of the sample which corresponds to overfitting.
On the other hand, simulations for the "predator–prey" model show the reduction of overfitting, this effect can reach up to 1.5–2 times reduction.

Figure 4: Deviation of the model from the hidden function vs number of iterations.
6 Conclusion
In this paper, physical and biological approaches to explain better generalization in machine learning are discussed. We use the approach based on the selection of wide minima to control overfitting. Then, description of stochastic gradient descent by the stochastic Langevin dynamics (or Brownian motion in a potential) explains selection of wide minima and improved generalization for the stochastic gradient descent procedure. Moreover thermodynamic methods allow to explain grokking which is delayed generalization phenomenon. We also consider a biological-like predator-prey model, where improved generalization is provided by the effect of pushing out of prey from narrow maxima by the predator. We give a numerical simulation for a simple learning problem which justifies this statement.
FUNDING
This research was funded by Ministry of Science and Higher Education of the Russian Federation, grant number 075-15-2024-529.
Conflict of interest
The authors declare that they have no conflict of interest.
References
[1] S. V. Kozyrev, I. A. Lopatin, and A. N. Pechen, “Control of Overfitting with Physics”, Entropy, 26, 1090 (2024). arXiv: 2412.10716.
[2] A. V. Gasnikov, Modern numerical optimization methods (Moscow, MCCME, 2021) [in Russian].
[3] G. Parisi, “Correlation functions and computer simulations”, Nucl. Phys. B 180, 378–384 (1981). https://doi.org/10.1016/0550-3213(81)90056-0.
[4] G. Parisi, “Correlation functions and computer simulations II”, Nucl. Phys. B 205, 337–344 (1982). https://doi.org/10.1016/0550-3213(82)90360-1.
[5] H. Eyring, “The Activated Complex in Chemical Reactions”, J. Chem. Phys. 3, 107–115 (1935). https://doi.org/10.1063/1.1749604.
[6] I. Goodfellow, J. Pouget-Abadie, M. Mirza, B. Xu, D. Warde-Farley, S. Ozair, A. Courville, and Y. Bengio, “Generative Adversarial Nets”, In Proceedings of the NIPS Montreal, Canada, Desember 8–13, 2014 (2014). https://arxiv.org/abs/arXiv:1406.2661.
[7] A. Power, Y. Burda, H. Edwards, I. Babuschkin, and V. Misra, "Grokking: Generalization Beyond Overfitting on Small Algorithmic Datasets" (2022). https://arxiv.org/abs/arXiv:2201.02177
[8] C. Qin, Y. Wu, J. T. Springenberg, A. Brock, J. Donahue, T.P. Lillicrap, and P. Kohli, “Training Generative Adversarial Networks by Solving Ordinary Differential Equations”, In Proceedings of NeurIPS, Vancouver, Canada, Desember 6–12, 2020 (2020). https://arxiv.org/abs/arXiv:2010.15040
[9] V. Khrulkov, A. Babenko, and I. Oseledets, “Functional Space Analysis of Local GAN Convergence”, In Proceedings of the 38th International Conference on Machine Learning, Virtual, July 18–24 2021 (2021). https://arxiv.org/abs/arXiv:2102.04448
[10] V. Nagarajan and J. Z. Kolter, “Gradient descent GAN optimization is locally stable”, In Proceedings of the 31st Conference on Neural Information Processing Systems, Long Beach, USA, December 04–09 2017 (2017). https://arxiv.org/abs/arXiv:1706.04156
[11] S. Geman and C.-R. Hwang, “Diffusions for Global Optimization”, SIAM J. Control Optim. 24, 1031–1043 (1986). https://doi.org/10.1137/0324060
[12] M. Welling and Y. W. Teh, “Bayesian Learning via Stochastic Gradient Langevin Dynamics”, In Proceedings of the 28th International Conference on Machine Learning, Bellevue, USA, June 28 – July 2 2011 (2011).
[13] S. Hochreiter and J. Schmidhuber, “Flat Minima”, Neural Comput. 9, 1–42 (1997). https://doi.org/10.1162/neco.1997.9.1.1
[14] O. Bousquet and A. Elisseeff, “Stability and Generalization”, J. Mach. Learn. Res. 2, 499–526 (2002).
[15] S. Kutin and P. Niyogi, “Almost-everywhere algorithmic stability and generalization error”, In Proceedings of the 18th Conference on Uncertainty in Artificial Intelligence, Alberta, Canada, August 1–4 2002 (2002). https://arxiv.org/abs/arXiv:1301.0579
[16] T. Poggio, R. Rifkin, S. Mukherjee, and P. Niyogi, “General conditions for predictivity in learning theory”, Nature 428, 419–422 (2004). https://doi.org/10.1038/nature02341.
[17] Z. Liu, O. Kitouni, N. Nolte, E. J. Michaud, M. Tegmark, and M. Williams, "Towards Understanding Grokking: An Effective Theory of Representation Learning" (2022). https://arxiv.org/abs/arXiv:2205.10343
[18] N. Nanda, L. Chan, T. Lieberum, J. Smith, and J. Steinhardt, "Progress measures for grokking via mechanistic interpretability" (2023). https://arxiv.org/abs/arXiv:2301.05217