Symbolic Equation

作者 lingzhi2279e6c085d65e3无许可证386 个星标收录于 2026年10月8日更新于 2026年10月8日仓库7个月前更新

Discover scientific equations from data using LLM-guided evolutionary search (LLM-SR). Multi-island algorithm with softmax-based cluster sampling, island reset, and LLM-proposed equation mutations. Use for symbolic regression and equation discovery.

AI 生成的概览

利用 LLM 引导的进化搜索与多岛采样,从数据中发现可解释的科学方程。

功能
引导智能体执行 LLM-SR 符号回归:先定义包含输入变量、输出变量、适应度函数与物理背景的问题规格,再运行多岛进化循环,由 LLM 提出改进的方程变体,并对其求值并按表现聚类。它通过温度调度的 softmax 聚类采样与周期性岛屿重置维持多样性,最后提取、排序并化简最优方程,给出物理解释。
适用场景
适用于需要从数值数据中还原可解释数学方程或公式的场景,尤其是可借助领域知识引导搜索的科学或物理问题。它面向符号回归任务,而非拟合不透明的黑箱模型。
运行要求
需要一个 LLM 来提出方程变异,以及带 numpy 和 scipy(BFGS 或 Adam 参数优化)的 Python 环境来评估候选方程。该技能不附带脚本,仅引用一份模式文档,并期望智能体自行编写并执行方程代码。

Symbolic Equation Discovery

Discover interpretable scientific equations from data using LLM-guided evolutionary search.

Input

  • $0 — Dataset description, variable names, and physical context

References

  • LLM-SR patterns (prompts, evolution, sampling): ~/.claude/skills/symbolic-equation/references/llmsr-patterns.md

Workflow (from LLM-SR)

Step 1: Define Problem Specification

Create a specification with:

  1. Input variables: Physical quantities with types (e.g., x: np.ndarray, v: np.ndarray)
  2. Output variable: Target quantity to predict
  3. Evaluation function: Fitness metric (typically negative MSE with parameter optimization)
  4. Physical context: Domain knowledge to guide equation discovery
python
# Example specification@equation.evolvedef equation(x: np.ndarray, v: np.ndarray, params: np.ndarray) -> np.ndarray:    """Describe the acceleration of a damped nonlinear oscillator."""    return params[0] * x

Step 2: Initialize Multi-Island Buffer

  • Create N islands (default: 10) for population diversity
  • Each island maintains independent clusters of equations
  • Clusters group equations by performance signature

Step 3: Evolutionary Search Loop

Repeat until convergence or max samples:

  1. Select island: Random island selection
  2. Build prompt: Sample top equations from clusters (softmax-weighted by score)
  3. LLM proposes: Generate new equation as improved version
  4. Evaluate: Execute on test data, compute fitness score
  5. Register: Add to island's cluster if valid

Step 4: Prompt Construction

Present previous equations as versioned sequence:

python
def equation_v0(x, v, params):    """Initial version."""    return params[0] * x
def equation_v1(x, v, params):    """Improved version of equation_v0."""    return params[0] * x + params[1] * v
def equation_v2(x, v, params):    """Improved version of equation_v1."""    # LLM completes this

Step 5: Island Reset (Diversity Maintenance)

Periodically (default: every 4 hours):

  1. Sort islands by best score
  2. Reset bottom 50% of islands
  3. Seed each reset island with best equation from a surviving island
  4. Restart cluster sampling temperature

Step 6: Extract Best Equations

After search completes:

  1. Collect best equation from each island
  2. Rank by fitness score
  3. Simplify if possible (algebraic simplification)
  4. Report with physical interpretation

Cluster Sampling

Temperature-scheduled softmax over cluster scores:

temperature = T_init * (1 - (num_programs % period) / period)probabilities = softmax(cluster_scores / temperature)
  • Higher temperature → more exploration
  • Lower temperature → more exploitation of best clusters
  • Within clusters: shorter programs are preferred (Occam's razor)

Rules

  • Equations must use only standard mathematical operations
  • Parameter optimization via scipy BFGS or Adam
  • Fitness = negative MSE (higher is better)
  • Timeout protection for equation evaluation
  • No recursive equations allowed
  • Physical interpretability is preferred over pure fit

Related Skills

  • Upstream: data-analysis, math-reasoning
  • Downstream: paper-writing-section
  • See also: algorithm-design

来源与署名

来源:lingzhi227/agent-research-skills位于skills/symbolic-equation提交9e6c085

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架