Can Transformers Do Enumerative Geometry?

## Abstract

Abstract. How can Transformers model and learn enumerative geometry? What is a robust procedure for using Transformers in abductive knowledge discovery within a mathematician-machine collaboration?
In this work, we introduce a new paradigm in computational enumerative geometry in analyzing the ψ 𝜓 \psi italic_ψ -class intersection numbers on the moduli space of curves.
By formulating the enumerative problem as a continuous optimization task, we develop a Transformer-based model for computing ψ 𝜓 \psi italic_ψ -class intersection numbers based on the underlying quantum Airy structure. For a finite range of genera, our model is capable of regressing intersection numbers that span an extremely wide range of values, from 10 − 45 superscript 10 45 10^{-45} 10 start_POSTSUPERSCRIPT - 45 end_POSTSUPERSCRIPT to 10 45 superscript 10 45 10^{45} 10 start_POSTSUPERSCRIPT 45 end_POSTSUPERSCRIPT .
To provide a proper inductive bias for capturing the recursive behavior of intersection numbers, we propose a new activation function, Dynamic Range Activator (DRA).
Moreover, given the severe heteroscedasticity of ψ 𝜓 \psi italic_ψ -class intersections and the required precision, we quantify the uncertainty of the predictions using Conformal Prediction with a dynamic sliding window that is aware of the number of marked points. Next, we go beyond merely computing intersection numbers and explore the enumerative “world-model” of the Transformers. Through a series of causal inference and correlational interpretability analyses, we demonstrate that Transformers are actually modeling Virasoro constraints in a purely data-driven manner.
Additionally, we provide evidence for the comprehension of several values appearing in the large genus asymptotic of ψ 𝜓 \psi italic_ψ -class intersection numbers through abductive hypothesis testing.

## 1. Introduction

Enumerative geometry is a fascinating branch of mathematics concerned with counting geometric objects or finding invariants that satisfy certain geometric conditions (see for instance [mumford1983towards, katz2006enumerative]). The objects of interest are typically complex curves that need to match a specific geometric blueprint. A classical question in enumerative geometry is: How many conics pass through five given points in the plane? A more contemporary question is: How many rational curves of degree one are there on a quintic threefold?

Approaching such problems often requires recursive computational methods. However, these methods can become computationally expensive and even infeasible, even for relatively small values of the parameters of interest. This is where we propose using Machine Learning (ML), particularly Transformers [vaswani2023attentionneed], to overcome this challenge. While recent work with Transformers, especially in Large Language Models (LLMs) [zhao2023survey], has focused on their ability to solve problems in natural language processing and image generation, these models still struggle with complex recursive and mathematical reasoning tasks in a zero-shot setting. This limitation is particularly critical in fields that require deep, structured mathematical reasoning. By incorporating Transformers as a primary tool in enumerative geometry, specifically for approximating $\psi$-class intersection numbers, we aim to address the computational complexity overhead and explore several important questions.
Traditional methods for computing these numbers, given genus $g$ and $n$ marked points, are computationally expensive with a complexity of $O(g!\cdot 2^{n})$.
These intersection numbers are famously computed by the Korteweg–de Vries equation [witten1991two, kontsevich1992intersection] and are of paramount importance in the study of various geometric and physical problems, such as Weil–Petersson volumes, Hurwitz numbers, Gromov–Witten invariants, and topological 2D quantum gravity.
Going further, we investigate whether our proposed model is capable of causal and abductive reasoning for knowledge discovery. Specifically, we ask if we can conduct parametric inference and extract mathematical insights from its internal understanding, beyond the raw data provided, to offer intuition and potentially generate new conjectures.

It is well known that Transformer-based models have difficulty with even periodic patterns, let alone recursive problems [ziyin2020neural]. Therefore, we first examine the architectural design choices and training pipeline variants necessary for learning the recursive reasoning processes involved in topological recursion [eynard2007invariants]. To this end, we introduce a non-linear activation function, the Dynamic Range Activator (DRA), which is particularly suited for learning recursive functions. Consequently, we develop DynamicFormer, a modified Transformer-based model designed to predict $\psi$-class intersection numbers given the quantum Airy structure [kontsevich2018airy] initial data. Additionally, we believe that a predictive model without uncertainty estimation is inherently unreliable. Therefore, we incorporate uncertainty quantification into our model’s predictions using Conformal Prediction [shafer2008tutorial].

To the best of our knowledge, this is the first time Transformers have been applied to enumerative problems in algebraic geometry, while also employing interpretability analysis [chefer2021transformer, liu2024interpretable, kantamneni2024transformers] to extract knowledge and illuminate the model’s internal understanding of deep research-level mathematical concepts. Thus, in this paper, we aim to target both machine learning scientists and mathematicians, as our work is relevant to both communities.

Figure: Figure 2. Illustration of DynamicFormer. It processes two main input modalities: the quantum Airy structure $B$ as an ordered sequence and partitions $d$ as a permutation-invariant set. The genus $g$ and number of marked points $n$ are incorporated as input properties, modulated with the main modalities at various stages. All layers, including the Multi-Head Attention (MHA) blocks, use the Dynamic Range Activator (DRA) non-linear activation function. The MHA block for $B$-modality integrates Dynamic Positional bias with linear positioning as well. The Talking-Modalities block consists of Batch Normalization [ioffe2015batch] and the self-supervised loss. The DRA prediction head is a 2-layer MLP that predicts $\psi$-class intersection numbers in logarithmic scale.
Refer to caption: x4.png

## 2. Related Works

Transformer-based models [vaswani2023attentionneed], which were originally developed for natural language processing [radford2018improving, devlin2019bert], have since been leveraged for various data modalities [dosovitskiy2021, gong2021astaudio, carolan2024reviewmultimodal]. Due to their flexibility and interoperability, they have been extensively used in different tasks in Artificial Intelligence (AI) for Science [wang2023scientific].
In recent years, a new branch of ML applications, often referred to as AI for Mathematics [he2023machine], has emerged. This branch includes Automated Theorem Proving [loos2017deepnetworkguidedproof, paliwal2020graph, an2024learnfailurefinetuningllms], Generation [trinh2024solving, wang2020learning, lin2024atg], Autoformalization [wang2020exploration, wu2022autoformalization, jiang2023multilingual, mikula2024magnushammer, ying2024lean], machine-human collaborative guidance [bao2020quiver, anderson2021moduli, davies2021advancing, berman2022machine, craven2023learning, coates2023machine, dong2024machine], examples/counterexamples search problems [halverson2019branes, gukov2021learning, wagner2021constructions, gukov2023searching, berglund2024generating, romera2024mathematical], and predictive problems (such as amplitude and mathematical expression prediction) [saxton2019, dersy2023simplifying, alnuqaydan2023symba, dascoli2022deep, cai2024transforming, coates2024machine]. These areas extensively use Transformers, particularly in problems arising from particle interactions and scattering processes.

Our work bridges the domains of machine-human collaborative guidance and predictive problems while introducing new methods. In the prediction task, while most studies remain within in-distribution settings, we extend our approach to out-of-distribution predictions, coupled with Conformal Prediction uncertainty estimation—a notably absent requirement in current literature.
Additionally, we enhance the predictive task by using multi-modal data, involving both discrete sets and continuous graph (sequence) representations. This approach moves beyond the focus on mere compact symbolic/numerical sequence modalities [meidani2024snip]. Furthermore, in the field of machine-human collaborative guidance, we conduct causal inference and correlational analyses to understand the “world-model” of Transformers [micheli2023transformers], offering deep insights into the underlying algebraic geometry problem at hand.

## 3. Mathematical Background

In this section, we review some background on the original mathematical problem. Let $\overline{\mathcal{M}}_{g,n}$ be the moduli space of genus $g\geq 0$ complex stable algebraic curves with $n>0$ distinct marked points. This is a complex, compact, smooth orbifold of dimension $3g-3+n$. Associated with each marked point is a natural cohomology class $\psi_{i}=c_{1}(\mathcal{L}_{i})$, defined as the first Chern class of the cotangent line bundle $\mathcal{L}_{i}$ at the $i$-th marked point.

In the early 90s, Witten [witten1991two] analyzed a theory of two-dimensional topological quantum gravity, where $\psi$-classes play the role of observables, and the intersection numbers (sometimes called amplitudes)

$$ $\langle\tau_{d_{1}}\cdots\tau_{d_{n}}\rangle_{g,n}\coloneqq\int_{\overline{ \mathcal{M}}_{g,n}}\psi_{1}^{d_{1}}\cdots\psi_{n}^{d_{n}}\,,\qquad d_{1}+ \cdots+d_{n}=d_{g,n}\coloneqq 3g-3+n\,,$ (3.1) $$

represent correlators of the theory, and are topological invariants of $\overline{\mathcal{M}}_{g,n}$. Based on a low genus profile and considerations from physics, Witten conjectured that the exponential generating function

$$ $Z(\bm{x};\hbar)=\exp\left(\sum_{\begin{subarray}{c}g\geq 0\\ n>0\end{subarray}}\frac{\hbar^{2g-2+n}}{n!}\sum_{\begin{subarray}{c}d_{1}, \ldots,d_{n}\geq 0\\ d_{1}+\cdots+d_{n}=d_{g,n}\end{subarray}}\left\langle\tau_{d_{1}}\cdots\tau_{d _{n}}\right\rangle_{g,n}x^{d_{1}}\cdots x^{d_{n}}\right)$ (3.2) $$

satisfies a infinite tower of quadratic partial differential equations with respect to the formal variables $(x^{i})_{i\geq 0}$ known as the Korteweg–de Vries (KdV) hierarchy. This was later proven by Kontsevich [kontsevich1992intersection].

In recent years, it has been discovered that many fundamental invariants in physics and geometry can be described via intersection numbers. In physics, interest in $\psi$-class intersection numbers has been revitalized due to their connection with Jackiw–Teitelboim gravity [saad2019jt]. From an algebraic geometry perspective, $\psi$-class intersection numbers represent the most basic form of Gromov–Witten invariants [behrend1997gromov]. These intersection numbers are central to enumerative problems addressed by [kontsevich1992intersection] and [mirzakhani2007weil] regarding the symplectic volumes of the moduli space of metric ribbon graphs and hyperbolic Riemann surfaces. Computing intersection numbers is pivotal in the asymptotic counting of geodesic curves in both flat and hyperbolic random geometries [mirzakhani2008growth, delecroix2021masur, andersen2023topological].

Given the wide and fascinating applications of intersection numbers, computing them for arbitrarily large genera remains an open problem. Their association with the KdV hierarchy has been illuminating for calculating these invariants [witten1991two, kontsevich1992intersection]. Another approach to characterizing these numbers involves Virasoro constraints [Dijkgraaf:1990dj], where the partition function is annihilated by a collection of differential operators that form a representation of the Virasoro algebra. Alternative recursive approaches include topological recursion [eynard2007invariants], the cut-and-join equation [alexandrov2011cut], and exact formulae for the generating series, such as error-function-type integrals [okounkov2002generating] and the determinantal formula [bergere2009determinantal]. However, the general computation of intersection numbers remains an open problem, as these methods can only be used to compute $\psi$-class intersection numbers for cases with small $g$ or $n$. Meanwhile, universality phenomena in flat and hyperbolic geometry and in the dynamics of surfaces manifest themselves in large genera. Only recently, Aggarwal [aggarwal_large] has found a closed-form formula for the large genus asymptotic of $\psi$-class intersection numbers.

### 3.1. Quantum Airy Structures

The conceptually simplest approach to computing $\psi$-class intersection numbers involves using Virasoro constraints recast in the language of quantum Airy structures. The latter is an algebraic reformulation of topological recursion of Eynard and Orantin [eynard2007invariants] due to Kontsevich and Soibelman [kontsevich2018airy]. A quantum Airy structure on a (possibly countably infinite-dimensional) complex vector space $V$, dually generated by $(x^{i})_{i\in I}$, is a family of differential operators $(L_{i})_{i\in I}$ in the Weyl algebra over $V$ of the form

$$ $L_{i}=\hbar\partial_{i}-\hbar^{2}\sum_{a,b\in I}\left(\frac{1}{2}A_{i,a,b}\,x^ {a}x^{b}+B_{i,a}^{b}\,x^{a}\partial_{b}+\frac{1}{2}C^{a,b}_{i}\,\partial_{a} \partial_{b}\right)-\hbar^{2}D_{i}\,,$ (3.3) $$

and forming a Lie sub-algebra of the Weyl algebra:

$$ $[L_{i},L_{j}]=\hbar^{2}\sum_{a\in I}f^{a}_{i,j}L_{a}\,,\qquad\qquad\forall i,j \in I\,.$ (3.4) $$

Here $\partial_{i}=\partial_{x^{i}}$ and $A_{i,a,b}=A_{i,b,a}$, $B_{i,a}^{b}$, $C_{i}^{a,b}=C_{i}^{b,a}$, $D_{i}$, and $f^{a}_{i,j}=-f^{a}_{j,i}$ are scalars indexed by $i,j,k\in I$. We remark that $I$ is the set of indices used to label the basis elements of $V$. In the infinite-dimensional setting, certain boundedness conditions must be imposed to guarantee that all sums are finite [andersen2024abcd].

Given a quantum Airy structure, one can uniquely find a suitably normalized formal function $Z$ on $V$, called partition function, which is annihilated by the diﬀerential operators $(L_{i})_{i\in I}$. More precisely, the following theorem holds.

###### Theorem 3.1 .

If $(L_{i})_{i\in I}$ is a quantum Airy structure on $V$, there exists a unique formal function $Z$ of the form

$$ $Z(\bm{x};\hbar)=\exp\left(\sum_{\begin{subarray}{c}g\geq 0\\ n>0\end{subarray}}\frac{\hbar^{2g-2+n}}{n!}\sum_{d_{1},\ldots,d_{n}\in I}F_{g; d_{1},\ldots,d_{n}}\,x^{d_{1}}\cdots x^{d_{n}}\right)$ (3.5) $$

with $F_{0;d_{1}}=F_{0;d_{1},d_{2}}=0$, $F_{g;d_{1},\ldots,d_{n}}$ symmetric in $d_{1},\ldots,d_{n}\in I$, and such that

$$ $L_{i}Z=0\qquad\qquad\forall i\in I\,.$ (3.6) $$

The elements $F_{g,n}=\sum_{d_{1},\ldots,d_{n}\in I}F_{g;d_{1},\ldots,d_{n}}\,x^{d_{1}}
\cdots x^{d_{n}}$ are symmetric tensors of rank $n$ over $V^{*}$. The collection of coefficients $(A,B,C,D)$ can also be regarded as tensors, and we will often refer to them as the quantum Airy structure data.

For a given quantum Airy structure, the coefficients $F_{g;d_{1},\ldots,d_{n}}$, called quantum Airy structure amplitudes, are determined recursively on (minus) the Euler characteristic $2g-2+n$. For the lowest values of $g$ and $n$, the base cases are given by

$$ $F_{0;i,j,k}\coloneqq A_{i,j,k}\,,\qquad\qquad F_{1;i}\coloneqq D_{i}\,,$ (3.7) $$

where $A_{i,j,k}$ and $D_{i}$ are part of the data of the quantum Airy structure. For higher values of $g$ and $n$ satisfying $2g-2+n>0$, the recursion formula, known as topological recursion, is given by

$$ $F_{g;d_{1},d_{2},\ldots,d_{n}}=\sum_{m=2}^{n}\sum_{a\in I}B^{a}_{d_{1},d_{m}}F _{g;a,d_{2},\ldots,\widehat{d_{m}},\ldots,d_{n}}\\ +\frac{1}{2}\sum_{a,b\in I}C^{a,b}_{d_{1}}\left(F_{g-1;a,b,d_{2},\ldots,d_{n}} +\sum_{\begin{subarray}{c}g_{1}+g_{2}=g\\ I_{1}\sqcup I_{2}=\{d_{2},\ldots,d_{n}\}\end{subarray}}F_{g_{1};a,I_{1}}\,F_{g _{2};b,I_{2}}\right).$ (3.8) $$

In general, the computation of the amplitudes has a computational complexity of $O(g!\,2^{n})$, which makes the calculation of the amplitudes at high genera problematic.

The simplest example of a quantum Airy structure involves taking $V=\mathbb{C}$ and setting $A=B=C=D=1$. Under these conditions, we have a unique differential operator given by

$$ $L=\hbar\partial_{x}-\hbar^{2}\left(\frac{x^{2}}{2}+x\partial_{x}+\frac{1}{2} \partial_{x}^{2}+1\right).$ (3.9) $$

The differential equation $LZ=0$ can be reduced to the Airy differential equation (hence the name “quantum Airy structure”). Therefore, the associated formal power series $Z$ is given by the properly normalized asymptotic expansion of the Airy function:

$$ $Z(x;\hbar)=\frac{e^{\frac{x}{\hbar}(1-\frac{\hbar x}{2})}}{\mathrm{Bi}(0)} \mathrm{Bi}\Biggl{(}\frac{1-2\hbar x-\hbar^{2}}{(2\hbar^{2})^{2/3}}\Biggr{)}.$ (3.10) $$

For higher-dimensional vector spaces $V$, finding a closed-form solution becomes increasingly impractical, if not impossible. Besides, the most interesting applications of quantum Airy structures involve an infinite-dimensional vector space $V$. The central example is the one associated to the $\psi$-class intersection numbers. In this case, the underlying vector space is generated by vectors indexed by $I=\mathbb{N}$, the non-negative integers. The differential operators $(L_{i})_{i\geq 0}$ are determined by the tensors

$$ $\displaystyle A_{i,j,k}\coloneqq\delta_{i,j,k}\,,$ (3.11) $\displaystyle B^{k}_{i,j}\coloneqq\delta_{i+j,k+1}\frac{(2k+1)!!}{(2i+1)!!(2j- 1)!!}\,,$ $\displaystyle C^{j,k}_{i}\coloneqq\delta_{i,j+k+2}\frac{(2j+1)!!(2k+1)!!}{(2i+ 1)!!}\,,$ $\displaystyle D_{i}\coloneqq\frac{\delta_{i,1}}{24}\,.$ $$

The resulting operators, after shifting of the indices as $\mathsf{L}_{i}=L_{i-1}$, form a representation of the Virasoro algebra: $[\mathsf{L}_{i},\mathsf{L}_{j}]=\hbar^{2}(i-j)\mathsf{L}_{i+j}$ for all $i\geq-1$. Remarkably, the associated amplitudes coincide with $\psi$-class intersection numbers:

$$ $F_{g;d_{1},\ldots,d_{n}}=\begin{cases}\langle\tau_{d_{1}}\cdots\tau_{d_{n}} \rangle_{g,n}&\text{if }d_{1}+\cdots+d_{n}=d_{g,n}\,,\\ 0&\text{otherwise.}\end{cases}$ (3.12) $$

In this paper, we focus on the specific choice of quantum Airy structure data given by equation 3.11, thereby computing the $\psi$-class intersection numbers. For ease of notation, we will denote a generic partition of $d_{g,n}$ of length $n$ as $\bm{d}=(d_{1},\ldots,d_{n})$. The associated $\psi$-class intersection number will be denoted by

$$ $\langle\bm{d}\rangle_{g,n}\coloneqq\langle\tau_{d_{1}}\cdots\tau_{d_{n}} \rangle_{g,n}.$ (3.13) $$

The goal of the next sections is to provide evidence for the possibility of regressing these numbers via a Transformer-based model, namely DynamicFormer, given the quantum Airy structure initial data. Our model is trained on known data computed by a brute force algorithm up to genus $13$ and is tested up to genus $16$. We then provide causal and correlational evidence that our model is actually learning and understanding the recursive nature of the intersection numbers. As a result, we aim to introduce a new paradigm for using Transformers in algebraic geometry as both a powerful and explainable amortization method and a source of intuition for the mathematician.

###### Theorem 3.1 .

## 4. Data Representation and Setup

The input data during training consisted of the sparse tensors $B$ and $C$ from equation 3.11, the genus $g$, the number of marked points $n$, and the partitions $\bm{d}=(d_{1},\ldots,d_{n})$ of $d_{g,n}$. We did not include $A$ and $D$ as input, as they are fixed initial conditions for all $\psi$-class intersection numbers.

As we will consider values of $g$ and $n$ such that the dimension $d_{g,n}$ will never exceed $d_{\textup{max}}=100$, the initial data will consist of only finitely many data. More precisely, the initial data during training were represented as follows.

- •
$\bm{B}$ Initial Data: A rank $3$ tensor $B_{i,j}^{k}\in\mathbb{R}^{d_{g,n}\times d_{g,n}\times d_{g,n}}$. Such a tensor links intersection numbers of the same genus (cf. equation 3.8). Since it is a sparse tensor with $d_{g,n}\leq d_{\textup{max}}=100$, we chose to represent its non-zero components in the COO (Coordinate List) format. In the COO format, $B$ is represented as a set of $4$-tuples, each containing the indices and the corresponding non-zero value:
$\bm{B}=\Set{(i,j,k,B_{i,j}^{k})}{B_{i,j}^{k}\neq 0}$
(4.1)
where $i,j,k\in[0,d_{g,n}]$, and $B_{i,j}^{k}$ are the non-zero components of the tensor. With this choice of $d_{\textup{max}}$, the maximum length of $\bm{B}$ is approximately 1500.
- •
$\bm{C}$ Initial Data: A rank $3$ tensor $C_{i}^{j,k}\in\mathbb{R}^{d_{g,n}\times d_{g,n}\times d_{g,n}}$. Such a tensor links intersection numbers of different genera (cf. equation 3.8). Again, since it is a sparse tensor with $d_{g,n}\leq d_{\textup{max}}=100$, we chose to represent its non-zero components in the COO format. In the COO format, $C$ is represented as a set of $4$-tuples, each containing the indices and the corresponding non-zero value:
$\bm{C}=\Set{(i,j,k,C_{i}^{j,k})}{C_{i}^{j,k}\neq 0}$
(4.2)
where $i,j,k\in[0,d_{g,n}]$, and $C_{i}^{j,k}$ are the non-zero components of the tensor. With this choice of $d_{\textup{max}}$, the maximum length of $\bm{C}$ is approximately 1500.
- •
Partitions: The intersection numbers $\langle\bm{d}\rangle_{g,n}$ are labeled by partitions $\bm{d}=(d_{1},\ldots,d_{n})\in\mathbb{N}^{n}$ of $d_{g,n}$ of length $n$.
An important feature of intersection numbers (and more generally, amplitudes computed from quantum Airy structures) is that they are invariant under permutation of the indices, that is, elements of the partition $\bm{d}$. For example given a partition $\bm{d}=(3,0,0)$, we have $\langle 3,0,0\rangle_{1,3}=\langle 0,3,0\rangle_{1,3}=\langle 0,0,3\rangle_{1,3}$.

We trained the model using data up to genus $g=13$ and then tasked it with predicting the intersection numbers for genera $g=14$, $15$, and $16$. During experimentation, we observed that, when comparing the contributions of $B$ and $C$, the $B$ tensor had a greater impact on $\psi$-class intersection numbers. Consequently, we incorporated only this initial data (excluding $C$), a decision further supported by the inherent properties of the intersection numbers.
This initial observation motivated the subsequent series of explainability analysis experiments and findings.

## 5. Methods

To handle the different input modalities, i.e. the continuous tensor $B$ in COO format and the discrete set $\bm{d}\in\mathbb{N}^{n}$, we developed a Transformer-based model as depicted in figure 2. However, managing different input formats is only part of the challenge. The recursive nature of many functions in enumerative geometry adds further complexity.
A key property of recursive maps, such as the factorial function, is their rapid growth. Learning this recursive behavior requires not only fitting patterns within a bounded region but also successfully extrapolating those patterns beyond that region. However, it has been shown that Transformers are not very successful at capturing recursive behavior [lakretz2021causal, zhang2024transformerbased].
To address the limitations of Transformers in learning the recursive behavior of invariants in enumerative geometry, we introduce DynamicFormer to capture such behavior and perform proper inference for recursive problems.

Dynamic Positional Bias.
The trunk of the network consists of two modified Transformers: one discrete, acting on the embedding of the partitions $\bm{d}$ and maintaining permutation equivariance, and one continuous, acting on the $B$ tensor [vaswani2023attentionneed]. The positions of elements in $B$, represented in COO format, correspond to particular combinations of indices that compute the intersection numbers.
To enhance generalization for longer input sequences, we integrated a modified version of Dynamic Positional Bias [wang2021crossformer, zhang2024transformerbased]. Dynamic Positional Bias computes a relative positional bias map for each attention head, which is learnable and adapts based on sequence length. However, because it does not inherently account for the distance from the start or end of a COO sequence, we apply masking during training based on input sequence length to address this limitation.

Dynamic Range Activator.
It has been shown [parascandolo2017taming, dauphin2017language, ziyin2020neural, so2021searching] that the choice of activation functions plays an important role in the interpolation and extrapolation properties of Transformers and, more generally, neural networks. To enable Transformer models to precisely capture the recursive behavior of the data, we introduce a simple activation function that we call the Dynamic Range Activator (DRA). DRA integrates both harmonic and hyperbolic components, as follows,

$$ $\mathrm{DRA}(x)\coloneqq x+a\sin^{2}\left(\frac{x}{b}\right)+c\cos(bx)+d\tanh( bx)\,,$ (5.1) $$

where $a,b,c,d$ are learnable parameters. This diversity allows the function to simultaneously model periodic data (through sine and cosine), rapid growth or attenuation (through the hyperbolic tangent), and maintain a linear baseline response.
DRA is inspired by the Snake non-linear function [ziyin2020neural]. However, Snake only offers a sinusoidal modulation added to a linear term, which, while providing a basic non-linear transformation, lacks the additional flexibility for rapid damping or amplification effects that hyperbolic tangents can provide.
To demonstrate the advantage of DRA in capturing recursive behavior, we set up a small experiment.
We generate a small dataset based on the recursive function $r(n)=n+(n,\mathrm{AND},r(n-1))$, where AND is the bitwise logical AND operator [10.1007]. We train a fully connected neural network with one hidden layer consisting of $64$ neurons over the interval $n\in[0,150]$, then test the model over $n\in[151,200]$.
The results are shown in figure 3.

Figure: Figure 3. Comparison of DRA with Snake, ReLU and Tanh non-linear activations in training region $n\in[0,150]$ and test (extrapolative) region $n\in[151,200]$.
Refer to caption: x5.png

This experiment demonstrates that neither ReLU nor Tanh is capable of capturing the recursive nature of the underlying function, as both baselines perform naive interpolation and extrapolation. Snake appears to learn some periodicity in both the training and testing regions.
In contrast, DRA shows a better ability to capture the correct fluctuations, as well as the rapid growth and drops of the underlying recursive function, in both the interpolation and extrapolation regimes.
This provides evidence that DRA has the desired flexibility for modeling recursive behavior and has the potential to effectively model such problems. We further conduct experiments to demonstrate the advantages of DRA over typical non-linear activation functions in predicting $\psi$-class intersection numbers.

[DYN] registry tokens and Talking Modalities. In multi-modal learning, effectively sharing and integrating information across different modalities is crucial for building robust models.
Inspired by the success of Self-Supervised Learning (SSL) [gui2024survey], we introduce a simple modification to enhance correspondence between modalities.
To achieve this, we concatenate Dynamic tokens, [DYN], to each modality. These tokens are similar to [CLS] tokens in BERT [devlin2019bert] and Vision Transformers [dosovitskiy2021], in that they are passed through the attention layers alongside the input data. However, unlike [CLS] tokens, they are not directly used for the downstream supervised task of amplitude prediction.
Instead, they are used indirectly, like register tokens [darcet2024vision], which store and process global information in Vision Transformers.

By attending to all tokens in the input, [DYN] tokens, similar to register tokens, facilitate a soft contrastive learning update, enabling them to learn a global context for each sample. Unlike register tokens, [DYN] tokens are also optimized to ensure that the outputs from different modalities of data—specifically from the $B$ tensor, which provides global information per sample, and the partitions $\bm{d}$, which serve as local information carriers—are as similar as possible while simultaneously reducing the redundancy of the information they carry.
Their optimization is guided by the Canonical Correlation Analysis [Abdi2018] family of SSL, where the aim is to infer the relationship between two modalities by analyzing their cross-covariance matrices [balestriero2023cookbook]. Inspired by Barlow Twins [zbontar2021barlow], the two modalities start to have a “conversation”, promoting an interaction in which the two modalities collaboratively refine their representations.
The idea behind this is that such a consensus mechanism not only enhances the model’s ability to generalize better to Out-Of-Distribution (OOD) data but also improves its robustness. The Talking Modalities loss is then defined as follows:

$$ $\mathcal{L}_{\textup{TM}}=\sum_{i=1}^{k}\left(1-\mathcal{C}_{ii}^{(\bm{B},\bm{ d})}\right)^{2}+\lambda\sum_{\begin{subarray}{c}i,j=1,\ldots,k\\ i\neq j\end{subarray}}\left(\mathcal{C}_{ij}^{(\bm{B},\bm{d})}\right)^{2},$ (5.2) $$

where $\mathcal{C}$ is the cross-correlation matrix of the representations from the two modalities, $(\bm{B},\bm{d})$, $k$ is the dimensionality of the model’s embeddings (vector representations), and $\lambda$ is the weighting factor that balances the contributions of talking modalities. The first term penalizes the diagonal elements of the cross-correlation matrix $\mathcal{C}$ for deviating from the identity, thus encouraging invariance. The second term penalizes the off-diagonal elements, encouraging the components of the representation vectors to be decorrelated.
In section 6, we will show that this modification enhances the performance of the model in the OOD prediction regime.

After the Transformer trunk of the network, all the embedded information is aggregated by a permutation-invariant block. We employ the Principal Neighbourhood Aggregation (PNA) layer [corso2020principal] to pool information from the modalities $(\bm{B},\bm{d})$. Once the information from these two branches, for each sample, is modulated with their corresponding genus and number of marked points positional attributes, $(g,n)$, it is mapped to the outputs, i.e. $\psi$-class intersection numbers, via an MLP head. DRA is the non-linear activation function used throughout these blocks.
As the loss function, we use the Mean Absolute Error (MAE) loss. Given that the range of amplitudes for the intersection numbers is very wide, $[10^{-45},10^{45}]$, MAE was the most appropriate metric. Essentially, MAE is not disproportionately affected by the massive range of the target values, unlike Mean Squared Error (MSE), which can be overly influenced by the squared terms of large numbers. Thus, the total loss is as follows:

$$ $\mathcal{L}_{\textup{Total}}=\mathcal{L}_{\textup{MAE}}+\mathcal{L}_{\textup{ TM}}\,.$ (5.3) $$

## 6. Results

To evaluate the performance of our approach, we consider two setups: In-Distribution (ID) and Out-Of-Distribution (OOD) settings. In these settings, we face both length extrapolation and context extrapolation challenges.
Given the wide range of values for $\psi$-class intersection numbers, we use R-squared ($\mathrm{R}^{2}$) to compare the results and assess the goodness-of-fit in the intersection number regression task.
$\mathrm{R}^{2}$ reflects the proportion of the variance in the dependent variable that is predictable from the independent variables. The higher the value of $\mathrm{R}^{2}$, the greater the relationship between prediction and ground truth values. For instance, an $\mathrm{R}^{2}$ value of $0.75$ indicates that 75% of the total variation in the data is explained by the model, while the remaining 25% is not captured by the model.

Uncertainty Quantification.
To estimate the uncertainty of the prediction, we incorporate Conformal Prediction (CP) [vovk1999machine]. CP is a probabilistic uncertainty quantification technique that provides prediction intervals in finite samples without making any distributional assumptions.
We integrate Inductive Conformal Prediction [4410411] with a dynamic sliding window [xu2023conformalpredictiontimeseries] that computes rolling residuals for predicted intersections for each set of marked points $n$.
In our modification, we fit a quantile regression model to the residuals within a rolling window of marked points, allowing us to predict the desired quantile that adapts to local variations in the residuals. Given the high heteroscedasticity in the data, where the variance of residuals changes across intersections, we employ a sliding window over the interval of each set of marked points.
This ensures that the residuals are more scale-dependent and appropriately adjusted for the inherent variability in the data, potentially capturing trends and heteroscedasticity better.
As a result, we report the Normalized Conformity Score (NCS)

$$ $\mathrm{NCS}\coloneqq\frac{|\langle\bm{d}\rangle_{g,n}-\langle\bm{d}\rangle_{g ,n}^{\textup{pred}}|}{\langle\bm{d}\rangle_{g,n}}$ (6.1) $$

and the Conformal Interval Width (CIW).

We perform two sets of experiments. First, we report the performance of DynamicFormer in both the ID and OOD settings. We compare DRA with Snake [ziyin2020neural] and GLU [so2021searching] activation functions as baselines to validate DRA’s non-linearity.
We also compare the results with and without the [DYN] register token [darcet2024vision] and the Talking Modalities mechanism in the OOD setting.
Thereafter, we engage in an interesting discussion on interoperability, correlational, and causal analysis of what the model is learning. We also explore how to perform abductive hypothesis testing based on the model’s internal understanding of the underlying enumerative problem to prove conjectures.

### 6.1. In-Distribution Results

In the ID setting, we examine data with the same genera as the training data, that is $g_{\textup{ID}}=14$, but with different, unseen numbers of marked points $n_{\textup{ID}}\in[3,9]$. In this setting, the $\mathrm{R}^{2}$ and NCS are shown in table 1. It is noteworthy that this is a test dataset where the model has not seen any of these amplitudes. The comparison between the ground truth data and the predicted values is shown in figure 4.

The average CIW for the ID setting is $0.03$, with an empirical coverage of $79\%$. This empirical coverage falls short of our target coverage of $90\%$, indicating that our conformal procedure is under-covering. This shortfall could be due to the severe recursive nature of the data, suggesting that our calibration data is still too localized and therefore not fully representative of the entire test domain. Despite this limitation, the $79\%$ coverage is the highest we have achieved with our conformal calibration method. In comparison, other methods, such as naive Inductive Conformal Prediction [4410411], achieved only $53\%$ coverage, and Conformalized Quantile Regression [romano2019conformal] yielded an empirical coverage of $57\%$.

**Table 1. $\mathrm{R}^{2}$ and NCS results with DRA activation function in the ID setting.**
| $(g,n)$ | $\mathrm{R}^{2}\uparrow$ | NCS $\downarrow$ |
| --- | --- | --- |
| $(14,3)$ | $97.2\pm 0.1$ | 0.19 |
| $(14,4)$ | $98.4\pm 0.1$ | 0.11 |
| $(14,5)$ | $99.3\pm 0.7$ | 0.08 |
| $(14,6)$ | $98.1\pm 0.5$ | 0.13 |
| $(14,7)$ | $99.0\pm 0.8$ | 0.09 |
| $(14,8)$ | $99.9\pm 0.3$ | 0.01 |
| $(14,9)$ | $99.9\pm 0.3$ | 0.01 |

Figure: Figure 4. Comparison of true, predicted, and $\mathrm{R}^{2}$ values in the ID setting. The plot shows the true values, the predicted values, and the $\mathrm{R}^{2}$ scatter plot, including a line representing perfect prediction.
Refer to caption: x9.png

### 6.2. Out-Of-Distribution Results

Now, we study the more challenging task of OOD prediction. In the OOD setting, we examine data with higher genus than the training data, specifically $g_{\textup{OOD}}=[15,16]$, and a number of marked points $n_{\textup{OOD}}\in[2,7]$. In this setting, the $\mathrm{R}^{2}$ metric is shown in table 2. The average CIW for the OOD setting is $1.45\times 10^{-5}$, with an empirical coverage of $76\%$. The comparison between the ground truth data and the predicted values is shown in figure 5.

The Snake and other activation functions failed completely in this OOD setting, as shown in table 3. These results demonstrate that DynamicFormer can capture intersection numbers even for genera and numbers of marked points outside the training data. Table 4 compares the performance of the model in the OOD regime with and without the [DYN] register token (i.e. the multi-modal version of [REG]) and the Talking Modalities mechanism. This experiment shows that the [DYN] register token generally provides a small boost to performance, and adding the Talking Modalities mechanism further improves prediction accuracy. We did not observe any performance improvement over the training data or in the ID setting. It seems that using register tokens as a method to query and process global information helps with the model’s generalization abilities.

**Table 2. $\mathrm{R}^{2}$ and NCS results with DRA activation function in the ODD setting.**
| $(g,n)$ | $\mathrm{R}^{2}\uparrow$ | NCS $\downarrow$ |
| --- | --- | --- |
| $(15,2)$ | $82.6\pm 0.9$ | 0.27 |
| $(15,3)$ | $97.7\pm 0.8$ | 0.11 |
| $(15,4)$ | $98.4\pm 0.9$ | 0.11 |
| $(15,5)$ | $99.4\pm 0.2$ | 0.08 |
| $(15,6)$ | $98.4\pm 0.8$ | 0.13 |
| $(15,7)$ | $98.5\pm 0.3$ | 0.11 |
| $(16,3)$ | $98.1\pm 0.6$ | 0.13 |
| $(16,4)$ | $80.0\pm 0.4$ | 0.44 |
| $(16,5)$ | $98.9\pm 0.3$ | 0.10 |

Figure: Figure 5. Comparison of true, predicted, and $\mathrm{R}^{2}$ values in the ODD setting. The plot shows the true values, the predicted values, and the $\mathrm{R}^{2}$ scatter plot, including a line representing perfect prediction.
Refer to caption: x10.png

As evidenced by table 3, we see that the DRA outperforms the GLU and Snake activation functions by a large margin in predicting the recursive intersection numbers in the OOD setting, where the models have to regress intersection numbers with previously unseen numbers of marked points.

**Table 3. Comparison of $\mathrm{R}^{2}$ and CIW between Transformer-based models with GLU, Snake, and DRA as their activation functions in the OOD regime $g\in[15,16]$ and $n\in[2,7]$.**
| GLU | Snake | DRA |  |  |  |
| --- | --- | --- | --- | --- | --- |
| $\mathrm{R}^{2}\uparrow$ | $\text{CIW}^{(\times 10^{-5})}$ $\downarrow$ | $\mathrm{R}^{2}\uparrow$ | $\text{CIW}^{(\times 10^{-5})}$ $\downarrow$ | $\mathrm{R}^{2}\uparrow$ | $\text{CIW}^{(\times 10^{-5})}$ $\downarrow$ |
| $84.1\pm 0.4$ | 9.33 | $68.9\pm 0.8$ | 200 | $\mathbf{95.8}\pm 0.6$ | $\mathbf{1.45}$ |

**Table 4. Comparison of $\mathrm{R}^{2}$ and CIW between models with and without [DYN] register token and Talking Modalities. A small performance improvement can be observed as a result of using register tokens Talking Modalities in the OOD regime $g\in[15,16]$ and $n\in[2,7]$.**
| None | [DYN] | [DYN]+TM |  |  |  |
| --- | --- | --- | --- | --- | --- |
| $\mathrm{R}^{2}\uparrow$ | $\text{CIW}^{(\times 10^{-5})}$ $\downarrow$ | $\mathrm{R}^{2}\uparrow$ | $\text{CIW}^{(\times 10^{-5})}$ $\downarrow$ | $\mathrm{R}^{2}\uparrow$ | $\text{CIW}^{(\times 10^{-5})}$ $\downarrow$ |
| $91.1\pm 0.4$ | $1.95$ | $94.6\pm 0.6$ | $1.46$ | $\mathbf{95.8}\pm 0.6$ | $\mathbf{1.45}$ |

### 6.3. Insights, Interoperability and Discussion

Up until now, we have tried to showcase that DynamicFormer, as a modified Transformer, is capable of performing enumerative geometry and predicting $\psi$-class intersection numbers. However, several key questions remain. Do Transformers actually understand the underlying mathematics? How does the AI agent learn this computation? Is it possible to extract useful knowledge or hints toward a possible (re)discovery of a theorem?

To address these questions, we have made several interesting observations throughout our work that offer deeper insights into the model’s behavior and learning process, hinting at potential mathematical knowledge discovery.

#### 6.3.1. The Dilaton Equation

The topological recursion formula (3.8) for the specific case of $\psi$-class intersection numbers and the choice of $d_{1}=1$ takes a particularly simple form, known as the Dilaton equation. After relabelling, it reads

$$ $\langle 1,d_{1},\ldots,d_{n}\rangle_{g,n+1}=(2g-2+n)\langle d_{1},\ldots,d_{n} \rangle_{g,n}\,.$ (6.2) $$

The equation states that the intersection number involving a $\tau_{1}$-term can be reduced to a simpler intersection number with one fewer marked point.

Let $\langle\bm{d}\rangle_{g,n}$ be the intersection numbers indexed by genus $g$ and number of marked points $n$. Given the the set of values of the tensor $\bm{B}$ and the set of partitions $\bm{d}\in\mathbb{N}^{n}$, the neural network embedding $p_{g,n}\colon\set{\mathbb{R}^{d_{g,n}\times d_{g,n}\times d_{g,n}},\mathbb{N}^
{n}}\rightarrow\mathbb{R}^{k}$ is a vector space of dimension $k$ and is denoted as $p_{g,n}(\langle\bm{d}\rangle_{g,n}\mid\bm{B},\bm{d})$. This embedding describes the hidden understanding of the Transformer (right before the prediction head). If we normalize these embeddings to unit length and then compute the self-projection of these embedding vectors onto themselves, we obtain the cosine of the angle between the normalized embeddings of $\psi$-class intersection numbers as a measure of similarity:

$$ $S_{i,j}=\frac{\langle p_{g,n}^{i},p_{g,n}^{j}\rangle}{\lVert p_{g,n}^{i}\rVert \,\lVert p_{g,n}^{j}\rVert}\,.$ (6.3) $$

The similarity matrix $S_{i,j}$ represents the geometric proximity between two pairs of $\psi$-class intersection numbers. Values in this matrix range from $-1$ to $1$, where $-1$ denotes complete dissimilarity, $1$ indicates perfect similarity, and 0 0 suggests orthogonality or decorrelation.

Figure: Figure 6. The Dilaton relations matrix (left) between $\psi$-classes intersection numbers for $g=14$ (top) and $g=15$ (bottom). Cosine similarity between embeddings of predicted intersection numbers (right). Cosine similarity between embeddings of predicted intersection numbers with a cut $S_{i,j}\geq 0.98$ (middle).
Refer to caption: x11.png

Looking at the cosine similarity between samples in the embedding space of the model’s internal activations, shown in figure 6, we observed some interesting recursive patterns. We hypothesize that these patterns stem from the Virasoro constraints between intersection numbers. To verify this, we visualized the Dilaton equations and confirmed that the model has effectively rediscovered it as relationships between intersection numbers. We translated the Dilaton equation into a Dilaton relation matrix by flagging any two intersection numbers that satisfy this equation. We then observed that the intersection numbers with high cosine similarity follow at least the Dilaton equation. We anticipate that other observed patterns may also be manifestations of the remaining Virasoro constraints. This phenomenon persists even in the OOD setting where the model has not seen any samples. This may explain how the model has succeeded in generalizing well by learning the underlying symmetries and relations. This provides evidence that DynamicFormer has independently learned the the Virasoro constraints in a data-driven way, without prior exposure to these governing rules.

#### 6.3.2. Large genus limit and abductive reasoning

Delecroix–Goujard–Zograf–Zorich [delecroix2021masur] conjectured that, in the large genus limit, $\psi$-class intersection numbers simplify to a specific asymptotic form. This conjecture was subsequently proven by Aggarwal [aggarwal_large], incorporating a combinatorial and probabilistic analysis of the associated Virasoro constraints.

###### Theorem 6.1 .

For $n=o(\sqrt{g})$, uniformly in $d_{1},\ldots,d_{n}$ as $g\to+\infty$:

$$ $\langle\bm{d}\rangle_{g,n}\,\prod_{i=1}^{n}(2d_{i}+1)!!=\frac{2^{n}}{4\pi} \frac{\Gamma(2g-2+n)}{(\frac{2}{3})^{2g-2+n}}\bigl{(}1+o(1)\bigr{)}\,.$ (6.4) $$

Here $\Gamma(x)$ is the Euler Gamma function.

This theorem illustrates that, as the genus $g$ grows large, the intersection numbers grow factorially as $(2g)!$, with a specific exponential behavior modulated by the constant $A=2/3$. Recently, another approach for computing the large-genus asymptotics of intersection numbers was proposed by [eynard2023resurgentlargegenusasymptotics], based on the resurgent analysis of the $n$-point functions of such intersection numbers. With this approach, the authors extended Aggarwal’s results by computing all subleading corrections:

$$ $\langle\bm{d}\rangle_{g,n}\,\prod_{i=1}^{n}(2d_{i}+1)!!=\frac{2^{n}}{4\pi} \frac{\Gamma(2g-2+n)}{(\frac{2}{3})^{2g-2+n}}\left(1+\frac{\frac{2}{3}\alpha_{ 1}}{2g-3+n}+\cdots\right).$ (6.5) $$

The process of identifying different components and fixing parameters (such as $A=2/3$ or the subleading corrections) can be approached using abductive reasoning, framing it as a hypothesis-testing problem. Abduction involves proposing plausible explanations for observed data, which is similar to hypothesizing different theories to determine which best aligns with the AI agent’s understanding of the data, such as the embedding vector space in models like Transformers. In hypothesis testing, one considers two hypotheses: the null hypothesis $H_{0}$ and the alternative hypothesis $H_{1}$. The goal is to decide whether the observed data sufficiently support the null hypothesis. Specifically, given a set of observations, the aim is to maximize the probability of making a discovery while controlling for a prescribed level of type I error.

In this context, one can investigate whether the AI agent has correctly understood parameters, such as the constant $A=2/3$ in the asymptotic formula, and whether this understanding can be recovered as an inverse problem. Thus, the important question we want to answer in computational enumerative geometry is: In scenarios where parameters in asymptotic formulas are unknown, can we use abduction to infer and provide evidence for their potential values? To address this question, we employ correlational and causal methods based on the Transformer’s internal understanding of the data, which can be applied to various enumerative problems. First, we check the reasoning of DynamicFormer by deciphering the model’s understanding of the parameters of the asymptotic form of the $\psi$-class intersection numbers, which are not explicitly provided to the model. The parameters of interest to be inferred and rediscovered are as follows:

- •
The exponential growth $A$.
- •
The first few subleading asymptotic polynomials $\alpha_{1},\alpha_{2},\ldots$ [guo2022largegenusasymptoticspsiclass, eynard2023resurgentlargegenusasymptotics].

One can claim that there is evidence that the model’s embedding vector space $p_{g,n}(\langle\bm{d}\rangle_{g,n}|\bm{B},\bm{d})$ encodes the parameter $A=2/3$ and the subleading polynomials if there is a correspondence between the embeddings and these parameters. A prominent method that attempts to shed light on this correspondence is probing [conneau2018cramsing], also known as diagnostic prediction [hupkes2020compositionality]. Under this methodology, one trains a simple model (e.g., kernel Ridge Regression [pml1Book]) as a probe to predict some desired information from the latent representations of the Transformer model. High prediction performance is interpreted as evidence that the information is encoded in the vector space representation. The efficacy of the encoding can be gauged by the amount of variance in these parameters that can be explained by $p_{g,n}(\langle\bm{d}\rangle_{g,n}|\bm{B},\bm{d})$, quantified by the $\mathrm{R}^{2}$ value of the probe. To quantify the uncertainty of our abductive reasoning through probing, we perform the conformal prediction procedure [shafer2008tutorial] as a statistical uncertainty quantification approach to obtain uncertainty bands around the predictions.

For $A=2/3$, we set up the experiment with a grid of alternative hypotheses. Specifically, we probe a discrete value space for the numerator of $A$, $\mathrm{num}={1,\ldots,10}$, and the denominator, $\mathrm{denom}={1,\ldots,10}$, which covers 90 candidates (with $A=1$ excluded as a trivial hypothesis). We find evidence that DynamicFormer encodes $A$ as $2/3$ with the highest $\mathrm{R}^{2}$ and lowest uncertainty, as shown in figure 7.

Figure: Figure 7. The model’s internal embedding’s predictive power of the exponential growth constant of $\psi$-class intersection numbers with hypothesis testing, gauged by the $\mathrm{R}^{2}$ and conformal uncertainty.
Refer to caption: x17.png

We perform the same analysis for the first few terms of the subleading series $\alpha_{k}$ with $k=0,1,2,3$. We found that with $90\%$ coverage, the Transformer’s vector space representation can predict the coefficients with an $\mathrm{R}^{2}=0.98$ and a conformal prediction interval of $\pm 531$. This interval is only about $5.4\%$ of the standard deviation of the coefficients, implying that the prediction interval is relatively narrow compared to the overall variability in the data. This suggests that nearly $98\%$ of the variance in the subleading coefficients is encoded in and predictable from the model’s internal vector space.

If we perform Principal Component Analysis (PCA) on the hidden embedding of each sample, $p_{g,n}$, we observe in figure 8 that DynamicFormer shows hierarchical representations of intersection numbers across both the genus $g$ and the number of marked points $n$. This provides evidence that the model has learned a recursive structure within the data. The PCA plots highlight that the two principal components with the highest variance form circular patterns, reflecting the model’s internal representation of amplitudes.

Figure: Figure 8. The first two principle components of model’s hidden states across different genera (left) and number of marked points (right).
Refer to caption: x18.png

So far, we have shown evidence of the possibility of recovering the exponential growth constant and the first few subleading terms from the AI agent. Now, we want to analyze the internal mechanisms and the inner causal understanding of the model via causal tracing [vig2020]. Transformers can be viewed as a causal graph, where information is propagated from the input to the output through a network of hidden states. Originally, causal tracing was introduced to quantify the storage and transfer of facts within the intermediate variables of Transformers [meng2022locating, feng2024language, wang2024grokked], which is not our focus here. We seek to use causal tracing to understand the model’s decision-making process, specifically identifying which input variables and modalities are more influential when predicting the intersection of $\psi$-classes. In other words, we want to uncover how the AI agent comprehends the underlying mathematics. We will refer to an input modality as $m[i]=\set{n[i],\bm{B}[i],\bm{d}[i]}$ for each input instance $i$. There are then two steps:

- (1)
Clean run. This run records the model’s prediction on a regular input for a fixed genus $g$. With this run, we record auto-correlation of the predicted intersection numbers across different number of marked points.
- (2)
Counter-factual intervention. In a counter-factual intervention [baron2023explainable], we input modified instances for each modality into the model to observe how these changes affect the predictions. These counter-factuals involve incorrectly assigning features to instances. For example, this could mean incorrectly associating the partition $\bm{d}=(29,10,5,3,1,0)$ with $n=3$ instead of $n=6$. Previous research on factual associations in Transformers has explored methods such as adding noise to inputs [meng2022locating], which creates redundant distribution shifts [zhang2024best], and exchanging tokens [feng2024language]. Our approach is similar to the latter method, focusing on how changes in input tokens affect model predictions.
Specifically, for the modality of interest (while keeping the other modalities unchanged), we replace the input instances with random alternatives of the same genus. This replacement results in a misassignment of features to a sample, which alters the target prediction, i.e., $m[i]\rightarrow m[j]$ where $i\neq j$, to obtain $p_{g,n}(\langle\bm{d}\rangle_{g,n}|\mathrm{do}(m[i]))$. The purpose of this intervention is to study how the model relates features to instances and to understand the underlying mathematical relationships between them. This analysis allows us to attribute cause and effect between interventions and the amplitudes. The counter-factual analysis provides causal evidence on the role of each input modality. The difference observed between the clean and intervened runs, as measured by $\mathrm{R}^{2}$, the autocorrelation of the intersection numbers, and the $\mathrm{R}^{2}_{\textup{probe}}$ of the probe for the exponential growth constant $A=2/3$, characterizes the causal impact of the modality of interest on the $\psi$-class intersection numbers.

**Table 5. Causal Strength for Different Modalities**
| $\mathrm{do}(m[i])$ | $\mathrm{R}^{2}$ | $\mathrm{R}^{2}_{\text{probe}}$ |
| --- | --- | --- |
| No Intervention | $0.98$ | $0.93$ |
| $n$ | $-12.6$ | $0.53$ |
| $\bm{B}$ | $0.54$ | $-3.62$ |
| $\bm{d}$ | $-52.2$ | $0.44$ |

Figure: Figure 9. Autocorrelation plot across different number of marked points $n$ for clean (leftmost) and intervened runs for $n$, $\bm{B}$, and $\bm{d}$.
Refer to caption: x20.png

What causal reasoning is the model learning?
We compute the $\mathrm{R}^{2}$ and $\mathrm{R}^{2}_{\textup{probe}}$ over the samples with $g=15$ to measure causal strength. As a result, the $\mathrm{R}^{2}$ of the intersection of $\psi$-classes is heavily affected when using counter-factual instances for the number of marked points $n$ and partitions $\bm{d}$. This indicates a strong causal connection between the partitions and the intersection numbers. This is also evident from the autocorrelation plot figure 9, where the correlation between the intersection numbers is completely lost after disrupting the binding between instances and their partitions. The presence of such a strong causal relationship for $n$ and $\bm{d}$ is not surprising, but their mild impact on $\mathrm{R}^{2}_{\textup{probe}}$ is an interesting discovery. Despite a weak causal connection between $\bm{B}$ and the predicted intersection numbers, there is evidence that the exponential growth constant, $A=2/3$, is causally connected to the quantum Airy structure initial datum $\bm{B}$. This suggests that the model’s internal reasoning (hidden states) of the $\bm{B}$ initial datum encodes this parameter. Meanwhile, the weak causal impact of $\bm{B}$ on the intersection numbers results in only a mild effect on their autocorrelation, which was unexpected.

###### Theorem 6.1 .

## 7. Conclusion and Discussions

While the capabilities of Large Language Models and Transformers, as their primary building blocks, have advanced significantly to encompass complex tasks across various domains, it remains an open question whether they can be effectively utilized for abstract mathematical reasoning and knowledge discovery. In this paper, we address a fundamental question: Can Transformers perform and learn enumerative geometry and topological recursion?
To answer this question, we investigated a deep but theoretically well-studied enumerative problem in algebraic geometry, specifically the computation of $\psi$-class intersection numbers. Given that these amplitudes exhibit recursive behavior, capturing this behavior presents a non-trivial challenge for Transformers.
We analyze the ability of Transformers to tackle such a task in a zero-shot setting, where the AI model is trained only on genus $g\leq 14$ and is asked to predict intersection numbers for $g_{\textup{ID}}=14$ and $g_{\textup{OOD}}=[15,16]$.
As a result, we introduced DynamicFormer, a multi-modal Transformer-based model. DynamicFormer takes the quantum Airy structure datum $\bm{B}$, the partition $\bm{d}$, and the global genus $g$ and number of marked points $n$ as input modalities to predict the $\psi$-class intersection numbers.
Throughout our experiments, we applied various techniques and modifications to Transformers to enhance their performance. We also identified the crucial role of non-linear activation functions in recursive tasks and introduced a new activation function, Dynamic Range Activator (DRA), which improves prediction precision in both ID and OOD settings.

In the second part of the results, we posed a straightforward question: How exactly does the AI agent perform enumerative geometry? To answer this question, we conducted a series of correlational, conformal, and causal interoperability analyses.

Firstly, by examining the internal vector representation of the model, we discovered that the Transformer is indeed learning Virasoro constraints. Specifically, we found strong evidence that the model has learned at least the Dilaton equations. This is particularly fascinating because no such constraints or conditions were imposed on the model; nonetheless, it managed to pick up and (re)discover them.
This finding is intriguing because it suggests that in cases where such relations and equations are not known but are suspected to exist, a pre-trained Transformer could potentially aid in a human-machine collaboration by providing hints and evidence for these relations in a purely data-driven manner.

Afterwards, we further explored whether it is possible to perform some form of abductive reasoning and hypothesis testing to estimate the parameters of asymptotic formulas for intersection numbers, or more generally, for quantum Airy structure amplitudes. Often, there is an expectation for such asymptotic growths, which then leads to a process of conjecture building and deductive reasoning to derive the final formula. In this work, we advocate that using the Transformer’s internal representation and understanding of the data, one can provide informed guesses and even reject alternative hypotheses about candidate parameters.
To achieve this, we conducted a grid search on a parameter of the asymptotic formula for $\psi$-class intersection numbers, specifically the exponential growth constant, based on the Transformer’s hidden representation. Using probing techniques and conformal prediction, we demonstrated that this information is indeed encoded in the model’s internal representation and provided strong evidence for recovering its value.
We also performed the same analysis (without any alternative hypotheses) on the first few terms of the subleading terms. We found that nearly $98\%$ of the variance in the subleading terms is encoded in and can be predicted with high confidence from the model’s internal vector space.

In the end, we analyzed the internal decision-making procedure of DynamicFormer using causal inference. By applying the causal tracing method with counterfactual interventions, we aimed to shed light on how various input modalities—namely, the partitions, quantum Airy structure, and number of marked points—are causally responsible for the model’s understanding of the intersection numbers of $\psi$-classes and the parameters for large genus.

### 7.1. Limitations and Future Directions

It is important to address some key limitations of this work and studies in this area. One of the central messages of this research is that simply predicting or classifying a mathematical object with machine learning is not sufficient. Even with a highly accurate model, uncertainties in predictions always exist, and it is crucial to account for them. A prediction without proper uncertainty estimation is not reliable, especially in mathematics, where observations and computations must be both robust and precise.

In our work, we aimed to enhance reliability and explainability, but uncertainties in predictions and knowledge discovery still persist. For instance, if the underlying quantum Airy structure changes, the model may struggle to generalize. One potential solution would be to incorporate symbolic embeddings [dascoli2022deep, meidani2024snip] of the quantum Airy structures, modulated by numerical values, to develop a foundational model for intersection numbers. This approach could facilitate the study of relationships between different theories and ultimately enable the symbolic prediction of closed-form formulas for asymptotic behaviors of intersection numbers.

Another limitation of our work is the performance of uncertainty estimation, where we employed conformal prediction. While introducing this type of uncertainty estimation to the community is a step forward, our current coverage is clearly insufficient, indicating that our uncertainty bands are not yet fully reliable. Future efforts should explore more robust and appropriate conformal methods [xu2024conformal] for uncertainty quantification.

A fascinating avenue for future research is to explore recent developments in intersection numbers [eynard2023newformula]. This new approach proposes a formula that involves sums over partitions of combinatorial factors and reveals that certain partitions with specific conditions have vanishing coefficients in their decomposition into elementary symmetric polynomials. Remarkably, empirical observations suggest that even more partitions have vanishing coefficients than the trivial ones. This unexpected result points to a deeper, hidden structure in intersection numbers, where the internal representation of the Transformer model could be very beneficial in examining these new results and uncovering the underlying patterns.

#### Acknowledgments

This research was supported by Excellence Cluster ORIGINS, funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Germany’s Excellence Strategy - EXC-2094-390783311. A.G. was supported by an ETH Fellowship (22-2 FEL-003) and a Hermann-Weyl-Instructorship from the Forschungsinstitut für Mathematik at ETH Zürich. B.H. wishes to express his gratitude to Gaëtan Borot, Elba Garcia-Failde, Lukas Heinrich, and François Charton for their invaluable discussions throughout this work.

## Peer Reviews

confidence: 3
contribution: 3
initial_rating: 5
presentation: 3
questions: **Notice: These questions have been answered during the discussion phase, and remain unedited for posterity.**

* What is the significance of $\hbar$ in the quantum Airy structure? How is it relevant specifically to training the DynamicFormer?
* Figure 3 may be a discrete sampling of an underlying (continuous?) map that gives an $R^2$ for each $A$, with a maximum at $A=2/3$. Can the authors characterize this map?
* Figure 4 shows a significantly weaker causal impact of $B$ on the number of intersection points, compared to $n$ and $d$. Though the authors call this unexpected in section 5's last paragraph, is there any explanation regarding the weak causal impact of $B$?
soundness: 4
strengths: * The new DRA functions, motivated by the evidence presented in the paper, are a significant contribution that may interest machine learning scientists.
* Training a DynamicFormer to predict $\psi$-class intersection numbers, which then allows one to investigate a system's deeper geometry, is a significant, novel contribution that will interest mathematicians investigating enumerative geometry.
* The use of Conformal Prediction to estimate uncertainty provides a concrete measure of confidence in the experimental results, contributing to the paper's soundness.
* The figures are clear and high-quality, with informative captions.
* The writing is clear and mostly organized, including the mathematical background, methodology, and results.
summary: The paper proposes and tests the usage of transformers in the field of enumerative geometry, specifically regarding topological recursions and $\psi$-class intersection numbers. To accomplish this, the paper proposes a new class of activation functions called Dynamic Range Activators (DRAs), and presents evidence of their performance in predicting a simple recursive function as part of a fully connected neural network, and then their ability to predict $\psi$-class intersection numbers as part of their DynamicFormer architecture. The paper then attempts to investigate the trained DynamicFormer to see if it can predict other concepts in enumerative geometry, including the Dilation equation that stems from Virasoro constraints, as well as the asymptotic behavior of $\psi$-class intersection numbers using abductive reasoning, verified using counter-factual intervention.
weaknesses: **Notice: These weaknesses have been adressed during the discussion phase, and apply only to the initial version of the manuscript. However, these will remain unedited for posterity.**

### Section 2
* The equations in this section use $\hbar$ without defining it in the text. It may be worth explicitly calling it the reduced Planck constant in the text.
* The last paragraph mentions excluding the tensor $C$ due to a decreased impact on the computed $\psi$-class intersection numbers, observed during experimentation. Appendix C justifies this exclusion, yet is not referenced in the text, making for seemingly unsound reasoning for excluding $C$. The authors should consider referencing appendix C here to further justify the exclusion of $C$, and expanding on this point within appendix C proper.

### Section 3
* In the first two paragraphs, the paper presents the DynamicFormer for the first time and references a figure placed within an unrelated appendix, resulting in a disjointed reading experience. The authors may consider moving some parts of section 3 (such as its first two paragraphs) into a new appendix showcasing the DynamicFormer in detail and including the figure close by.
* In the same paragraphs, the authors use the initials COO without previously defining them. These initials seem to appear nowhere else in the main text, and only in appendix B are they defined as Coordinate List. Besides hurting the paper's readability, this seems to be an implementation detail that does not need to appear in the main text.
* The last paragraph mentions the [DYN] registry tokens, but fails to reference appendix B1. It may be appropriate to reference it here.

### Section 5
* Equation 5.4 is presented without proof, with the authors claiming they used an approach described in Eynard et al. (2023). A sketch of the proof (perhaps in an appendix) will contribute to the work's soundness.
* Figure 3, and the relevant experiment, are based on the assumption that $A$ is rational. The authors should consider justifying the choice of testing only rational values of $A$, perhaps by connecting it back to equation 5.3, as proven by Aggarwal (2021).
* Figure 3 presents a significantly higher value of $R^2$ for $A=2/3$ compared to the values for $A=4/6$ and $A=6/9$, despite being identical numbers. This issue does not appear for other such sets of identical rational numbers, such as $A=3/4$ and $A=6/8$. Since the rest of the subsection on Abductive Reasoning relies on $A=2/3$ being the correct answer, **this error calls the entire subsection into question and significantly hurts the paper's soundness and overall rating**. The authors must justify how the $R^2$ of $A=2/3$ is different from the other two values, or replace the figure (and perhaps rewrite some of the supporting text). Based on the other values of the figure, it should be expected to see a maximal $R^2$ around $A=2/3$, but without such a significant jump.

### Typos
* Section 5.1 line 319: "The topological recursion formula equation 2.4 [...]". Consider removing either "formula" or "equation", or placing all of "equation 2.4" in parentheses.
* Section 5.1.1. has multiple citations included in sentences with their parentheses. The ICLR 2025 formatting instructions (section 4.1) require such references to not have parentheses except around the year. The references in question appear in lines 371, 378, and 381.
* Section 5.1.1 line 417: "As a result, We find an evidence [...]". "We" does not need to be capitalized, and "an" should be removed.
* Appendix C line 950: "Figure 6 shows (s) numerical [...]".
* The title of appendix D and the caption of figure 7 both mistakenly write Princip**le** Component Analysis instead of Princip**al** Component Analysis.

---

confidence: 2
contribution: 3
initial_rating: 5
presentation: 2
questions: + I wonder why the authors choose transformers as the regression function? 
+ In Figure 1, have you tried to apply DRA to MLP or other potential neural networks?
+ Will the code and the datasets be available?
soundness: 3
strengths: + The idea of using transformers to do enumerative geometry is new. 
     + Meanwhile, the authors proposed a new activation function, DRA, which found to be useful to improve the prediction performance.
     + The authors compared DRA with other popular activations functions in Figure 1 and Table 2.

+ Experiments show some evidence of transformers can learn to predict the $\psi$-class intersection numbers.
     + Meanwhile, the authors also presented a discussion on how transformers being able to achieve that by inspecting internal vector space of the model.

+ The author also investigated how inputs affect the model’s understanding of $\psi$-class intersection numbers and the parameters for large genus.
summary: This paper introduced DynamicFormer to learn and predict the $\psi$-class intersection numbers. Experiments include both in-distribution results and out-of-distribution results. The author also presented some experiments to illustrate how transformers perform enumerative geometry. Meanwhile, the authors also investigated whether the proposed method could perform abductive reasoning and hypothesis testing to estimate the parameters of asymptotic form for intersection numbers.
weaknesses: I am not an expert in "enumerative geometry". However, I think the paper lacks many important clarifications and discussions.
 
+  The paper lacked discussion of the reasons/motivations of using transformers.  At the moment, the paper seemed only a combination of  a popular neural network architecture and a new mathematical problem.
+ The "Related Work" section is quite weak at the moment: the authors spent only one paragraph to discuss related works and then summarized their contributions.
+  From my perspective, the proposed DRA is not the only way to capture the periodic behavior in data. This lacks sufficient discussion in the paper.
+ From experiments in Figure 1, the authors did not apply DRA to other neural network architectures (eg MLP), and provided readers with more discussions on that.
+ Lack of theoretical discussion on the proposed method.
+ Code is not available.

---

confidence: 4
contribution: 2
initial_rating: 3
presentation: 4
questions: It would be good if the authors could at least mention questions that would bring something interesting to the enumerative geometry (something feels interesting when they perform an analysis of the internal representation of the network, but it stops just before it gets interesting...).
soundness: 3
strengths: The care and clarity of the writing, the fact that some extensive research has been done, the general trust in the results that this paper inspires.
summary: The authors investigate the ability of transformers to compute the psi-intersection numbers in geometry and found that they perform (unsurprisingly) very well in distribution and quite well outside of distribution, and performed a series of analyses to understand which structures are being learned this way. They find in particular that the model learns the Dilaton equation and some information about the exponential growth of these psi-intersection numbers.

Overall, this paper is written very carefully, with excellent explanations of what is being done, although the importance of some details is unclear (like: what do we need to know about psi-intersection numbers? most of the sophisticated formulae are not really used in a meaningful way). However I am not sure the work is very interesting from a geometric point of view (the interesting thing is to gain theoretical insight into what psi-intersection numbers, not get somehow numerically accurate estimates of them) or from a machine learning point of view (it is not clear what is more interesting about these numbers than about any sequence in the OEIS, say). The experimental results are not particularly surprising given what is known about transformers, or at least I don't see it. 

While this work can be viewed as a first step towards making progress in applying machine learning to enumerative geometry, and the carefulness of the writing and experiments should be commended, I don't think it brings a lot of interesting new informations about machine learning or enumerative geometry.
weaknesses: What do we learn about machine learning or enumerative geometry? We seem to learn something that could be expected, a particular case of a general phenomenon.

---

confidence: 2
contribution: 1
initial_rating: 3
presentation: 2
questions: *Recommendation*

I recommend to reject the paper mainly because I believe ICLR is not a suited venue, both for referring this paper (this paper needs to be reviewed by at least one expert in enumerative geometry, I don't know if there are such reviewers at ICLR) and for disseminating it (a journal in the field of computational enumerative geometry may be more suited). Furthermore, in my opinion the presentation of the material can be improved in several aspects before publication.

 
*Comments and questions*

- To which extent incorporating the conformal prediction framework in your analysis necessary? I am afraid this adds an additional layer of complexity that further hinders the communication of your findings. Maybe this discussion should be deferred to the appendix, keeping only what is strictly necessary to understand the main conclusion of your experiments in the main paper. 

- I don't understand the paragraph on top of p. 7, and I don't think this is due to my lack of expertise in enumerative geometry. In particular, what does "the neural network embedding p_g,n ... is a vector space"  means ? How can a function be a vector space? What does "go to the inner product space" means? These are (to me) very loose nonsensical mathematical statements.

*Minor comments & typos*

- p.3 the acronym COO has not been introduced

- Figure 5 should be included in the main part of the paper. In general, avoid forward references to far away, especially in the appendix without mentioning that it is in the appendix. 

- Use capitalization when reference tables, figures, sections, equations, etc. in the text (no capitalization needed when referring to figures or tables in general). E.g. Figure lines 168, 197, 334, Section lines 204, Table lines 274,298, Equation lines 319, 389 ... ... 

- line 196 we -> We

- line 421: the sentence "The interesting thing is that this is the performance of the non-linear probe." could be rephrased to better suit a formal publication.
soundness: 2
strengths: (S1) Investigating to which extent the recent successes of transformer models can transfer to other tasks, such as the one of solving fundamental problems in mathematics, is worthwhile and relevant.
summary: Unfortunately, I have no expertise at all in computational enumerative geometry. My review will thus be quite superficial.

*Summary*

This paper proposes to use transfomer models to tackle what I understood is a central problem in enumerative geometry: computing the phi-class intersection numbers on the moduli space of curves. From my pretty crude rudimentary and pragmatical ML perspective, the authors reduce this problem to learning a multi modal function mapping input tuples of the form (quantum Airy structure datum [a tensor / sequence of tensors], genus [integer], number of marked points [integer], partitions [permutation-invariant set]) to output intersection numbers [sequence of integers (?)]. The model is trained on solutions computed using brute-force methods up to some genus, and evaluated on its ability to extrapolate to find solutions for higher genus (geni?). 

The main technical contribution of the papers are methodological and consist in 

(i) designing a specific multi-modal transformer architecture suited to the problem at hand (combining mostly existing models / techniques)
(ii) introducing a novel activation function specifically suited to model recursive functions, which are crucial to solve the problem. 

Experiments on synthetic data are provided demonstrating that the model seems to be able to extrapolate to higher geni than the ones seen in the training data. The authors also provide some more qualitative analysis to investigate to which extent the internal representations learned by the model encode mathematical structures that are known to be relevant to solve the problem.
weaknesses: (W1) The relevance and technical aspects cannot be well understood / evaluated unless the reader has some non-trivial background knowledge of enumerative geometry.

(W2) The writing and exposition of the material can be improved.

Meta-review: **Summary:**  
This paper introduces a Transformer-based model, DynamicFormer, with a novel Dynamic Range Activator (DRA) activation function tailored to model recursive functions with high variance and factorial growth. The study applies this methodology to computational enumerative geometry, specifically in computing \(\psi\)-class intersection numbers. Additionally, the paper incorporates conformal prediction for uncertainty quantification and provides interpretability analyses that uncover evidence of the model learning mathematical structures, such as the Virasoro constraints.

**Strengths:**  
1. **Novel Methodology:**  
   - The DRA activation function addresses challenges in modeling recursive functions with factorial growth, a significant contribution beyond standard applications of transformers.  
   - Incorporates uncertainty quantification in a rigorous and tailored manner for high-variance recursive data.  

2. **Interdisciplinary Contribution:**  
   - Bridges machine learning and enumerative geometry, showcasing how AI can assist in tackling complex mathematical problems.  
   - Reveals new insights into mathematical structures through model interpretability, contributing to the AI for Science community.  

3. **Solid Experimental Design:**  
   - Comprehensive evaluation of DRA against other activation functions on synthetic data.  
   - Demonstrates the ability of DynamicFormer to generalize to out-of-distribution cases.  
   - Insightful analysis of the network's internal representations and their alignment with known mathematical properties.  

**Weaknesses:**  
1. **Complexity and Accessibility:**  
   - The paper's interdisciplinary nature makes it challenging for readers without expertise in enumerative geometry or advanced mathematics to fully grasp the significance of the contributions.  
   - The initial presentation of material was fragmented, though significantly improved during the discussion phase.  

2. **Limited Exploration of Applications:**  
   - While the paper demonstrates the feasibility of using transformers for \(\psi\)-class intersection numbers, broader applications and deeper theoretical insights into the DRA activation function could strengthen the work further.  

3. **Venue Suitability Concerns:**  
   - Some reviewers questioned whether ICLR is the most appropriate venue for this work, given its mathematical focus. However, the paper aligns with the growing interest in interdisciplinary research at ML conferences.  

**Discussion:**  
The reviewers expressed mixed opinions. One reviewer rated the paper highly, highlighting its interdisciplinary novelty and methodological contributions. Other reviewers raised concerns about the presentation and accessibility but acknowledged the potential of the work. The authors addressed these concerns through substantial revisions, clarifications, and added context, improving the paper significantly. Despite its complexity, the paper offers novel contributions to both the ML and mathematical communities.

**Suggestions for Camera-Ready Submission:**  
1. Continue improving the clarity and accessibility of the manuscript, particularly for readers with limited background in enumerative geometry.  
2. Highlight broader implications and potential applications of the DRA activation function in modeling recursive functions beyond the specific mathematical context explored.  
3. Ensure all implementation details and code are easily accessible to facilitate reproducibility.  

**Conclusion:**  
This paper represents an original and significant contribution to the intersection of AI and advanced mathematics. While the application is domain-specific, the methodologies and insights have broader relevance to the AI for Science community. The constructive feedback from reviewers has been well-addressed, and I recommend the revised manuscript for acceptance.

Decision: Accept (Poster)