In-Context Symbolic Regression: Leveraging Large Language Models for Function Discovery
Matteo Merler, Katsiaryna Haitsiukevich, Nicola Dainese, Pekka Marttinen
TL;DR
The paper introduces In-Context Symbolic Regression (ICSR), a framework that uses Large Language Models to generate seed symbolic forms and then refines them through an external nonlinear optimization loop to fit data while penalizing expression complexity. By combining LLM-based skeleton generation with a complexity-regularized NMSE objective and coefficients optimized via nonlinear least squares, ICSR achieves competitive or superior performance on four SR benchmarks while producing simpler, more interpretable equations and better out-of-distribution generalization. The work demonstrates that foundation models endowed with mathematical priors can effectively contribute to SR without task-specific fine-tuning, offering a flexible natural-language interface and clear avenues for future enhancements such as domain-aware prompts, chain-of-thought reasoning, and hybrid search strategies. Limitations include context-window constraints and higher-dimensional scaling, suggesting that advances in prompt design and multimodal or hierarchical prompting could further improve robustness and applicability in complex SR tasks.
Abstract
State of the art Symbolic Regression (SR) methods currently build specialized models, while the application of Large Language Models (LLMs) remains largely unexplored. In this work, we introduce the first comprehensive framework that utilizes LLMs for the task of SR. We propose In-Context Symbolic Regression (ICSR), an SR method which iteratively refines a functional form with an LLM and determines its coefficients with an external optimizer. ICSR leverages LLMs' strong mathematical prior both to propose an initial set of possible functions given the observations and to refine them based on their errors. Our findings reveal that LLMs are able to successfully find symbolic equations that fit the given data, matching or outperforming the overall performance of the best SR baselines on four popular benchmarks, while yielding simpler equations with better out of distribution generalization.
