# In-Context Symbolic Regression: Leveraging Language Models for Function Discovery

## ๐ Abstract

The paper investigates the integration of pre-trained Large Language Models (LLMs) into the Symbolic Regression (SR) pipeline, utilizing an approach that iteratively refines a functional form based on the prediction error it achieves on the observation set, until it reaches convergence. The method leverages LLMs to propose an initial set of possible functions based on the observations, exploiting their strong pre-training prior. These functions are then iteratively refined by the model itself and by an external optimizer for their coefficients. The process is repeated until the results are satisfactory. The paper also analyzes Vision-Language Models in this context, exploring the inclusion of plots as visual inputs to aid the optimization process. The findings reveal that LLMs are able to successfully recover good symbolic equations that fit the given data, outperforming SR baselines based on Genetic Programming, with the addition of images in the input showing promising results for the most complex benchmarks.

## ๐ Q&A

### [01] In-Context Symbolic Regression: Leveraging Language Models for Function Discovery

**1. What is the goal of the paper?**
The paper investigates the integration of pre-trained Large Language Models (LLMs) into the Symbolic Regression (SR) pipeline, utilizing an approach that iteratively refines a functional form based on the prediction error it achieves on the observation set, until it reaches convergence.

**2. How does the proposed method work?**
The method leverages LLMs to propose an initial set of possible functions based on the observations, exploiting their strong pre-training prior. These functions are then iteratively refined by the model itself and by an external optimizer for their coefficients. The process is repeated until the results are satisfactory.

**3. What is the role of Vision-Language Models in this context?**
The paper also analyzes Vision-Language Models, exploring the inclusion of plots as visual inputs to aid the optimization process.

**4. What are the key findings of the paper?**
The findings reveal that LLMs are able to successfully recover good symbolic equations that fit the given data, outperforming SR baselines based on Genetic Programming, with the addition of images in the input showing promising results for the most complex benchmarks.

### [02] Related Work

**1. What are the traditional approaches for Symbolic Regression?**
Genetic Programming (GP) has traditionally formed the backbone for SR methods, combining fundamental blocks for mathematical expressions into more complex formulas using strategies borrowed by evolutionary biology, such as mutations and fitness.

**2. What are some recent Deep Learning approaches for Symbolic Regression?**
More recently, Deep Learning methods have also been proposed for symbolic regression, including Recurrent Neural Networks, Graph Neural Networks, and various Transformer-based models.

**3. How do Large Language Models (LLMs) relate to mathematical reasoning?**
There has been research on the mathematical understanding of LLMs, showing their capabilities in tasks like theorem proving, pattern recognition, and higher-order optimization methods.

**4. What is the role of Vision-Language Models in this context?**
Vision-Language Models have gained traction in aligning text and image representations, and can potentially provide richer context for mathematical optimization tasks by incorporating visual information like plots.

### [03] Method

**1. How does the proposed OPRO-based approach work for Symbolic Regression?**
The method uses a meta-prompt that includes previously tested functions and their scores on the dataset. The LLM is then tasked to generate a new function that could be a better fit for the given observations. This process is repeated iteratively until the error is low enough.

**2. How are the seed functions generated initially?**
Instead of relying on a fixed set of seed functions, the model is asked to generate the initial conditions, which typically produces a complex and diverse set of functions for the model to explore and refine.

**3. How is the error score computed?**
The paper uses Mean Squared Error (MSE) as the error score, but mentions that other metrics like the coefficient of determination could also be used.

**4. How are the function parameters optimized?**
The paper uses SciPy's implementation of Non-linear Least Squares to optimize the function parameters, repeating the process multiple times with different random initializations.

### [04] Experiments

**1. What benchmarks were used to evaluate the proposed method?**
The paper evaluates the method on four popular Symbolic Regression benchmarks: Nguyen, Constant, Keijzer, and R.

**2. How does the performance of the OPRO-based approach compare to a simple Genetic Programming method?**
The OPRO-based approach using Llama3 outperforms the simple Genetic Programming method across all benchmarks.

**3. How does the performance of the text-only Llama3 model compare to the Vision-Language LLaVa-NeXT model?**
The Vision-Language model matches or slightly underperforms the text-only Llama3 model on the simpler benchmarks, but shows more significant improvements on the more complex Keijzer benchmark.

**4. How important is the iterative refinement process compared to the initial seed function generation?**
The results suggest that the initial seed function generation plays a key role, but the iterative refinement process is still necessary to achieve good quality solutions, especially for more complex benchmarks.

### [05] Discussion

**1. What are the key strengths of the proposed approach?**
The method shows that LLMs can be successfully leveraged for Symbolic Regression, outperforming a simple Genetic Programming approach. The lack of necessity for expensive task-specific training is also highlighted as a benefit.

**2. What are the main limitations of the approach?**
The main limitations include the dimensionality constraint due to the use of images, and the context window size of the LLMs, which can limit the amount of input information that can be processed.

**3. How can the approach be improved in future work?**
Potential improvements include experimenting with more powerful LLMs and VLMs, fine-tuning the models to improve their mathematical reasoning capabilities, and exploring ways to handle higher-dimensional inputs.

**4. What are the broader implications of this work?**
The paper demonstrates the potential of leveraging the unique reasoning abilities of LLMs for mathematical tasks like Symbolic Regression, suggesting promising avenues for future research in this direction.