[Paper Review] SymFormer: End-to-end symbolic regression using transformer-based architecture
SymFormer proposes an end-to-end transformer-based architecture for symbolic regression that jointly predicts symbolic expressions and numerical constants in a single forward pass, significantly improving fitting accuracy and inference speed over prior methods. By integrating learned constants with gradient-based fine-tuning, it achieves state-of-the-art performance with an R² of 1.0000 and relative error of 0.0010 on benchmark datasets.
Many real-world problems can be naturally described by mathematical formulas. The task of finding formulas from a set of observed inputs and outputs is called symbolic regression. Recently, neural networks have been applied to symbolic regression, among which the transformer-based ones seem to be the most promising. After training the transformer on a large number of formulas (in the order of days), the actual inference, i.e., finding a formula for new, unseen data, is very fast (in the order of seconds). This is considerably faster than state-of-the-art evolutionary methods. The main drawback of transformers is that they generate formulas without numerical constants, which have to be optimized separately, so yielding suboptimal results. We propose a transformer-based approach called SymFormer, which predicts the formula by outputting the individual symbols and the corresponding constants simultaneously. This leads to better performance in terms of fitting the available data. In addition, the constants provided by SymFormer serve as a good starting point for subsequent tuning via gradient descent to further improve the performance. We show on a set of benchmarks that SymFormer outperforms two state-of-the-art methods while having faster inference.
Motivation & Objective
- To address the limitation of existing neural symbolic regression models that generate formulas without numerical constants, leading to suboptimal fits.
- To improve symbolic regression performance by training a transformer to jointly predict symbolic expressions and concrete constant values during inference.
- To enhance model generalization and fitting accuracy by using predicted constants as initialization for local gradient descent optimization.
- To validate the effectiveness of a novel constant encoding strategy that improves attention and sequence modeling in symbolic generation.
- To enable fast, accurate, and generalizable symbolic regression for real-world scientific and engineering applications.
Proposed method
- A transformer-based architecture is trained end-to-end on a large-scale dataset of hundreds of millions of symbolic formulas.
- The model generates both symbolic tokens (e.g., '+', 'sin', 'x') and numerical constants in a single autoregressive sequence, using a modified token vocabulary that includes constant placeholders.
- A novel 'extended encoding' strategy preprocesses constants using logarithmic and exponential transformations (e.g., expressing 'a^x' as 'exp(x * ln(a))') to improve numerical stability and model attention over constant values.
- The predicted constants are used as initialization points for local optimization via BFGS or gradient descent to refine the final formula and improve fit on input data.
- The model leverages attention mechanisms to condition symbolic generation on previously predicted constants, enabling more coherent and accurate expression construction.
- A two-stage inference pipeline is employed: first, the model generates a candidate formula with constants; second, gradient-based optimization further tunes the constants to minimize mean squared error on observed data.
Experimental results
Research questions
- RQ1Can joint prediction of symbolic expressions and numerical constants during inference improve symbolic regression accuracy compared to models that predict constants separately?
- RQ2Does the use of logarithmic and exponential transformations for constants enhance model performance and numerical stability in symbolic generation?
- RQ3How does the integration of gradient-based fine-tuning using predicted constants as initialization affect final model accuracy and convergence speed?
- RQ4To what extent does the proposed extended encoding strategy improve attention and sequence modeling in symbolic transformers compared to standard constant representation?
- RQ5How does SymFormer compare in performance and inference speed to state-of-the-art symbolic regression methods, especially in terms of R² and relative error on benchmark datasets?
Key findings
- SymFormer achieves an R² of 1.0000 and a relative error of 0.0010 on benchmark datasets using Top-K sampling with K=20 and 256 samples, significantly outperforming prior methods.
- The ablation study confirms that predicting constants during training improves performance: the base encoding with constant prediction (R² = 0.9979, error = 0.0669) outperforms models without constants (R² = 0.9929, error = 0.1547).
- The extended encoding strategy with gradient-based fine-tuning achieves the best results (R² = 1.0000, error = 0.0010), demonstrating that proper constant representation enhances model generalization and attention.
- SymFormer's inference speed is significantly faster than evolutionary methods, with inference times in the order of seconds, making it suitable for real-time applications.
- The model exhibits strong extrapolation capabilities, generalizing well beyond the training input range, as validated through out-of-distribution testing.
- Qualitative analysis reveals that SymFormer can recover complex mathematical relationships (e.g., Fourier-like decompositions) from data, indicating strong inductive bias from pretraining on diverse formulas.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.