Introduction
Symbolic regression is the task of discovering an analytic mathematical expression that fits a given dataset, without assuming a predefined form. In contrast to traditional regression that tunes parameters of a fixed formula, symbolic regression searches the space of possible formulas to find one that best explains the data (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). This allows uncovering underlying equations or physical laws directly from data, providing interpretable models of relationships between variables. Symbolic regression can yield deep insights (for example, revealing astrophysical scaling laws or analytical models in spectroscopy (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework)) but it is computationally challenging – the space of expressions grows combinatorially with complexity, making the search NP-hard (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). Similar principles extend to discovering differential equations: given time-series or spatio-temporal data, one can seek a symbolic ODE/PDE (ordinary/partial differential equation) that governs the system’s dynamics. These “equation discovery” tasks generalize symbolic regression to finding formulas involving derivatives, such as or for some field . Solving such problems can reveal compact, human-understandable laws behind dynamical systems and processes ([2210.02181] DISCOVER: Deep identification of symbolically concise open-form PDEs via enhanced reinforcement-learning).
In recent years, advanced machine learning methods – especially transformer-based models and reinforcement learning (RL) – have been applied to tackle symbolic regression and equation discovery. This investigation will delve into the formal problem setups for symbolic regression, symbolic ODE discovery, and symbolic PDE discovery, including mathematical formulations and derivations. We focus on modern transformer and RL approaches, discussing theoretical foundations (search strategies, training paradigms, and generalization) and highlighting how these methods have been applied in practice. In particular, we emphasize how these developments relate to broader phenomena in deep learning: (a) grokking, (b) training dynamics, (c) in-context learning, and (d) mechanistic interpretability. We aim to provide a rigorous and comprehensive view, linking the theory of these approaches with their implications for understanding neural network behavior.
Problem Formulation: Symbolic Regression and Equation Discovery
Symbolic Regression (Problem Definition)
Symbolic regression aims to find a mathematical expression that best fits a given dataset (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). Formally, let be observed data (for simplicity, and ). We assume a hypothesis space of allowed expressions (built from a predefined set of primitives like variables, constants, , , , etc.). The goal is to find an expression in that minimizes some loss, typically the discrepancy with data points:
A simple example of a symbolic regression problem is: given points sampled from an unknown function (say, a pendulum’s period as a function of length), find an analytic formula (e.g. ) that fits those points. Unlike polynomial regression of fixed degree, symbolic regression can invent the square-root and division structure needed to match the data, discovering the hidden law with minimal prior assumptions (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework).
Mathematically, expressions can be represented as binary expression trees, where internal nodes are operators and leaves are operands (variables or constants). The search then becomes a tree search over possible compositions. Traditional methods like Genetic Programming (GP) evolve a population of such expression-trees with genetic operators, and reinforcement learning or other search methods can also be used to traverse this discrete space (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework) (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). The challenge is that the number of possible trees grows exponentially with depth, and most candidates are poor fits, so the algorithm must cleverly prune and guide the search toward promising regions.
Symbolic ODE Discovery
In symbolic ODE discovery, the task is to recover the underlying ordinary differential equation of a system from observed time-series data. Consider an -dimensional dynamical system (which may or may not explicitly depend on time ). We observe one or more trajectories and aim to find the symbolic form of each component of such that for . A common assumption is an autonomous system (no explicit ), so . Formally, from sampled data (and possibly measured or approximated derivatives), we seek expressions from some library of terms that minimize error in predicting the observed derivatives:
The output of this problem is a set of equations, e.g. , , (a system like this could represent a learned simplified model of a chaotic system, for instance). Notably, discovering an ODE often requires that the single observed trajectory is informative enough to infer the general law – which implies some inductive bias or assumption of simplicity is crucial, or multiple varied trajectories might be needed.
A landmark early example was Schmidt & Lipson (2009) discovering laws like conservation equations from motion data (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework) (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). More recently, data-driven ODE discovery has been approached with sparse regression (the SINDy algorithm selects a small set of basis functions to match the derivative data) and now with neural sequence models. We will see that a transformer model (ODEFormer) has been developed to infer ODE systems from a single trajectory in a symbolic form (ODEFormer: Symbolic Regression of Dynamical Systems with Transformers | OpenReview).
Symbolic PDE Discovery
Symbolic PDE (partial differential equation) discovery generalizes the above to systems with spatially distributed dynamics. For example, one might observe a spatio-temporal field (like a temperature field evolving over space and time) and wish to discover a PDE such as (a Burgers’ equation with diffusion). Formally, we collect data or perhaps full snapshots on a grid, and aim to find a symbolic equation involving partial derivatives of that is satisfied by the data. A general form could be:
PDE discovery methods often split the problem into two parts: structure selection (which terms to include) and parameter estimation (fitting coefficients). A popular approach is again sparse regression: one posits a linear combination of many candidate terms and uses L1 regularization to zero out all but a few (this was done in the SINDy-PDE method). However, more flexible approaches treat it as a discrete search where terms and structure (like products of variables and derivatives) are selected combinatorially. The formal objective can be written similarly to ODE case: minimize the mismatch of the discovered PDE to the observed evolution: minexpression G
Symbolic PDE discovery is extremely challenging due to noise amplification in computing high-order derivatives and the vast space of possible terms. It often requires incorporating domain knowledge (e.g. known symmetries or conserved quantities) to make the search feasible. For instance, one might enforce that the discovered PDE is invariant under certain transformations or that it conserves mass, narrowing the search. We will discuss how modern RL-based approaches impose such constraints to keep equations physically reasonable ([2210.02181] DISCOVER: Deep identification of symbolically concise open-form PDEs via enhanced reinforcement-learning).
In summary, symbolic regression, ODE discovery, and PDE discovery can all be seen as instances of a general problem: find a concise symbolic expression (or set of expressions) that satisfy a set of input-output constraints (points or derivative relationships). Despite this unified view, the methods and difficulty scale differ – PDE discovery typically has the richest search space and thus may rely more on hybrid and guided techniques. Next, we examine how transformer neural networks and reinforcement learning have been leveraged to tackle these problems.
Transformer-Based Approaches to Symbolic Regression and ODE/PDE Discovery
Transformers have emerged as powerful sequence modeling tools and have been adapted to generate mathematical expressions. A transformer can be trained to take in representation of the data (points or trajectories) and output a sequence of tokens representing the formula. This sequence-to-sequence formulation treats the equation discovery like a translation problem: the “source language” is the dataset, and the “target language” is the symbolic equation.
Transformers for Symbolic Regression
Early attempts at symbolic regression used evolutionary algorithms or RL to search afresh for each new dataset. A newer paradigm is to train a transformer model on a large corpus of synthetic regression problems so that it learns a general mapping from data to formula (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). After such training, the model can solve new regression tasks in one forward pass, drastically accelerating inference (no iterative search needed) ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning).
Problem encoding: One non-trivial aspect is how to present a set of data points to a transformer, which expects a sequence. Different encoding strategies exist:
- Sequence of value pairs: One can list the data as a sequence like , perhaps sorted by or some order. Each pair can be tokenized (e.g. as numbers or discretized values). The transformer’s encoder processes this sequence.
- Learned embedding of sets: Some works use an encoder that is invariant to permutation of points, so that the model truly treats the input as an unordered set of points on the function ([2312.04070] A Transformer Model for Symbolic Regression towards Scientific Discovery) ([2312.04070] A Transformer Model for Symbolic Regression towards Scientific Discovery). For example, an encoder might average or attend over points in a way that doesn’t depend on their order. Enforcing permutation equivariance ensures that shuffling data doesn’t change the output, which is a desirable property in symbolic regression. However, achieving this in a transformer (which is naturally sequence-ordered) can be tricky – architectures that treat each -coordinate as a “column” and use positional embeddings for sample index can maintain some invariance, but often a trade-off exists between flexibility and strictly obeying symmetries ([2312.04070] A Transformer Model for Symbolic Regression towards Scientific Discovery).
- Alternate representations: Another approach is to summarize the dataset by some statistics or evaluations on a fixed grid of values. But generally, allowing the model to see raw points gives it more freedom to fit complex behaviors.
Training procedure: Models are typically trained on synthetic data: a large set of randomly generated expressions (within some complexity limit) and sampled points from those expressions ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning). This supervised training teaches the transformer to invert the data-generation process. For instance, SymbolicGPT (Generative Pre-trained Transformer for SR) was trained on a big dataset of expression–value pairs and can then generate expressions consistent with given inputs (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). Likewise, other transformer architectures (Symformer (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework), the ICLR 2022 model by Li et al. (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework), and Kamienny et al. NeurIPS 2022 (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework)) have demonstrated the ability to produce correct formulas for test functions not seen in training.
Example: Kamienny et al. (2022) trained a transformer that takes in a set of samples and outputs the expression tree in a linearized format (like prefix notation). They achieved end-to-end symbolic regression with transformers and reported strong performance on benchmarks (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). These models leverage the transformer’s strength in capturing long-range dependencies – for example, in a formula like , the relationship between the coefficient “2” and the token might be far apart in the sequence, but attention mechanisms can still learn the correlation. Transformers can also learn to generate well-formed expressions thanks to training on many examples, essentially learning the grammar of mathematical expressions.
Inference and generalization: Once trained, a transformer model can produce an answer in one shot, which is orders of magnitude faster than iterative search methods ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning). However, this speed comes with a caveat: the model’s success is limited by the distribution of functions it saw during training. If a target function is very different or more complex than those in the training set, the model might fail to find the correct form (or output nothing useful). In other words, its extrapolation beyond training support is not guaranteed. Additionally, noise in the input data can fool a purely learned model, since it may not have seen similar noisy patterns during training ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning). Researchers observed that transformer-based SR methods can suffer in noise robustness and versatility, because they effectively interpolate within the space of learned patterns ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning).
Mitigating weaknesses: Recent work has looked at combining transformers with search or other techniques to get the best of both worlds. For example, one approach integrates Monte Carlo Tree Search (MCTS) into transformer decoding: at each step, the transformer proposes probabilities for next tokens, and MCTS explores several high-probability continuations to find an expression with minimal error (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). This transformer-based planning improves reliability by not relying solely on one pass – it can backtrack and try alternatives if the initial guess is suboptimal. Li et al. (2024) use a GPT model to guide MCTS, which significantly improved efficiency and accuracy in discovering formulas (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). Another hybrid method is using the transformer to generate multiple candidate expressions and then evaluating or refining them (perhaps with a local search or gradient-based adjustment of constants). The key idea is that the neural model gives a great prior over the search space, which can then be fine-tuned by classical search for exactness.
To summarize the transformer approach:
- Pros: Once trained, extremely fast inference (just feed data and get formula). Capable of capturing complex dependencies and generating human-readable formulas. Scalable to large training corpora, and can leverage modern hardware for training.
- Cons: Training is expensive and requires a large diverse set of symbolic functions. Generalization is tied to training distribution – the model may memorize patterns rather than truly derive them, leading to potential failures on out-of-distribution functions or noisy data ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning). Also, sequence models can suffer from exposure bias (during training they see ground-truth prefix sequences, but at test time they have to generate sequences without guidance, which can cause compounding errors). Efforts like curriculum learning (starting with simpler formulas) or techniques to alleviate exposure bias (such as scheduled sampling or order-agnostic training (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework)) have been explored to improve training.
Example: ODEFormer – A Transformer for ODE Discovery
A notable recent development is ODEFormer (ODEFormer: Symbolic Regression of Dynamical Systems with Transformers | OpenReview), a transformer model specifically designed for inferring ordinary differential equations from data. ODEFormer is reported as “the first transformer able to infer multi-dimensional ODE systems in symbolic form from the observation of a single solution trajectory” (ODEFormer: Symbolic Regression of Dynamical Systems with Transformers | OpenReview). This is a remarkable capability: given one trajectory of a dynamical system (say, the curves of a predator-prey model), ODEFormer can output the underlying equations (e.g. , ) in symbolic form.
How it works: While the exact architecture is complex, the essence is:
- Input: a sequence of state observations. In practice, the model might take a time-series for each state variable, possibly concatenated or encoded via an RNN or transformer encoder that captures temporal patterns. Irregular time sampling and noise are handled by the model’s robust encoding, which is trained to infer the derivative patterns despite these.
- Output: a sequence of tokens representing the system of ODEs. One can linearize a system of equations as one long sequence (perhaps with separators for different ), or generate one equation at a time.
Training data: The authors of ODEFormer curated two datasets: (i) the Strogatz dataset of classic 2D systems from Strogatz’s nonlinear dynamics textbook, and (ii) ODEBench, a new collection of 1D to 4D ODE systems from literature (ODEFormer: Symbolic Regression of Dynamical Systems with Transformers | OpenReview). They generated synthetic trajectories from each system (with various initial conditions, time steps, etc.) and used those as training examples for the transformer. Because the model learns from many systems, it develops a form of meta-learning: it captures a distribution over ODE systems. At test time, it can generalize to new systems in the same “family” of dynamics.
Performance: ODEFormer outperforms existing methods and is more robust to noise and irregular sampling (ODEFormer: Symbolic Regression of Dynamical Systems with Transformers | OpenReview). Traditional system identification might require clean data or multiple trajectories to guess the right terms, but ODEFormer’s learned prior helps it recognize, for example, that a spiraling trajectory suggests a quadratic damping term or a sinusoidal component. In benchmarks, it was able to infer correct equations even with fairly sparse or noisy observations, where methods like sparse regression (SINDy) struggle because numerical differentiation becomes unreliable. Additionally, inference is fast (just running the network) compared to heavy iterative searches.
Interpretation: ODEFormer’s success hints that the transformer learned to internally approximate the differentiation and pattern-matching process that a human or an algorithm might do. For instance, it might implicitly estimate from the input sequence and then match that against a library of learned patterns (like “ indicates an interaction term”). By training on many systems, it can distinguish, say, linear growth, quadratic damping, or sinusoidal oscillation, and put together appropriate tokens.
While ODEFormer specifically tackled ODEs, the approach could extend to other parametric law discoveries, possibly difference equations or discrete iterative maps, by a similar sequence learning approach.
Transformer Prospects for PDE Discovery
Applying transformers to PDE discovery is even more ambitious. In principle, one could feed a transformer a 2D or 3D array of field values (a movie of the evolving field) and train it to output the PDE that governs it. This would require the model to discern spatial patterns and invariances. There has been work on using deep learning to solve PDEs or represent PDE solutions (like physics-informed neural nets), but discovering the PDE symbolically is relatively new territory for deep learning.
Currently, most successes in symbolic PDE discovery have come from RL or evolutionary strategies (discussed below) rather than transformers, due to data representation issues. A sequence model would have to serialize a multi-dimensional array of observations into a sequence, which might be very long and hard to learn from. One could imagine feeding random spatial locations and their values as input tokens (to give a sense of the function’s behavior) – similar to how symbolic regression is fed points, but now points are in space. Some early attempts might involve encoding spatial data via convolutional networks and then using a transformer decoder for the equation. There is also the question of how to encode partial derivative information: the model might have to either estimate derivatives internally or be given pre-computed derivative data (which could be noisy).
As of now, the literature has a gap in a clear “PDEFormer” purely transformer approach. However, one recent work “DISCOVER” took a hybrid route, using a neural agent (an RNN) with reinforcement learning to find PDEs ([2210.02181] DISCOVER: Deep identification of symbolically concise open-form PDEs via enhanced reinforcement-learning). It demonstrates that neural sequence models can handle the discovery if guided properly. It’s reasonable to expect that with further advances, transformer models could be applied to PDE discovery by leveraging their strength in handling long-range dependencies (for example, relating a pattern at one location to a term that must hold globally).
In summary, transformer-based methods have shown impressive results for symbolic regression and ODE discovery, effectively learning a general solver. They convert the equation-finding problem into a pattern recognition task on lots of training examples. The next section will turn to reinforcement learning approaches, which tackle the search problem from a different angle – by treating it as a sequential decision process of constructing an expression with feedback.
Reinforcement Learning Approaches to Symbolic Regression and Equation Discovery
Reinforcement learning methods approach symbolic regression as a search problem with a reward signal. Instead of (or in addition to) supervised learning from known solutions, RL algorithms learn by exploration: they build candidate expressions piece by piece and receive a reward based on how well the candidate fits the data (and possibly how simple it is). Over many episodes, the RL agent improves its policy for generating expressions, analogous to how an agent might learn to navigate a maze by trial and error.
RL for Symbolic Regression: Policy Gradient and Beyond
A seminal work in this area is Deep Symbolic Regression (DSR) by Petersen et al. (2019), which framed symbolic regression as a sequential decision process (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). In DSR, an agent generates an expression tree by adding one token at a time (subject to syntax rules), and only after the expression is complete it gets a reward based on the negative error (or a fitness measure). Petersen et al. used a risk-seeking policy gradient algorithm to train a neural policy that favors high-reward (low-error) outcomes (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). “Risk-seeking” here means they slightly modified the objective to prioritize the best trajectories (expressions) found, not just the expected reward – this helps the agent focus on the few expressions that really fit well rather than the average outcome (which is usually poor for random expressions). The reward typically was defined as (negative normalized root mean square error) so that maximizing reward corresponds to minimizing error (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework).
Training dynamic: The RL agent starts off generating more or less random expressions, which mostly fit the data poorly. Over time, it learns which sub-expressions are promising. For example, if it finds that including a term drastically improved the fit for some oscillatory data, the policy will increase the probability of using in similar contexts. The policy network often has an LSTM or similar sequence model that processes the expression as it’s being built, so it has a notion of the context (e.g. if it already placed a , it might then place a variable inside it, etc.). The optimization is challenging because the reward signal is sparse (only after completing an expression) and non-differentiable with respect to the discrete choices. Policy gradient methods like REINFORCE with a baseline are used to propagate the reward backward into preferences for the chosen tokens.
Drawbacks: A big drawback of naive RL in symbolic regression is that it requires many trials for each new dataset. Essentially, one policy is learned per regression problem from scratch (unless one does meta-learning). Searching the expression space by RL is still costly – it might sample thousands of candidate formulas before hitting a good one. Petersen et al. noted the method is computationally expensive and “requires searching for every expression from scratch”, making it time-consuming (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). This is in contrast to transformers which do a lot of upfront training but then solve any instance quickly.
Improvements and hybrids: Subsequent research combined RL with other techniques:
- Neural-guided genetic programming: One example is by Mundhenk et al. (2021), where they used a neural network to help initialize a population for genetic programming (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). Essentially, a model learns from previous GP runs to propose better starting expressions for new runs. This creates a loop where experience accumulates (a form of meta-RL or at least cross-problem learning). Their approach yielded better performance than pure GP or pure RL alone (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework).
- Beam search or MCTS with learned priors: Instead of sampling expressions entirely stochastically via policy gradient, one can use a search algorithm that expands multiple candidates. The search can be guided by a learned value function or policy. For instance, one could train a model to predict which partial expression is promising (value) or what token to add (policy), and use tree search (like MCTS) to systematically find a high-reward expression. This was done in some recent works (e.g. incorporating MCTS with a transformer as discussed before (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework)).
- Offline RL (Q-learning): The Sym-Q framework (Tian et al. 2023) took an offline reinforcement learning approach (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework) (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). Instead of learning by online trial-and-error on each new problem, they first generated a large dataset of (state, action, reward, next state) from many regression tasks (perhaps using a simpler agent or brute force). Then they trained a Q-network (a neural estimator of the value of partial expressions) on this collected experience. The result is a single agent (called Sym-Q) that can be applied to new problems without retraining, by using its Q-function to greedily build an expression. This is similar in spirit to how a transformer is pre-trained, but here it’s done via RL on a dataset of tasks. The authors highlight that Sym-Q, not relying on a transformer decoder, could integrate easily with human guidance (user can tweak the expression at intermediate steps) (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework) (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). This interactive ability is appealing in scientific settings where a human might want to enforce known constraints or adjust the form.
Reward design: A critical aspect in RL approaches is the reward function. Typically it includes:
- A term for data fit (e.g. or correlation with ).
- A term for complexity (e.g. a penalty for each node or for certain functions).
- Possibly domain-specific penalties: e.g. if we know the function should be smooth or monotonic, the reward could penalize violations to incorporate prior knowledge.
- In physical applications, rewards can include checks for dimensional consistency or known invariants, to avoid nonsensical formulas.
By shaping the reward, RL can encode a preference for simpler formulas (Occam’s razor) automatically, which is often done in GP as well (via multi-objective selection or parsimony pressure).
State-space and actions: The state in this RL formulation is the partial expression (or the expression tree being built so far). Representing this to the agent can be done by linearizing it (prefix notation string processed by an RNN), or by a custom tree representation. Some works use a stack-based representation for expressions (since you can parse expressions with a stack machine, an agent can maintain a stack and push/pop tokens, which naturally enforces syntactic correctness). The actions are then choosing the next token to push. The agent must learn to end the expression at a sensible point (some implementations use a special End token when the expression tree is complete and valid).
In summary, RL-based symbolic regression treats formula discovery like a game: the agent wins by constructing a formula that achieves a high score (good fit, low complexity). This approach is powerful because it allows flexible integration of feedback (any computable reward can be used, not just differentiable losses). It also doesn’t require example solutions – it can operate even when the true formula is unknown, whereas supervised training of a transformer requires a ground-truth expression for each training example. On the flip side, pure RL can be sample-inefficient and slow, which is why hybrid approaches and pre-training are important.
RL for ODE and PDE Discovery
Reinforcement learning can be applied similarly to building differential equations. The agent’s action space now includes derivative terms. For ODEs, you might have tokens like x, y, *, +, plus possibly a token representing (though usually we are constructing the right-hand side , so itself is the left side and not in the expression). Essentially, it’s the same as symbolic regression but with a larger library of basis functions that might involve products of state variables (for interactions) or known functions (like sin, cos for oscillatory systems).
Example – PDE via RL (DISCOVER): Deep Identification of Symbolically Concise PDEs (DISCOVER) by Du et al. (2023) is a prime example of an RL approach for PDE discovery ([2210.02181] DISCOVER: Deep identification of symbolically concise open-form PDEs via enhanced reinforcement-learning). In DISCOVER, an agent (a “structure-aware” RNN) generates candidate PDEs term by term. They define a symbol library of operands (e.g. etc.) and operators, so the agent’s actions are to pick symbols and assemble them into terms like or ([2210.02181] DISCOVER: Deep identification of symbolically concise open-form PDEs via enhanced reinforcement-learning). Once a set of terms is generated, a sparse regression step is used to fit the coefficients of those terms to the data ([2210.02181] DISCOVER: Deep identification of symbolically concise open-form PDEs via enhanced reinforcement-learning). This separation is clever: the RL proposes the structure (which terms appear), and a quick linear regression finds the best coefficients for those terms. The assembled PDE is then evaluated on how well it fits the data (e.g. measured by the error in predicting ) and how complex it is. A meticulously designed reward balances the data fitness and parsimony ([2210.02181] DISCOVER: Deep identification of symbolically concise open-form PDEs via enhanced reinforcement-learning). They also add constraints to ensure the PDE is physically sensible – for example, they might forbid the agent from creating terms that violate known symmetries or that have unbounded order (to keep things concise) ([2210.02181] DISCOVER: Deep identification of symbolically concise open-form PDEs via enhanced reinforcement-learning).
They use model-based RL to improve efficiency ([2210.02181] DISCOVER: Deep identification of symbolically concise open-form PDEs via enhanced reinforcement-learning): this could mean they train a model (surrogate) of the environment to help predict rewards without always fully evaluating on data, or they use the idea of planning in the learned model of equation space. In experiments, DISCOVER managed to find correct PDEs for various systems, including cases with mixed derivatives, fractional powers, or high-order derivatives, which are notoriously hard for brute-force searches ([2210.02181] DISCOVER: Deep identification of symbolically concise open-form PDEs via enhanced reinforcement-learning). It essentially rediscovered equations with minimal prior knowledge, demonstrating the power of RL-guided search in the vast space of PDEs.
Why RL is suitable for PDEs: In PDE discovery, the space is so large and the data so complex that a purely supervised approach (like training a transformer on random PDEs) would be extremely challenging. Instead, an RL approach can incorporate prior knowledge on the fly via rewards and constraints, and it can focus search around simpler patterns. The agent can start by trying simple terms (like , ) and only add complexity as needed to improve reward, somewhat mirroring how a scientist might incrementally build a model. Additionally, RL doesn’t require a huge library of solved examples – it just needs a simulation environment to get rewards from. For a new PDE discovery problem, one can run an RL search on that data specifically.
Combining RL with search: Many PDE discovery frameworks combine stochastic search with deterministic elimination. For example, one can randomly generate terms (like in genetic programming) but then use Lasso regression to select which terms matter. RL can be seen as biasing the random generation toward better regions.
Summary of Transformer vs RL Approaches
It’s useful to contrast the two paradigms:
- Training data: Transformers typically need many solved examples (expression-data pairs) in advance; RL can work on the single target dataset (but might use multiple runs or meta-learning to get better).
- Computation: Transformer: heavy computation in training (offline), light at inference. RL (online search): lighter prior training, heavy computation per inference (since it’s doing a search).
- Generality: A trained transformer has a fixed capacity for the kinds of expressions it can produce (limited by training); RL can, in principle, discover entirely novel formulas as it just uses reward feedback.
- Hybrid approaches: There is a clear trend of combining them to mitigate each other’s weaknesses:
- Use a transformer as a prior or initial policy for RL search (warm-start the search in a good region).
- Use RL or other search to fine-tune the transformer’s outputs (e.g. use the transformer’s solution as a starting guess and then locally improve it by targeted search or regression).
- FormulaGPT (2024) is a striking example of a hybrid: it trains a GPT model on the “learning trajectories” of an RL algorithm ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning). In other words, they ran an RL-based symbolic regression on many problems and recorded the sequences of expressions the RL agent tried and improved upon. These sequences (which are like an agent’s thinking process) were used to train a transformer (FormulaGPT). The result is a model that encodes an RL search strategy in its in-context behavior ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning). At test time, given a new dataset, FormulaGPT can generate its own sequence of candidate expressions and refinement steps in a single forward pass, essentially simulating an RL procedure internally ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning) ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning). This yields state-of-the-art results, combining the fast inference of transformers with the robustness of an RL search (since it can adjust the “policy” in context as it sees how well initial guesses match the data) ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning). FormulaGPT is an example of in-context reinforcement learning: the model’s output includes a sequence of attempts and adjustments, thereby updating its strategy on the fly without gradient updates ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning).
In conclusion, both transformers and RL have pivotal roles in modern symbolic regression and equation discovery. Transformers provide a data-driven direct map from observations to formulas, while RL treats it as a guided search with feedback. Theory-wise, transformers rely on generalization from a training distribution (raising questions of expressiveness and generalization bounds), whereas RL relies on exploration and exploitation trade-offs (raising questions of convergence and optimality in a non-smooth search space). Both face the curse of dimensionality in different ways, and both have seen creative solutions (like MCTS, policy distillation, curriculum learning) to push their performance.
Next, we will explore deeper connections of these approaches to broader deep learning concepts: how does the phenomenon of grokking (sudden generalization) appear in symbolic learning? What can we learn from training dynamics of these models? In what sense is symbolic regression an instance of in-context learning? And how can mechanistic interpretability help us understand these models or even extract the learned formulas directly?
Connections to Grokking, Training Dynamics, In-Context Learning, and Mechanistic Interpretability
The intersection of symbolic regression with fundamental ML phenomena provides insight into both the task and the learning process:
(a) Grokking in Symbolic Tasks
Grokking refers to the perplexing observation that a neural network can eventually achieve perfect generalization long after it has overfit the training data ([2201.02177] Grokking: Generalization Beyond Overfitting on Small Algorithmic Datasets). In the original Grokking study by Power et al. (2022), small transformer networks were trained on simple algorithmic tasks (like modular arithmetic). They found that the model’s training loss would reach near zero (the model memorizes the training examples) but the test loss remained high for a long time; then suddenly, after many more training iterations, the test loss dropped precipitously to near zero as well – the model had groked the underlying rule ([2201.02177] Grokking: Generalization Beyond Overfitting on Small Algorithmic Datasets). In other words, the network eventually discovered the true pattern (e.g. the modular addition rule) and thus could generalize, but it required an extended period of what looked like pure overfitting before the general solution “clicked”.
In the context of symbolic regression and equation discovery, one can draw parallels:
- A model might initially find a way to fit the training data that doesn’t generalize (essentially memorizing the points with a complicated piecewise function or a high-degree polynomial). This is analogous to the network’s initial memorization phase.
- With continued training or the right inductive biases (like weight decay or architecture constraints), the model might eventually simplify the representation to the true underlying formula, thereby achieving low error not just on the seen points but on the function as a whole. This would be the “grokking moment” where it transitions from fitting points to understanding the relationship.
The conditions that lead to grokking include having an overparameterized model and a relatively small dataset ([2310.06110] Grokking as the Transition from Lazy to Rich Training Dynamics). This is often the case in symbolic regression: the neural networks we use (transformers or deep policies) have far more parameters than the number of data points in any single regression problem. They could easily just memorize a mapping from input points to output expression (especially a transformer trained on many tasks could overfit a particular task). Yet, we hope they find the simpler rule that works for all points (including unseen ones). Grokking suggests that if we train long enough or with the right regularization, the simple rule can emerge as the preferred solution.
A theoretical explanation by Kumar et al. (2023) posits that grokking is a transition from “lazy” learning (where the network acts like a kernel machine memorizing data with fixed features) to “rich” feature learning (where it actually develops new features that align with the true pattern) ([2310.06110] Grokking as the Transition from Lazy to Rich Training Dynamics) ([2310.06110] Grokking as the Transition from Lazy to Rich Training Dynamics). In symbolic regression, the analogue would be the model initially using generic interpolants vs. eventually learning features corresponding to meaningful components (e.g. detecting frequency if the true function is sinusoidal). If the initial features of the model are not aligned with the target function, it will take a long time for gradient descent to sculpt new features; during this time, the model can fit training data in a brute-force way. Once the right feature (or internal sub-representation) forms, the model’s performance on unseen data jumps.
Have we observed grokking in practice here? There is anecdotal evidence. For instance, a transformer being trained to predict formulas might initially just memorize the most common patterns for a given set of points. But after extended training, it might suddenly start outputting novel formulas that generalize to test functions, indicating it discovered a more systematic strategy (like fitting simpler basis functions). Similarly, an RL agent might plateau finding approximate fits, and only after many iterations discover a fundamentally better equation that dramatically improves reward (this would look like a sudden jump in the reward curve).
One concrete connection: the mechanistic interpretability analysis of grokking by Nanda et al. (2023) actually reverse-engineered a model that grokked modular addition ([2301.05217] Progress measures for grokking via mechanistic interpretability). They found that the model eventually learned to implement addition by using a discrete Fourier transform internally, converting addition mod into a linear operation in Fourier space ([2301.05217] Progress measures for grokking via mechanistic interpretability). This is a very symbolic solution (using properties of sine and cosine to encode numbers on a circle). Before grokking, the model’s behavior was essentially rote memory of the addition table; after grokking, it had an interpretable algorithm. Symbolic regression models might undergo a similar transition: e.g., a network might initially simulate a lookup table of the dataset (a form of memory), but with enough training it might realize the data lies on a simple curve and then represent that curve with a small set of neurons or attention heads computing something like a polynomial or sinusoid.
In summary, grokking highlights the difference between fitting data and learning the underlying concept. For equation discovery, we ultimately care about the underlying concept (the formula). Grokking suggests that even if early in training a model seems to just memorize, given the right circumstances it might later “figure out” the real pattern. This underscores the importance of monitoring not just training error but generalization behavior during training. It also suggests using regularization (like weight decay) or early stopping carefully: too early stopping might lock in an interpolative but non-general solution, whereas allowing a bit of overfitting and then continuing to train with small steps could eventually favor the simpler model (as the complex memorizing solution might be unstable or not as optimal when considering weight decay).
(b) Training Dynamics and Phase Transitions
The training dynamics of models for symbolic regression often exhibit interesting phases and transitions. As hinted above, mechanistic interpretability work on grokking identified three phases in training a small transformer on an algorithmic task ([2301.05217] Progress measures for grokking via mechanistic interpretability):
- Memorization phase: The network quickly fits the training data, reducing training loss, but mainly by brute-force means. Little to no generalization is present (test loss remains high).
- Circuit formation phase: The network gradually develops internal structures (circuits) that correspond to the actual algorithm or simplified representation. This may not immediately reflect in test performance if the memorizing parts still dominate output, but internally the seeds of general solution are growing.
- Cleanup phase: The network refines and amplifies the correct circuits while pruning away reliance on the memorized parts. During this phase, the test performance shoots up (grokking occurs) as the correct mechanism takes over and the spurious memorization is dropped ([2301.05217] Progress measures for grokking via mechanistic interpretability).
In a symbolic regression transformer, one might analogously see:
- Initially, the model memorizes a bunch of mapping from input points patterns to expressions (effectively, using its large capacity to store example-specific “tricks”). The loss on training tasks might drop, but for novel functions not in the training set, it might not do well.
- As training continues (especially if tasks are diverse), the model starts identifying reusable substructures – e.g. it might learn that many expressions combine simpler components, so it forms internal representations for those components (like a neuron that detects a polynomial trend, or an attention head that focuses on oscillatory behavior of data). This is akin to circuit formation.
- Eventually, the model’s predictions rely more on these learned sub-concepts. At this point, the model can mix and match them to generalize better to new combinations, and its performance on unseen test tasks improves significantly. Essentially, it “understands” the language of expressions rather than recalling specific ones.
From the RL perspective, training dynamics often show high variance. In policy gradient for DSR, one commonly sees the reward (negative error) jump around as the agent discovers occasionally a much better expression, then maybe loses it (exploration can cause regression), and then finds it again consistently. Techniques like keeping a replay buffer of top solutions or risk-seeking updates help stabilize progress toward better solutions (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). The phase transition here could be when the agent discovers the correct functional form for the first time – after that, the policy network can quickly adapt to reproduce that form consistently, making further episodes almost always yield the correct solution (hence a jump in success rate). This is somewhat analogous to how, in games, an RL agent might struggle until it finds a winning strategy once, then rapidly exploit it.
One might measure training dynamics in symbolic regression by tracking:
- The distribution of expression lengths the model outputs over time.
- The diversity of functional forms explored.
- The training and validation error on tasks.
- In multi-task training (like transformer training on many problems), one could watch easier tasks get solved first (short expressions) and harder ones later – indicating a curriculum-like effect emerging naturally. Indeed, if the training set includes a range of difficulties, models often learn simple patterns first and complex ones later (a phenomenon also seen in standard neural nets).
Curriculum learning can be deliberately used to guide training dynamics. For instance, one can start training a model on only simple formulas (short depth) and then gradually increase complexity. This helps the model learn basic building blocks first (like how to fit linear or quadratic functions) before it has to learn composition. Such a curriculum was used by Lample & Charton (2019) when training a transformer to do symbolic integration: they started with short integration problems and progressively increased the length as the model mastered each level (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). A similar approach could benefit symbolic regression models, to avoid getting stuck or overwhelmed by very complex expressions early on.
Continuous vs discrete transitions: Because these tasks involve discrete structures (either in the data or in the hypothesis), training often isn’t a smooth, convex optimization. It can have discrete jumps when a new structure is discovered. Mechanistic interpretability gives us tools to recognize these jumps for what they are: the formation of a new algorithm inside the network. For example, identifying that “discrete Fourier transform” circuit emerging in the modular addition task ([2301.05217] Progress measures for grokking via mechanistic interpretability) is a big win – it turns a mysterious jump in accuracy into a known cause. In symbolic regression, if a network suddenly gets much better at fitting oscillatory data, one might suspect it learned to represent sine waves internally. If one could peek inside, perhaps one would find a neuron representing something like a frequency detector. This is speculative, but plausible given how networks tend to reuse features.
In summary, the training dynamics of transformer and RL models on symbolic problems are characterized by nonlinear progress, often with plateaus and sudden improvements. Understanding these can help in diagnosing training (e.g., if we expect a phase transition but never see it, perhaps the model capacity is insufficient or regularization too high to let it happen). It also connects to theory: these dynamics relate to questions of how neural networks optimize in high-dimensional non-convex landscapes, and why they prefer simpler solutions (minimum description length) in the long run despite being able to fit noise early.
(c) In-Context Learning and Meta-Learning
In-context learning refers to a model’s ability to learn and perform a task from the context of its input alone, without any parameter updates. Large language models (like GPT-3) demonstrate this by, for example, seeing a prompt that contains a few examples of a task (like translating a sentence) and then continuing to do the translation for a new sentence – essentially learning the task from the prompt (). The model’s weights are fixed; the “learning” happens in how it interprets the prompt.
Symbolic regression transformer models are explicitly trained to do a form of in-context learning: they take a set of datapoints as context and output a formula as the answer. They don’t get to update their weights per new dataset; instead, they must use the context data to deduce the relationship. This is effectively meta-learning – the model has learned a learning algorithm. During training on many tasks, the transformer implicitly learns how to perform regression on arbitrary new data. When we feed it a new dataset, it is performing that learned regression procedure internally (in the forward pass). Thus, symbolic regression with a pre-trained transformer is a prime example of in-context learning. It’s analogous to few-shot learning except that the “few shots” are actually the data points for that regression problem, and the model must output a description of the pattern connecting them.
One interesting aspect is how the model might internally represent and process the context. For instance, given points , the model might internally fit a rough curve before generating tokens. There could be an attention head that compares pairs of points to guess if the relationship is linear, another that checks if differences between values are proportional to differences in (indicating linearity) or if ratios are constant (indicating exponential), etc. In effect, the model may perform computations analogous to standard regression techniques: e.g. computing slope between points, detecting periodicity, etc., all as part of its forward pass. This is what we mean by the model learning an algorithm – it might simulate the logic of a curve-fitting process using its neural machinery.
Large language models not specifically trained for symbolic tasks can sometimes also do symbolic regression via in-context learning. For example, if you prompt GPT-4 with a few examples of data and their formula, it might guess the formula for a new dataset (especially if it’s something simple like a polynomial) because it has both some inherent capability and perhaps it has seen similar problems in its training corpus. This showcases the generality of in-context learning: the model has absorbed enough patterns during pretraining that it can adapt on the fly to a new small-scale problem.
Meta-learning vs in-context: In research literature, “meta-learning” often refers to training a model to learn new tasks quickly (which could be via in-context or via rapid weight updates). Transformers do in-context meta-learning simply by virtue of the sequence attention mechanism and being trained on many tasks: they can treat the earlier part of a sequence as training data and later part as test data. In symbolic regression, every training example is essentially “learn a function from these points”. So the transformer is meta-trained to do that task. This is very explicit meta-learning (not an emergent property but a designed one).
Connection to RL approaches: In RL, to handle many tasks, one might also employ meta-RL, where an agent learns a learning strategy that can be applied to new tasks. For example, an RL agent could learn to adapt its proposal distribution based on results so far (which is similar to how FormulaGPT was made to imitate an RL algorithm). In context, RL could mean that the model’s output includes a trajectory of trial-and-error, effectively doing RL within the output. That’s exactly what FormulaGPT does: “When new test data comes, FormulaGPT can directly generate a ‘reinforcement learning process’ and automatically update the learning policy in context.” ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning). This means the model’s output might look like: guess expression , evaluate (in a differentiable way or approximate) how fits, then based on that, adjust to , etc., all encoded in the output sequence, until it arrives at a final answer. The transformer’s attention and recurrence over its own outputs allow it to simulate the iterative improvement.
This is related to the broader idea that transformers can implement gradient descent internally if trained to do so. Recent theoretical work has shown that a sufficiently large transformer can learn to mimic an optimizer algorithm given appropriate training data (this is a form of learned algorithmic reasoning). In our case, the algorithm is “fit an equation to data”, which could be done by something like beam search over formulas or gradient-based fitting of coefficients. If the transformer can approximate that in a forward pass, it’s effectively doing symbolic regression in-context.
Induction and pattern completion: Another connection is to the concept of induction heads discovered in mechanistic interpretability of language models. Olsson et al. (2022) found specific attention heads (called induction heads) that allow a model to continue a pattern from earlier in the prompt () (). For example, if a sequence “A, B, A, B, A, …” appears, the model completes it with B because an induction head notices that “A, B” appeared and then later another “A” and copies the subsequent token “B”. In symbolic regression context, if the model sees a pattern in the data (like repeating cycles), it might analogously have an attention mechanism to extrapolate that pattern. In-context learning fundamentally relies on such pattern recognition and continuation abilities.
In summary, in-context learning is at the heart of transformer-based symbolic regression. The model is a meta-learner that sees each new regression task as context to condition on. This offers flexibility – the same model can adapt to an infinite variety of functions limited only by what it has learned to represent. It also offers an explanation for how these models can sometimes solve tasks they were not explicitly trained on: they contain a generic problem-solving procedure that goes beyond memorizing a mapping from data to formula.
(d) Mechanistic Interpretability
Mechanistic interpretability seeks to open up the black box of neural networks and understand the algorithmic mechanism inside – in other words, to reverse-engineer the network’s computations into human-understandable components. This is particularly relevant for symbolic tasks, because if a network truly learns to do symbolic reasoning, we might be able to find internally something resembling symbols or operations.
There are a few dimensions to consider:
- Interpretability of the learned model’s solution vs interpretability of the model itself. In symbolic regression, we often focus on the interpretability of the output (the discovered formula), which is a big win over, say, a neural net that approximates the function. However, the process by which a neural net found that formula is still hidden in its weights. Mechanistic interpretability targets the latter: can we understand how the transformer or RL policy came up with that expression?
- Using symbolic regression as a tool for interpretability: Interestingly, the connection can go both ways – we can use symbolic regression to interpret neural networks. For example, one could take the activation pattern of a neuron or a combination of neurons and try to fit a symbolic expression that predicts that activation from the network’s input. If successful, that expression might describe what feature or concept the neuron is detecting (Reverse-engineering using interpretability — LessWrong). This approach has been suggested in interpretability research: “recent advances in symbolic regression and equation learning might be useful… to help generate functions describing component behavior” (Reverse-engineering using interpretability — LessWrong). Essentially, if a neuron computes something like , a symbolic regression algorithm given the neuron’s inputs and output could recover that formula, revealing a truth about the network’s internal computation. This could simplify the network (finding that a complex combination of weights is effectively doing a known mathematical operation).
- Fully reverse-engineering algorithms: The grokking study by Nanda et al. we discussed is a shining example of mechanistic interpretability success. They “fully reverse engineer the algorithm learned” by a small transformer for modular addition, finding it does a discrete Fourier transform internally ([2301.05217] Progress measures for grokking via mechanistic interpretability). This gives us a blueprint for how to proceed with other tasks: attempt to find meaningful transformations or subroutines in the network. For instance, if a transformer is trained to do integration (like in Lample & Charton’s work), one might inspect the attention patterns and intermediate representations to see if it’s learned something analogous to the power rule or recognition of special integrand forms. If a symbolic regression model is trained on many tasks, perhaps certain heads specialize: one head might identify that the data looks polynomial and effectively compute coefficients, another might identify periodic structure and compute a phase/frequency. If we could identify these, we could literally say “head 5 is performing a Fourier transform on the input points” or “neuron 200 is computing the slope between the first two points”.
Approaches in mechanistic interpretability include:
- Activation patching and ablation: One can test hypotheses by ablating part of the network or feeding in modified activations to see if the behavior changes. In the modular addition case, they ablated in Fourier space to confirm the model was using that representation ([2301.05217] Progress measures for grokking via mechanistic interpretability).
- Probing: Train simple models to predict some known property (like “is the function sinusoidal?”) from the network’s internal state. If a probe can do it, the information is present in the latent representation.
- Circuit analysis: Manually or semi-automatically trace which neurons influence which, trying to simplify the computation graph into something like a flowchart of logical/mathematical operations.
One could imagine applying these to a symbolic regression transformer:
- If it outputs for sinusoids, somewhere inside it might have computed that the output varies periodically. Trace back from the output tokens to see what input information they attend to: maybe the final token attended strongly to a pattern in input values that looked sinusoidal.
- If the model outputs a product for two-variable data, perhaps an intermediate representation explicitly had a value proportional to for the given inputs, meaning the model internally multiplied those features to test if a product term explains the data.
Mechanistic interpretability can also inform training. If we know what we hope the model will do, we might design architectures that make that easier. For instance, if we suspect the model should do a Fourier transform to detect frequencies, we could provide a layer or mechanism that explicitly performs something Fourier-like (or at least space for it). Some research in interpretable or modular networks tries to build in such inductive biases so that what the network learns is closer to human logic.
Another interesting angle: program synthesis via mechanistic interpretability – there is work like MIP that tries to extract a discrete program from a trained RNN by interpreting it ([PDF] program synthesis via mechanistic interpretability - arXiv). They convert the RNN to a finite state machine and then apply symbolic regression to get an interpretable description of the state transitions (Mechanistic Interpretability for Progress Towards Quantitative AI Safety). This is directly using symbolic methods to understand a neural network’s function. In the case of a transformer solving math problems, program synthesis could mean extracting an actual algorithm (in pseudocode or equations) that the transformer is effectively implementing.
Finally, mechanistic interpretability is crucial for trust and verification. If a transformer proposes a certain physical law, we not only want to verify it fits the data but also trust that the model wasn’t just guessing from spurious correlations. If we understand the model’s reasoning (say it identified a conservation law from the data and built the equation around that), we have more confidence in the result. Moreover, by understanding the model, we might correct it – e.g., if it mis-interpreted a noise pattern as a genuine effect, we could detect that in its internal logic and adjust.
In conclusion, mechanistic interpretability and symbolic regression are natural allies:
- Symbolic regression provides tools to describe behavior in closed form, which can be applied to neural network internals.
- Interpretability efforts can uncover whether the network has truly learned symbolic-like reasoning or is just approximating.
- The ultimate dream is a system that explains itself – e.g., a symbolic regression model that not only outputs a formula but also can justify why that formula, perhaps by showing how it considered alternatives or which features in data indicated that choice. We are not there yet, but the pieces (transformers, RL, interpretability techniques) are being assembled in research.
Conclusion
Transformer-based and reinforcement learning-based approaches have significantly advanced the field of symbolic regression and equation discovery, tackling the formidable search problem with modern machine learning tools. On the theoretical side, we have formalized these tasks as searching an expression space to minimize a loss (data error + complexity), an NP-hard combinatorial optimization (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). Transformers address this by learning a direct mapping from data to expressions, effectively compressing a vast search experience into a model’s weights, while RL addresses it by exploring the space intelligently online, guided by reward feedback.
We discussed how transformers, armed with attention mechanisms, can learn to generate valid and often correct expressions in an auto-regressive fashion (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework), and how they excel in leveraging large training corpora to achieve one-shot inference ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning). Reinforcement learning, on the other hand, offers a framework to incorporate arbitrary constraints and optimization goals (through reward design) and does not require ground-truth formulas for training – it can discover formulas from scratch (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework). Hybrid approaches like MCTS-guided decoding (Interactive Symbolic Regression through Offline Reinforcement Learning: A Co-Design Framework) and the FormulaGPT in-context learner ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning) demonstrate the synergy of planning algorithms with learned models, marrying the search-based rigor of RL with the speed of neural networks.
Through the lens of grokking, we see that sometimes learning a symbolic task is not a smooth ride – a model may need to traverse a period of apparent overfitting or random exploration before uncovering the simple structure hidden in the problem ([2201.02177] Grokking: Generalization Beyond Overfitting on Small Algorithmic Datasets). This reminds us not to prematurely stop training or give up during those plateaus. The analysis of training dynamics and the phases of learning ([2301.05217] Progress measures for grokking via mechanistic interpretability) provides a conceptual roadmap for what’s happening inside these models as they learn to reason symbolically. Features and circuits form gradually, and with tools from mechanistic interpretability, we can sometimes catch a glimpse of these emerging structures – be it a Fourier transform module solving a modular arithmetic problem ([2301.05217] Progress measures for grokking via mechanistic interpretability), or an attention head detecting a polynomial trend.
In-context learning emerged as a central theme: a transformer model for symbolic regression effectively does “learning within the prompt,” treating each new dataset as something to reason about and solve without gradient updates. This showcases the power of meta-learning – the model has learned the procedure of fitting equations, not just a static mapping ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning). As models like FormulaGPT illustrate, even reinforcement learning procedures can be encoded into a forward pass of a transformer ([2404.06330] Generative Pre-Trained Transformer for Symbolic Regression Base In-Context Reinforcement Learning), hinting at a future where models could carry out complex problem-solving (like experimenting with different hypotheses) all in a single sequence of self-generated thought.
Mechanistic interpretability offers both a microscope and a bridge: a microscope to peer into the networks and verify if they truly understand or are just superficially matching patterns, and a bridge to connect neural network behavior with human-understandable algorithms. The case study of grokking via mechanistic interpretability gave us an example of fully translating network computation into symbolic terms (DFT and trig identities) ([2301.05217] Progress measures for grokking via mechanistic interpretability). As we apply similar analyses to symbolic regression models, we may find they have learned human-like strategies (or sometimes non-human but valid strategies) for analyzing data. Each attention pattern or neuron that we interpret brings us closer to white-box AI, where we can trust and even mathematically verify the steps the model is taking.
In practical applications, transformer and RL-based symbolic regression have started to contribute to scientific discovery, sifting through data for analytic laws in physics, biology, and beyond. They complement human intuition by exploring huge formula spaces and yet provide results in a form humans can interpret. The theory-heavy discussion here underscores that behind these empirical successes lies rich interaction between machine learning theory and classic ideas of generalization, search, and representation. Concepts like grokking and in-context learning show that even when solving centuries-old style problems (finding formulas), these deep models operate in regimes that defy purely classical analysis – requiring us to develop new theory or adapt existing ones (like NTK theory for lazy vs rich regime ([2310.06110] Grokking as the Transition from Lazy to Rich Training Dynamics)) to understand them.
Open challenges remain: improving the reliability and proving correctness of discovered formulas (perhaps with formal methods or additional validation), handling higher-dimensional or more complex functional forms (where the expression language might need to include special functions or integrals), and scaling interpretability to larger networks (since current full interpretability successes are on relatively small models). Furthermore, balancing the dual objectives of accuracy and simplicity in a principled way (potentially via better MDL – minimum description length – frameworks) is an ongoing area of research.
In conclusion, the intersection of transformers, RL, and symbolic regression is a fertile ground where theoretical computer science (search algorithms, complexity), mathematics (approximation theory, algebra), and modern AI (deep learning, meta-learning) converge. By studying their connections to phenomena like grokking, we not only improve these models but also gain insight into how neural networks learn abstract concepts. As interpretability techniques advance, we may eventually watch a neural network “think” through a symbolic reasoning process step by step, giving us confidence in its solutions and perhaps even teaching us new mathematics that eluded human scientists. The journey toward that goal is well underway, built on the robust theoretical and empirical foundations we discussed, and it exemplifies the exciting blend of rigor and discovery in contemporary AI research.