Inspiration

Deep learning is incredibly powerful, but it has a fundamental flaw: it produces "black-box" models. If you train a neural network to model physical phenomena or financial trends, you get a massive matrix of weights, not an equation. We wanted to build an autonomous agent that could read raw, noisy data and discover the actual governing mathematical laws (closed-form equations) of the system. By combining large language models for reasoning and classical symbolic math engines for fitting, we sought to create a true automated scientist.

What it does

The Neuro-Symbolic Hypothesis Engine is an autonomous web-augmented discovery loop. When given a raw dataset:

  1. Domain Identification: It detects the variables and uses web research agents (via Firecrawl) to search scientific databases for existing formulas and theories.
  2. Hypothesis Generation: A hosted LLM proposes mathematically sound candidate equations.
  3. Sandboxed Verification: Candidates are parsed into symbolic trees, validated against strict math constraints, and checked for singularities (division by zero).
  4. Parameter Optimization: SciPy fits the coefficients using non-linear least squares.
  5. Local Genetic Evolution: The engine takes the best-fitting structures and mutates them locally using mathematical node trees (operators swapping, growth, pruning) to optimize them without expensive API calls.
  6. Wolfram Alpha Loop: An interactive log CLI allows users to run symbolic validation queries directly using the Wolfram Spoken Result API.

How we built it

  • Backend: FastAPI web server orchestrating the search loop.
  • LLM Engine: Featherless AI hosting Qwen/Qwen2.5-Coder-32B-Instruct for mathematical reasoning and code repair.
  • Web Scraping RAG: Firecrawl API for autonomous web search.
  • Symbolic Processing: SymPy for AST tree parsing, safety verification, and symbolic simplifications.
  • Numerical Fit: SciPy (curve_fit) and NumPy for parameter optimization and error metrics (R², AIC, BIC).
  • Frontend: Responsive, modern glassmorphic dashboard built using Vanilla CSS, HTML5, and Chart.js for real-time scatter plots and fit curves.

Challenges we ran into

  • LLM Mathematical Hallucinations: LLMs frequently generate invalid math syntax or formulas with division-by-zero singularities. We resolved this by building a self-healing compiler loop: the engine parses the math in an AST sandbox, catches syntax/runtime errors, and passes the error logs back to the LLM to recursively correct the code.
  • Local Optimization Costs: Making LLM calls for every minor structural change is slow and costly. We built a local genetic mutation system using custom expression trees, allowing us to evolve and fit equations locally.
  • Chart.js Fit Ordering: If data points are not sorted along the x-axis, Chart.js draws lines that cross back over themselves. We implemented dynamic key-sorting before feeding datasets to the renderer.

Accomplishments that we're proud of

  • Self-Healing Loop: The AST safety parser and self-healing loop successfully correct invalid candidate equations autonomously.
  • Web RAG Seeding: Integrating Firecrawl means the LLM is seeded with physical reality (like actual equations from arXiv papers) rather than guessing in a vacuum.
  • Visual Polish: Built a stunning, glassmorphic UI dashboard that updates live with fitting lines and real-time terminal output.

What we learned

  • Hybrid Systems Win: Combining the intuitive pattern matching of LLMs with the absolute mathematical precision of symbolic algebra engines is far more effective than trying to make an LLM solve equations on its own.
  • Strict Sandboxing is Essential: Executing generated strings requires robust security. Statically walking the AST ensures no arbitrary python code can be executed on the host system.

What's next for the Neuro-Symbolic Hypothesis Engine

  • Multi-Variable Regressions: Expanding the mathematical expression trees to support multi-dimensional inputs (y = f(x1, x2, ...)).
  • Deep Neural Network Initialization: Using the discovered closed-form equations to initialize the weights or architectures of neural networks for hybrid physics-informed ML models (PINNs).
  • Advanced Wolfram API Integration: Scaling the Spoken Results CLI to the Full Results XML API to pull step-by-step mathematical proofs.

Built With

Share this project:

Updates

Submission history