Learning Q-gonality from arithmetic data

A story about incomplete labels, conflicting metrics, and readable formulas

← Back to AI 4 Math

Project: Machine Learning and LLM-Boost Symbolic Regression for Predicting \(\mathbb{Q}\)-Gonality of Modular Curves · Code · AI4MATH at ICML 2025

With Xiaokang Wang, Yuxiang Yao, Po-Chu Hsu, and Peikai Qi.

The awkward part of this dataset is also the mathematically interesting part: not every modular curve comes with an exact gonality. For some curves we know the value; for others we know only that it lies in an interval.

That distinction shaped how we trained the models and, more importantly, how we interpreted their predictions. I did not see the project as a contest to maximize one accuracy score. The more useful questions were how much of gonality is already visible in standard arithmetic invariants, where that signal stops being reliable, and whether any part of it can be written in a form that one can inspect mathematically.

The integer hiding a map

Before this became a machine-learning problem, it was a problem about finding a map.

A modular curve \(X_H\) is attached to an open subgroup

\[H\subseteq \operatorname{GL}_2(\widehat{\mathbb Z}).\]

Very roughly, its noncuspidal points describe elliptic curves together with the torsion or level structure encoded by \(H\). Compactifying this moduli space adds cusps, which represent degenerations of elliptic curves. This is why one LMFDB row can contain group-theoretic data such as level and cusp orbits alongside geometric data such as genus and gonality.

A nonconstant function \(f\in\mathbb Q(X_H)\) defines a map

\[f:X_H\longrightarrow\mathbb P^1_{\mathbb Q}.\]

If the map has degree \(d\), then a generic value of the rational parameter has \(d\) preimages, counted with multiplicity. The \(\mathbb Q\)-gonality is the smallest possible degree:

\[\gamma_{\mathbb Q}(X_H) = \min_{f\in\mathbb Q(X_H)\setminus\mathbb Q} [\mathbb Q(X_H):\mathbb Q(f)].\]

Equivalently, one is looking for the smallest base-point-free pencil \(g^1_d\) defined over \(\mathbb Q\). Gonality one means that the curve is rational over \(\mathbb Q\); gonality two means that it admits a double cover of the projective line. The field matters: a map can appear after extending scalars even when it is not defined over \(\mathbb Q\), so

\[\gamma_{\overline{\mathbb Q}}(X_H) \leq \gamma_{\mathbb Q}(X_H).\]

Our target was the arithmetic quantity on the right.

The curve already comes with one map

Every modular curve has a natural map obtained by forgetting the level structure and retaining only the \(j\)-invariant:

\[j:X_H\longrightarrow X(1)\simeq\mathbb P^1.\]

Its degree, controlled by the index of the subgroup defining the curve, immediately gives an upper bound

\[\gamma_{\mathbb Q}(X_H)\leq\deg(j).\]

It is an available map, not necessarily the smallest one. Other upper bounds can come from explicit rational functions or linear systems on the curve.

Lower bounds arrive from a different direction. At a prime power \(q\) of good reduction, a degree-\(d\) map to \(\mathbb P^1\) has at most \(d\) points above each of the \(q+1\) rational points of the target. Thus

\[\#X_H(\mathbb F_q)\leq d(q+1), \qquad d\geq\frac{\#X_H(\mathbb F_q)}{q+1}.\]

This simple inequality explains one way a point count can rule out small degrees. More global lower bounds use the index of the modular group. In practice, the constructive upper-bound argument and the obstructive lower-bound argument often stop before they meet. The gap between them is not missing bookkeeping; it records an unfinished mathematical problem.

Not every label is a number

After cleaning and deduplication, our data contained 40,460 curves with exact gonality and 5,800 curves with only a lower and an upper bound. We kept these two kinds of information separate rather than turning each interval into an arbitrary midpoint.

There was another asymmetry in the data. The values 2, 4, 6, 8, and 16 account for 95.473% of the exact labels. A model can therefore look convincing on the typical cases while behaving quite differently on rarer or larger values.

{
  "type": "bar",
  "data": {
    "labels": ["2", "4", "6", "8", "16", "All other"],
    "datasets": [
      {
        "label": "Number of curves",
        "data": [5960, 17268, 788, 8068, 6544, 1832],
        "backgroundColor": [
          "rgba(138, 87, 196, 0.65)",
          "rgba(23, 162, 184, 0.65)",
          "rgba(138, 87, 196, 0.65)",
          "rgba(23, 162, 184, 0.65)",
          "rgba(138, 87, 196, 0.65)",
          "rgba(128, 128, 128, 0.5)"
        ],
        "borderColor": [
          "rgb(138, 87, 196)",
          "rgb(23, 162, 184)",
          "rgb(138, 87, 196)",
          "rgb(23, 162, 184)",
          "rgb(138, 87, 196)",
          "rgb(128, 128, 128)"
        ],
        "borderWidth": 1
      }
    ]
  },
  "options": {
    "responsive": true,
    "aspectRatio": 1.7,
    "plugins": {
      "title": {
        "display": true,
        "text": "Distribution of exact Q-gonality labels",
        "color": "#888888"
      },
      "legend": {
        "display": false
      }
    },
    "scales": {
      "x": {
        "title": {
          "display": true,
          "text": "Q-gonality",
          "color": "#888888"
        },
        "ticks": {
          "color": "#888888"
        },
        "grid": {
          "display": false
        }
      },
      "y": {
        "beginAtZero": true,
        "title": {
          "display": true,
          "text": "Curves",
          "color": "#888888"
        },
        "ticks": {
          "color": "#888888"
        },
        "grid": {
          "color": "rgba(128, 128, 128, 0.15)"
        }
      }
    }
  }
}

The interval-valued labels and the concentration on a few common values made a single accuracy number insufficient. We used rounded exact match, \(R^2\), RMSE, bounds accuracy, and a separate high-level test because each reveals a different kind of error.

Why the columns were not arbitrary

The numerical features were not eight unrelated database fields. They were different shadows of the same curve.

The level says how deep the congruence condition defining \(H\) lives. If one defining subgroup is contained in another, forgetting part of the level structure produces a finite map \(\pi:X\to Y\) between the corresponding modular curves. Composing maps gives

\[\gamma_K(X)\leq\deg(\pi)\,\gamma_K(Y).\]

So the subgroup lattice supplies a network of possible upper bounds. This does not make gonality monotone in the numerical level—two curves at nearby levels can have very different geometry—but it gives a reason to expect level data to carry signal.

The genus controls which linear systems can exist. For a curve of genus \(g>1\), Riemann–Roch gives general upper bounds for gonality; when a rational point is available, one can build divisors over \(\mathbb Q\) more economically. A rational cusp is such a point. The total number of cusps records the boundary over \(j=\infty\), while the number of rational cusps records part of its Galois structure. Modular units also have divisors supported at cusps, so cusp data is a natural place to look for low-degree rational functions.

The recorded rank and conductor carry information from the Jacobian and its \(L\)-function. A map to \(\mathbb P^1\) is ultimately a statement about rational divisor classes with enough sections, which makes Jacobian data a plausible indirect witness. That sentence is a motivation, not a theorem: rank alone does not determine whether gonality rises or falls.

Finally, the two coarse fields help distinguish curves that the six core numerical invariants do not. I treat them as useful disambiguating information, not as an explanation by themselves. The learning problem was interesting precisely because these invariants interact, while none of them separately is the gonality in disguise.

What does 93.84% actually mean?

The simplest useful reference point was XGBoost on eight numerical invariants: level, genus, rank, the numbers of cusps and rational cusps, log conductor, coarse class number, and coarse level. It reached 93.84% exact-match accuracy on the ordinary test set, with \(R^2=0.9988\) and RMSE 0.302.

That result told us that the recorded invariants contain a strong predictive signal. It did not tell us whether one or two invariants were doing most of the predictive work. With six core numerical invariants, exact accuracy remained at 92.61% and \(R^2\) at 0.9985. With only coarse level and coarse class number, accuracy fell to 24.69% and \(R^2\) to 0.2487. The two coarse descriptors were not enough to explain the baseline.

We also tried a richer FT-Transformer representation with categorical and list-valued fields. Its ordinary exact accuracy, 93.64%, was close to the tree model. A more elaborate representation did not by itself resolve the harder question: would the same relationships survive outside the levels seen during training?

A random split still resembles its training set, so we looked separately at curves of level greater than 59.

Model High-level exact accuracy High-level \(R^2\) High-level RMSE Bounds accuracy
XGBoost 80.96% 0.7206 16.0031 87.57%
FNN 68.71% 0.9950 2.141 91.93%
FT-Transformer 82.98% 0.3486 24.435 89.74%

On this set, the FT-Transformer had the highest rounded exact accuracy, 82.98%, but also \(R^2=0.3486\) and RMSE 24.435. The FNN had lower exact accuracy, 68.71%, yet obtained \(R^2=0.9950\) and RMSE 2.141. Neither statement cancels the other: they describe different error shapes. A few large misses can have little effect on rounded accuracy and still dominate the continuous metrics.

This changed how I read the headline number. No model was best under all three high-level metrics, and “correct after rounding” was only one version of being close.

A bound can still train a model

The dataset did not begin with a clean regression target. It began with a familiar situation in arithmetic geometry: sometimes we can prove that a sufficiently small map cannot exist and, separately, construct a map from above without making the two arguments meet.

A record \([a_i,b_i]\) means

\[a_i\leq\gamma_{\mathbb Q}(X_i)\leq b_i.\]

The lower endpoint rules out degrees below \(a_i\); the upper endpoint says that a map or linear system of degree no larger than \(b_i\) is available. Only when the endpoints agree do we know the gonality exactly. An interval such as \([8,12]\) does not say that 10 is more likely than 8 or 12. Replacing it by its midpoint would manufacture information that the mathematics never supplied.

Once the metrics are separated in this way, the curves with only bounds no longer look like incomplete versions of the exact dataset. They provide a different kind of supervision.

For a bounded curve, the data do not identify one target value. They do tell us which predictions are inconsistent with what is already known. For a prediction \(\widehat y_i\) and an interval \([a_i,b_i]\), we encoded exactly that information in the loss

\[\mathcal L_{\mathrm{interval}} = \frac{1}{n}\sum_i \left[ \max(a_i-\widehat y_i,0)^2 + \max(\widehat y_i-b_i,0)^2 \right].\]

A prediction inside the interval receives no penalty; only predictions below the lower bound or above the upper bound are penalized. The model uses everything the interval tells us without inventing an exact gonality.

The resulting FNN reached 98.21% bounds accuracy on its bounded test split, although its exact-label accuracy was 87.94%. XGBoost showed the opposite emphasis: stronger exact-label performance, but 89.14% bounds accuracy. The interval-loss FNN was a separate experiment rather than a fold-for-fold comparison, so I would not read this as one model defeating the other. Fitting known exact values and respecting partially known values are related, but genuinely different objectives.

Prediction is not yet an explanation

The predictive experiments answer whether the signal is present. They do not tell us whether that signal has a short mathematical description.

For that question we built LLM-Boost. It starts from a degree-three polynomial model. At each iteration, a language model proposes short nonlinear features from the available invariants. It does not decide which features enter the final model: each candidate is orthogonalized against the selected terms, fitted to the current residual, and retained only when it improves validation accuracy.

If the proposed feature at step \(k\) is \(f_k\), the update is

\[\widetilde f_k(x) = \widetilde f_{k-1}(x) + b_k\left(f_k(x)-\sum_{i=1}^{k-1}a_i f_i(x)\right), \qquad \widetilde\epsilon_k(x)=y-\widetilde f_k(x).\]

This division of labor mattered to us: the language model supplied candidate structure, while the data decided what survived. The textual rationale returned with a feature was not part of the selection rule.

Among the symbolic methods, LLM-Boost had the best exact-match accuracy, 73.50%, and the best bounds accuracy, 81.52%. LLM-SR instead had better \(R^2\) and RMSE, but only 35.88% exact accuracy. The same tension among metrics appeared again, this time inside symbolic regression. A compact expression and a strong point predictor are not the same object.

I read the resulting expressions as candidates for inspection: which combinations of invariants repeatedly reduce the residual, and which of those combinations might have a mathematical explanation?

What would a prediction buy us?

Suppose a model predicts 12 for a curve whose known bounds are \([8,20]\). Mathematically, the interval has not changed. The prediction is instead a suggestion about where to look: try to construct a rational function or a base-point-free \(g^1_{12}\), inspect nearby curves in the modular-map lattice, and ask whether the same combination of genus, cusps, and level reappears in a recognizable family.

Turning that suggestion into a theorem still takes two separate arguments. An upper bound needs an actual map over \(\mathbb Q\). An exact value also needs a proof that no smaller-degree map exists. The model supplies neither. If its prediction falls outside a proven interval, the prediction is wrong; the bound is not being challenged.

This is also how I read the symbolic expressions produced by LLM-Boost. If a combination of invariants repeatedly removes residual error, it may point toward a family worth isolating or a relation worth trying to explain. It is not automatically a formula for gonality.

For me, the useful output is therefore not a replacement for a gonality computation. It is a way to order the next computations: which bounded curves look unusually rigid, which ones may admit unexpectedly small maps, and which numerical patterns survive when we move to higher levels.

What I take from this project

The most useful lesson for me is that partial mathematical knowledge should not automatically be treated as missing data. An interval can be used directly, and doing so changes both the training objective and the meaning of success.

The disagreement among exact accuracy, \(R^2\), and RMSE was equally informative. It showed where a model was matching the common cases and where it was making a smaller number of much larger errors. Whether these errors reflect sparse data or missing mathematical structure, they identify cases that deserve separate examination.

Finally, the symbolic experiment made prediction and interpretation into two distinct goals. I would use the numerical models to locate patterns and exceptional cases, and the symbolic model to suggest relations worth examining. I would not use either one to certify the gonality of an individual curve.

← Back to AI 4 Math