Language-model proposals#

Large language models as proposal generators for equation discovery.

Recent work uses large language models (LLMs) to propose equation skeletons from scientific context and the current best fits, while a numerical optimizer fits the constants: in-context symbolic regression (Merler et al., 2024), LLM-SR (Shojaee et al., 2025) and concept-guided search (Grayeli et al., 2024).

eqdisco supports this without depending on any LLM service. A proposer is any callable proposer(prompt: str) -> str; it can wrap the client library of any provider. This module builds the prompt from the variables, their meaning, a data summary and the best equations so far, parses the answer into expressions with free constants, and fits them:

Proposals are treated as untrusted text: they are parsed by SymPy into the restricted expression language of eqdisco and never executed.

Prompt construction, safe parsing and the LLM-guided regressor.

Classes#

TemplateProposer(templates[, n, random_state])

Offline proposer that answers with templates (no language model).

LLMGuidedRegressor([proposer, n_iterations, ...])

Iterative equation discovery with a proposer (LLM or templates) and constant fitting.

Functions#

build_prompt(feature_names, X, y[, best, ...])

Prompt that asks for n new candidate equations.

parse_proposals(text, feature_names[, max_size])

Parse an answer into expressions; constants c0, c1, ... become parameters (start value 1).

propose_expressions(proposer, best, pset, X, y)

Ask the proposer for n expressions and fit their parameters; failures give an empty list.