Searching for Neural Exchange-Correlation Functionals with an LLM That Can Check Physics

Density functional theory (DFT) is the workhorse calculation behind most modern catalyst, battery and materials studies. It replaces the intractable many-electron wavefunction with the electron density, a function of only three spatial coordinates. One piece of it is unknown: the exchange-correlation functional, the term that captures the quantum effects electrons have on each other. Every DFT result depends on an approximation to this term. Neural networks are an obvious candidate for a better approximation, but designing one is fiddly. A functional that fits reference energies well can still make the self-consistent field (SCF) loop diverge or oscillate. The SCF loop is the iterative procedure that repeatedly recomputes the density from the potential until the two agree. A functional can also break exact physical rules, such as correct behavior for a uniform electron gas, which makes it fail on systems unlike its training data.

This note proposes using a large language model (LLM) as the designer of neural exchange-correlation functionals inside a closed search loop. The LLM's search state carries a machine-checked list of exact physical constraints and an SCF-stability report alongside the code. Candidates pass through a staged evaluation: cheap constraint checks run in seconds, a non-self-consistent energy check on fixed densities is moderately priced, and a full self-consistent benchmark is expensive. The failures from each stage are fed back to the LLM as structured text. The scientific question is concrete. LLM-guided architecture search has so far been shown to work when evaluation means "train and measure accuracy." Can it also work when the real test is whether the model behaves correctly inside an iterative physical solver, which is exactly where cheap proxies are known to break?

Core Claim

We claim that an LLM with structured physics feedback finds neural functionals that are both accurate and self-consistently stable using far fewer full SCF evaluations than two alternatives: evolutionary search and Bayesian optimization over the same design space. We further claim that this advantage comes from two things: the constraint and stability feedback, and the LLM's prior knowledge of chemistry and machine learning. It should not come merely from having more compute.

The claim has a falsifiable corollary that matters regardless of whether the LLM wins. We will measure how well the cheap stages predict the expensive one. Earlier work on physical hardware found that zero-cost proxies can even correlate negatively with true performance. If the same is true here, that finding constrains every future search method for physics-embedded networks, not just ours.

Relation to Prior Work

The method comes from the LLM-guided neural architecture search literature. LLMatic embeds a code-generating LLM inside quality-diversity search, which keeps an archive of good but behaviorally different networks. It showed that LLMs cannot design well without closed-loop execution feedback. We reuse its archive idea, but our behavioral descriptors are physical (constraint profile, SCF iteration count) rather than width-to-depth ratio and compute cost. GraphIR gives the LLM a structured intermediate view of the network, including a "validity envelope" of tensor-shape contracts. Doing so raised its dependency-reasoning score from 0.4060 to 0.5040. We extend that idea from shape validity to physical validity: the envelope reports which exact constraints the candidate satisfies by construction, which it satisfies numerically, and which it violates.

Two papers motivate the proposal and also constrain it. PINNsAgent is the closest system. It is an LLM multi-agent tool that searches width, depth and activation for physics-informed networks solving partial differential equations, using tree search over residual error. Its search space is generic network hyperparameters, and its evaluation is a single training loss. Ours is the functional form itself, evaluated inside a nonlinear fixed-point solver. UH-NAS for physical neural networks found that zero-cost proxies fail when physical non-idealities are present, so full noisy evaluation was needed. That negative result is why we treat the reliability of our cheap stages as an open question to measure rather than an assumption. Its companion version (LLM-Guided Neural Architecture Search for Robust Co-Design of Physical Neural Networks LLM-Guided Neural Architecture Search for Robust Co-Design of Physical Neural Networks) also supplies the multi-objective framing we borrow, where search traces a trade-off curve between accuracy and a robustness cost. DiffNAS showed that an LLM with search memory and shortened proxy training can find diffusion U-Net variants. That supports our use of short proxy evaluations, provided they are validated.

On the DFT side, the application pull is adsorption and reaction energies. Work on poisoning-resistant Pd-Au catalysts, IrRuO2 alloys for CO2 reduction and single-atom Fe–N sites all rests on adsorption energies whose accuracy is set by the functional. Adsorption energies are necessary but not sufficient to identify good catalysts cautions that better energies alone will not settle catalyst design. We therefore frame transfer to adsorption chemistry as a test of generalization, not as a promise of catalyst discovery. The research file did not surface any prior LLM-guided search over exchange-correlation functionals. It also contained no benchmark numbers for neural functionals, so we report none below.

Research Program

The search space is the class of "local plus semi-local" neural functionals. Each one is a network that maps density features at a point (the density, its gradient, kinetic-energy density) to an enhancement factor that multiplies a known baseline exchange energy. This class is standard enough that a hand-designed constrained version exists as a strong baseline. It is also rich enough that design choices matter: input feature transforms, which constraints to build in by construction versus enforce by penalty, the output nonlinearity, depth and width, and whether spin is handled by an exact scaling rule.

We will build three components.

The first is a physics validity envelope, computed automatically for every candidate. It checks the uniform-electron-gas limit, the Lieb-Oxford bound on how negative exchange can be, correct spin and coordinate scaling where applicable, and smoothness of the potential. The potential is the functional's derivative with respect to density, and its roughness is a known cause of SCF trouble. Each check is either an analytic property of the code (verified symbolically, as GraphIR does with shapes) or a numerical test on a grid of sampled feature values.

The second is staged evaluation. Stage one is the envelope, which costs seconds. Stage two trains the candidate on reference energies computed with fixed, pre-converged densities, which is cheap because no SCF loop is needed. Stage three runs full self-consistent calculations on a small validation set of molecules and records energy error, convergence rate and iteration count. These calculations use an open-source Gaussian-basis DFT code that accepts a user-supplied functional.

The third is the LLM loop. A prompt contains the GraphIR-style code view, the validity envelope and a compact history of earlier candidates' stage results. The model proposes edits, and a quality-diversity archive keyed on constraint profile and SCF stability keeps the population from collapsing to one design.

A fixed budget of stage-three evaluations is the currency of every comparison. The analysis then asks three questions. Does the LLM reach a given accuracy-and-stability level in fewer stage-three calls? Do its designs rediscover known principles, for instance enforcing the uniform-gas limit by construction, or find unusual ones? How often does it propose candidates that fail stage one, and does envelope feedback reduce that rate?

Baselines

The naive reference point is a standard semi-local functional of the same form class: the non-neural analytic functional the enhancement factor is built on. It is evaluated self-consistently on the same test set. Every learned functional must beat it on test-set energy error without converging less often. Otherwise the neural search has produced nothing usable.

The strongest existing competitor is a hand-designed, constraint-by-construction neural functional with its hyperparameters tuned by Bayesian optimization. It is a small network whose output is mapped through a fixed transformation that guarantees the uniform-gas limit and the Lieb-Oxford bound. This is what a careful practitioner would build without any search, and it already absorbs most of the physics our envelope checks. It receives the same reference data and the same budget of stage-three evaluations for tuning, and it may use stages one and two freely, as our method does. Beating it means one of two things at equal stage-three budget. The first is lower test energy error at equal or better SCF convergence rate. The second is a strictly better accuracy-versus-stability trade-off curve, judged over at least three search seeds with non-overlapping spread. No reported result found on Lacuna for neural exchange-correlation functionals on any benchmark, so the bar will be set by our own runs of this baseline.

A third baseline is evolutionary search with random code-level mutations over the same intermediate representation, using the same archive and the same staged evaluation. It isolates whether the LLM's prior knowledge adds anything beyond the search machinery. Two ablations isolate the key ingredient. One removes the validity envelope and stability report from the prompt, leaving only scalar energy errors. The other removes stages one and two so every candidate goes straight to full SCF. If the first ablation matches the full system, the claim about physics feedback is wrong.

Why not just…?

Why not just build all constraints into the architecture by hand and tune it? This is the most serious threat. If the hand-constrained functional with Bayesian-optimized hyperparameters matches the LLM search, the honest conclusion is that this design space is too well understood to need search. That is exactly the comparison in our strongest baseline, at equal budget. We keep the outcome open. Exact constraints do not guarantee SCF stability or accuracy on bonding regimes far from training data, and those are the dimensions where we expect search to pay off. Our first experiment will show whether this expectation holds.

Why not just train on non-self-consistent energies and skip the SCF loop? It is far cheaper, and for many candidates it may rank designs correctly. Whether it does is precisely our stage-two-versus-stage-three correlation measurement. UH-NAS's finding that proxies fail under physical non-idealities ( LLM-Guided Neural Architecture Search for Robust Co-Design of Physical Neural Networks) gives a reason for doubt but not proof. If the rank correlation is high, we will report that the self-consistent stage can be shrunk drastically, which is a useful result in itself.

Why not just use evolutionary search or a PINNsAgent-style tree search over hyperparameters? PINNsAgent found near-optimal configurations within five iterations, but over width, depth and activation for a fixed loss. Such a search never edits the functional form or decides which constraints to build in. Our random-mutation baseline on the same intermediate representation tests whether an LLM is needed even when the search can edit the form. If it ties the LLM, the LLM's role reduces to code generation, and we will say so.

Proposed Experiments

The data are reference energies for small molecules and reactions from a higher-level quantum chemistry method, split by chemistry type. Training uses main-group thermochemistry; validation for stage three is a disjoint molecule set; testing covers reaction barriers and a held-out set of small-cluster adsorption energies for CO, CO2 and sulfur species. These species echo the chemistry in the Pd-Au and IrRuO2 studies. The research file supplied no named DFT benchmark with reported numbers, so we will fix and publish the splits before any search runs.

The metrics are mean absolute energy error on each test subset, the fraction of SCF runs that converge, the median iteration count, the stage-one failure rate of proposed candidates, and the number of stage-three calls needed to reach the baseline's accuracy. All methods get the same stage-three budget, a few hundred self-consistent validation evaluations, and three seeds each.

Three decisive checks follow. First, does the full LLM system beat the hand-constrained Bayesian-optimized functional on the accuracy-versus-stability trade-off curve at equal budget? If it does not, the main claim fails. Second, does removing the validity envelope from the prompt erase the advantage? If it does not, the physics-feedback mechanism is not what drives the gains. Third, what is the rank correlation between stage-two and stage-three scores across all evaluated candidates? A low or negative value would extend the UH-NAS proxy-failure result to DFT and would justify full self-consistent evaluation. A high value would show that cheap fixed-density screening is safe for this class. Finally, we will inspect the best discovered functionals to see whether the improvements carry over to the held-out adsorption energies. That is the only part of the result a catalysis researcher would actually use.