WorksComputer Science
Physics2Weight: Direct Neural Network Architecture and Weight Generation from Physical Laws Using Large Language Models
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.
Introduction
Neural networks (NNs) have demonstrated strong performance across a wide range of tasks, including computer vision, natural language processing, and scientific computing [17, 12] (He et al. 2016). However, obtaining their weights typically relies on gradient-based optimization, often using large amounts of training data or task-specific loss functions.
Recent advances in large language models (LLMs) [17, 1] have opened up the possibility of weight-space programming (WSP) [15], in which LLMs directly generate NN weights without gradient-based optimization. This approach offers an alternative paradigm for constructing NNs by generating their parameters rather than learning them through conventional training.

Figure 1. Conceptual comparison between (a) conventional physics-informed neural networks (PINNs) and (b) the proposed Physics2Weight (PtW). PINNs optimize neural network weights by minimizing physics-informed loss functions, whereas PtW edits architectures and directly generates weights from governing equations and initial and boundary conditions using an LLM, without gradient-based optimization.
Solving partial differential equations (PDEs) is a potential application of WSP, as physical problems are often specified by governing equations and initial and boundary conditions. Physics-informed neural networks (PINNs) [12] incorporate these conditions into loss functions and optimize NN weights through gradient-based training. In contrast, whether WSP can directly generate NN weights that achieve both accurate solution approximation and physical consistency remains unclear.
In this paper, we propose Physics2Weight (PtW), a framework that extends WSP to solving PDEs by directly generating NN weights using LLMs (Fig. 1). PtW introduces two physics-guided strategies: (1) physics-constrained prompting, which explicitly specifies additional physical constraints to guide weight generation, and (2) physics-guided architecture editing, which incorporates mathematical structures of governing equations into NN architectures. These strategies are combined with an iterative weight refinement procedure based on WSP Takehi et al., [15] to improve the generated solutions without gradient-based optimization.
We evaluate PtW on four PDEs: heat, advection, Burgers’, and Allen–Cahn equations. Through comparisons with PINNs and WSP and ablation studies, we quantitatively assess solution accuracy and physical consistency. The results show that PtW achieves lower solution errors than PINNs and WSP across all four PDEs, although improvements in solution accuracy do not always correspond to lower PDE residuals.
Our contributions are summarized as follows:
We introduce PtW, a framework for solving PDEs through direct NN weight generation using LLMs, without gradient-based optimization.
We investigate physics-constrained prompting and physics-guided architecture editing, combined with iterative weight refinement, to improve solution accuracy and physical consistency.
We systematically evaluate PtW across four PDEs, demonstrating improved solution accuracy over PINNs and WSP while identifying limitations in physical consistency.
Related Work
Neural Network Weight Generation. NN weight generation aims to produce the parameters of target NNs without directly optimizing each target network. Hypernetworks (Ha et al., 2017) generate target NN weights using a separately trained network. Weight-space learning Navon et al., [11] further investigates the structure and representations of NN parameters, while recent generative approaches [18, 13, 7] explore the generation of NN weights from learned parameter distributions. Text-conditioned approaches extend this direction by generating weights from natural language descriptions Tian et al., [16]. More recently, WSP Takehi et al., [15] has reported that general-purpose LLMs can directly generate and refine NN weights without training a dedicated weight generator. Building on WSP, PtW introduces explicit physical constraints and physics-guided architecture editing to construct NN representations for solving PDEs.
Neural Architecture Search and Editing. Neural architecture search (NAS) aims to automatically identify effective NN architectures for a given task. Early NAS methods employ reinforcement learning Zoph & Le, [21] or gradient-based optimization Liu et al., [9] to explore architecture search spaces. Recent LLM-based approaches, such as GE-NIUS Zheng et al., [20] and LLMatic Nasir et al., [10], generate and iteratively refine NN architectures using performance feedback. RZ-NAS (Ji et al., 2025) further incorporates LLM-based reflection to guide architecture search. Unlike general-purpose NAS, PtW uses the mathematical structure of governing equations to guide architecture editing, explicitly incorporating physically motivated operations into NN computations.
Physics-Informed Neural Networks. PINNs incorporate governing equations and initial and boundary conditions into loss functions to approximate PDE solutions without requiring extensive labeled solution data Raissi et al., [12]. Earlier work enforced boundary conditions exactly through trial functions Lagaris et al., [8]. Subsequent studies have investigated adaptive loss balancing Wang et al., [19], domain decomposition Jagtap & Karniadakis, [4], and exact imposition of boundary conditions with distance functions Sukumar & Srivastava, [14] to improve training and constraint satisfaction. In particular, hard-constrained approaches incorporate analytical structures into NN representations to satisfy prescribed physical conditions. Unlike these methods, PtW uses LLMs to edit NN architectures based on governing equations and directly generate and refine their weights without gradient-based optimization.
Preliminaries
Problem Formulation
We consider an initial-boundary value problem governed by a PDE:
where denotes the unknown solution, is the spatial coordinate, is time, and , , and represent the governing equation, initial condition, and boundary condition operators, respectively.
We approximate the solution using an NN , parameterized by weights and architecture :
The objective is to construct an NN representation that accurately approximates the solution while satisfying the governing equation and initial and boundary conditions.
Gradient-based Weight Optimization
Given spatiotemporal coordinates , PINNs predict the approximate solution and minimize a physics-informed loss function consisting of governing equation residuals and initial and boundary condition errors:
where , , and measure violations of the governing equation, initial condition, and boundary condition, respectively, and , , and are their weighting coefficients.
Given a fixed architecture , PINNs obtain NN weights by minimizing the physics-informed loss function through gradient-based optimization:
This process iteratively updates the weights using gradients of the loss function with respect to .
Weight-Space Programming
WSP enables pretrained LLMs to directly generate NN weights from a specification of the target network without gradient-based optimization [15]. Given an NN architecture and a task specification , the generated weights are expressed as
where describes the target task and denotes the initially generated weights.
WSP also supports iterative weight refinement [15]. The LLM evaluates the generated network by executing forward passes and uses the resulting feedback to modify its weights. At iteration , this process can be expressed as
where denotes the evaluation feedback obtained by the LLM. This process iteratively refines NN weights without computing gradients of the evaluation objective. In contrast, PtW adapts this refinement procedure to PDE solving by providing physics-based feedback from an external evaluator, without granting the LLM tool access.
Physics2Weight
Framework Overview
As illustrated in Figure 2, PtW constructs an NN for solving PDEs using a pretrained LLM without gradient-based optimization. Given the governing equation , initial condition , boundary condition , physical constraints , and an initial NN architecture , PtW generates an architecture and weights :

Figure 2. Overview of the proposed PtW framework. Given governing equations, initial and boundary conditions, and an initial NN architecture, an LLM edits the architecture and directly generates NN weights without gradient-based optimization. Physics-constrained prompting specifies additional physical constraints, while iterative weight refinement, adapted from WSP, updates the generated weights based on external evaluation feedback.
PtW combines three components: physics-constrained prompting (PC), physics-guided architecture editing (AE), and iterative weight refinement (WR). PC explicitly specifies physical constraints, while AE incorporates mathematical structures of governing equations into NN architectures. WR, adapted from WSP [15], iteratively refines the generated weights based on external evaluation feedback. The complete PtW framework combines all three components, while their individual effects are investigated through ablation studies.
Physics-Constrained Prompting
In standard WSP, the task specification includes the governing equation, computational domain, initial and boundary conditions, NN architecture, and evaluation criteria. Physics-constrained prompting (PC) additionally specifies physical constraints that the exact solution is known to satisfy. These constraints include initial and boundary condition tolerances, maximum principles, conservation or dissipation properties, and problem-specific physical properties. We construct a physics-constrained prompt by augmenting the original task specification with a set of constraints :
The prompt states that a network violating any constraint is regarded as physically incorrect even if its solution error is small, and that solution accuracy and physical fidelity are evaluated together. During iterative weight refinement, constraint violations are evaluated without reference solutions and incorporated into the feedback and model selection. The physical constraints used for each PDE are detailed in Appendix § 13.
Physics-Guided Architecture Editing
Physics-guided architecture editing (AE) allows the LLM to modify the initial NN architecture based on the mathematical structure of the governing equation and its initial and boundary conditions. Rather than restricting weight generation to a predefined architecture , the LLM incorporates analytical operations and physically motivated transformations into the NN representation. For example, exponential decay in the heat equation and characteristic coordinate transformations in the advection equation can be embedded into the forward computation. The edited architecture is expressed as
where denotes architecture editing rules that restrict the available operations and parameter count while preserving trainable NN components.
The edited architecture consists of mathematical expressions and MLP blocks, allowing physical knowledge to be incorporated into the network structure. The generated architecture is validated against , and any violations are returned to the LLM for correction. Given the edited architecture , the LLM directly generates its weights:
This enables the NN to represent physical solutions through both its architecture and weights without gradient-based optimization. The architecture editing rules and supported operations are described in Appendix § 14.
Iterative Weight Refinement
WR follows the iterative refinement loop of WSP, but differs in its evaluation procedure: the LLM has no tool access and receives physics-based feedback from an external evaluator. Given the generated weights , the NN is evaluated using the physics-informed loss in Eq. (3), including PDE residuals and initial and boundary condition errors. The evaluation also provides spatial and temporal residual diagnostics and, when PC is enabled, the results of physical constraint checks. These evaluations are performed externally without providing reference solutions or solution errors to the LLM. At iteration , the LLM updates the weights as
where denotes the evaluation feedback. The architecture remains fixed during refinement, and the weights are modified without gradient-based optimization.
The final weights are selected from the generated candidates based on physical constraint satisfaction and the physics-informed loss. Specifically, PtW prioritizes the number of violated constraints and uses the physics-informed loss to distinguish candidates with the same number of violations:
where the minimization follows lexicographic ordering. Without PC, the final weights are selected solely by minimizing . This selection strategy prioritizes physical constraint satisfaction rather than solution accuracy alone.
Experiments
Experimental Setup
We evaluate PtW on four time-dependent PDEs: heat, advection, Burgers’, and Allen–Cahn equations, covering diffusion, transport, nonlinear convection-diffusion, and reaction-diffusion. Their governing equations are given by
with , , , , and . We use refinement rounds, so the final weights are selected from candidates, including the initially generated weights. The corresponding physical parameters, computational domains, and initial and boundary conditions are provided in Appendix § 11.
We compare PtW with PINN and WSP as baseline methods. PINN obtains NN weights through gradient-based optimization, whereas WSP directly generates weights using an LLM. To investigate the effects of individual components, we evaluate PINN-WR, WSP-PC, WSP-WR, WSP-PC-WR, and WSP-PC-AE. The complete PtW framework combines PC, AE, and WR. Here, AE is evaluated together with PC, while WR can be applied independently of PC and AE.
We evaluate solution accuracy using the relative error between the predicted and reference solutions:
where denotes the reference solution evaluated at the same points. Physical consistency is evaluated using the mean squared PDE residual and initial and boundary condition errors, denoted by , , and , respectively. Reference solutions are used only for independent evaluation and are not provided to the LLM.
We use Claude Opus 5.5 for all LLM-based methods. The initial architecture is a fully connected NN with two hidden layers of 20 tanh units, which is also used for the PINN baseline. All LLM-based methods generate weights without gradient-based optimization. Each experiment is repeated three times, and the median performance is reported. Additional implementation details are provided in Appendix § 12.
Heat Equation
Table 1 presents the quantitative results on the heat equation. PtW achieves a relative error of , substantially outperforming all baseline methods. The PDE residual and initial and boundary condition errors are also nearly zero. This high accuracy is primarily attributed to architecture editing, which incorporates the analytical structure of the heat equation into the NN representation.
| Method | Rel. ↓ | PDE Res. ↓ | IC ↓ | BC ↓ |
| PINN | ||||
| WSP | ||||
| WSP-PC | ||||
| PtW |
Table 1. Quantitative results on the heat equation. Values are medians over three runs.
Figure 3 compares the predicted spatiotemporal solutions and pointwise absolute errors. While all methods visually reproduce the reference solution, the baseline methods exhibit nonzero errors across the spatiotemporal domain. In contrast, PtW reproduces the reference solution with pointwise errors approaching machine precision, consistent with the quantitative results.

Figure 3. Comparison of spatiotemporal solutions and pointwise absolute errors for the heat, advection, and Burgers’ equations. Reference solutions are compared with predictions from PINN, WSP, WSP-PC, and PtW. For each equation, the top row shows the predicted solutions, while the bottom row shows the pointwise absolute errors on a logarithmic color scale shared across all panels, with errors below displayed using the lowest color. Black lines indicate , and each method is represented by the run with the median relative error among three runs.
Advection Equation
Table 2 presents the quantitative results on the advection equation. PtW achieves a relative error of , substantially outperforming all baseline methods. The PDE residual and initial and boundary condition errors are also nearly zero. This high accuracy is primarily attributed to architecture editing, which incorporates the characteristic coordinate transformation into the NN representation.
| Method | Rel. ↓ | PDE Res. ↓ | IC ↓ | BC ↓ |
| PINN | ||||
| WSP | ||||
| WSP-PC | ||||
| PtW |
Table 2. Quantitative results on the advection equation. Values are medians over three runs.
Figure 3 compares the predicted spatiotemporal solutions and pointwise absolute errors. While PINN exhibits noticeable deviations from the reference solution, WSP and WSP-PC reproduce the traveling wave with smaller errors. PtW further reduces these errors to machine precision, accurately preserving the wave propagation throughout the spatiotemporal domain.
curately preserving the wave propagation throughout the spatiotemporal domain.
Burgers’ Equation
Table 3 presents the quantitative results on Burgers’ equation. PtW achieves the lowest relative error of among the methods in Table 3. It also achieves the lowest initial and boundary condition errors. However, its PDE residual MSE is substantially higher than that of PINN. This discrepancy is caused by a few localized residual peaks: the median squared residual of PtW is lower than that of PINN ( versus ), whereas its MSE increases by orders of magnitude on a finer spatial grid. For one PtW run, increasing the spatial resolution from 256 to 2001 points raises the MSE from to , while the PINN MSE changes by less than 20%.
| Method | Rel. ↓ | PDE Res. ↓ | IC ↓ | BC ↓ |
| PINN | ||||
| WSP | ||||
| WSP-PC | ||||
| PtW |
Table 3. Quantitative results on Burgers’ equation. Values are medians over three runs. PDE residual MSE is evaluated on a grid and is sensitive to spatial resolution for PtW.
Figure 3 compares the predicted solutions and pointwise absolute errors. The errors of PINN concentrate along the shock at and persist after the shock has formed, whereas those of WSP and WSP-PC spread over the smooth region. PtW has the lowest error away from the shock (root-mean-square error for , versus for PINN) and at the shock after it has formed ( for and , versus for PINN). Its error concentrates near while the shock forms, where the maximum pointwise error of 0.19 occurs at .
Allen–Cahn Equation
Table 4 presents the quantitative results on the Allen–Cahn equation. PtW achieves a relative L2 error of , outperforming PINN, WSP, and WSP-PC. It also achieves near-zero initial and boundary condition errors. However, PINN achieves a lower PDE residual than PtW, indicating that improved solution accuracy does not necessarily correspond to better satisfaction of the governing equation.
| Method | Rel. ↓ | PDE Res. ↓ | IC ↓ | BC ↓ |
| PINN | ||||
| WSP | ||||
| WSP-PC | ||||
| PtW |
Table 4. Quantitative results on the Allen–Cahn equation. Values are medians over three runs.
Figure 4 compares the predicted spatiotemporal solutions. Both PtW and WSP-PC reproduce the interface annihilation observed in the reference solution. However, PtW achieves lower solution and energy errors than WSP-PC, indicating a more accurate approximation of the overall interface dynamics.

Figure 4. Comparison of spatiotemporal solutions for the Allen–Cahn equation. The bottom panels provide enlarged views of the interface dynamics, highlighting differences in interface evolution and annihilation timing between the reference solution and the evaluated methods. Each method is represented by the run with the median relative error among three runs. The dotted line indicates the reference annihilation time (), and the enlarged panels use a color range of .
Analysis of Generated Weights and Architectures
To investigate how PtW represents PDE solutions, we analyze the generated NN architectures and weights, as shown in Figure 5 and Table 5. The edited networks contain substantially fewer parameters than the initial architecture with 501 parameters. Specifically, the generated networks have 4–33 parameters for the heat equation, 4–17 for advection, 104–342 for Burgers’, and 36–52 for Allen–Cahn.

Figure 5. Structures inside the networks generated by PtW (median runs). (a) Heat: relative error of the decay rate of the fundamental mode; the network computes . (b) Advection: against the characteristic coordinate ; the network computes and collapses onto , unlike PINN. (c) Burgers’ equation at : two chains of MLPs, and , iterate the characteristic relation for the two sides of the shock, and a tanh switch combines them into ; where a chain switches roots, has local spikes. (d) Allen–Cahn: the network computes from with a sine-activated MLP , where is a monotone function of , so the interfaces are the zeros of ; colored curves show at – and black ticks the reference interfaces.
| Method | LLM calls | Heat params | Heat time [s] | Advection params | Advection time [s] | Burgers’ params | Burgers’ time [s] | Allen–Cahn params | Allen–Cahn 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 |
Table 5. Network size and computational cost (medians over three runs). Time is the wall-clock time per network, including PINN training (PINN, PINN-WR) and all LLM calls; LLM times depend on server load. For WSP-PC on Burgers’ equation, two of the three runs include a first call that exceeded the output-token limit after 82 and 92 minutes before a successful retry.
For the heat and advection equations, the LLM incorporates analytical solution structures into the NN architectures. For the heat equation, the generated network represents exponential decay using , where the MLP produces a constant decay rate corresponding to (Figure 5a). For advection, the network uses the characteristic coordinate and represents the traveling wave through an MLP applied to (Figure 5b). These analytical structures contribute substantially to the near-machine-precision solution accuracy.
For Burgers’ equation, the generated networks approximate the characteristic relation through unrolled iterative computations using multiple small MLPs. The median network combines two iterative branches with a tanh-based transition function to represent the nonlinear solution structure (Figure 5c). However, abrupt root switches within the unrolled iterations produce isolated points with very large second derivatives (Figure 5c), which dominate the PDE residual despite the low solution error. For Allen–Cahn, the generated network represents the evolving spatial field using a nonlinear MLP and applies a tanh transformation to model the interfaces (Figure 5d). The nonlinear MLP structure is important for representing the interface dynamics, as replacing it with affine transformations increases the solution error.
These results suggest that physics-guided architecture editing is particularly effective when analytical solution structures can be incorporated into the NN representation. For nonlinear PDEs, the generated architectures can achieve accurate global solution approximations, although local violations of the governing equations remain a challenge.
Ablation Study
Table 6 presents the ablation results for PC, AE, and WR. We first evaluate the effect of PC by comparing WSP and WSP-PC. PC does not improve the relative error across the four PDEs. However, it reduces the median number of violated physical constraints from 3 to 1 for Burgers’ equation and from 2 to 0 for the Allen–Cahn equation (Table 7). These results indicate that PC improves physical constraint satisfaction rather than solution accuracy.
| Method | Heat L2 | Heat PDE | Heat IC | Heat BC | Advection L2 | Advection PDE | Advection IC | Advection BC | Burgers’ L2 | Burgers’ PDE | Burgers’ IC | Burgers’ BC | Allen–Cahn L2 | Allen–Cahn PDE | Allen–Cahn IC | Allen–Cahn 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 |
| WSP-PC-WR | 4.58e-7 | 4.99e-13 | 1.92e-7 | 2.18e-7 | 1.61e-7 | 2.48e-29 | 1.14e-7 | 3.19e-9 | 9.62e-2 | 4.68e-1 | 1.41e-3 | 2.65e-4 | 1.39e-1 | 7.47e-2 | 3.29e-2 | 1.00e-4 |
| WSP-PC-AE | 1.21e-14 | 1.70e-28 | 0 | 5.73e-17 | 2.64e-9 | 0 | 1.86e-9 | 1.86e-16 | 1.17e-2 | 9.24e+1 | 1.65e-16 | 3.00e-12 | 3.49e-2 | 3.31e-2 | 8.13e-17 | 5.03e-16 |
| PtW | 4.31e-17 | 3.14e-33 | 0 | 5.73e-17 | 2.00e-17 | 0 | 0 | 1.75e-16 | 1.53e-2 | 1.43e+1 | 4.90e-15 | 6.39e-7 | 3.53e-2 | 1.67e-2 | 8.13e-17 | 4.88e-16 |
Table 6. Ablation study of physics-constrained prompting (PC), architecture editing (AE), and weight refinement (WR). Values are medians over three runs. The best result for each metric and PDE is shown in bold.
| Method | Heat V | Heat Phys. | Advection V | Advection Phys. | Burgers’ V | Burgers’ Phys. | Allen–Cahn V | Allen–Cahn 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 |
| WSP-PC-WR | 0 (3/3) | 3/3 | 0 (3/3) | 3/3 | 0 (3/3) | 1/3 | 0 (3/3) | 3/3 |
| WSP-PC-AE | 0 (3/3) | 3/3 | 0 (3/3) | 3/3 | 0 (2/3) | 3/3 | 1 (1/3) | 3/3 |
| PtW | 0 (3/3) | 3/3 | 0 (3/3) | 3/3 | 0 (3/3) | 2/3 | 0 (3/3) | 3/3 |
Table 7. Physical constraint violations. : median number of violated constraints among C1–C5 (Appendix § 13) over three runs, with the number of runs with in parentheses. Phys.: number of runs whose problem-specific physical metric (Table 9) is within tolerance.
We next investigate the effect of AE, which is combined with PC in our experiments. Compared with WSP-PC, WSP-PC-AE substantially reduces the relative error across all four PDEs. The improvements are particularly significant for the heat and advection equations, where analytical solution structures can be incorporated into the NN architectures. For Burgers’ and Allen–Cahn equations, AE also improves solution accuracy, demonstrating its effectiveness for nonlinear PDEs.
Finally, we evaluate the effect of WR. When applied to WSP, WR improves solution accuracy for the heat and advection equations, while providing limited or negative improvements for Burgers’ and Allen–Cahn equations. When applied to trained PINN weights, WR improves only the advection equation, reducing the relative error from to . In all three runs, the LLM discarded the PINN weights in the first refinement round and replaced them with an analytical construction. For the other three PDEs, PINN-WR produces the same results as PINN. When combined with PC and AE, WR increases the number of runs satisfying all physical constraints from 2/3 to 3/3 for Burgers’ equation and from 1/3 to 3/3 for the Allen–Cahn equation. However, these improvements do not necessarily reduce the relative error, as the final model is selected by prioritizing physical constraint satisfaction.
Overall, AE provides the largest improvements in solution accuracy, particularly for PDEs with known analytical structures. PC mainly improves constraint satisfaction, while WR improves accuracy for heat and advection and, combined with PC, constraint satisfaction.
Limitations
For the heat and advection equations, PtW achieves near-machine-precision accuracy by incorporating known analytical solution structures into the NN architectures. Therefore, these results do not necessarily demonstrate the ability to generate highly accurate weights for PDEs without known analytical solutions. For Burgers’ equation, the generated networks exhibit large local derivatives, resulting in high PDE residuals despite relatively accurate solution approximations. These residuals are highly sensitive to spatial grid resolution and should not be interpreted as grid-converged estimates. Furthermore, our evaluation is limited to one-dimensional PDEs, a single LLM, and three runs per method. Future work will investigate more complex PDEs without known analytical solutions, improve the physical consistency of generated networks, and explore the integration of LLM-generated architectures with gradient-based optimization.
Conclusion
We proposed PtW, a framework for solving PDEs by directly generating NN architectures and weights using an LLM without gradient-based optimization. Experiments on four PDEs demonstrated that PtW achieves lower solution errors than conventional PINNs and WSP, while satisfying the specified physical constraints. Ablation studies showed that architecture editing is the primary contributor to solution accuracy, whereas physics-constrained prompting and weight refinement mainly improve constraint satisfaction. However, relatively large PDE residuals remain for nonlinear PDEs, indicating limitations in physical consistency.
PDE Settings
All problems are one-dimensional in space with . The physical constraints used for each problem are summarized in Table 8.
| PDE | Physical constraints |
| Heat | C1: Initial condition (maximum error ). C2: Dirichlet boundary conditions (maximum error ). C3: Maximum principle (tolerance 0.01). 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 0.01). C4: Conservation of mass (absolute tolerance 0.04) and (relative tolerance 1%). C5: Transport speed of the first Fourier mode (relative tolerance 1%), with amplitude ratio . |
| Burgers’ | C1: Initial condition (maximum error ). C2: Dirichlet boundary conditions (maximum error ). C3: Maximum amplitude (tolerance 0.01). C4: Non-increasing energy (increase ). C5: Odd symmetry (maximum error ). |
| Allen–Cahn | C1: Initial condition, including interface positions (position tolerance 0.01). C2: Non-increasing number of interfaces. C3: Maximum amplitude . C4: Non-increasing energy (increase ). C5: Interface slopes at within times the stationary kink slope. |
Table 8. Physical constraints used in PC. Each PDE is evaluated using five constraints (C1–C5) with specified tolerances.
Heat Equation
We consider with on , subject to and . The reference solution is given by .
Advection Equation
We consider with on , subject to and periodic boundary conditions. The reference solution is given by .
Burgers’ Equation
We consider with on , subject to and . The solution develops a steep viscous shock near . The reference solution is computed using the Cole–Hopf transformation with numerical quadrature.
Allen–Cahn Equation
We consider with and on , subject to periodic boundary conditions for and . The initial condition is defined as
where and . The initial field contains six interfaces, which evolve and undergo annihilation during the simulation. The reference solution is computed using a Fourier pseudo-spectral method with 2048 spatial grid points and fourth-order exponential time differencing (ETDRK4) [6] with a time step of .
Implementation Details
LLM. All LLM-based methods use Claude Opus 5.5 (claude-opus-5-5) with high reasoning effort. The model is accessed through Claude Code in non-interactive mode without tool access. Architecture editing, weight generation, and iterative refinement are performed within a single LLM session. The LLM generates architectures and weights without executing code or performing numerical optimization. Each run consists of a single generation step (preceded by architecture editing for AE) and, for methods with WR, refinement rounds; each LLM call has a time limit of one or two hours.
Prompts. All LLM-based methods receive the governing equation, computational domain, initial and boundary conditions, NN architecture, and evaluation criteria. PC additionally specifies physical constraints, while AE provides architecture editing rules and supported operations. The LLM outputs the generated weights in JSON format. Reference solutions and solution errors are not provided to the LLM.
Initial architecture. The initial architecture is a fully connected NN with two hidden layers of 20 tanh units:
The network contains 501 parameters and is evaluated in double precision without coordinate normalization.
Physics-informed loss and feedback. The physics-informed loss is defined as , using 4096 PDE collocation points, 256 initial points, and 128 boundary times. All sampling points are fixed within each run, and derivatives are computed using automatic differentiation. For periodic boundary conditions, the loss penalizes mismatches between the two boundaries, including first-order derivatives for Allen–Cahn. During WR, the LLM receives the loss components, PDE residual diagnostics, initial and boundary condition errors, and coarse-grid predictions. When PC is enabled, physical constraint evaluations are also included in the feedback.
Baselines. PINN is trained using Adam with a learning rate of for 10,000 steps, followed by L-BFGS with a maximum of 10,000 iterations. The PINN baseline uses the same initial architecture and collocation points as the LLM-based methods. PINN-WR applies iterative weight refinement to pretrained PINN weights without gradient-based optimization during refinement.
Evaluation. All methods are evaluated on a uniform spatiotemporal grid. Solution accuracy is measured using the relative error. Physical consistency is evaluated using the mean squared PDE residual and the root-mean-square initial and boundary condition errors. Each method is evaluated over three independent runs, and the median of each metric is reported. The visualizations correspond to the run with the median relative error.
Physical Constraints
Physics-constrained prompting (PC) introduces five physical constraints for each PDE, as summarized in Table 8. These constraints are derived from the governing equations and their initial and boundary conditions. Each constraint is evaluated independently from the generated NN without using reference solutions. A constraint is regarded as satisfied when its evaluation falls within the specified tolerance.
For each generated network, we define the number of violated constraints as
where is the indicator function. During WR, the evaluation results are provided to the LLM as feedback, and is used to prioritize physical constraint satisfaction in the final model selection.
Architecture Editing Rules
Physics-guided architecture editing (AE) allows the LLM to construct NN architectures by combining mathematical expressions and MLP blocks. The architecture is represented as a sequence of named layers, followed by an output expression. Each layer either evaluates a mathematical expression or applies an MLP to the outputs of preceding layers.
Expression layers support arithmetic operations, integer powers, and elementary functions, including sin, cos, exp, log, tanh, and softplus. Additional supported functions include sinh, cosh, sigmoid, , erf, and artanh. Expressions can use spatial and temporal coordinates, PDE coefficients, the initial condition , and outputs of preceding layers. Numerical constants are restricted to integers between and , , and . The coefficients of the initial condition cannot be directly introduced as numerical constants.
To preserve the NN representation, all trainable parameters must be weights or biases of MLP blocks. Each MLP supports tanh, sin, sigmoid, or softplus activations, with at most four hidden layers and 64 units per hidden layer. The output must depend on at least one MLP containing a hidden layer. The total number of trainable parameters is limited to 501, matching the initial architecture .
The architecture contains at most 40 layers, with at most 32 inputs per MLP. Each MLP input expression is limited to 24 symbols, while the combined expression layers and output expression are limited to 40 symbols. The output must be finite, twice differentiable in space, and once differentiable in time. Non-differentiable operations such as comparisons, conditionals, absolute values, minimum, and maximum are not permitted. The generated architecture is validated against these rules, and violations are returned to the LLM for correction, with at most two correction attempts.
Additional Results
We further evaluate problem-specific physical properties of the generated solutions, as summarized in Table 9. For the heat equation, we measure the relative error of the decay rate of the fundamental mode. For advection, we evaluate the propagation speed and amplitude of the first Fourier mode. For Burgers’ equation, we measure the shock formation time and the maximum spatial gradient. For Allen–Cahn, we evaluate the interface annihilation time and the relative energy error.
| Method | Heat | Heat | Advection | Advection | Burgers’ | Burgers’ | Allen–Cahn | Allen–Cahn |
| Decay err. | Speed err. | Amplitude err. | Energy err. | |||||
| Reference (tol.) | 0 () | 0 () | 0 () | 0.23 () | 1 () | 0.28 () | 0 | |
| PINN | 0.445 | 0.21 | 0.99 | 0.50/0.28/– | 0.216 | |||
| WSP | 0.22 | 1.13 | –/–/– | 0.0204 | ||||
| WSP-PC | 0.29 | 1.05 | 0.29/0.26/0.25 | 0.133 | ||||
| PtW | 0.22 | 1.01 | 0.28/0.30/0.27 |
Table 9. Problem-specific physical metrics. Values are medians over three runs, except for Allen–Cahn annihilation times, which are reported for individual runs. The reference row includes the corresponding tolerances.
For the heat and advection equations, PtW achieves errors near machine precision in the decay rate, propagation speed, and amplitude. These results are consistent with the analytical structures incorporated through architecture editing.
For Burgers’ equation, PtW reproduces the shock formation time and final gradient magnitude close to the reference values. For Allen–Cahn, PtW reproduces interface annihilation in all three runs, with annihilation times between 0.27 and 0.30, compared with 0.28 for the reference. PtW also achieves a lower relative energy error than the baseline methods. These results demonstrate that the generated networks can reproduce important physical dynamics, although low PDE residuals are not guaranteed.
References
- [1]Brown, T., Mann, B., Ryder, N., Subbiah, M., Kaplan, J. D., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., et al. Language models are few-shot learners. NeurIPS, 33:1877–1901, 2020.arxiv.org/abs/2005.14165
- [4]Jagtap, A. D. and Karniadakis, G. E. Extended physics-informed neural networks (xpinns): A generalized space-time domain decomposition based deep learning framework for nonlinear partial differential equations. Communications in Computational Physics, 28(5), 2020.
- [6]Kassam, A.-K. and Trefethen, L. N. Fourth-order time-stepping for stiff pdes. SIAM Journal on Scientific Computing, 26(4):1214–1233, 2005.DOI
- [7]Kim, J., Mehta, S., Hsu, H.-L., Ryu, H., Liu, Y., and Pajic, M. Nnit: Width-agnostic neural network generation with structurally aligned weight spaces. arXiv preprint arXiv:2603.00180, 2026.arxiv.org/abs/2603.00180
- [8]Lagaris, I. E., Likas, A., and Fotiadis, D. I. Artificial neural networks for solving ordinary and partial differential equations. IEEE transactions on neural networks, 9(5):987–1000, 1998.DOI
- [9]Liu, H., Simonyan, K., and Yang, Y. Darts: Differentiable architecture search. arXiv preprint arXiv:1806.09055, 2018.arxiv.org/abs/1806.09055
- [10]Nasir, M. U., Earle, S., Togelius, J., James, S., and Cleghorn, C. CLImatic: neural architecture search via large language models and quality diversity optimization. In proceedings of the Genetic and Evolutionary Computation Conference, pp. 1110–1118, 2024.DOI
- [12]Raissi, M., Perdikaris, P., and Karniadakis, G. E. Physics-informed neural networks: A deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations. Journal of Computational physics, 378:686–707, 2019.DOI
- [13]Soro, B., Andreis, B., Lee, H., Jeong, W., Chong, S., Hutter, F., and Hwang, S. J. Diffusion-based neural network weights generation. In ICLR, volume 2025, pp. 99644–99675, 2025.arxiv.org/abs/2402.18153
- [14]Sukumar, N. and Srivastava, A. Exact imposition of boundary conditions with distance functions in physics-informed deep neural networks. Computer Methods in Applied Mechanics and Engineering, 389:114333, 2022.DOI
- [15]Takehi, R., Teoh, J., Zhang, A., and Khattab, O. Sparks of Weight-Space Programming: LLMs can natively read & write neural network weights. https://rikiyaqt.github.io/blog/weight-space-programming/, November 2026. Blog post.
- [16]Tian, B., Chen, W., Li, Z., Lai, S., Wu, J., and Yue, Y. Text2weight: Bridging natural language and neural network weight spaces. In ACM MM, pp. 10152–10160, 2025.arxiv.org/abs/2508.13633
- [17]Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L., and Polosukhin, I. Attention is all you need. NeurIPS, 30, 2017.arxiv.org/abs/1706.03762
- [18]Wang, K., Tang, D., Zeng, B., Yin, Y., Xu, Z., Zhou, Y., Zang, Z., Darrell, T., Liu, Z., and You, Y. Neural network diffusion. arXiv preprint arXiv:2402.13144, 2024.arxiv.org/abs/2402.13144
- [19]Wang, S., Teng, Y., and Perdikaris, P. Understanding and mitigating gradient flow pathologies in physics-informed neural networks. SIAM Journal on Scientific Computing, 43(5):A3055–A3081, 2021.
- [20]Zheng, M., Su, X., You, S., Wang, F., Qian, C., Xu, C., and Albanie, S. Can gpt-4 perform neural architecture search? arXiv preprint arXiv:2304.10970, 2023.arxiv.org/abs/2304.10970
- [21]Zoph, B. and Le, Q. V. Neural architecture search with reinforcement learning. arXiv preprint arXiv:1611.01578, 2016.arxiv.org/abs/1611.01578
Machine contribution statement
No AI-use declaration is available for this version in Valency.
The available record does not establish whether AI systems or models contributed to this work.