SymTorch: Extracting Equations from Neural Networks
This presentation explores SymTorch, a PyTorch-based framework that transforms neural network interpretability by automatically distilling trained models into explicit symbolic equations. Rather than inspecting neurons or attention patterns, SymTorch uses symbolic regression to recover the actual mathematical formulas learned by network components. The talk demonstrates how this approach enables hybrid neural-symbolic models, accelerates transformer inference by 8.3%, and successfully extracts physical laws from graph neural networks—opening new pathways for explainability, scientific discovery, and efficient model deployment.Script
What if you could ask a neural network to write down its equations—not as a metaphor, but literally? SymTorch makes that possible, distilling trained networks into explicit symbolic formulas that reveal exactly what they've learned.
Most interpretability tools try to understand neural networks by looking at their internal structure. SymTorch takes a fundamentally different approach: it uses symbolic regression to recover the actual mathematical equations that approximate what each network component computes.
The machinery behind symbolic distillation is surprisingly elegant.
SymTorch wraps around any neural network component, capturing its input-output behavior during forward passes. Multi-population genetic algorithms then search for mathematical expressions that reproduce this behavior, building a Pareto frontier where you can choose between accuracy and interpretability.
The entire workflow integrates seamlessly into PyTorch. You collect activation traces from trained components, run symbolic regression independently on each output dimension, and can then dynamically swap neural blocks for their discovered equations—creating models that are part neural network, part explicit mathematics.
One compelling application targets the computational bottleneck in large language models.
When the authors replaced transformer MLP layers in Qwen 2.5 with symbolic surrogates—using PCA for dimensionality reduction first—they achieved an 8.3% inference speedup. The perplexity increased by only 3 points, and critically, the symbolic replacement itself contributed minimally to accuracy loss compared to dimensionality compression alone.
The framework doesn't just compress models—it can extract the fundamental laws they've learned.
By distilling the edge model MLPs in graph neural networks trained on particle interactions, SymTorch explicitly reconstructs the true physical force laws governing the system. With appropriate architectural constraints and regularization, it reliably extracts equations like inverse square laws—demonstrating that the network genuinely learned the underlying physics, not just a lookup table.
Physics-informed neural networks encode domain constraints directly into their loss functions, and this structure makes them ideal candidates for symbolic distillation. When the authors applied SymTorch to a PINN solving the heat equation, it successfully extracted the analytic solution—something a regular neural network failed to do, even with the same training data.
SymTorch positions symbolic distillation as a practical tool across architectures—from transformers to graph networks to physics simulators. It opens pathways for transparent evaluation of language model arithmetic, inference acceleration through hybrid architectures, and recovery of interpretable scientific relationships. The main constraint remains computational: symbolic regression scales exponentially with input dimensions, requiring careful dimensionality reduction strategies.
Neural networks no longer need to be black boxes that merely predict—they can now explain themselves in the language of mathematics. Visit EmergentMind.com to explore more research and create your own video presentations.