arXiv:2608.25291cs.LGAug 2026

Manuscript Offprint

arXiv:2608.25291

InsightSR: Refining Symbolic Regression Search Spaces via Parallel Semantic and Structural LLM Guidance

Yating Ling, Wenjing Cun, Zhitang Chen

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Symbolic regression (SR) seeks to discover parsimonious mathematical laws from observational data, yet conventional approaches often struggle with the vast combinatorial search space of physically meaningful expressions. We present InsightSR, a framework that embeds Large Language Models (LLMs) as a guiding layer around the PySR genetic programming engine. Rather than relying on LLMs to generate expressions directly, InsightSR uses LLMs to progressively transform the search space itself through two complementary pathways: a Semantic Seed Pathway that proposes dimensionally consistent functional skeletons, and a Structural Feature Pathway that recommends nonlinear feature transformations. These transformations accumulate over iterations, broadening the input space and shifting the symbolic search from constructing deep expression trees over raw variables to assembling shallow trees over a rich, semantically informed feature set. A post-generation feedback loop evaluates candidates, categorizes features by their empirical utility, and refines the guidance for the next iteration, transforming the discovery process from open-ended generation into iterative, self-correcting refinement. Across three benchmarks, InsightSR achieves a 95% exact recovery rate on the Feynman benchmark and 80.18% accuracy on the LLM-SRBench LSR-Transform task, substantially outperforming state-of-the-art genetic programming and neural-symbolic methods while maintaining strong out-of-distribution generalization on real-world datasets.

Introduction

Symbolic regression (SR) aims to distill underlying mathematical laws directly from observed data, serving as a cornerstone for automated scientific discovery (Schmidt and Lipson 2009; Brunton, Proctor, and Kutz 2016). While SR produces interpretable closed-form expressions, its optimization is inherently NP-hard (Virgolin and Pissis 2022) and the combinatorial search space of candidate expressions grows exponentially with expression complexity. A further challenge is the difficulty of incorporating physical constraints, such as dimensional consistency and known conservation laws, into the search process. As a result, purely data-driven SR methods frequently yield expressions that achieve high numerical accuracy but violate basic physical principles.

Existing approaches predominantly rely on stochastic search over the discrete space of mathematical expressions. The most widely used are Genetic Programming (GP) variants (Koza 1994; Cranmer 2023; Virgolin et al. 2021), which evolve populations of expression trees through mutation and crossover, and more recent methods based on Monte Carlo Tree Search (MCTS) (Sun et al. 2022; Shojaee et al. 2023), which frame discovery as a sequential decision-making task. Although these methods can recover approximate symbolic forms, they suffer from low sample efficiency and tend to overfit under observational noise. More critically, without mechanisms to enforce physical constraints, they frequently produce expressions that are mathematically flexible but physically meaningless, lacking the parsimony and domain consistency necessary for scientific interpretation.

The integration of neural networks has further expanded the SR toolkit. Deep reinforcement learning methods such as DSR (Petersen et al. 2021) and uDSR (Landajuela et al. 2022) treat equation discovery as a policy optimization problem, using learned gradients to guide the search through expression space. Transformer-based models such as NeSym-ReS (Biggio et al. 2021) and E2E (Kamienny et al. 2022) leverage large-scale pre-training to map data patterns directly to mathematical expressions. Other specialized approaches, such as PhySO (Landajuela et al. 2021), incorporate dimensional constraints into the search to enforce physical consistency. Although these neural methods accelerate discovery, they are fundamentally data-driven: their performance depends heavily on the training distribution, and they often fail to generalize to out-of-distribution regimes. Moreover, the physical constraints they enforce are typically hard-coded during training rather than dynamically reasoned about, limiting their adaptability to novel physical contexts.

Recent work has explored integrating Large Language Models (LLMs) into SR to leverage scientific priors encoded. LLM-SR (Shojaee et al. 2025a) generates equation skeletons via an LLM and optimizes their parameters through BFGS, storing successful patterns in an experience buffer to guide future iterations. SR-LLM (Guo et al. 2025) casts SR as a reinforcement learning problem with an LLM-based policy network, coupled with retrieval-augmented generation for incremental knowledge accumulation. LaSR (Li et al. 2024) focuses on LLM-guided feature engineering, recommending transformations to expand the input space. PiSR via LLM (Taskin, Xie, and Lazebnik 2026) incorporates LLM-derived evaluations into the loss function as a physics-informed regularization term. While promising, these methods are often constrained by two limitations. First, they incur substantial inference overhead, as they require frequent LLM queries throughout the search process. Second, and more importantly, each method employs LLM guidance along a single dimension—either structural hypothesis generation or input space transformation—without exploiting the potential synergy of integrating both. This separation overlooks a key opportunity: structural priors can inform which features to engineer, and engineered features can simplify the structural forms needed to fit the data.

To address these limitations, we propose InsightSR, a framework that embeds LLMs as a guiding layer around the PySR genetic programming engine (Cranmer 2023). Rather than relying on the LLM to generate candidate expressions directly, InsightSR uses the LLM to progressively transform the search space through two complementary pathways. A Semantic Seed Pathway proposes dimensionally consistent functional skeletons that provide a physics-informed warm-start, while a Structural Feature Pathway recommends nonlinear feature transformations that accumulate over generations, progressively broadening the input space. This shifts the burden of the search from constructing deep expression trees over raw variables to assembling shallow combinations over a semantically enriched feature set. A learning-from-results feedback loop closes each generation: the LLM evaluates the Pareto-optimal candidates, categorizes features by their empirical utility, and updates a knowledge base that informs both pathways in the subsequent iteration, transforming symbolic discovery from open-ended generation into iterative, self-correcting refinement.

Our work makes three key contributions:

  1. Semantic Seed Pathway. We introduce a mechanism that leverages domain-aware LLMs to propose dimensionally consistent functional skeletons that serve as physics-informed seeds for the evolutionary search. By auditing and reconfiguring candidate topologies to align with target physical units, this pathway prunes the search space of physically inconsistent expressions before numerical fitting begins. The LLM also provides per-operator complexity biases that steer the genetic programming engine toward physically plausible operator combinations.

  2. Structural Feature Pathway. We design a complementary pathway in which the LLM recommends nonlinear feature transformations based on the problem context and the performance history of prior generations. These transformations accumulate across iterations, progressively broadening the input space. This shifts the evolutionary search from constructing deep expression trees over raw variables to assembling shallow combinations over an enriched feature basis, substantially reducing the structural complexity that the symbolic engine must resolve.

Algorithm 1 InsightSR Search Procedure

Require: Dataset (X, y), problem context C, units U Ensure: Optimal symbolic expression f∗f^{*} Initialize knowledge base K←∅K \leftarrow \emptyset for g=1g = 1 to G do // Dual-Path Heuristic Guidance Fseed←F_{seed} \leftarrow LLM.SEMANTICSEEDS( C,U,KC, U, K) ▹\triangleright Seed Pathway Xaug←X_{aug} \leftarrow LLM.STRUCTURALFEATURES( C,KC, K) ▹\triangleright Feature Pathway G←G \leftarrow MergeGuidance( Fseed,XaugF_{seed}, X_{aug}) candidates ←\leftarrow PYSR.GUIDEDSEARCH( Xaug,y,GX_{aug}, y, G) eval, insights ←\leftarrow LLM.STRATEGICANALYSIS(candidates) K←K \leftarrow KB.ACCUMULATE(insights, eval) if Loss( f∗f^{*}) < 10−1010^{-10} then break end if end for return Best expression f∗f^{*} from candidates

  1. Closed-Loop Iterative Refinement. We implement a learning-from-results mechanism that closes the discovery loop. After each generation, the LLM evaluates candidates along multiple dimensions including numerical accuracy, physical interpretability, and feature utility. These assessments are accumulated in a dynamic knowledge base that informs both the semantic and structural pathways in subsequent iterations, enabling the search to self-correct and progressively converge toward the optimal symbolic form.