Physics2Weight: Direct Neural Network Architecture and Weight Generation from Physical Laws Using Large Language Models
Organizations: NTT, Inc., Japan.
Abstract
Recent advances in large language models (LLMs) have enabled weight-space programming (WSP), which directly generates neural network weights without gradient-based optimization. However, extending WSP to physical problems remains challenging, particularly in achieving both solution accuracy and physical consistency. In this paper, we propose Physics2Weight (PtW), a framework that extends WSP to solving partial differential equations by directly generating neural network weights and editing architectures based on governing equations and initial and boundary conditions. PtW introduces physics-constrained prompting and physics-guided architecture editing, combined with iterative weight refinement from WSP, to improve solution accuracy and physical consistency without gradient-based optimization. Experiments on four PDEs, namely the heat, advection, Burgers', and Allen--Cahn equations, demonstrate lower solution errors than conventional physics-informed neural networks, while revealing limitations in satisfying the governing equations for nonlinear PDEs.
Figures & tables
| Method | Rel. L2 | PDE Res. | IC | BC |
|---|---|---|---|---|
| PINN | ||||
| WSP | ||||
| WSP-PC | ||||
| PtW |
| Method | Rel. L2 | PDE Res. | IC | BC |
|---|---|---|---|---|
| PINN | ||||
| WSP | ||||
| WSP-PC | ||||
| PtW |
| Method | Rel. L2 | PDE Res. | IC | BC |
|---|---|---|---|---|
| PINN | ||||
| WSP | ||||
| WSP-PC | ||||
| PtW |
| Method | Rel. L2 | PDE Res. | IC | BC |
|---|---|---|---|---|
| PINN | ||||
| WSP | ||||
| WSP-PC | ||||
| PtW |
| Heat | Advection | Burgers’ | Allen–Cahn | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Method | LLM calls | params | time [s] | params | time [s] | params | time [s] | params | time [s] |
| PINN | 0 | 501 | 186 | 501 | 136 | 501 | 187 | 501 | 247 |
| WSP | 1 | 501 | 290 | 501 | 121 | 501 | 1009 | 501 | 705 |
| WSP-PC | 1 | 501 | 269 | 501 | 144 | 501 | 5909 | 501 | 2037 |
| PtW | 7–8 | 4–33 | 76 | 4–17 | 70 | 104–342 | 1066 | 36–52 | 588 |
| Heat | Advection | Burgers’ | Allen–Cahn | |||||||||||||
| Method | L2 | PDE | IC | BC | L2 | PDE | IC | BC | L2 | PDE | IC | BC | L2 | PDE | IC | BC |
| PINN | 2.28e-4 | 6.45e-7 | 2.49e-4 | 2.15e-4 | 2.86e-1 | 7.37e-5 | 1.76e-2 | 8.32e-2 | 4.69e-2 | 4.44e-3 | 1.29e-2 | 9.44e-4 | 5.20e-1 | 1.44e-3 | 5.87e-2 | 2.53e-3 |
| PINN-WR | 2.28e-4 | 6.45e-7 | 2.49e-4 | 2.15e-4 | 2.38e-7 | 2.45e-29 | 1.64e-7 | 1.60e-8 | 4.69e-2 | 4.44e-3 | 1.29e-2 | 9.44e-4 | 5.20e-1 | 1.44e-3 | 5.87e-2 | 2.53e-3 |
| WSP | 1.10e-5 | 6.02e-7 | 7.78e-6 | 7.10e-6 | 3.88e-4 | 2.54e-29 | 2.72e-4 | 2.15e-5 | 2.21e-2 | 3.66e-1 | 9.96e-3 | 2.45e-4 | 7.45e-2 | 1.44e-1 | 3.30e-2 | 1.71e-2 |
| WSP-PC | 4.63e-5 | 7.51e-7 | 3.27e-5 | 4.79e-5 | 3.88e-4 | 2.55e-29 | 2.72e-4 | 2.15e-5 | 7.17e-2 | 7.07e-1 | 1.41e-3 | 2.71e-4 | 2.29e-1 | 2.86e-1 | 1.85e-2 | 7.63e-5 |
| WSP-WR | 2.55e-7 | 2.77e-13 | 1.19e-7 | 1.14e-7 | 1.14e-9 | 2.44e-29 | 5.18e-10 | 2.63e-9 | 2.17e-2 | 1.60e-1 | 9.94e-3 | 2.45e-4 | 1.29e-1 | 3.24e-2 | 4.11e-2 | 2.63e-4 |
| Heat | Advection | Burgers’ | Allen–Cahn | |||||
|---|---|---|---|---|---|---|---|---|
| Method | Phys. | Phys. | Phys. | Phys. | ||||
| PINN | 0 (3/3) | 3/3 | 4 (0/3) | 0/3 | 3 (0/3) | 3/3 | 3 (0/3) | 1/3 |
| PINN-WR | 0 (3/3) | 3/3 | 0 (3/3) | 3/3 | 3 (0/3) | 3/3 | 3 (0/3) | 1/3 |
| WSP | 0 (3/3) | 3/3 | 0 (3/3) | 3/3 | 3 (0/3) | 3/3 | 2 (0/3) | 0/3 |
| WSP-PC | 0 (3/3) | 3/3 | 0 (3/3) | 3/3 | 1 (0/3) | 1/3 | 0 (3/3) | 3/3 |
| WSP-WR | 0 (3/3) | 3/3 | 0 (3/3) | 3/3 | 3 (0/3) | 3/3 | 1 (0/3) | 0/3 |
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
| PDE | Physical constraints |
|---|---|
| Heat | C1: Initial condition (maximum error ). C2: Dirichlet boundary conditions (maximum error ). C3: Maximum principle (tolerance ). C4: Non-increasing energy (increase ). C5: Symmetry (maximum error ). |
| Advection | C1: Initial condition (maximum error ). C2: Periodic boundary condition (maximum error ). C3: Maximum amplitude (tolerance ). C4: Conservation of mass (absolute tolerance ) and (relative tolerance ). C5: Transport speed of the first Fourier mode (relative tolerance ), with amplitude ratio . |
| Burgers’ | C1: Initial condition (maximum error ). C2: Dirichlet boundary conditions (maximum error ). C3: Maximum amplitude (tolerance ). C4: Non-increasing energy (increase ). C5: Odd symmetry (maximum error ). |
| Allen–Cahn | C1: Initial condition, including interface positions (position tolerance ). C2: Non-increasing number of interfaces. C3: Maximum amplitude . C4: Non-increasing energy (increase ). C5: Interface slopes at within times the stationary kink slope. |
| Heat | Advection | Burgers’ | Allen–Cahn | ||||
|---|---|---|---|---|---|---|---|
| Method | Decay err. | Speed err. | Amplitude err. | Energy err. | |||
| Reference (tol.) | ( ) | ( ) | ( ) | ( ) | ( ) | ( ) | |
| PINN | / /– | ||||||
| WSP | –/–/– | ||||||
| WSP-PC | / / | ||||||
| PtW | / / | ||||||