HATSolver: Learning Gröbner Bases with Hierarchical Attention Transformers
Mohamed Malhou, Ludovic Perret, Kristin Lauter
International Conference on Learning Representations 2026 · Oral
Overview
This talk introduces HATSolver, a novel Hierarchical Attention Transformer designed to tackle the computationally intensive problem of solving systems of multivariate polynomial equations by computing their Gröbner bases. Presented by Mohamed Malhou, under the supervision of Ludovic Perret and Kristin Lauter, this work addresses a fundamental challenge at the intersection of pure mathematics and machine learning. The ability to efficiently solve such non-linear systems is critical across numerous fields, including cryptography, coding theory, optimization, and biology, yet remains largely intractable for classical algorithms as system complexity grows.

Key moments
- 0:30 The challenge of solving multivariate polynomial equations
- 1:30 Limitations of prior transformer approaches for Gröbner bases
- 2:50 HATSolver's hierarchical attention architecture for efficiency
- 4:05 HATSolver's performance versus classical algorithms (54/54 solved)
- 4:55 HATSolver's efficiency and robustness across different fields
- 5:40 Conclusion: Architecture design and future research directions
- 6:15 Q&A: HATSolver's application on the decoder side
- 6:40 Q&A: Generalizing HATSolver to larger, untrained problems
HATSolver: Learning Gröbner Bases with Hierarchical Attention Transformers
Speakers: Mohamed Malhou; Ludovic Perret; Kristin Lauter
Conference: ICLR 2026
YouTube: https://slideslive.com/39062116
Overview
This talk introduces HATSolver, a novel Hierarchical Attention Transformer designed to tackle the computationally intensive problem of solving systems of multivariate polynomial equations by computing their Gröbner bases. Presented by Mohamed Malhou, under the supervision of Ludovic Perret and Kristin Lauter, this work addresses a fundamental challenge at the intersection of pure mathematics and machine learning. The ability to efficiently solve such non-linear systems is critical across numerous fields, including cryptography, coding theory, optimization, and biology, yet remains largely intractable for classical algorithms as system complexity grows.
The core innovation of HATSolver lies in its ability to circumvent the quadratic computational cost inherent in traditional transformer architectures, which has historically bottlenecked their application to large-scale mathematical problems. By representing polynomial systems as hierarchical tree structures and employing a specialized attention mechanism, HATSolver significantly extends the frontier of solvable problems, demonstrating unprecedented success on systems with many variables where classical methods fail outright. This research not only pushes the boundaries of what machine learning can achieve in symbolic mathematics but also offers a promising new paradigm for designing scalable neural architectures for inherently hierarchical data.
Background
▶ Watch: The challenge of solving multivariate polynomial equations (0:30)
The challenge of solving systems of multivariate polynomial equations is a cornerstone problem in mathematics and computer science. While linear equations are readily solved using techniques like Gaussian elimination, their non-linear counterparts pose a much greater hurdle. The primary algorithmic tool for addressing these systems is the Gröbner basis, which can be conceptualized as a generalization of Gaussian elimination for polynomial ideals. A Gröbner basis transforms a complex system into a structured, often triangular form, making individual equations solvable through methods like back-substitution.
However, computing Gröbner bases is notoriously difficult. Modern classical algorithms, such as F4 and F5, and their highly optimized implementations (e.g., msolve), operate in exponential time with respect to the number of variables and the degree of the polynomials. This exponential complexity renders these methods intractable for even moderately sized systems. For instance, a system with just 13 variables and polynomials of degree 11 can generate up to 25 million monomials, quickly overwhelming classical computational resources.
Recognizing this intractability, the machine learning community has begun exploring neural network approaches. Kira et al. (NeurIPS 2024) pioneered the use of transformers to directly predict Gröbner bases from input polynomial systems. While their work demonstrated initial success, it encountered a significant bottleneck: standard transformers exhibit a quadratic computational complexity (O(L^2)) with respect to the input sequence length (L). Given that polynomial systems grow exponentially in size with increasing variables or degrees, this quadratic scaling severely limited the practical applicability of prior transformer models, restricting them to very sparse systems with only around five variables.
To generate the necessary training data for these models, researchers often employ a "backward method." This approach, proposed by Kira et al., starts from a known solution (focusing on shape position ones) and then obfuscates it using an invertible unimodular matrix with polynomial entries. This process creates a synthetic pair of a system and its Gröbner basis. Crucially, Camby (2025) provided a geometric proof demonstrating that these synthetically generated samples are sufficiently diverse and general, ensuring that models trained on such data can generalize effectively to real-world problems.
Key Findings
▶ Watch: HATSolver's hierarchical attention architecture for efficiency (2:50)
HATSolver represents a significant leap forward in the automated computation of Gröbner bases, addressing limitations of both classical algorithms and prior machine learning approaches. The key findings underscore its superior performance and architectural efficiency:
- Breaching Intractability Barriers: HATSolver successfully computes Gröbner bases for systems with 13 variables, a scale at which state-of-the-art classical algorithms (like F4 and F5) consistently fail or time out within a generous two-hour limit.
- Substantial Performance Gains: On a test set of 13-variable systems, HATSolver achieved an exact match accuracy of 54% within a few minutes of inference time, whereas classical algorithms could only solve 12% of the systems within two hours. When considering support accuracy (predicting the correct monomials regardless of coefficients), the performance jumped to 71%.
- Efficient Scaling: The hierarchical attention mechanism dramatically reduces the computational complexity associated with long input sequences, enabling the model to process significantly larger polynomial systems than previous transformer-based methods. This is evidenced by HATSolver's ability to complete 400k training steps on n=10 variable systems, compared to the base transformer's 120k steps in the same timeframe.
- Effectiveness of Curriculum Learning: Training HATSolver with a curriculum, starting with smaller systems (e.g., 3 variables) and progressively increasing complexity up to 13 variables, proved highly effective. This approach yielded a 54% exact match accuracy, significantly outperforming direct training on 13-variable systems, which achieved 34%.
- Robustness Across Finite Fields: The model demonstrated consistent performance across different finite fields, including prime fields (F7, F17) and extension fields (F16), indicating its field-agnostic applicability, particularly relevant for cryptographic contexts where F16 is commonly used.
- Early Learning Advantage: Even at smaller scales (e.g., n=6 variables), where a vanilla transformer failed to learn (0% accuracy), HATSolver began learning effectively after just a few thousand training steps, highlighting the benefits of its specialized architecture.
Technical Deep Dive
▶ Watch: HATSolver's efficiency and robustness across different fields (4:55)
The core innovation of HATSolver lies in its Hierarchical Attention Transformer architecture, specifically designed to overcome the quadratic complexity bottleneck of traditional transformers when processing long sequences representing polynomial systems. The key insight is to leverage the inherent hierarchical structure of these mathematical objects.
HATSolver views a polynomial system not as a flat sequence of tokens, but as a tree structure. At the top level, the root represents the entire system. This system is composed of multiple equations, each of which is composed of terms, and each term, in turn, is made up of variables and coefficients. This tree-like representation allows for a more intelligent orchestration of attention, focusing on relevant tokens at different granularities rather than requiring every token to attend to every other token globally.
The hierarchical attention mechanism operates in two distinct phases:
- Bottom-Up Phase (Local Attention and Pooling):
- Within each parent node in the tree structure (e.g., an equation node containing multiple term nodes), local attention is computed. This means that tokens (e.g., individual terms) only attend to other tokens within their immediate parent's scope, rather than the entire system.
- After computing local attention, the representations of these child nodes are pooled to generate a consolidated representation for their respective parent node. This process effectively summarizes the information from the lower levels and passes it up the hierarchy. This phase continues until the root node (representing the entire system) has its representation computed.
- Top-Down Phase (Cross-Attention):
- Once the root's representation is established, information needs to be propagated back down to the leaves to inform the final output. This is achieved through cross-attention.
- Each child node in the hierarchy (e.g., a term node) cross-attends to its parent's representation, allowing it to incorporate global context and relevant information from higher levels of the tree. This phase ensures that the final representations of the leaf nodes are rich with both local details and global context.
This hierarchical approach aims to dramatically reduce computational complexity. While standard transformers incur a quadratic cost of O(L^2) with respect to the sequence length L, the speaker stated that HATSolver achieves a complexity "something like L to the power of 13 for our case." This specific exponent, if taken literally, would represent a significant increase in complexity rather than a reduction. However, given the context of addressing the quadratic bottleneck, it is highly probable that a different, much lower exponent or a different complexity class (e.g., O(L^(1.x)) or O(L log L)) was intended, or that '13' was a misstatement for a different value (e.g., 1.3 or 4/3) that signifies an improvement. The goal is unequivocally to move away from the prohibitive L^2 cost.
The underlying model is an encoder-decoder architecture. The hierarchical attention mechanism (HATSolver) is primarily applied to the encoder side to handle the potentially very long input sequences corresponding to complex polynomial systems. For the decoder side, which generates the Gröbner basis, HATSolver is not currently implemented. This is because the solutions (Gröbner bases) are often sampled to be relatively small in size during data generation. However, the authors are considering future work that would incorporate hierarchical cross-attention into the decoder for even greater efficiency and scalability if solution lengths become a bottleneck. The design of HATSolver is also engineered to be general, meaning it does not depend on a fixed number of levels in the tree structure and can adapt to various system complexities.
Experimental Setup & Results
▶ Watch: Conclusion: Architecture design and future research directions (5:40)
The experimental evaluation of HATSolver focused on demonstrating its ability to solve multivariate polynomial systems, particularly those that are intractable for classical algorithms.
Problem Definition: The task is to compute Gröbner bases for systems of multivariate polynomial equations. The primary focus was on systems over finite fields, specifically F7, F17 (prime fields), and F16 (an extension field). Finite fields are particularly relevant for applications in cryptography and coding theory, and previous research (Kira et al.) indicated they present a harder challenge for Gröbner basis computation compared to infinite fields.
Target System Size: The experiments primarily targeted systems with 13 variables, as this is the scale at which classical algorithms typically fail or time out.
Data Generation: Training data was generated using the backward method, starting from known solutions (shape position ones) and obfuscating them with unimodular matrices to create diverse system-solution pairs.
Baselines: HATSolver's performance was benchmarked against the best available classical Gröbner basis algorithms, including F4 and F5, implemented in highly optimized software like msolve. These classical solvers were given a strict two-hour time limit for each system. If a solver failed to produce a Gröbner basis within this period, it was considered a failure.
Key Metrics:
- Exact Match Accuracy: The percentage of test systems for which HATSolver's predicted Gröbner basis exactly matched the ground truth.
- Support Accuracy: The percentage of test systems for which HATSolver correctly predicted the set of monomials in the Gröbner basis, irrespective of their coefficients.
- Efficiency: Training steps completed within a given timeframe, and inference time per system.
Headline Results (13-variable systems):
- Solvability: HATSolver successfully solved 54% of the test systems within minutes of inference time. In stark contrast, classical algorithms managed to solve only 12% of the same test set within their two-hour limit.
- Support Accuracy: The support accuracy for 13-variable systems reached 71%, indicating strong capability in identifying the correct polynomial structure even when coefficients might vary slightly.
- Inference Speed: HATSolver's inference for these complex systems typically took only a "few minutes," significantly faster than the two-hour timeout for classical methods.
Ablation Studies and Further Results:
- Curriculum Learning: The impact of curriculum learning was substantial. Training the model progressively, starting with small systems (e.g., 3 variables) and gradually increasing complexity, yielded the impressive 54% exact match accuracy. When the model was trained directly on 13-variable systems without this curriculum, the exact match accuracy dropped to 34%, highlighting the importance of structured training for such complex tasks.
- Comparison with Base Transformer (without HAT):
- For systems with n=6 variables, the base transformer (without hierarchical attention) stalled at 0% accuracy, failing to learn. HATSolver, in contrast, started learning directly after just a few thousand training steps.
- For n=10 variables, the base transformer was only able to complete 120,000 training steps within a given timeframe, whereas HATSolver completed 400,000 steps in the same duration, demonstrating its superior computational efficiency and scalability during training.
- Field Agnosticism: Experiments on different finite fields (F7, F17, F16) showed that HATSolver's performance was "agnostic to the fields." This indicates that the model's learned principles for Gröbner basis computation generalize well across various field characteristics, which is crucial for its broad applicability, especially in cryptography where F16 is widely used.
- Scaling Laws: The authors observed that scaling up the model size and the training dataset led to even higher accuracy, suggesting further potential for performance improvement with increased computational resources.
The results unequivocally demonstrate HATSolver's ability to tackle previously intractable Gröbner basis problems, significantly outperforming both classical algorithms and prior transformer-based approaches, particularly at larger scales and across diverse finite fields.
Practical Implications
▶ Watch: Q&A: Generalizing HATSolver to larger, untrained problems (6:40)
HATSolver's advancements in computing Gröbner bases have profound practical implications for a wide array of fields and for various roles within the ML ecosystem.
For practitioners and researchers in areas like cryptography, coding theory, and optimization, HATSolver offers a powerful new tool to solve problems previously deemed intractable. Many cryptographic schemes, for instance, rely on the hardness of solving polynomial systems; HATSolver could be used to analyze their security or, conversely, to design more robust systems. In optimization, finding global optima often involves solving polynomial equations, and HATSolver could enable faster or more comprehensive solutions.
For ML infrastructure teams and model builders, HATSolver presents a compelling case study for designing efficient deep learning architectures for structured, hierarchical data. The hierarchical attention mechanism provides a blueprint for mitigating the quadratic complexity of transformers, making them applicable to domains with very long and complex input sequences. This could inspire similar architectural innovations for other graph-structured or tree-structured data problems beyond symbolic mathematics. The work underscores the value of curriculum learning in training complex models, suggesting that a staged approach to increasing problem difficulty can be critical for achieving high performance.
Deployers of ML models might find HATSolver's fast inference times attractive. While training requires significant resources, once trained, the model can generate Gröbner bases in minutes, a dramatic improvement over hours or even days for classical solvers. This speed could enable real-time applications or rapid prototyping in fields where such computations are bottlenecks.
However, there are also tradeoffs and limitations.
- Data Dependency: HATSolver, like other supervised ML models, relies on large, high-quality training data. While the "backward method" provides a way to synthetically generate this data, the complexity of generating truly diverse and representative samples for ever-larger systems remains a challenge.
- Generalization to Out-of-Distribution Data: The current model's generalization capabilities to systems with degrees or variable counts significantly higher than those encountered during training are not fully explored. The speaker noted that the current vocabulary size limits the model's ability to directly evaluate on systems much larger than what it was trained on, which is an area for future work.
- Interpretability: While HATSolver effectively solves the problem, understanding why it makes certain decisions or how it arrives at a Gröbner basis is still an open question. This lack of interpretability is a common challenge in deep learning and could hinder trust or adoption in high-stakes applications.
- Hardware Requirements: Training these large transformer models, even with hierarchical attention, still demands substantial computational resources, including powerful GPUs or TPUs.
Looking forward, the authors are exploring exciting future directions. One key avenue is using reinforcement learning (RL) to optimize classical Gröbner basis algorithms. By supervising intermediate steps, such as S-polynomial selections and reductions within F4 and F5 algorithms, HATSolver could potentially enhance the efficiency of existing symbolic solvers. Another goal is to develop a single, unified model capable of operating across all finite fields and handling arbitrary dimensions and degrees, maximizing its utility and reducing the need for specialized models. Furthermore, incorporating hierarchical cross-attention into the decoder side of the model is being considered to improve efficiency if solution lengths become a bottleneck.
Key Takeaways
- Breaching Intractability: HATSolver successfully computes Gröbner bases for systems of multivariate polynomial equations with 13 variables, a scale previously intractable for state-of-the-art classical algorithms and prior transformer models.
- Hierarchical Attention for Scalability: The novel Hierarchical Attention Transformer architecture effectively addresses the quadratic complexity bottleneck of traditional transformers, enabling efficient processing of inherently hierarchical and long-sequence inputs like polynomial systems.
- Significant Performance Improvement: HATSolver achieves a 54% exact match accuracy (71% support accuracy) on complex systems in minutes, drastically outperforming classical solvers which manage only 12% within a two-hour limit.
- Curriculum Learning is Crucial: A progressive curriculum training approach, starting with simpler systems and gradually increasing complexity, is vital for achieving high performance on challenging mathematical problems.
- Field-Agnostic Robustness: The model demonstrates consistent performance across various prime and extension finite fields, highlighting its general applicability, particularly for cryptographic and coding theory contexts.
- ML's Potential in Symbolic Math: This work showcases the immense potential of machine learning to solve fundamental, long-standing problems in pure mathematics, opening new avenues for research and application.
About the Speaker(s)
The talk was presented by Mohamed Malhou, who conducted this research as part of his work. He was supervised by Ludovic Perret and Kristin Lauter. While specific titles or affiliations beyond their roles in this project were not detailed in the transcript, their involvement underscores the interdisciplinary nature of this work, combining expertise in machine learning and advanced mathematics.
Reviews
→ Top-rated talks at International Conference on Learning Representations 2026
All talks from International Conference on Learning Representations 2026