Skip to content

Menu

WorksComputer Science

Neural Petri flows for chemical reactions

Download PDFView on arXiv

Ask your agent about this work

Your agent reads this work through Valency, with its citations and similar works. Paste this at the start of a chat.

Use the Valency MCP. Work: W_4gsscjg4. Fetch it with get_paper_by_id, then find its nearest works with find_similar_papers and tell me what it adds.

Works with any MCP client. Not connected yet? Connect your agent

Abstract

Petri nets have been used to describe chemical processes such as reactions.They map well to chemistry: Places are the bonds between atoms and the free valence of each atom, a token is a unit of bond order, a transition forms or breaks a bond, the conserved quantities are the valence budgets of the atoms, and the enabling rule is the valence rule. These semantics are not guaranteed by learned models of reactions or neural networks that are built on Petri nets that use the net as a scaffold for message passing. Here, we ask what architecture remains a Petri net for every value of its weights. We find the answer in the theory, where all semantics of a net share the firing form m′=m+Cσm^\prime=m+Cσ, locality, as enabling reads only the inputs of a transition, and the enabling rule, and we prove that conservation forces the firing form and that non-negativity forces the enabling rule on local rate laws. This leaves free the rate law, which is the propensity of each transition to fire. We introduce Neural Petri Flow, which learns this rate law, or a readout for classification, and hard-wires the rest as parameter-free layers. On what we denote a valence net, atom mapping, reaction classification, and forward prediction become three tasks on one firing vector. Without training, the minimum firing vector maps 88.8% of the curated Golden set against 85.6% for RXNMapper, and 88.7 against 77.9% of the enzymatic reactions of EnzymeMap. On USPTO-480K, NPF trained on these firing vectors predicts 87.7% of the products and 67.4% when trained on a 1% subset of the training reactions. EC numbers of ECREACT are predicted at the third level for 90.2% of reactions, 5.6 points ahead of the best published method. With electrons as tokens, the same token game predicts 90.5% of the elementary steps of FlowER first, ahead of the published baseline, and every top-1 prediction is a valid molecule without a filter.

Introduction

Petri nets were devised in order to describe chemical processes [Petri and Reisig, 2008]. While Petri nets became a standard tool for concurrency, chemistry kept them to describe reaction networks, where places are species [7] (Koch 2010). We take this approach down to chemical bonds of a single reaction, and ask what kind of neural network it takes for its outputs to obey the rules of that net for every value of its weights, as the rules are computed instead of learned. Learning only fills in what the rules leave open, such as which bonds change.

A reaction as a net. Given the heavy atoms, which are all atoms other than hydrogen, of the precursors of a chemical reaction, we define a bond place BijB_{ij} for every pair (i,j)(i,j) of atoms and a slack place SiS_i for every atom ii. Tokens on BijB_{ij} are units of bond order, where a single bond is one token, a double bond is two tokens, and an aromatic bond one and a half. Tokens on SiS_i are units of valence of atom ii not spent on bonds with other heavy atoms, namely, its hydrogens, its negative charge, and a capacity to become cationic or hypervalent, one token for nitrogen and none for carbon. A marking is the vector of all token counts or, in chemistry terms, a set of molecules. A reaction is then a pair of markings, mAm_A and mBm_B for the reactants and the products, respectively. The two are written on different atoms, and an atom map, which assigns every product atom to the matching precursor atom, makes them markings of one net. Transitions tt are elementary bond changes, where, for every atom pair (i,j)(i,j) and every amount δ\delta, a transition takes δ\delta tokens from each of SiS_i and SjS_j and puts δ\delta tokens on BijB_{ij}, forming a bond of order δ\delta. The reverse operation breaks the bond. Firing a transition is the realisation of that bond change, and the firing-count vector σ\sigma, firing vector for short, counts the firings of every transition, describing a reaction as an unordered list of bond changes. The state equation mB=mA+Cσm_B = m_A + C\sigma reads products = precursors + bond changes, where the matrix CC records which places each transition empties and fills. The PP-invariants are the quantities no firing can change, namely, the valence budgets of the atoms, each the bond orders plus its free valence of an atom. The enabling rule that states that a transition may only fire when its input places hold enough tokens, is the valence rule. For example, a carbon with four bonds to other heavy atoms has to break one before it can form another. This net, the valence net of the reaction, has no parameters, as it is fixed by the precursor atoms and the rules of valence.

A reaction as two markings of its valence net, a token game, and three tasks

Figure 1. (a) A reaction as two markings of its valence net. (b) Only the rate law (magenta) is learned. (c) The minimum firing vector σ\sigma maps atoms, trains the token game and feeds the classifier.

Sequence models can write strings that are not a valid molecule, and electron-flow and graph-edit models can predict bond changes that are not guaranteed to respect valence for every output. Stated in net terms, the outputs of these models are not markings (states) that any firing sequence can reach. Current Petri graph neural networks pass messages between places and transitions, using the net as a computation graph, but the states they update are not markings [2] (Hu et al. 2020). We therefore ask whether a model of reactions can, for every value of its weights, guarantee products with valid valences and bond changes accounting for the observed change exactly, and whether this guarantee increases or decreases accuracy.

Approach. Discrete, continuous, and stochastic nets, the three semantics of a net, only differ in their rate law, which is the propensity of a transition to fire given the tokens on its input places, and share the firing form, the enabling rule, and locality. Therefore, Neural Petri Flow (NPF) only learns the rate law, or a readout for classification, and computes the rest without trainable parameters. Atom mapping solves the state equation for the firing vector that forms or breaks the fewest bonds without learned weights, and gives the forward model its training target. For forward prediction, NPF plays a token game in which it fires one bond change at a time with the learned rate law choosing each move (Figure 1). For chemistry, the rate law reads the whole marking and as the token game fires one bond change at a time, non-negativity still requires the enabling rule, which is imposed as a mask (Section 4). With electrons as tokens, the same token game predicts the elementary steps of reaction mechanisms (Section 5).

More than a Petri net in name only. To avoid introducing a generic neural network that is a Petri net in name only, we support every Petri component of the valence net that carries a guarantee with a proof, a reason no neural network without the Petri net can do the same, a numerical check, and every component except conservation with a comparison to a generic network of equal size. For the valence rule, we prove that, for every value of its weights, the token game never gives a carbon with a valence budget of four a fifth bond (Proposition 4), and that the rule removes orders of bond changes but never a product within the valence budgets (Lemma 2). With untrained weights, no marking that the token game visits breaks the rule by more than half a token (Appendix D.5). Graph-edit and electron-flow models also change one bond or electron pair at a time, however, most fix or learn an order of edits [18] (Sacha et al. 2021), learn the valence rule, as FlowER does [Joung et al., 2025], or check only that the giving site has electrons, and not that the receiving atom has room, as in MAELLE [Xuan-Vu et al., 2026]. In NPF, the valence rule holds at every step for every weight, and the state equation makes the order irrelevant.

Contributions.

  • Neural networks that remain Petri nets. Neural Petri Flow only learns what the theory of the net leaves open, namely, one rate law that is shared across nets with conflict or, for classification tasks, a readout of the firing vector, and computes the firing form, the enabling rule, and the state equation as layers without trainable parameters. The conservation of every PP-invariant forces the firing form, and keeping markings non-negative forces the enabling rule on any continuous, local rate law shared across nets. For every value of the weights, every marking visited by the token game is reachable in the valence net once every atom holds half a token of extra free valence for aromatic bonds of order 32\frac{3}{2}.

  • The valence net, a single object for three tasks. Atom mapping, reaction classification, and reaction forward prediction become three tasks on one firing vector, which is the unordered list of bond changes. Mapping infers it, classification reads a label off it, and the forward model predicts it. Like other atom mappers of minimum chemical distance [22, 3] (Jochum et al. 1980; Mann et al. 2014), our mapper minimises bond changes, without learned weights, and it maps reactions with a missing reactant or by-product (Appendix D.1) and proves the map optimal for 100 % of a curated reaction set. Its tied optima are training targets of the forward model, which therefore needs neither the maps of a learned model nor an order of edits.

  • Mechanisms as nets of electrons. Taking electrons as tokens turns the elementary steps of a mechanism into firings of an electron net, in which fishhook and curly arrows are the transitions, the number of electrons is a PP-invariant, and the octet rule is the enabling rule. With the rate law and token game of the forward model, it predicts 90.5 % of the elementary steps of FlowER first and recovers 94.5 % of the pathways, ahead of the published baselines, and every end marking is a Lewis structure by construction.

Related work

Petri nets and learning. Abdul Hameed et al. [2025] introduced a max-plus network learning the timing of timed event graphs, which are conflict-free nets. Trainable mass-action reaction networks as introduced by Nagipogu and Reif [2025] and Dack et al. [2026] and a neural Petri net computed by the state equation by Demin-Marin et al. [2023] are also nets for every value of their parameters, each for one system. Message passing along Pre and Post was introduced as a Petri net convolution for scheduling by Hu et al. [2020], and PGNN by Admenovic Tahirovic et al. [2025], which we use as a baseline, passes messages between the places and transitions of attributed nets.

Conservation and structure in neural networks. Hybrid models where a neural network predicts rates inside first-principle balances are the closest to the token-game layer from Appendix C.2 [Spichigios and Ungar, 1992]. Sturm and Wexler [2022] discuss a fixed stoichiometric matrix on learned fluxes of atoms between molecules in atmospheric photochemistry, with kinetic models pass learned rates through such a layer [23] (Kircher et al. 2024). Chemical reaction neural networks hard-wire mass action and learn the associated stoichiometry [19] (Ji and Deng 2021). These models realise the sufficiency direction of Proposition 1.

Reactions. Petri nets are used to model reaction networks with species as places [7, 4] (Koch 2010), while reversing Petri nets enable the symbolic modelling of covalent bonds [Melgratti et al., 2022]. We use a net a level below the species, for the bonds in a single reaction, where the state equation on the bond places is the bond–electron matrix equation introduced by Dugundji and Ugi [1973]. Our firing vector is, up to hydrogens and charges, the imaginary transition state or the condensed graph of reaction, counted as firings [24] (Varnek et al. 2005). Atom mappers are learned [11, 6] (Schwaller et al. 2021a) or compute the mapping of minimum chemical distances [Jochum et al., 1980], solved exactly as integer or constraint programs [22, 3] (Latendresse et al. 2012; Mann et al. 2014). As for reaction classifiers, they use fingerprints [Schneider et al., 2015, Probst et al., 2022b] or learned representations [Schwaller et al., 2021b, Heid and Green, 2021], while our readout is a learned difference fingerprint with a proof that what is left unchanged by a reaction cancels. Finally, forward reaction predictors generate SMILES [Schwaller et al., 2019, Tetko et al., 2020, Irwin et al., 2022, Tu and Coley, 2022, Zhong et al., 2022], apply templates [10], predict graph edits [13, 18, 9] (Jin et al. 2017; Sacha et al. 2021), or redistribute electrons [8, 12] (Meng et al. 2023; Joung et al. 2025). While the latter conserve electrons, none of them enforces valence on every discrete output. Recently, Xuan-Vu et al. [2026] introduced MAELLE, which learns a Markov chain of electron moves from unordered move sets. It is a stochastic net in our terms, with enabling rules on the source only, no valence invariant, and products ranked by their sampling frequency, training on the atom maps of RXNMapper, where our targets come from the net.

Preliminaries

Nets. A net is defined as N=(P,T,Pre,Post)N = (P,T,\mathrm{Pre},\mathrm{Post}), where places PP and transitions TT are finite disjoint sets and Pre,Post:P×T→R≥0\mathrm{Pre},\mathrm{Post}: P \times T \to\mathbb{R}_{\ge0} are arc weights. For the input and output places of transition tt, we write ∙t={p:Pre(p,t)>0}{}^{\bullet}t = \{p : \mathrm{Pre}(p,t) > 0\} and t∙={p:Post(p,t)>0}t^{\bullet} = \{p : \mathrm{Post}(p,t) > 0\}, respectively. The incidence matrix of the net is C=Post−Pre∈RP×TC = \mathrm{Post} - \mathrm{Pre} \in\mathbb{R}^{P \times T}, where CtC_t are the columns.

Markings, enabling, and firing. A marking m∈R≥0Pm \in\mathbb{R}_{\ge0}^{P} assigns mpm_p tokens to place pp. enabl⁡(t,m):=min⁡p∈∙tmp/Pre(p,t)\operatorname{enabl}(t,m) := \min_{p \in{}^{\bullet}t} m_p/\mathrm{Pre}(p,t) is the enabling degree of tt at mm, and ∞\infty if ∙t=∅{}^{\bullet}t = \varnothing. In the discrete case, tt is enabled if enabl⁡(t,m)≥1\operatorname{enabl}(t,m) \ge1 and fires in amount α=1\alpha= 1 [17], and in the continuous case in any amount 0<α≤enabl⁡(t,m)0 < \alpha\le\operatorname{enabl}(t,m). A firing yields m′=m+αCtm' = m + \alpha C_t, written as m→αtm′m \xrightarrow{\alpha t} m'. A firing sequence s=α1t1⋯αntns = \alpha_1t_1 \cdots\alpha_nt_n is enabled at m0m_0 if every step can fire, in its amount, at the marking reached so far, and we call the markings it reaches reachable from m0m_0. The firing-count vector σ(s)∈R≥0T\sigma(s) \in\mathbb{R}_{\ge0}^{T} has the entries σt=∑k:tk=tαk\sigma_t = \sum_{k:t_k=t} \alpha_k.

State equation and invariants. The state equation is given by summing the firing rule along a sequence

m0→sm⇒m=m0+Cσ(s).(1)m_0 \xrightarrow{s} m \Rightarrow m = m_0 + C\sigma(s). \tag*{(1)}

The converse of this fails in general, as a non-negative solution σ\sigma of m=m0+Cσm = m_0 + C\sigma does not need to be the count vector of any enabled sequence [Murata, 1989], however, on the valence net it holds for every firing vector that changes each bond place at most once and reaches a non-negative marking (Lemma 2). Two sequences enabled at m0m_0, with the same count vector, reach the same marking by Equation (1), and we call them count-equivalent. A vector x∈RPx \in\mathbb{R}^{P} with xTC=0x^{\mathsf{T}}C = 0 is a P-invariant. By (1), xTm=xTm0x^{\mathsf{T}}m = x^{\mathsf{T}}m_0 for every mm of the form m0+Cσm_0 + C\sigma, specifically for every reachable marking. A vector y∈RTy \in\mathbb{R}^{T} with Cy=0Cy = 0 is a T-invariant. By (1), an enabled firing sequence returns the net to its starting marking exactly when its count vector is a T-invariant. In chemistry terms, different orders of the same bond changes are count-equivalent sequences.

Timed semantics. The stochastic net introduced by Molloy [1982] is a continuous-time Markov chain on NP\mathbb{N}^{P} that jumps from mm to m+Ctm + C_t at a rate λt(m)\lambda_t(m), where λt(m)=0\lambda_t(m) = 0 unless tt is enabled at mm. Nt(τ)N_t(\tau) counts the firings of tt up to time τ\tau, so m(τ)=m(0)+CN(τ)m(\tau) = m(0) + CN(\tau), conserving P-invariants pathwise, which ensures that every atom keeps its valence budget after every single bond change and on every sampled route. The rate law λ\lambda is local in λt\lambda_t depends on mm through (mp)p∈∙t(m_p)_{p \in{}^{\bullet}t} only. The rate law represents the chemistry, namely, how likely each bond change is given the molecules present.

Two learning problems. The net, the static attributes epe_p and ete_t of places and transitions, respectively, and the markings are observed, while the rate law is not. The forward problem to predict m(τ+Δ)m(\tau+ \Delta) from m(τ)m(\tau), which is, in chemistry terms, predicting the products from the precursors. The inverse problem is the prediction of the bond changes, or firing counts σ∗=N(τB)−N(τA)\sigma^* = N(\tau_B) - N(\tau_A) given the precursors AA and the products BB.

In reactions, the products are recorded on their own atoms. Then, an atom map, an injection π\pi of the product atoms onto the precursor atoms of the matching element, places them on the precursor places as PπmBP_\pi m_B. The inverse problem is atom mapping, that is, to find π\pi and σ∗\sigma^* with PπmB=mA+Cσ∗P_\pi m_B = m_A + C\sigma^* on the bond places. As we show in Appendix § 8.§ 5, the markings fix neither π\pi nor the part of σ∗\sigma^* in ker⁡C\ker C. Classification reads a label off σ∗\sigma^*.

Neural Petri flow

The semantics introduced in § 3 share state changes of the form CσC\sigma with σ≥0\sigma\ge0, which we call the firing form, and locality, as enabling reads only the input places of a transition. We hard-wire these while learning the rate law, the single object the theory leaves free. For classification, a readout is learned instead (§ 4.2). Appendix § 10 tests the layers with a local rate law on measured metabolic fluxes.

Enforcing the firing form and the enabling rule

We show that the firing form and the enabling rule are forced, rather than chosen. If a marking is updated, every PP-invariant at every marking is kept iff it is a combination of the columns of CC, u(m)=Cv(m)u(m) = Cv(m) (Proposition 1). This means that a model exactly keeps every valence budget for all weights whenever it changes the marking by bond changes, while a generic readout with an output bias would conserve only for a set of weights of measure zero. The enabling rule follows from non-negativity. If a rate law is local and shared across nets, continuous, and non-negative, it keeps every marking non-negative only if it is zero whenever an input place is empty (Proposition 2). In chemistry terms, a negative slack place is an atom with more bonds than allowed by the valence rule. Proposition 1 extends Theorem 3.1 of Horie and Mitsume [2024], which states that message passing on a graph conserves only a total with antisymmetric fluxes, to all PP-invariants of a net, and it keeps a learned update in the stoichiometric subspace of reaction network theory [21]. Angeli et al. [ [5] assume a zero rate when a reactant is absent, and the absence of negative cross-effects characterises mass-action kinetics [14]. Proposition 2 derives this zero rate for a rate law that is shared across nets, given that learned weights are the same on every net.

However, for reactions the rate law is not local, as the reactivity of a bond depends on its molecule and on the available reagents, so Proposition 3 does not apply and we impose the enabling rule as a mask, which sets the rate of every transition that is not enabled to zero (Figure 2b). Such masks are standard for valence in molecule generation, where bonds are only added [Liu et al., 2018], and for enabled transitions in reinforcement learning on nets [Sachweh et al., 2024, Lassoued and Schwung, 2024]. This is the only way to stay valid for all weights for one firing at a time, as a not enabled bond-forming transition takes more tokens from a slack place than it holds (Appendix § 8).

A bromo Suzuki-type coupling as a token game

Figure 2. A bromo Suzuki-type coupling as a token game of the model trained without precomputed mappings. (a) Showing the most probable order, each bond that changes in magenta, dashed if formed. ⊙\odot is a token that at a broken bond returns to the slack place of its atom. The order is valence bookkeeping, not the Pd mechanism, which would break C–Br first. (b) Forming C–C requires a token of free valence on both aryl carbons that can only be supplied by the two breaks, meaning enabling excludes the four orders that form C–C before the two bond breaks. The two remaining orders fire the same transitions and reach the same product.

The state-equation readout

In order to classify a reaction, NPF reads the change described by the state equation without the atom map that would place both markings on a single net. A local encoder, which is message passing along bonds for KK rounds, assigns every atom and bond of each side a learned descriptor ψ\psi, and a small multilayer perceptron maps the difference

r=∑i∈VBψB(i)−∑j∈VAψA(j)r = \sum_{i\in V_B} \psi_B(i) - \sum_{j\in V_A} \psi_A(j)

to the class. For all weights and every atom map, an atom whose surroundings within RR bonds are the same on both sides cancels exactly against its partner, with R=KR=K for atom terms and R=K+1R=K+1 for bond terms (Proposition 3). What remains are the atoms whose surroundings Cσ(π)C\sigma(\pi) or attributes change, those within RR bonds of them, and the atoms that leave. Therefore, the readout rr depends only on these atoms and is computed without π\pi or σ(π)\sigma(\pi). A readout that pools each side, e.g. ρ(∑Bψ,∑Aψ)\rho(\sum_B \psi,\sum_A \psi), is, in general, not invariant to a far decoration (Appendix § 8).

Solvents and catalysts without a partner do not cancel, so a participation gate wM∈(0,1)w_M \in(0,1) for every precursor is trained on the maps of the mapper and moves them to a separate vector. Proposition 3 therefore only holds for the pure readout w=1w=1. We introduce a second classifier that reads the firing vector σ^\hat{\sigma} of the mapper instead, with one learned term per transition that fires.

Reactions as firing sequences of valence and electron nets

The valence net A bond place BijB_{ij} holds the bond order bij∈{0,1,32,2,3}b_{ij} \in\{0,1,\frac{3}{2},2,3\}, and a slack place SiS_i holds the free valence si=hi+max⁡(−qi,0)+cis_i=h_i+\max(-q_i,0)+c_i of atom ii, from its hydrogens hih_i and negative charge qiq_i, and a capacity of cic_i of 1 for N, O, Cl, Br, and I, 2 for S and P, and 0 for all other elements. For every pair of atoms i<ji<j and every δ∈{12,1,32,2,3}\delta\in\{\frac{1}{2},1,\frac{3}{2},2,3\}, which is therefore spent two bond orders, a transition increases bijb_{ij} by δ\delta, while its reverse decreases it:

tij+δ:δSi+δSj→δBij,tij−δ:δBij→δSi+δSj.(2)t_{ij}^{+\delta}:\delta S_i+\delta S_j\to\delta B_{ij},\qquad t_{ij}^{-\delta}:\delta B_{ij}\to\delta S_i+\delta S_j. \tag*{(2)}

The PP-invariants are spanned by the ∣V∣|V| valence budgets x(i)Tm=∑jbij+six^{(i)\mathsf{T}}m=\sum_j b_{ij}+s_i. While the net conserves heavy atoms and valence budgets, it does not conserve hydrogen or charge, which decoding reads back from the free valence Appendix § 9.

Atom mapping by the minimum firing vector. An atom map π\pi seats the product marking on the precursor places, while the state equation PπmB−mA=Cσ(π)P\pi m_B-m_A=C\sigma(\pi) fixes the firing vector on every bond place with a seated end (Figure 3). We map by the cheapest firing vector, based on the principle of minimum chemical distance [Jochum et al., 1980], under a lexicographic cost without continuous parameters. The first level counts the bonds that are formed and broken, with a hydrogen on carbon as a bond of its own, and a hydrogen on a heteroatom, which exchanges with the medium, not counted. The second level then counts the changes of bond order on kept bonds and of formal charge. A branch and bound over the seatings that is bounded by linear assignments on the places of the net then finds the minimum and proves it optimal for 100.0 % of the Golden set within 60 s, in a median time of 0.02 s per reaction. Mappings that tie on both levels are ranked by a third level of three counts, chosen on 200 reactions from the Golden set (Appendix § 11.§ 1). The mapper runs once per reaction before training and its firing vectors feed the token game and the second classifier.

The firing vector

Figure 3. The firing vector. (a) A map π\pi seats each product atom on the precursor atom with its number, and grey atoms leave unrecorded. (b) The state equation gives σ(π)\sigma(\pi), one firing per changed bond place, and the grey entry follows as mA+Cσm_A+C\sigma. The H that moves from N to Cl passes from S5S_5 to S4S_4, while cycles in ker⁡C\ker C, such as the C=O of the tetrahedral intermediate, and the order of the firings stay unseen. (c) The mapper ranks maps by the bonds formed and broken, then by bond orders and charges, and returns σ^=σ(π1)\hat{\sigma}=\sigma(\pi_1).

Forward prediction by the token game. The product is the marking that an enabled firing sequence reaches from mAm_A. NPF plays the net one bond change at a time (Figure 2). From the current marking mm, the next event is:

Pr⁡(t∣m)=λθ,t(m)[t enabled at m]λθ,STOP(m)+∑t′λθ,t′(m)[t′ enabled at m](3)\Pr(t \mid m) = \frac{\lambda_{\theta,t}(m)[t\ \text{enabled at }m]}{\lambda_{\theta,\mathrm{STOP}}(m) + \sum_{t'} \lambda_{\theta,t'}(m)[t'\ \text{enabled at }m]} \tag*{(3)}

the embedded jump chain of the stochastic net in § 3, its sequence of markings without the waiting times, where STOP ends the game. A transition is enabled if allowed by the valence rule with half a token of tolerance on slack places (aromaticity), and each bond place is re-typed at most once. The rate law, which is a message-passing network with attention over the whole marking (Appendix § 9), ranks bond changes and is fitted to products that carry no times, so it is not a kinetic rate law. The targets are the firing vectors σ\sigma of the cheapest mappings that decode to the product, a set Σ∗\Sigma^*, with ∣Σ∗∣≤8|\Sigma^*| \le8. Because the loss sums over the whole set, the model never has to choose among equally cheap mappings. Furthermore, no order is needed as count-equivalent sequences reach the same marking. In training, we drop the model at a random point along a correct path, and reward it for putting probability on any correct next step. Beam search then keys partial predictions by firing vector, thereby merging count-equivalent sequences and adding their probabilities (Figure 2b). The resulting final marking still holds every precursor atom and is decoded into molecules by conservation rules, so by-products omitted in the input data set, come with the prediction. Note that the order of firings is valence bookkeeping and not a mechanism. Products carry no stereochemistry.

The electron net For mechanisms, we introduce a net whose tokens are electrons. Every atom has an atom place holding its non-bonding electrons, and every pair of atoms has a bond place holding the electrons they share, two for a single bond. A transition moves one electron, a fish-hook arrow, or a pair of electrons, a curly arrow, from an atom place into a bond place, or removes one from a bond place into an atom place. The total number of electrons is a PP-invariant and no transition adds an atom, so, each step conserves atoms, protons, and electrons by construction.

In this case, the enabling rule is the octet rule, by which an electron may only move onto an atom with shell room available. The shell capacities and the possible formal charges are read per element from the training steps (Appendix § 9), and the guarantees hold relative to them. The STOP is enabled only when every formal charge is whole and within its window and every bond place holds a whole number of pairs, so every end marking is a Lewis structure. Restricting the transitions to pairs gives the arrow net as a subnet whose firings are the curly arrows of arrow pushing, and cannot express steps that move single electrons. The rate law and the token game are the same as in the forward model, a step fires at most 16 arrows and never undoes one, and the products are the end marking. Molecules enter both nets as Kekulé structures (Appendix § 9).

Experiments and Discussion

We test each task on standard benchmarks (Tables 1 to Table 4), described in Appendix § 9. For every model, we report the mean and sample standard deviation over three seeds unless stated otherwise, and baselines as reported by their authors on the same splits.

methodparams12351235
Molecular Transformer12M88.7596.6298.4298.9288.3195.6497.0297.59
Graph2SMILES18M89.0996.7598.0898.66<u>92.51</u>95.9497.0397.76
Graph2SMILES+H18M87.3995.3196.8797.6789.2293.7095.1096.19
FlowER7M88.4896.4297.9698.6088.9794.7596.4897.39
FlowER-large16M<u>89.74</u><u>97.40</u><u>98.66</u><u>99.13</u>92.50<u>96.89</u><u>98.15</u><u>98.61</u>
NPF, arrow net7.3M88.85 ± 0.0496.13 ± 0.0697.33 ± 0.0797.71 ± 0.1490.54 ± 0.0594.20 ± 0.0994.88 ± 0.0895.19 ± 0.13
NPF, electron net8.2M90.47 ± 0.0997.85 ± 0.0899.08 ± 0.0899.46 ± 0.1494.49 ± 0.3698.46 ± 0.2199.21 ± 0.1399.52 ± 0.16
upper limit91.2798.8999.7999.99––––

Table 4. Top-kk accuracy (%) on the FlowER test set for individual steps (162 002) and full pathways (28 049 reactions). A pathway counts as correct if some route to a recorded end product has every step in the top kk. Steps from PMechDB and RMechDB are excluded. The upper limit reflects steps with more than one valid outcome. NPF ranks by beam probability. Baselines rank by sample frequency and come from Fig. 2 of Joung et al. [2025]. Best in bold, second <u>underlined</u>.

Reactions

Atom mapping. On the Golden set, scored as by Lin et al. [2021] on the 1 760 reactions with a curated map, the minimum firing vector reproduces the curated map, up to the symmetry of the molecules, for 88.81 %, and RXNMapper, a transformer pretrained on 2.8M reactions for 85.57 % (p<0.001p < 0.001), and 88.53 against 85.58 on the 1 560 reactions not used to choose the cost (see Appendix § 11.§ 1). On SynRXN (Table 1), which compares reaction centres, our mapper is ahead of RXNMapper on Golden (p=0.003p = 0.003) and its subset NatComm (p=0.01p = 0.01). It is level with the graph-based learned mappers by Chen et al. [ [11] and Nugamov et al. [2022] on Golden (p≥0.51p \ge0.51), non-significantly behind them on NatComm. It is behind all three learned mappers on USPTO-3k (p<0.001p < 0.001). SynRXN Golden and NatComm contain 121 and 24 of the 200 reactions used to choose the cost, and without them our mapper scores 89.37 and 90.36 %, still ahead of RXNMapper (p=0.006p = 0.006 and p=0.03p = 0.03). On all three organic sets, our mapper is ahead of the rule-based RDT by Rahman et al. [2016]. On Recon3D it is ahead of the learned mappers, by at least 7.1 points (p<0.001p < 0.001) and RDT by 2.9 (p=0.02p = 0.02). On E. coli, RDT is ahead, although not significantly (p=0.06p = 0.06), and we match RXNMapper. To break the tie on E. coli, we evaluated both on EnzymeMap [Heid et al., 2023b], where we establish a lead over RXNMapper with 88.70 against 77.92 (Table 10).

criterionNPF, minimum firing vectorRXNMapperonly onepp
reaction centre (SynRXN)88.7077.925 213 / 741< 0.001

Table 10.

Reaction classification. On Schneider50k, the classifier that reads the firing vector of the mapper reaches 98.80 ±\pm 0.04 % accuracy (Table 2), ahead of the generic network on the same firing vector (98.64 ±\pm 0.09 %, p=0.01p = 0.01) and of DRFP with a perceptron (95.52 ± 0.04 %). Reading the two sides of the reaction without any map at test time, the state-equation readout reaches 97.68 ± 0.09 %, level with the generic readout (97.74 ± 0.01 %, p=0.21p = 0.21), and with all labels the cancellation of Proposition 3 does not change accuracy, while the firing vector adds 1.1 points, so the map of the net carries information that the two sides alone do not expose. As rules on the reaction centre assigned the classes of Schneider50k [Schneider et al., 2015], the EC numbers are the harder test.

Schneider50k (50 classes)nnaccuracymacro-F1
DRFP + MLP395.52 ± 0.0495.47 ± 0.04
PGNN, readout397.67 ± 0.0797.65 ± 0.07
PGNN, firing vector5<u>98.64 ± 0.09</u><u>98.63 ± 0.09</u>
NPF, readout597.68 ± 0.0997.67 ± 0.10
NPF, firing vector598.80 ± 0.0498.80 ± 0.04
ECREACT, Enzyformer splitEC4EC3EC2EC1
BEC-Pred–76.981.285.8
DRFP + CLM–81.785.688.3
Synthcoder-DistilBERT–84.486.7<u>90.9</u>
Enzyformer–<u>84.6</u><u>88.2</u><u>90.9</u>
NPF75.75 ± 0.1890.20 ± 0.1592.45 ± 0.2395.40 ± 0.23
CARE task 2, easyEC4EC3EC2EC1
CLIPZyme12.239.961.879.9
DRFP similarity59.377.185.290.6
CREEP39.466.479.992.9
NPF, no map<u>67.85 ± 0.39</u><u>82.27 ± 0.29</u><u>89.74 ± 0.39</u><u>95.76 ± 0.59</u>
NPF + mapper70.23 ± 1.59<u>84.31 ± 0.64</u><u>92.03 ± 0.78</u>96.78 ± 1.03
CREEP + text60.389.393.9<u>96.7</u>

Table 2. Reaction classification, accuracy and macro-F1 in %, ±: sample standard deviation over nn seeds, three for NPF on ECREACT and CARE. ECREACT, split of Liu et al. [2026], 4907 test reactions, baselines the mean over three runs. CARE task 2, easy split, 393 test reactions, baselines from Yang et al. [2024]. Best in bold, second underlined.

methodlearnedGoldenNatCommUSPTO-3kRecon3DE. coli
RDTrules82.5484.1190.8754.9778.02
RXNMapperyes87.4387.5893.5348.6972.53
LocalMapperyes89.08<u>92.67</u>97.7750.7969.96
GraphormerMapperyes<u>89.59</u>92.8795.1034.8242.12
NPF, minimum firing vectorno89.7090.6392.1357.85<u>72.89</u>

Table 1. Atom mapping on SynRXN [Phan et al., 2026]. Best in bold, second underlined. Statistical tests and detailed numbers can be found in Table 9.

setRDTRXNMapperLocalMapperGraphormerMapper
Golden175 / 49, < 0.001109 / 69, 0.003119 / 108, 0.51122 / 120, 0.95
NatComm41 / 9, < 0.00124 / 9, 0.0121 / 31, 0.2121 / 32, 0.17
USPTO-3k78 / 40, < 0.0013 / 45, < 0.0014 / 173, < 0.00117 / 106, < 0.001
Recon3D15 / 4, 0.0235 / 0, < 0.00130 / 3, < 0.00190 / 2, < 0.001
E. coli17 / 31, 0.0630 / 29, 1.0022 / 14, 0.2490 / 6, < 0.001

Table 9.

On ECREACT [Probst et al., 2022a], in the split of Liu et al. [2026], the state-equation readout predicts the EC number to the third level for 90.20 ± 0.15 % of the test reactions, 5.6 points ahead of the best retrained method, Enzyformer (84.6 %), and leads at EC levels 2 and 1 by 4.3 and 4.5 points. At the full EC number, which no baseline reports, it reaches 75.75 ± 0.18 %, where the 224 test reactions whose EC number never occurs in training cap any method at 95.4 %. On CARE, most EC numbers have four or fewer training reactions, here the classifier reaches 70.23 ± 1.59 % at the full EC number with the maps of the mapper and 67.85 ± 0.39 % without maps, against 59.3 % for DRFP similarity, the best method that reads only the reaction. CREEP with a text description of the reaction reaches 60.3 % at the full EC number and leads at EC levels 3 and 2 (89.3 and 93.9 against 84.31 and 92.03 % for NPF), while the structure of the reaction alone recovers the full EC number better than CREEP.

Forward prediction. On USPTO-480K [Jin et al., 2017], NPF trained on targets of the net predicts the recorded product first for 87.7 % of the 40 000 test reactions under the rule of Appendix § 9 (Table 3), matching MAELLE (87.2 %), which learns the movement of the electrons, and above the graph-edit models MEGAN (86.3 %) and GTPN (83.2 %). Sequence models such as Graph2SMILES (90.3 %) and Molecular Transformer (88.6 %), as well as the electron-edit model NERF (90.7 %), remain ahead at top-1, and at top-5 NPF (93.7 %) is level with NERF (93.7 %) and MAELLE (93.9 %). Training NPF on the minimum firing vectors of the mapper instead of the supplied atom maps raises top-1 from 86.8 to 87.71 %, as on 10 % of the data over three seeds (Appendix § 11.§ 3), so the model does not need external atom maps. With 1 % of the training data, the token game predicts the major product first for 67.44 % of the test reactions (Table 14). Without the enabling rule, accuracy is unchanged (87.6 %), but 5 out of the 40 000 predictions break the valence rule (Table 17), which the enabling rule prevents for every value of the weights. Trained on USPTO-480K, the network thus learns the valence rule almost perfectly by itself, but only the net guarantees it.

methodprediction modalitytop-1top-3top-5
Molecular Transformer† [Schwaller et al., 2019]SMILES0.8860.9350.942
Graph2SMILES† [Tu and Coley, 2022]SMILES0.9030.9400.948
MEGAN† [Sacha et al., 2021]Graph edits0.8630.9240.940
GTPN† [18]Graph edits0.8320.8600.865
NERF† [8]Electron edits0.9070.9330.937
MAELLE [Xuan-Vu et al., 2026]Electron flow0.8720.9300.939
NPF, recorded maps (ours)Token game0.8680.9210.934
NPF, targets of the net (ours)Token game0.8770.9270.937
NPF, targets of the net, no enabling rule (ours)Token game0.876<u>0.927</u><u>0.938</u>

Table 3. Top-kk accuracy comparison on USPTO-480K. Entries taken from the original papers, as collected by Xuan-Vu et al. [2026], are marked with †. NPF is scored as in Appendix § 9, one seed. With the enabling rule, every NPF prediction stays within the valence budgets of its atoms (Table 17).

Table 14: Forward prediction on the nested 1, 10 and 25 % subsets of the USPTO-MIT training file (4 090, 40 900 and 102 259 lines), top-1 and top-5 in % of all 40 000 test reactions for the major product, the largest molecule of a prediction against the recorded major product, from beam search. NPF: mean ± sample standard deviation over three seeds, 1.6M parameters at width 128 and 9.8M at width 256. The Molecular Transformer (MT) is trained from scratch for 5 000, 50 000 and 75 000 steps, one run each.

model1 % top-11 % top-510 % top-110 % top-525 % top-125 % top-5
MT0.160.3774.1684.1982.3990.37
NPF, supplied maps67.24 ± 0.2480.36 ± 0.3678.85 ± 0.0488.73 ± 0.08––
NPF, targets of the mapper67.44 ± 0.1980.45 ± 0.1878.83 ± 0.1488.78 ± 0.1681.73 ± 0.1390.64 ± 0.06
NPF width 256, supplied maps––––82.95 ± 0.2691.04 ± 0.12
NPF width 256, targets of the mapper––––83.23 ± 0.2091.00 ± 0.07

Table 14.

Table 17: Validity of the top-1 predictions on USPTO-480K (39 994 test reactions that RDKit parses), one seed each. Valence rule: share of predictions whose markings respect the enabling rule of the valence net. Valid molecules: share of predictions whose products RDKit sanitises, with the number of invalid predictions. Dropped fragments: share of predictions in which a touched molecule could not be decoded and was left out. Invalid products of the aromatic models come from the half-token tolerance on aromatic bonds.

NPF modelvalence rulevalid moleculesinvaliddropped fragments
aromatic, recorded maps10099.87550–
aromatic, targets of the net10099.897410.130
aromatic, targets of the net, no enabling99.98799.890440.138

Table 17.

Reaction mechanisms. We use the elementary steps of FlowER [Joung et al., 2025] in their published split (Appendix § 9). Given the reactants of a step, a model predicts its products, and a prediction is correct if its canonical SMILES without atom maps and stereochemistry equals that of the recorded products. We report the top-kk step accuracy and the top-kk pathway accuracy of Joung et al. [2025], computed as in their evaluation script.

Every top-1 prediction of both nets is a valid molecule (Table 18), without a filter, while FlowER discards its invalid samples, about 5%, before ranking, and 70 to 79% of the top-1 predictions of the sequence models are valid. Every prediction of both nets conserves atoms, protons and electrons, which 17 to 33% of the predictions of the sequence models do. The electron net predicts the recorded step first for 90.47% of test steps (Table 4), ahead of every baseline, the best being FlowER-large (89.74%), and within 0.8 points of the 91.27% upper limit. The electron net leads at every kk with 8.2M parameters, against 16M for FlowER-large. On whole reactions it recovers the pathway at top-1 for 94.49 ± 0.36% (Table 4), against 92.51% for Graph2SMILES and 92.50% for FlowER-large, the best baselines, and 88.97% for FlowER.

Table 18: Validity and conservation of the predictions on the FlowER test set, in %. Valid SMILES of the top-1 prediction, and the share of predictions that conserve heavy atoms, and heavy atoms, protons and electrons together. For NPF and FlowER, conservation holds by construction, as every firing keeps the P-invariants of the net (Proposition 1) and FlowER’s electron changes sum to zero. For NPF we report mean sample standard deviation over three seeds, all 162 002 steps. Baselines from the text of Joung et al. [2025], single runs, where FlowER’s validity is given as approximately 95 %.

methodvalid SMILESheavy atomsatoms, protons, electrons
Molecular Transformer70.239.133.0
Graph2SMILES76.330.717.2
Graph2SMILES+H78.827.719.0
FlowER95by constructionby construction
NPF, arrow net100by constructionby construction
NPF, electron net100by constructionby construction

Table 18.

The arrow net, which moves only pairs, scores 88.85% top-1, and its difference to the electron net comes from the 1.79% of test steps that move single electrons (Appendix § 11.§ 4).

What does each Petri component contribute?

We evaluated, on Schneider50k for forward prediction and classification, the proposed Petri net architecture against counterparts of equal size but without each component we introduced (Appendix § 11.§ 5). Playing the net one bond change at a time, as the stochastic net from § 3 fires, raises the greedy top-1 from 79.72 to 93.34%. Enabling, introduced in § 4.1, makes every prediction valence-valid for every value of the weights (Proposition 4) at no cost in accuracy (p=0.22p = 0.22), whereas the generic one-shot model breaks a budget in 2.79%, and the token game without the mask in 0.02%, and in 0.16% after a shift to 5 000 USPTO-480K test reactions. The pure state equation readout (w=1w = 1, § 4.2) is invariant to an inserted far methyl group. When trained on subsamples of 1 000 and 250 reactions, the pure readout is ahead of its generic counterpart, the firing vector (§ 3) only on 250. A D-MPNN on the condensed graph of reaction by Heid and Green [2021] with the same maps is behind the firing vector except on larger molecules, where the two are level (Appendix § 11.§ 2).

Conclusion

In this work, we asked what a neural network looks like when its outputs obey the rules of a Petri net for every value of its weights. The theory answers that it has to keep the firing form and the enabling rule, while it can only learn the rate law or a readout of the firing vector. On the valence net, atom mapping, reaction classification, and forward prediction become three tasks on a firing vector. The minimum firing vector maps atoms without learned weights. It is competitive across a range of reaction data sources, and its tied optima replace learned atom maps as the training targets of the forward model. On USPTO-480K, NPF trained on these targets is level with or ahead of the electron-flow model MAELLE and the graph-edit models, and ahead of the NPF trained on the supplied maps. The state-equation readout predicts EC numbers ahead of published methods on ECREACT and at the full EC number on CARE. On the electron net, the token game predicts the elementary steps of FlowER ahead of published baselines. The enabling mask makes validity a guarantee at no cost in accuracy, while the readout and the firing vector gain on small training sets but no on distribution shifts in molecule size.

Acknowledgements

We would like to thank Dr. Alma Ademovic Tahirovic for sharing her insights and the useful and enjoyable discussions on neural Petri nets as applied in her own work.

Reproducibility statement

We have taken care to provide training data, scripts, and logs together with the source code to assist reproducibility. The source code, data, scripts, and logs are available at https://github.com/daenuprobst/npf. Proofs are in Appendix A and Appendix B describes the data, splits, hyperparameters, and metrics.

Proofs

Nets, markings, enabling, the incidence matrix CC, and the attributes epe_p and ata_t are those introduced in Section 3. For the consumers of pp, we write p∙={t:Pre⁡(p,t)>0}p^\bullet= \{t : \operatorname{Pre}(p,t) > 0\}. If ∙t∩t∙=∅{}^\bullet t \cap t^\bullet= \varnothing for all tt, the net is pure, meaning no transition takes from and gives to the same place. 1p\mathbf{1}_p is the unit vector of place pp. On the valence net of the precursor atoms VV, we write bij=mBb_{ij} = m_B for the bond order and si=mSis_i = m_{S_i} for free valence. Transitions are tij+δ:δSi+δSj→δBijt_{ij}^{+\delta}: \delta S_i + \delta S_j \to\delta B_{ij} and their reverse is tij−δt_{ij}^{-\delta}, for every pair i<ji < j of atoms and every δ∈{12,1,32,2,3}\delta\in\left\{\frac{1}{2}, 1, \frac{3}{2}, 2, 3\right\}. All columns of one pair are multiples of 1Bij−1Si−1Sj\mathbf{1}_{B_{ij}} - \mathbf{1}_{S_i} - \mathbf{1}_{S_j}, so CC has rank (∣V∣2)\binom{|V|}{2} and ker⁡CT\ker C^{\mathsf{T}} is spanned by the ∣V∣|V| valence budgets x(i)=1Si+∑j1Bijx^{(i)} = \mathbf{1}_{S_i} + \sum_j \mathbf{1}_{B_{ij}}, with (x(i))Tm=si+∑jbij(x^{(i)})^{\mathsf{T}}m = s_i + \sum_j b_{ij}. Arc weights and markings are all multiples of 12\frac{1}{2}, so doubling them gives a discrete net. An atom map π\pi seats the product marking on the precursor places as PπmBP_\pi m_B (see Section 3). The implementation masks transitions that are not enabled with a log-rate of −104-10^4 instead of −∞-\infty, realising Proposition 4 when the log-rate of STOP exceeds −103-10^3.

The inverse problem uses the two orthogonal decompositions

RT=im⁡CT⊕ker⁡C,RP=im⁡C⊕ker⁡CT,(4)\mathbb{R}^{T} = \operatorname{im} C^{\mathsf{T}} \oplus\ker C,\qquad\mathbb{R}^{P} = \operatorname{im} C \oplus\ker C^{\mathsf{T}}, \tag*{(4)}

and the pseudoinverse C+C^+, where C+CC^+C and I−C+CI - C^+C project orthogonally onto im⁡CT\operatorname{im} C^{\mathsf{T}} and ker⁡C\ker C. Therefore, every σ\sigma splits into one part in im⁡CT\operatorname{im} C^{\mathsf{T}}, which is determined by the observed change as C+(m−m0)C^+(m-m_0), and another part containing cycles in ker⁡C\ker C. im⁡\operatorname{im}, the image, is all that can be produced by the matrix, while ker⁡\ker, the kernel, is all that it maps to zero. In chemistry terms, im⁡C\operatorname{im} C holds the changes of bonds and free valence that bond changes can cause, ker⁡CT\ker C^{\mathsf{T}} the valence budgets, ker⁡C\ker C the bond changes that cancel each other out, and im⁡CT\operatorname{im} C^{\mathsf{T}} the part of the bond changes determined by the products.

Conservation is equivalent to the firing form

Proposition 1 (The conservation is equivalent to the firing form). Assume the PP-invariants span ker⁡CT\ker C^{\mathsf{T}}. An update m↦m+u(m)m \mapsto m + u(m) satisfies xT(m+u(m))=xTmx^{\mathsf{T}}(m + u(m)) = x^{\mathsf{T}}m for all markings mm and all PP-invariants xx iff u(m)∈im⁡Cu(m) \in\operatorname{im} C for all mm, i.e. u=C∘vu = C \circ v for some v:R≥0T→RTv : \mathbb{R}_{\ge0}^{T} \to\mathbb{R}^{T}.

Proof. Fix mm. The condition xTu(m)=0x^{\mathsf{T}}u(m) = 0 for all x∈ker⁡CTx \in\ker C^{\mathsf{T}} says u(m)∈(ker⁡CT)⊥=im⁡Cu(m) \in(\ker C^{\mathsf{T}})^\perp= \operatorname{im} C. If u(m)∈im⁡Cu(m) \in\operatorname{im} C for all mm, put v(m):=C+u(m)v(m) := C^+u(m), then Cv(m)=CC+u(m)=u(m)Cv(m) = CC^+u(m) = u(m). Conversely, xTCv=0x^{\mathsf{T}}Cv = 0 for every PP-invariant xx.

Note that vv can have negative entries for reverse firings.

Conservation fails under generic parameters. A model updates a marking as mp+=mp+rθ(hp)+cm_p^+ = m_p + r_\theta(h_p) + c, with a free output bias c∈Rc \in\mathbb{R}. This is the same that message-passing models with an MLP readout do. Let xx be a PP-invariant where ∑pxp≠0\sum_p x_p \ne0. Two parameter vectors differing only in cc give values of xT(m+−m)x^{\mathsf{T}}(m^+ - m) that differ by (c−c′)∑pxp≠0(c-c')\sum_p x_p \ne0. This means that for every input and every value of the other weights, at most one value of cc conserves xx. Thus, the conserving parameters form a set of Lebesgue measure zero, giving gradient training no reason to find. In short, a loss can drive such a model towards conservation, but nothing in the architecture keeps it there on new inputs.

The enabling rule is forced

Proposition 2 (The enabling rule is forced). vt(m)=f((mp,ep,Pre⁡(p,t))p∈∙t,at)v_t(m) = f\left((m_p,e_p,\operatorname{Pre}(p,t))_{p\in{}^\bullet t},a_t\right) is a rate law is local shared across nets, where f≥0f \ge0 continuous. If on every pure net and from every m(0)∈R≥0Pm(0) \in\mathbb{R}_{\ge0}^{P} the equation m˙=Cv(m)\dot{m} = Cv(m) has a solution that stays in R≥0P\mathbb{R}_{\ge0}^{P} on some [0,ϵ)[0,\epsilon), then f=0f = 0 whenever an input place is empty.

Proof. Suppose f>0f > 0 at an argument with mq=0m_q = 0 for some q∈∙tq \in{}^\bullet t. Then consider a pure net consisting of tt, input places with these attributes and weights, and one new output place, letting m(0)m(0) have these values. By hypothesis, there is a solution with m(s)≥0m(s) \ge0 on some [0,ϵ)[0,\epsilon). The place qq has no producer, so 0≤mq(τ)=−Pre⁡(q,t)∫0τf ds0 \le m_q(\tau) = -\operatorname{Pre}(q,t)\int_0^\tau f\,\mathrm{d}s along the solution. As f≥0f \ge0, the integrand vanishes for most ss, and by continuity of ff and of the solution for every ss, especially at s=0s=0, there is a contradiction.

The rate law is the same formula everywhere, which means that if it should fire a transition with an empty input place, we could build a one-transition net that creates this situation. As nothing refills the empty place, it would go negative.

However, as negative markings are forbidden, the rate has to be zero when an input place is empty. This is important because this tells us that the enabling rule is not a design choice that we impose, but a consequence of non-negativity. Any learned or handwritten rate law that is local, shared, continuous, and that keeps markings nonnegative has to respect it, while one that violates it will, at some point, produce impossible states. For one firing at a time, as in the jump chain of § 3 and in the token game, the rule is force without locality. On a pure net, a transition tt that is not enabled at mm has mp<Pre⁡(p,t)m_p < \operatorname{Pre}(p,t) for some input place pp, so a rate law that keeps every marking non-negative has to set λt(m)=0\lambda_t(m)=0. The valence net is pure, and this zero rate is the mask of § 4.1, applied to mA∘m_A^\circ of Proposition 4.

Cancellation and invariance of the readout

Setting. The two graphs GA=(VA,xA,bA)G_A=(V_A,x^A,b^A) and GB=(VB,xB,bB)G_B=(V_B,x^B,b^B) with node attributes xx and bond types b(⋅,⋅)b(\cdot,\cdot), where 0=0= no bond, and π=VB→VA\pi=V_B\to V_A is injective. The RR-ball of node (atom) ii is the attributed (sub) graph induced on the nodes within distance RR of ii. ψG(i)\psi_G(i) only depends on the isomorphism class of the RR-ball of ii in GG. Let D⊆VBD\subseteq V_B contain ii if xiB≠xπ(i)Ax_i^B\ne x_{\pi(i)}^A, or bB(i,k)≠bA(π(i),π(k))b^B(i,k)\ne b^A(\pi(i),\pi(k)) for some k∈VBk\in V_B, or bA(π(i),u)≠0b^A(\pi(i),u)\ne0 for some u∉π(VB)u\notin\pi(V_B), and let DR={i:dist⁡B(i,D)≤R}D_R=\{i:\operatorname{dist}_B(i,D)\le R\}.

In chemistry terms, we have two molecules AA and BB that are atom-to-atom mapped by π\pi. The featuriser ψG(i)\psi_G(i) describes the atom ii by its chemical environment within RR bonds. DD is the set of atoms in BB where elements or bonding differs from their counterparts in AA and DRD_R adds every atom within a radius of RR. This is conceptually similar to the DRFP fingerprint.

Proposition 3 (Cancellation and invariance). Let r=∑i∈VBψB(i)−∑j∈VAψA(j)r=\sum_{i\in V_B}\psi_B(i)-\sum_{j\in V_A}\psi_A(j). Then r=∑i∈DR[ψB(i)−ψA(π(i))]−∑j∉π(VB)ψA(j)r=\sum_{i\in D_R}\left[\psi_B(i)-\psi_A(\pi(i))\right]-\sum_{j\notin\pi(V_B)}\psi_A(j). Specifically, attaching the same attributed subgraph by one edge to ii and π(i)\pi(i), where ii is more than 2R2R away from DD and the attributes of ii and π(i)\pi(i) change identically, leaves rr unchanged.

Lemma 1. If dist⁡B(i,D)>R\operatorname{dist}_B(i,D)>R, then π\pi restricts to an isomorphism of the RR-ball of ii in GBG_B onto the RR-ball of π(i)\pi(i) in GAG_A. Specifically, it preserves distances to the root, and ψB(i)=ψA(π(i))\psi_B(i)=\psi_A(\pi(i)).

Proof. No node uu of RR-ball UU of ii lies in DD, this means that the neighbours of π(u)\pi(u) in GAG_A are exactly the images of the neighbours of uu, with equal bond types and none of them is unmatched. By induction on d≤Rd\le R, π\pi maps the nodes at a distance dd from ii onto the nodes at distance dd from π(i)\pi(i). Attributes agree on UU and bond types agree on U×UU\times U due to U∩D=∅U\cap D=\varnothing. □\square

Proof of Proposition 3. As π\pi is injective, VAV_A is the disjoint union of π(VB)\pi(V_B) and the unmatched nodes, so r=∑i∈VB[ψB(i)−ψA(π(i))]−∑j∉π(VB)ψA(j)r=\sum_{i\in V_B}[\psi_B(i)-\psi_A(\pi(i))]-\sum_{j\notin\pi(V_B)}\psi_A(j), and the terms with i∉DRi\notin D_R vanish by Lemma 1. For invariance, attach HH to i0i_0 and to π(i0)\pi(i_0), where dist⁡B(i0,D)>2R\operatorname{dist}_B(i_0,D)>2R, and extend π\pi by the identity on HH. As HH is pendant and fully matched, and i0i_0 and π(i0)\pi(i_0) change identically, the sets DD, DRD_R and the unmatched nodes are unchanged, so it suffices to check that no term of the formula changes. For i∈DRi\in D_R the triangle inequality gives dist⁡B(i,i0)>R\operatorname{dist}_B(i,i_0)>R, so i0i_0 and HH lie outside the RR-ball of ii in GBG_B. By Lemma 1 applied to i0i_0, the RR-ball of π(i0)\pi(i_0) in GAG_A is the image of the RR-ball of i0i_0, hence contains no π(i)\pi(i) with i∈DRi\in D_R and no unmatched node. Therefore, every term of the formula is unchanged. □\square

For chemistry, this means the difference fingerprint rr only depends on the atoms at the reaction centre and within RR bonds of this centre, and any leaving atoms. All other atoms have the same environment on both sides and cancel each other out. Invariance is a consequence of this, as decorating reactants and products identically far from the reaction centre leaves rr unchanged. In short, atoms are split into three groups, those that changed or are close to a change, those far away from any change and those that leave. According to Lemma 1, the middle group contributes equally to sums and disappears, leaving only the first group plus the leaving atoms.

Similar to message passing, the encoder updates the embedding of each atom from its bonded neighbours for KK rounds. Atom terms have R=KR=K, and bond terms that read the embeddings of an atom and of its neighbours along bonds of one type have R=K+1R=K+1. In Section 6.2, we use K=3K=3 and attachment sites at least 9 bonds from DD. A readout ρ(∑Bψ,∑Aψ)\rho(\sum_B\psi,\sum_A\psi) with a generic ρ\rho has neither cancellation nor invariance, as the sums themselves change with every spectator atom.

Validity of the token game

Proposition 4 (Validity). Let mA∘=mA+12∑i1Sim_A^\circ=m_A+\frac{1}{2}\sum_i\mathbf{1}_{S_i} be the marking of the precursors with half a token of tolerance on every slack place. For all weights, given mm is a marking visited by the token game described in § 5, then m∘=m+12∑i1Sim^\circ=m+\frac{1}{2}\sum_i\mathbf{1}_{S_i} is reachable from mA∘m_A^\circ in the valence net. Specifically mm is non-negative on the bond places and at least −12-\frac{1}{2} on the slack places, has the valence budgets of mAm_A, and ∑jbij≤(x(i))TmA+12\sum_j b_{ij}\le(x^{(i)})^\mathsf{T}m_A+\frac{1}{2} for every atom ii.

Proof. By induction over the steps. A step re-types one bond place BijB_{ij} from its order to another order in {0,1,12,2,3}\{0,1,\frac{1}{2},2,3\}. If the order grows by δ\delta, the step is a firing of tij+δt_{ij}^{+\delta}. The game admits it only if δ≤si+12\delta\le s_i+\frac{1}{2} and δ≤sj+12\delta\le s_j+\frac{1}{2}, which is the enabling rule at mA∘m_A^\circ, whose slack places hold si+12s_i+\frac{1}{2}. If the order is reduced by δ\delta, the step is a firing of tij−δt_{ij}^{-\delta}, which is enabled. Therefore, the next marking is reachable, non-negative, and the valences, being PP-invariant, remain unchanged.

A few notes. (1) The half token is needed for aromatic bonds. (2) We make the following design choices given the data: A game re-types each bond place once per reaction at most and fires twelve times at most. (3) The budget of an atom depends on its element and on its state in mAm_A as an atom already cationic or hypervalent there keeps its spare tokens. (4) Training states mA+CσFm_A+C\sigma_F apply random parts of a target firing vector without order and does not have to be reachable. The guarantee only concerns the markings visited at inference. (5) A new bond needs δ≥1\delta\ge1, so a carbon with a valence budget of four, with ∑jbij≤412\sum_j b_{ij}\le4\frac{1}{2}, never gets a fifth bond. Aromatic carbons at a ring fusion hold 4124\frac{1}{2} in mAm_A and aromatic carbons with an exocyclic double bond hold 5. Only the Kekulé net of Appendix § 9 caps their total bond order at four.

Lemma 2 (Realisability on the valence net). Let σ\sigma be a firing vector of the valence net with σt≤1\sigma_t \le1 for every transition tt and at most one fired transition on every bond place. Let m=mA+Cσm=m_A+C\sigma be non-negative. Then every sequence that fires the transitions of σ\sigma once each, with the bond-breaking ones first, is enabled at mAm_A, so σ\sigma is the count vector of a firing sequence enabled at mAm_A. The same holds with mA∘m_A^\circ, the precursors with half a token more on every slack place (see Proposition 4), in place of mAm_A whenever m∘=mA∘+Cσm^\circ=m_A^\circ+C\sigma is non-negative.

Proof. A firing tij−δt_{ij}^{-\delta} of σ\sigma is enabled at every marking before it, as no other firing of σ\sigma changes BijB_{ij} and δ≤bij\delta\le b_{ij} at mAm_A as m≥0m \ge0. Breaking a bond only adds tokens to slack places. Let si′s'_i be the slack after all breaks, and let tij+δt_{ij}^{+\delta} be a bond-forming firing after some of the others. Every forming firing removes tokens, which means that SiS_i then holds at least si′s'_i minus the tokens of all forming firings at ii except this one, that is, at least mSi+δ≥δm_{S_i}+\delta\ge\delta. Same for SjS_j. Therefore, every step is enabled and the same holds for mA∘m_A^\circ.

This means that the converse of the state equation, which fails in general as discussed in § 3 holds for the firing vectors that the mapper returns and that the token game trains on, whenever the stated product marking is non-negative. In chemistry terms this means that breaking every bond first frees all the valence that the formations need. Therefore, the valence rule can forbid an order of the bond changes, such as a new bond to a carbon that still has four bonds, however, it can never forbid a product in which every atom stays within its valence budget, as long as each bond changes at most once because breaking the bonds first is then always an allowed order. So if we keep only training targets with an allowed order (Appendix § 9), it only ever asks that their products have valid valences.

What two markings can and cannot identify

Our layers are shaped by three gauge freedoms that limit what any estimator recovers from pairs of markings.

  • Rate scale. The embedded jump chain only uses λ\lambda through λt(m)/(λSTOP(m)+∑t′λt′(m))\lambda_t(m)/(\lambda_{\mathrm{STOP}}(m) + \sum_{t'} \lambda_{t'}(m)), this means that a common factor ec(m)e^{c(m)} on all the rates at a marking does not change any observation. Untimed pairs, as we have in chemistry, only identify the relative law. However, given timed chemistry data means that reactants and products by themselves could not tell fast kinetics observed briefly from slow kinetics observed for long. A PP-invariant term x⊤mx^{\top}m in every log rate, which in chemistry is the valence budget of an atom, is such a factor that is constant along every path. Therefore, which bond changes happen would solely depend on how the possible changes compare and never on an overall speed or concentration.

  • The kernel of C. Any given pair of markings only fixes σ\sigma modulo ker⁡C\ker C, which is large in the valence net. This means that a bond formed and then broken again, or a double bond made in one step instead of two, does not leave any trace in the products. Excluding both those cases, the token game re-types each bond place only once, making σ↦Cσ\sigma\mapsto C\sigma injective and σ\sigma a function of the change PπmB−mAP_{\pi}m_B-m_A under a correspondence π\pi. The map π↦σ(π)\pi\mapsto\sigma(\pi) is constant on correspondences that differ by a symmetry of an unchanged part, moving the ambiguity to the choice of π\pi, and the mapper whose minimum contains no cycling, is the right encoder for the inverse problem. For chemistry, this means that swapping two equivalent atoms, while changing the atom map, does not affect the bond changes. Therefore, uncertainty is limited to which atom is which, and this is left to the atom mapper.

  • Orders inside a trace. Assuming that transitions aa and bb are enabled at mm in any order and nothing enabled after both, the chain fires aa or bb first with a probability of xx or yy, respectively, and stops with a probability z=1−x−yz = 1 - x - y, and stops after the first firing with a probability of s1s_1 or s2s_2. The four final markings are seen with the probabilities zz, xs1xs_1, ys2ys_2 and x(1−s1)+y(1−s2)x(1-s_1) + y(1-s_2), so the order is never recovered. Therefore, two markings identify which transitions fire, not the order in which they do. This also applies to chemistry, and not required by our models.

In summary, products fix the net bond changes and not the route, the speed, or anything constant along the way, and the layers are shaped in a way that they learn exactly the part that is fixed and nothing else.

Implementation details

Training. All our networks are trained with AdamW with a weight decay of 10−510^{-5} as optimiser and a one-cycle learning rate schedule peaking at 10−310^{-3}, and at 4×10−44 \times10^{-4} for the rate law with width 256 after a warm-up over the first 10 % of the steps with gradients clipped at norm 1. For the token game on USPTO-MIT we use 4⋅10−44 \cdot10^{-4}. The table gives the hyperparameters of the models we report on Schneider50k and USPTO-MIT. The DRFP baseline is a perceptron with one hidden layer of 1024 units and a dropout of 0.2, trained with AdamW and a weight decay of 10−410^{-4} for 40 epochs at a constant learning rate of 10−310^{-3}.

token gamewidth 256one-shot counterpartsclassifierclassifier, firing vector
width128256128128128
message-passing rounds68633
attention layers484––
epochs6060606060
batch size3232326464
parameters1.6M9.8M1.6M2.1M2.5M

Table 1 (PDF p. 18).

  • Features. We one-hot encode the element, degree, formal charge, number of hydrogens, aromaticity, and ring membership. Atom-map numbers are removed before canonical atom ordering so they are not leaked by either features or order. The encoder has one message function per bond type, residual updates, and layer normalisation.

  • Token game. In addition to the fixed features above, the input contains two quantities that change with the marking, namely the hydrogen count of every atom at the current marking (which is the slack place, its free valence minus capacity and negative charge) and whether a bond place of the atom has fired. Pair logits come from [hi+hj,hi⊙hj][h_i + h_j, h_i \odot h_j] (the pair feature read by the rate law for the bond place BijB_{ij}), the current bond type, a same-molecule flag, and a fired flag. Batch size is 32. Training fires a random part σF≤σ∗\sigma_F \leq\sigma^* of some σ∗∈Σ∗\sigma^* \in\Sigma^*, and the loss is −log⁡∑σT∖σFPr⁡(σT∣mA+CσF)-\log\sum_{\sigma_T \setminus\sigma_F} \Pr(\sigma_T \mid m_A + C\sigma_F) over the enabled transitions that continue a vector of Σ∗\Sigma^* containing σF\sigma_F, together with STOP if σF∈Σ∗\sigma_F \in\Sigma^*.

  • Classifier. We want locality, so there is no attention. Dropout is 0.2. The participation gate learns whether a precursor molecule holds a seated atom from the maps via a binary cross-entropy of 0.5. We matched the

number of parameters with the generic comparison. The generic head pools each side and adds one learned term per seated atom. When marked, the transition types that fired are predicted by an auxiliary head, with targets from the maps of the mapper of all training reactions, including those with withheld class labels.

  • Forward. On the USPTO-480K forward prediction, the rate law has width 256, eight message-passing rounds and eight attention layers over the whole marking, 9.8M parameters, and is trained for 60 epochs with batches of 32 reactions, a peak learning rate of 4⋅10−44 \cdot10^{-4} and mixed precision. The targets are the minimum firing vectors of the mapper that decode to the recorded product, up to eight per reaction. A training reaction without such a vector is left out, which keeps 393 621 reactions, against 399 184 with the recorded atom maps. After every epoch the model is scored greedily on 1 500 validation reactions, and the best epoch is kept. At test time, a beam of width 5 merges count-equivalent sequences. The variant without the enabling rule is the same network with the mask removed, so it may fire any transition whose input places hold tokens, whether or not the atoms have room for the new bond.

token game, recorded mapstoken game, targets of the nettoken game, targets of the net, no enabling
width256256256
message-passing rounds888
attention layers888
epochs606060
batch (reactions)323232
peak learning rate4⋅10−44 \cdot10^{-4}4⋅10−44 \cdot10^{-4}4⋅10−44 \cdot10^{-4}
beam width at test time555
training reactions399 184393 621393 621
parameters9.8M9.8M9.8M

Table 21.

  • Enzyme classifiers. The CARE and ECREACT classifiers are the state-equation readout of § 4.2 with the participation gate, trained with AdamW, a weight decay of 10−410^{-4} and a one-cycle schedule for 40 epochs; the model after the last epoch is evaluated. They have 4.6M and 4.8M parameters, the difference coming from the output layer over 4 874 and 5 192 EC numbers. The EnzymeMap classifier reads the firing vector of the mapper, as on Schneider50k, and is trained for 60 epochs.

arrow netelectron netclassifier, CARE, ECREACTclassifier, EnzymeMap
width256256128128
message-passing rounds6633
attention layers66––
epochs12124060
batch (atom pairs / reactions)≤2⋅106\le2 \cdot10^{6}≤2⋅106\le2 \cdot10^{6}1616
peak learning rate5⋅10−45 \cdot10^{-4}5⋅10−45 \cdot10^{-4}10−310^{-3}10−310^{-3}
parameters7.3M8.2M4.6M / 4.8M2.5M

Table 22.

  • Mechanism nets. The shell capacity of an element is the largest shell of that element seen at least ten times in the training steps. Eight electrons for C, N, O, F, Cl, and Br, twelve for P, S, and I, never below what the atom starts with. Every formal charge stays within a window per element, widened by one while the step progresses. Both nets are trained with AdamW, a weight decay of 10−210^{-2}, a one-cycle schedule with a warm-up over the first 5% of the updates and gradients clipped at norm 1. A step of nn atoms has n2n^2 bond places, so batches are formed by size rather than by count: steps are sorted by size, and each batch holds steps of similar size up to 2⋅1062 \cdot10^6 padded atom pairs and at most 256 steps, about 138 steps on average and 10 309 batches per epoch, in a random order per epoch. Twelve epochs are about 1.2⋅1051.2 \cdot10^5 updates. The pair head has width 64, a step fires at most 16 arrows, and validation top-1 is measured greedily on 3 000 validation steps after every epoch. At test time, seed 0 uses a beam of 10 and seeds 1 and 2 a beam of 5.

arrow netelectron net
tokenelectron pairelectron
width256256
message-passing rounds66
attention layers66
pair head width6464
epochs1212
batch (padded atom pairs)≤2⋅106\le2 \cdot10^{6}≤2⋅106\le2 \cdot10^{6}
peak learning rate5⋅10−45 \cdot10^{-4}5⋅10−45 \cdot10^{-4}
weight decay10−210^{-2}10−210^{-2}
arrows per step, at most1616
beam width at test time10 / 510 / 5
training steps1 445 1891 445 189
parameters7.3M8.2M

Table 20.

Kekulé structures in the electron net. Molecules enter both mechanism nets as Kekulé structures, in which aromatic rings are written with alternating single and double bonds, as an aromatic bond of order 23\frac{2}{3} would hold three electrons. Arrow pushing and the bond–electron matrix used by Joung et al. [2025] start from a Kekulé structure for the same reason. The valence net, in contrast, keeps aromatic bonds of order 32\frac{3}{2}, as its tokens count bond order rather than electrons, so a half token per atom is enough.

A Kekulé variant of the valence net. Every molecule is kekulised with RDKit [Landrum et al., 2026], so every bond place holds a whole number of tokens. Three changes are applied. First, a ring usually has more than one Kekulé structure, and RDKit may write a product ring in a different one than the precursor ring. This would make every bond of an unchanged ring look changed. Before the firing vector is computed, we therefore redraw each aromatic ring of the product with its double bonds in the same positions as in the precursor, using the atom map to match the atoms, so that a ring the reaction does not touch shows no bond changes. The positions are found by a maximum-weight perfect matching on the atoms that need a double bond. When no perfect matching exists, RDKit’s structure is kept. Second, the enabling rule is exact, without the half token of tolerance of Proposition 4. Third, a transition that forms a bond is also enabled only if the atom’s total bond order to heavy atoms stays within a maximum per element, measured on the training data. These are, 4 for C and N, 3 for O and 6 for S, so a spare token of capacity cannot give an atom more bonds than it can hold. With whole bond orders, the decoding rule for aromatic rings (Appendix § 9, rule 3) is no longer needed. Atom maps are computed on the aromatic molecules and transferred to the Kekulé atom order through canonical ranks, so both of the representations use the same maps.

Benchmarks

Benchmarks. Atom mapping is evaluated on the Golden set by Lin et al. [2021], whose maps were curated by chemists, on the data sets recently introduced by Phan et al. [2026], and, for enzymatic reactions, on the 41 510 reactions of EnzymeMap from Heid et al. [2023b] against their validated maps. Reaction classification uses the published split of Schneider50k, whose 50 reaction classes were assigned by the rule-based NameRxn [Schneider et al., 2015]. EC classification, predicting the enzyme commission number of an enzymatic reaction, uses three benchmarks, namely, ECREACT [Probst et al., 2022a] in the split of Liu et al. [2026], on which six methods were retrained, task 2 of CARE [Yang et al., 2024] in its easy split, and EnzymeMap at EC level 3, where we compare maps from different sources as input to the same classifier (Table 13). Forward prediction is evaluated on USPTO-MIT (USPTO-480K), the patent reactions of Jin et al. [2017] in their standard split with 40 000 test reactions, and the ablations use Schneider50k, including training sets of 1 995 and 7 973 reactions for forward prediction and of 1 000 and 250 for classification. Reaction mechanisms are evaluated on the elementary steps of FlowER [Joung et al., 2025], where the electron net predicts the products of each step and whole reactions are scored as pathways of steps. Products are compared after aromaticity is perceived again, so the Kekulé structure a ring is written in does not matter. A test reaction counts for the pathway accuracy if some route from its reactants to a recorded product has every step within the top kk.

atom mapsaccuracymacro-F1pp (accuracy)pp (macro-F1)
none, state-equation readout90.36 0.4866.80 0.77––
RXNMapper90.47 1.0067.23 1.960.870.75
minimum firing vector (the mapper)91.04 0.7467.51 1.540.260.53
EnzymeMap’s curated maps91.81 0.1269.63 0.580.030.008

Table 13. EC classification on EnzymeMap at EC level 3 (200 classes; 41 816 training and 4 715 test reactions, 10 % of every class held out), accuracy and macro-F1 in %, mean ± sample standard deviation over three seeds. The same classifier reads the firing vector of each source of atom maps: without maps, the state-equation readout reads the two sides of the reaction. pp from Welch’s test against the classifier without maps.

Capacities of the valence net. Based on the data used in our experiments, one spare token lets N, O, Cl, Br, and I share a lone pair in one extra bond, where the atom still has eight valence electrons, and carbon has none, the enabling rule thereby keeps neutral and anionic C, N, O, and halogen atoms within the octet. S and P get two spare tokens, so they can form the S=O and P=O bonds of sulfoxides and phosphine oxides, but a sulfide cannot become a sulfone in one reaction. An atom that is already cationic or hypervalent in the precursors keeps its spare token, giving it a looser budget, while a nitro nitrogen could take a fifth bond.

Data. USPTO-MIT by Jin et al. [2017] holds patent reactions from Lowe [2012], split into 409 035 training, 30 000 validation, and 40 000 test reactions with reagents among the precursors and without stereochemistry. RDKit parses 409 006 training and 39 994 test reactions [Landrum et al., 2026]. For training and model selection we keep the 401 102 reactions with at most 100 and 70 heavy atoms in the precursors and products, respectively, to speed up training. We also remove reactions with a major product in the Golden set (940 for targets of the net, 931 for precomputed maps). The test set is never filtered, the results are shares of all 40 000 reactions, and the 6 unparsable reactions count as failures. The nested 1 % and 10 % subsets are the first 4 090 and 40 900 reactions of one fixed shuffle.

Schneider50k by Schneider et al. [2015] contains 50 000 reactions from patents in 50 classes from a rule-based classifier. 49 994 are parsable by RDKit. For classification, we use the published split, 200 training reactions per class, for a total of 10 000, and 800 per class for testing, for a total of 40 000. We use 500 training reactions to choose the best epoch.

The elementary steps of FlowER [Joung et al., 2025] come from USPTO-Full reactions whose mechanisms were imputed with 1 220 expert templates for 252 reaction classes, keeping the routes that reach the recorded product, together with the curated polar and radical steps of PMechDB and RMechDB. We use the published split into 1 445 189 training, 15 744 validation and 162 002 test steps, from 250 782, 2 801 and 28 049 overall reactions. Every atom, hydrogens included, is part of the net, and 2 905 test steps (1.79 %) move single electrons.

ECREACT [Probst et al., 2022a] is used in the split released with Enzyformer [Liu et al., 2026]: 49 202 enzymatic reactions with cofactors and common by-products removed from both sides, randomly split into 39 404 training, 4 891 validation and 4 907 test reactions. Compared to the split by Probst et al. [2022a], which keeps the products of training and test reactions apart, this split is random, and as a reaction can have more than one EC number, a test reaction can occur in training under another EC number. As in Enzyformer, training and validation reactions are pooled for training, two that RDKit cannot parse are dropped, leaving 44 293. The labels are the 5 192 four-level EC numbers of all splits, and the 224 test reactions whose EC number does not occur in training count as errors.

CARE task 2 [Yang et al., 2024], easy split, holds out reactions rather than EC numbers: 55 416 training, 5 858 validation and 393 test reactions over 4 874 EC numbers, with a median of four training reactions per EC number.

EnzymeMap is used at EC level 3 with 200 classes. Its own splits hold out whole EC classes, on which a classifier can only score zero, so we hold out reactions instead: 10 % of the reactions of every class with at least three reactions go to the test set, drawn once with a fixed seed and shared by all runs, which gives 41 816 training and 4 715 test reactions.

From a marking to a product. As previously discussed, a slack token on an atom can be a hydrogen, a lone pair, or a charge, without the marking saying which. This means that decoding a marking into molecules requires a rule set. These rules only use conservation arguments, are chosen on training reactions, and run after the token game has stopped. They are:

  1. An atom whose free valence decreased first loses hydrogens and becomes an onium centre such as ammonium, once there are none left. Onium carrying a hydrogen are deprotonated.

  1. S, Se and P, and I take up tokens in steps of two without a charge, while the valence expansion of S=O and P=O, and S, Se, P, and the halogens return tokens in steps of two.

  1. In an aromatic ring, surpluses and deficits at a carbon are settled by moving a hydrogen from or to a ring nitrogen where the ring has one. These are the tautomer shifts that are hidden by bond order 32\frac{3}{2}.

  1. Total charge is conserved. This means that for every new cation, an atom that would have gained a hydrogen becomes an anion instead. Examples are N-oxides, nitro groups, and the halide counter-ions of quaternary salts.

  1. Molecules that were touched by a firing sequence and that hold two or more heavy atoms are written in neutral form. This is by convention, unless their charges pair up within the molecule as, for example, in a nitro group. Single-atom ions stay charged.

Note that the net does not record where a hydrogen comes from, so a fragment that leaves is capped with hydrogen. The record of an atom shows bond orders, hydrogens, and formal charge as ∑jbij+hi−qi\sum_j b_{ij}+h_i-q_i. This is the PP-invariant xm(i)⊤x_m^{(i)\top} of the valence net minus the fixed capacity cic_i and, for cations, minus qiq_i. In Schneider50k, this count is the same for a product atom and the precursor atom it maps to in 99.85 % of the product atoms. This is the conservation law the net enforces (Proposition 1), and it is holding in real reactions. The 0.15 % that are lost are the price of the guarantee. Furthermore, with these rules, the firing vectors reproduce the product for 99.3 % of 5 000 training reactions in Schneider50k and for 96.6 % of all 40 000 test reactions in USPTO-MIT.

The mapping metrics. On the Golden set, we follow Lin et al. [2021]. A mapping is counts as correct if its condensed graph of reaction is isomorphic to that of the curated mapping. Where the canonical atom orders of the output of RXNMapper and of our molecules differ, the molecules are matched as graphs without stereochemistry.

The forward-prediction metric. A prediction is assumed correct, if the recorded major product (the largest recorded molecule, canonical SMILES without stereochemistry, which is not contained in USPTO-MIT) is among the molecules touched by a firing and every recorded product molecule occurs in the final marking. Molecules, such as by-products and spectators omitted in the products of a data set are naturally ignored, as in other graph-edit models. All 40 000 test reactions of USPTO-MIT, including six that could not be parsed by RDKit count for the denominator.

General nets

Here we introduce a general net with continuous-time semantics that is separate from chemistry. It gives the layers of NPF when the rate law stays local, their guarantees and a test on measured metabolic fluxes against PGNN [2].

Continuous-time semantics and a local rate law

On general nets the rate law of NPF is local, meaning that for a transition tt with attributes ata_t, we set

λθ,t(m)=exp⁡(βθ(at)+∑p∈∙tgθ(mp,ep,Pre⁡(p,t)))⋅min⁡{1,enabl⁡(t,m)},(5)\lambda_{\theta,t}(m)=\exp\left(\beta_\theta(a_t)+\sum_{p\in{}^\bullet t}g_\theta(m_p,e_p,\operatorname{Pre}(p,t))\right)\cdot\min\{1,\operatorname{enabl}(t,m)\}, \tag*{(5)}

with two small multilayer perceptrons βθ\beta_\theta and gθg_\theta learning a log rate constant from the attributes of the transition and a log factor per input place. They are shared across all transitions and nets. Reading only the input places, the law is local. It vanishes when an input place is empty, as Proposition 2 requires the laws. The enabling factor is continuous, as in fluid nets. The product form is that of generalised mass action, which is g=Pre⁡(p,t)log⁡mpg=\operatorname{Pre}(p,t)\log m_p up to the enabling factor.

Forward semantics, the token-game layer

This is the continuous version of the token game described in § 5. Every transition fires at once, in a fractional amount, compared to the chemistry that fires one at a time. One round with step hh computes the demands dt=hλθ,t(m)d_t=h\lambda_{\theta,t}(m), shares out the tokens of each place, limits each transition by its scarcest input, and finally applies the state equation,

xp=1mp∑t∈p∙Pre⁡(p,t)dt,vt=dtmin⁡p∈∙tφ(xp),m+=m+Cv,φ(x)=1−e−xx,(6)x_p=\frac{1}{m_p}\sum_{t\in p^\bullet}\operatorname{Pre}(p,t)d_t,\qquad v_t=d_t\min_{p\in{}^\bullet t}\varphi(x_p),\qquad m^+=m+Cv,\qquad\varphi(x)=\frac{1-e^{-x}}{x}, \tag*{(6)}

with φ(0)=1\varphi(0)=1, φ(xp):=0\varphi(x_p):=0 when mp=0m_p=0 and some consumer has dt>0d_t>0, and with min⁡p∈∙tφ(xp):=1\min_{p\in{}^\bullet t}\varphi(x_p):=1 when ∙t=∅{}^\bullet t=\varnothing, so a source transition fires its full demand. A place with load xpx_p offers mp(1−e−xp)m_p(1-e^{-x_p}) tokens that is shared in proportion to the demands. A forward model is KK rounds with tied weights, making depth time, and h=1/Kh=1/K. For any demands, the layer conserves and stays non-negative.

Proposition 5 (Non-negativity of the token-game layer). For all dt≥0d_t\geq0 and m≥0m\geq0, the marking m+m^+ of Equation (6) satisfies m+≥0m^+\geq0, mp>0m_p>0 whenever mp>0m_p>0, and xTm+=xTmx^\mathsf{T}m^+=x^\mathsf{T}m for every PP-invariant xx.

Proof. Let out⁡p=∑tPre⁡(p,t)vt\operatorname{out}_p=\sum_t\operatorname{Pre}(p,t)v_t be the consumption at pp. If mp>0m_p>0, every consumer t∈p∙t\in p^\bullet has vt≤dtφ(xp)v_t\leq d_t\varphi(x_p) because p∈∙tp\in{}^\bullet t takes part in the minimum, therefore out⁡p≤φ(xp)∑tPre⁡(p,t)dt=φ(xp)xpmp=mp(1−e−xp)≤mp\operatorname{out}_p\leq\varphi(x_p)\sum_t\operatorname{Pre}(p,t)d_t=\varphi(x_p)x_pm_p=m_p(1-e^{-x_p})\leq m_p. If mp=0m_p=0, then either ∑tPre⁡(p,t)dt=0\sum_t\operatorname{Pre}(p,t)d_t=0, so that dt=0d_t=0 for all consumers, or the convention φ(xp)=0\varphi(x_p)=0 applies. In both cases, out⁡p=0\operatorname{out}_p=0. Therefore, mp+=mp−out⁡p+∑tPost⁡(p,t)vt≥mpe−xpm_p^+=m_p-\operatorname{out}_p+\sum_t\operatorname{Post}(p,t)v_t\geq m_pe^{-x_p}, which is non-negative, and positive if mp>0m_p>0. Finally, xTm+=xTm+xTCv=xTmx^\mathsf{T}m^+=x^\mathsf{T}m+x^\mathsf{T}Cv=x^\mathsf{T}m for every PP-invariant xx.

Therefore, each round is an enabled, continuous step of the net, which is how the layer stays a net for all weights.

Inverse semantics, the firing counts between two markings

Between two markings of a single run, NPF integrates the rate law over the elapsed time along a token game from mAm_A, whose end is pinned to mBm_B. This gives counts σ~\tilde{\sigma} and a bounded learned correction that stands in for conditioning the run on its end. A map Π\Pi then imposes the state equation σ^=Π(σ~)∈S={σ:Cσ=mB−mA}\hat{\sigma}=\Pi(\tilde{\sigma})\in S=\{\sigma:C\sigma=m_B-m_A\}, as the I-projection, the point of SS closes in Kullback-Leibler divergence to σ~\tilde{\sigma} made positive [15].

Every output is positive for all weights, meeting the state equation up to the tolerance of the solve, 0.006 to 0.019 mmol/gDW/h in Table 5. Up to this tolerance, the error has no component in im⁡CT\operatorname{im}C^{\mathsf{T}} and learning only has to resolve the part along the TT-invariants, which are the cycles that cancel. Message passing cannot substitute for this layer.

Table 5: Relative error of the fluxes of held-out cultures of E. coli, mean ±\pm sample standard deviation over three seeds for the learned models, within the studies, on a held-out study and on other carbon sources, and the balance residual ∥Cσ−(mB−mA)∥1\lVert C\sigma- (m_B - m_A)\rVert_1 within the studies, in mmol/gDW/h.

methodwithin studiesnew studynew carbon sourcebalance
NPF, GMA rate law0.114±0.0020.114 \pm0.0020.153±0.0130.153 \pm0.0130.385±0.0020.385 \pm0.0020.0060.006
NPF, rate law described in Section C.10.149±0.0070.149 \pm0.0070.157±0.0190.157 \pm0.0190.363±0.0230.363 \pm0.0230.0190.019
PGNN, GMA rate law0.119±0.0080.119 \pm0.0080.260±0.0190.260 \pm0.0190.798±0.0530.798 \pm0.0532 2162\,216
PGNN0.144±0.0230.144 \pm0.0230.280±0.0190.280 \pm0.0190.858±0.0700.858 \pm0.0701 0091\,009
PGNN+ with the state equation, GMA0.211±0.0170.211 \pm0.0170.208±0.0720.208 \pm0.0720.399±0.0250.399 \pm0.0250.0080.008
random forest, projected onto the net0.0950.0950.1610.1610.3500.3500.0000.000
random forest0.0960.0960.1700.1700.8600.8600.9440.944
ridge regression, projected onto the net0.1300.1300.1800.1800.6550.6550.0000.000
ridge regression0.0950.0950.2070.207164164172172
flux sampling0.1960.1960.1940.1940.3550.3550.0000.000
pFBA0.3260.3260.3230.3230.4750.4750.0000.000
state equation alone0.3050.3050.3020.3020.3800.3800.0010.001

Table 5.

Proposition 6 (Locality lower bound). On the path net p0→t1→p1…tL→pLp_0\to t_1\to p_1\ldots t_L\to p_L without TT-invariants and σk∗=−∑j<k(mB−mA)j\sigma_k^*=-\sum_{j<k}(m_B-m_A)_j, let ff be any estimator whose output at tkt_k depends only on the part of the input within distance rr of tkt_k in the incidence graph. If p0p_0 and pLp_L are farther than rr from tkt_k, then for every δ>0\delta>0 are two valid inputs on which ftkf_{t_k} coincides while σk∗\sigma_k^* differs by δ\delta. Therefore, sup⁡∣ftk∣≥δ/2\sup\lvert f_{t_k}\rvert\ge\delta/2 for every δ\delta that the token range admits.

Proof. The incidence matrix of the path net has the columns 1pk−1pk−1\mathbf{1}_{p_k}-\mathbf{1}_{p_{k-1}} that are linearly independent. This means that ker⁡C=0\ker C=0 and σ∗\sigma^* is determined by mB−mAm_B-m_A. Summing the state equation over p0,…,pk−1p_0,\ldots,p_{k-1} gives σk∗=−∑j<k(mB−mA)j\sigma_k^*=-\sum_{j<k}(m_B-m_A)_j. Let (mA,mB)(m_A,m_B) be a valid input with a firing sequence ss, and let mA′=mA+δ1p0m'_A=m_A+\delta\mathbf{1}_{p_0} and mB′=mB+δ1pLm'_B=m_B+\delta\mathbf{1}_{p_L} with δ>0\delta>0, a positive integer for discrete nets. As an input, this is valid as well. Firing t1,…,tLt_1,\ldots,t_L from mA′m'_A in amount δ\delta each, moves δ\delta tokens from p0p_0 to tLt_L and is enabled step by step, and then firing ss, which is enabled because enabling is monotone in the marking. Its count vector is σ∗+δ1\sigma^*+\delta\mathbf{1}. The two inputs only differ at p0p_0 and pLp_L, which are farther than rr from tkt_k, resulting in ftkf_{t_k} taking the same value on both, while the targets differ by δ\delta. One of the two errors is therefore at least δ/2\delta/2.

Results on metabolic fluxes

We cast metabolism as a Petri net whose markings are measured. With known stoichiometry, the uptake, secretion, and growth of a culture fix how metabolites change. The internal fluxes, measured by 13C{}^{13}\mathrm{C} labelling, are the firing counts to be inferred. This tests the inverse semantics on real data, against PGNN and generic regressors. We show that the net makes the fluxes balance and lets NPF transfer to new studies and carbon sources where PGNN fails, the new studies only with unmeasured by-products open, while generic regressors projected onto the net are accurate.

Data and net. Five studies estimated the central fluxes of E. coli by 13C{}^{13}\mathrm{C} metabolic flux analysis [Ishii et al., 2007, Haverkorn van Rijsewijk et al., 2011, Long and Antoniewicz, 2019, Holm et al., 2010, Gerosa et al., 2015], and 159 of their cultures are kept. The net is the core model with the reactions of iJO1366 [Orth et al., 2010, 2011] that the studies measure or need, the Entner–Doudoroff pathway, cytochrome bo3, and the uptake of galactose, gluconate and glycerol. Places are metabolites, one biomass place, and one maintenance place. A reversible reaction is a forward and a backward transition. The two markings of a culture are one hour apart, their difference is the measured uptake, secretion, and growth. The fluxes are the firing counts of each hour. Exchanges that a study did not measure stay open as sinks, except for acetaldehyde, which no source model exchanges. We use the same nets for every method.

Closed by-products. We repeat the comparison with every unmeasured carbon by-product closed (Table 6). This makes the untrained state equation worse, 0.404 against 0.305 within studies, and NPF inherits part of it. Its fluxes still balance, and on new carbon sources it stays ahead of PGNN (0.387 against 0.979, p=0.03p=0.03, all 6 cultures), but within studies PGNN is ahead (0.120 against 0.170, p<0.001p<0.001), and on a new study the two are level (0.245 against 0.256, p=0.21p=0.21). A projected random forest is the most accurate on a new study and on new carbon sources (0.154 and 0.333), and within studies the most accurate method whose fluxes balance (0.117), behind ridge regression (0.095).

Table 6: The comparison of Table 5 with every carbon by-product that a study did not measure closed, carbon dioxide the only free carbon exchange. Mean ±\pm sample standard deviation over three seeds for the learned models. NPF with the rate law of Appendix § 10.§ 1 and PGNN without read arcs were not run under this rule.

methodwithin studiesnew studynew carbon sourcebalance
NPF, GMA rate law0.170±0.0130.170 \pm0.0130.245±0.0850.245 \pm0.0850.387±0.0200.387 \pm0.0200.0110.011
PGNN, GMA rate law0.120±0.0030.120 \pm0.0030.256±0.0200.256 \pm0.0200.979±0.4380.979 \pm0.4382 0522\,052
PGNN+ with the state equation, GMA0.265±0.0880.265 \pm0.0880.355±0.1410.355 \pm0.1410.348±0.0160.348 \pm0.0162.5122.512
random forest, projected onto the net0.1170.1170.1540.1540.3330.3330.0000.000
random forest0.1120.1120.1750.1750.8690.8691.3141.314
ridge regression, projected onto the net0.1440.1440.1760.1760.6490.6490.0000.000
ridge regression0.0950.0950.2070.207164164172172
flux sampling0.2260.2260.2230.2230.3790.3790.0000.000
pFBA0.5790.5790.5770.5770.6030.6030.0000.000
state equation alone0.4040.4040.4000.4000.4060.4060.0010.001

Table 6.

Additional results

The minimum firing vector

Cost. Each mapping π\pi yields a firing vector σπ\sigma_\pi by the state equation (see Figure 3), and the mapper scores π\pi on two levels. The first level counts the bonds formed and broken, which are the bond places that σ(π)\sigma(\pi) takes from empty to marked or vice versa. The second level counts the changes of bond order on kept bonds, in half bonds as an aromatic bond has an order of 32∑kept∣Δbij∣\frac{3}{2}\sum_{\mathrm{kept}} |\Delta b_{ij}|, and the changes of formal charge, 2∑i∣Δqi∣2\sum_i |\Delta q_i|. The second level only decides between mappings that tie in the first level. This is illustrated in Figure 3, where π1\pi_1 forms one bond and breaks one, and π2\pi_2 forms and breaks three bonds each. Now note that hydrogens do not have atom numbers, which we handle in the following way: For the cost, in the first level, a hydrogen on carbon gets a bond place of its own, so that a formed or broken C–H bond counts like any other bond, but not again in the second level. Most C–H bonds do not exchange under ordinary conditions, so we assume that a change of hydrogen on carbon is a bond that was formed or broken by the reaction. A hydrogen on atoms other than carbon, mostly O, N, or S, is not counted, as proton transfer with a protic solvent or with an acid or a base exchanges the hydrogen quickly, so its number on a product atom reflects the acid-base form in which the data set writes the product rather than a bond change. Finally, a map does not need to use every precursor atom. The atoms it leaves out go into by-products that are missing on the product side, such as the Cl of HCl in Figure 3a. In Schneider50k, this happens in 99.4 % of reactions. A bond from a product atom to such an atom counts as broken, and a bond between two of them counts as unchanged.

This cost is not fitted. The levels are compared in order rather than weighted against each other, with every count having a weight of one. How the cost is defined is a design decision we made based on experimenting on 200 random reactions on the Golden set, with the remaining 1 560 held out (Table 7).

costchoiceheld outallintervalproved
bonds made and broken only83.081.0381.2579.4 to 83.199.94
+ second level, all hydrogen83.582.4482.5680.8 to 84.399.89
+ hydrogen on heteroatoms not counted85.083.4083.5881.8 to 85.399.89
+ C–H as bond places (the cost)86.083.6583.9282.2 to 85.6100.00
+ third level (the mapper)91.088.5388.8187.3 to 90.2100.00
RXNMapper85.585.5885.5783.9 to 87.2–

Table 7. Atom mapping on the Golden set. Scored by the full condensed graph of reaction, for every level of the cost, on the 200 reactions of the random choice, the 1 560 held out, and all 1 760 usable reactions with a 95 % bootstrap interval. Of the held out reactions, 112 are only mapped correctly by the best variant of our mapper, and 66 only by RXNMapper. Proved is the share of reactions where the search finishes within 60 s.

Finding the cheapest map. We use branch and bound. As the number of possible maps grows factorially with the number of atoms, the mapper doesn’t try them all. It places the product atoms on precursor atoms of the same atom type one by one, and, after each placement, bounds the cost of every way to finish the map from below. A branch whose bound exceeds the cost the search aims for is dropped. This is branch and bound. The bound compares neighbourhoods. The bonds among placed atoms are already fixed, so a product atom placed on a precursor atom with different neighbours causes at least one bond change. By matching all atoms that are not yet placed to their candidates at once and halving the sum (as a bond has two atoms) bounds the bonds formed and broken in the rest of the map, while a second assignment bounds the changes of bond order and charge. This assignment also rules out single candidates that cannot reach the target. An atom with one candidate left is placed at once, and precursor atoms a symmetry of the molecule exchanges are tried only once. The target starts at the bound of the empty map and rises by one bond at a time, making the first complete map found the cheapest. A search then collects all other maps with the same cost for the third level discussed in the next paragraph. A search that finishes proves that no cheaper maps exist.

Introducing a third level. After implementing tie-breaking levels 1 and 2, a comparison with RXNMapper showed that most of our errors were still ties between maps of equally low cost. Therefore, we chose three further terms against the curated maps of the 200 development reactions, in the following order. (1) The sum of the absolute changes of oxidation state of the product carbons, as most reactions oxidise or reduce few carbons. We chose this because a step that is not a redox step moves no electrons between carbons. (2) The number of bond places that switch between an aromatic carbon and a heteroatom, as substitution there requires activation. (3) Has the number of bond places switched between an electron sink and an atom other than a carbon. A sink is a non-aromatic atom with a double or triple bond to a more electronegative atom, which can pass an incoming electron pair to that atom and take it back. This count enters with a negative sign, so the mapper prefers a nucleophile that adds to a sink while a leaving group leaves it.

The open net for missing reactants. In 4.75 % of reactions in the Golden data set and 0.85 % in Schneider50k, the products have more atoms of a given atom type than precursors. This means that no injection exists. For these reactions, the net opens with two source transitions, one for a potentially missing precursor molecule and one for a single atom of an atom type at a deficit in the products. Each costs one unit on each level. This allows us to map all 88 Golden and 426 Schneider50k reactions that previously failed.

Table 8: The Golden set by the number of places that the curated map changes, high numbers may be one-pot or multi-step reactions. Accuracy is given in %, the reactions that only our mapper or only RXNMapper map correctly with the exact sign test, and the share of curated maps that are not minimal, as they change more places than the cheapest map. Our mapper is ahead in every bin. Curated maps that are not minimal become more common the more places change, as a mechanism with more steps is likelier to move atoms along a costlier path, and a bond that forms and breaks again is invisible for every map.

placesreactionsNPFRXNMapperonly oneppnot minimal
1 or 277295.192.738 / 200.0250.4
3 or 465887.884.846 / 260.0243.6
5 or 621282.174.530 / 140.0233.8
7 or more11865.362.716 / 130.71112.7

Table 8.

Table 9: Atom mapping on SynRXN, our mapper against each mapper from the original publication. Reactions that only our mapper maps correctly / only the other mapper, and the exact McNemar pp. The accuracies are in Table 1. Only 5 of the 382 Recon3D references are clean injections, the others reuse atom-map numbers, which caps every bijective mapper there, and 257 of the 273 of E. coli are.

EnzymeMap mapping Results of our mapping system in comparison to RXNMapping of the EnzymeMap dataset reactions Table 10.

Table 10: Atom mapping of enzymatic reactions on EnzymeMap (41 510 reactions), against its validated maps. Correct reaction centre under the validator of SynRXN, as in Table 1 in %. Only one: reactions mapped correctly by our mapper only / by RXNMapper only, with the exact sign test.

Reaction classification

Table 11 shows the results on the published split of Schneider50k. Table 12 shows the results of experiments testing whether the two classifiers of the net, namely the state-equation readout and the firing vector of the mapper, are more accurate than counterparts of the same size without the net, a generic readout that pools each side, a generic head on the same maps, and DRFP by Probst et al. [2022b] as a strong baseline. We ask where the Petri net helps.

methodnnaccuracymacro-F1
DRFP + MLP395.52 ± 0.0495.47 ± 0.04
generic readout397.74 ± 0.0197.72 ± 0.02
generic head, firing vector598.64 ± 0.0998.63 ± 0.09
NPF, state-equation readout597.68 ± 0.0997.67 ± 0.10
NPF, firing vector of the mapper598.80 ± 0.0498.80 ± 0.04

Table 11. Reaction classification on Schneider50k, published split with 200 training and 800 test reactions per class. Mean ± sample standard deviation over nn seeds. Best in bold, second underlined.

modelfull training setlarger molecules1 000 labelled alone1 000 labelled + firing task250 labelled alone250 labelled + firing task
DRFP + MLP95.52 ± 0.0478.43 ± 0.6386.62 ± 0.77–65.03 ± 1.58–
generic readout97.74 ± 0.0171.76 ± 1.0878.59 ± 1.2790.02 ± 0.1632.14 ± 1.6452.64 ± 1.33
NPF, state-equation readout without gate97.47 ± 0.1467.43 ± 1.0391.26 ± 0.2794.17 ± 0.3261.19 ± 4.2481.65 ± 3.21
NPF, state-equation readout97.68 ± 0.0971.55 ± 3.6591.57 ± 0.6494.76 ± 0.2057.01 ± 3.1986.77 ± 1.26
generic head on the firing vector98.64 ± 0.0982.83 ± 1.0393.83 ± 0.51–48.99 ± 1.31–
NPF, firing vector of the mapper98.80 ± 0.0476.07 ± 3.7595.07 ± 0.65–81.19 ± 1.27–
with the participation gate98.73 ± 0.1081.30 ± 1.4995.04 ± 0.55–79.77 ± 2.26–
CGR D-MPNN, Chemprop defaults (357K)96.83 ± 0.1263.43 ± 1.2661.25 ± 3.61–12.54 ± 2.32–
balanced reaction mode97.01 ± 0.1177.74 ± 3.0076.83 ± 5.10–9.14 ± 2.90–
width 850 (2.4M)97.61 ± 0.1372.35 ± 1.0283.33 ± 1.28–25.29 ± 3.61–
defaults, matched steps––83.39 ± 2.19–30.33 ± 1.06–
balanced, matched steps––89.18 ± 0.70–40.53 ± 2.66–
width 850, matched steps––89.02 ± 1.50–39.56 ± 2.65–

Table 12. Classification on Schneider50k, accuracy on the 39 994 test reactions of the published split, mean ± sample standard deviation over 5 seeds for the readout, the firing vector and its generic head with all labels and 3 otherwise. With 1 000 or 250 labelled reactions, 20 or 5 per class, a stratified subsample drawn with the seed of the run, alone trains on these reactions only and + firing task also on the maps of the unlabelled rest. Larger molecules trained on reactions up to the median size and tested on the largest quarter. Firing task trained with the auxiliary task on the training reactions without a label (Appendix § 9). A dash where the task does not apply, as DRFP and the CGR D-MPNN have no net to attach it to, and the firing vector already holds what it predicts. The CGR D-MPNN is Chemprop 2.3.1 on the condensed graph of reaction with the maps of the mapper, 5 seeds with all training reactions and 3 otherwise, and with a label budget and matched steps it trains for the optimiser steps of its default run on all training reactions.

Against the established baseline. The firing vector is, up to hydrogens and charges, the condensed graph of reaction counted as firings, so a D-MPNN on the condensed graph of reaction Heid and Green, 2021, which reads the same maps is the established model closest to it. We ran it with Chemprop 2.3.1 by Heid et al. [2023a] on the same training, validation, and test reactions, label draws, and size split, with the default settings of Chemprop and nothing tuned, in three arms (Table 12), namely, the default reaction mode with 357K parameters, the balanced mode, in which atoms that leave do not count as broken bonds, and the default mode with widths of 850 instead of 300 (2.4M parameters). With all training reactions and on the size split, Chemprop keeps the epoch of the lowest validation loss. With a label budget, no validation reaction enters, and Chemprop keeps the epoch of the lowest training loss. With its default 50 epochs, a label budget gives only 200 optimiser steps at 250 labels, where the training loss stayed far above zero. After these runs had been seen, we added runs with the optimiser steps of the default run on all training reactions. The CGR D-MPNN is ahead of DRFP with all training reactions (97.61 ±\pm 0.13 % at width 850) and behind the firing vector (98.80 ±\pm 0.04 %, p<0.001p < 0.001). The gap widens with fewer labels. Its best arms reach 89.18 ±\pm 0.70 % on 1 000 and 40.53 ±\pm 2.66 % on 250 training reactions, against 95.07 ±\pm 0.65 and 81.19 ±\pm 1.27 % for the firing vector (both with p<0.001p < 0.001) and 86.62 and 65.03 % for DRFP. On larger molecules its best arm, the balanced mode, reaches 77.74 ±\pm 3.00 %, level with the firing vector with the gate (81.30 ±\pm 1.49 %, p=0.17p = 0.17) and with DRFP (78.43 %).

Locality of the readout. The contribution of a matched atom through the atom terms of the class readout falls from 22.2 at the re-typed bond to 0.001 four bonds away, reaches below 10−510^{-5} for 99.8 % of the atoms four bonds away. This is predicted by Proposition 3 for the atom terms R=K=3R = K = 3. The exceptions lie near changes of attributes that are not bond changes.

Forward prediction

Targets of the forward model. The forward model is trained on the set of tied minimum firing vectors of the mapper instead of the atom maps provided by the data set. On 10 % of USPTO-MIT these targets are ahead of the supplied maps by 1.2 points, 79.72 ± 0.03 against 78.57 ± 0.04 % greedy top-1 (p<0.001p < 0.001, Table 15), and by 1.1 points on the major product, 79.48 against 78.37 %. One vector of each set reaches 79.15 ± 0.26 %, between the two (p=0.06p = 0.06 against each).

Table 15: Targets of the forward model on 10 % of USPTO-MIT, greedy and beam top-1 in % on all 40 000 test reactions under the rule of Appendix B, mean ± sample standard deviation over three seeds. Training reactions are those of the subset with a target that decodes to the product.

targetstraining reactionsgreedy top-1beam top-1
atom maps supplied in the data set39 93678.57 ± 0.0479.05 ± 0.04
mapper, set of tied vectors39 38179.72 ± 0.0380.08 ± 0.05
mapper, one vector39 38179.15 ± 0.2679.54 ± 0.25

Table 15.

Table 16: Forward prediction on our split of Schneider50k, 4 667 test reactions and 3 seeds. Greedy top-1 against the number of training reactions with a target, beam top-1 and top-5 with all of them, and the share of valence-valid predictions.

modelgreedy top-1 1 995greedy top-1 7 973greedy top-1 37 220beam top-1beam top-5valid
NPF token game84.31 ± 0.7190.34 ± 0.3493.34 ± 0.2893.39 ± 0.1898.08 ± 0.07100.00 ± 0.00
without the enabling mask84.19 ± 0.1889.82 ± 0.6493.06 ± 0.1193.13 ± 0.1298.07 ± 0.0499.98 ± 0.02
one-shot, greedy valence repair––81.60 ± 0.50––100.00 ± 0.00
one-shot, generic66.28 ± 0.5175.02 ± 0.5379.72 ± 0.22––97.21 ± 0.30

Table 16.

Reaction mechanisms

The arrow net scores 88.85 % top-1. Compared to the electron net, the difference comes entirely from steps that move single electrons. On the 98.21 % of test steps that move only pairs, the two nets match in scores, while the remaining 2 905 steps that move single electrons cannot be expressed by the arrow net. The electron net predicts 91.08 % correctly. Most of these steps are binding or release of phosphinite at palladium, whose dative bond is written as a bond between two neutral atoms by FlowER.

What does each Petri component contribute?

The Petri net buys guarantees for every value of the weights, and accuracy where training data are scarce (Table 19). Enabling keeps every prediction valence-valid and the pure readout is unmoved by atoms far from the reaction, where the generic counterparts either break a budget or change their prediction. The mask itself does not add accuracy. Playing the net one bond change at a time is more accurate at every training size, the readout and the firing vector gain most on small training sets, and neither gains on molecules larger than those in the training set. With the participation gate, they match the generic counterparts.

Firing one bond change at a time. On our split of Schneider50k, the token game predicts the product for 93.34 % of the test reactions and a one-shot model with the same encoder, which labels all bond places at once and trains on the first vector of each target set, for 79.72 %. This gap grows with fewer training reactions. A valence repair, dropping a bond formation or adding a bond break until every atom is obeying the enabling rule, thereby making every output of the one-shot model valid only lifts it to 81.60 %. We can therefore say that the accuracy comes from sequential decoding, with each bond change being chosen at the marking the previous ones produced. This is an empirical effect without a proposition. Of course, sequential graph edits are not new, see Do et al. [ [18] and Sacha et al. [2021], but here, they need neither a supervised order nor atom maps. Note that this comparison does not isolate conservation, as the one-shot model shares the firing form.

Table 19: Each Petri component against a counterpart of equal size without it on Schneider50k, with 4 667 forward test reactions, 3 seeds for forward prediction, and 3 to 5 seeds for classification. Mean ± sample standard deviation where shown, pp from a Welch test, and a dash where a proposition guarantees the value. The rows of Proposition 3 are the pure readout, ω=1\omega= 1, for which it holds. Subsamples of 1 000 and 250 training reactions, 20 and 5 per class, are stratified and drawn with the seed of the run, the same for all models of that seed. Italic, not load-bearing, as the Petri component is not significantly better, p≥0.05p \ge0.05, or is worse.

componentcriterionPetrigenericpp
one bond change at a timetop-1, all training reactions93.34 ± 0.2879.72 ± 0.22< 0.001
sametop-1, 1 995 training reactions84.31 ± 0.7166.28 ± 0.51< 0.001
enabling (Prop. 4)valence-valid products100 (all weights)97.21 ± 0.30–
enabling mask in the gametop-193.34 ± 0.2893.06 ± 0.110.22
readout (Prop. 3)% changed by a far methyl0.000.27–
sameaccuracy, 1 000 / 250 training reactions91.26 / 61.1978.59 / 32.140.002 / 0.003
sameall training reactions / larger molecules97.47 / 67.4397.74 / 71.760.08 / 0.007
with the gateall training reactions / larger molecules97.68 / 71.5597.74 / 71.760.21 / 0.93
firing vectoraccuracy, 250 training reactions81.1948.99< 0.001
against a CGR D-MPNN of equal sizeaccuracy, 1 000 / 250 training reactions95.07 / 81.1989.02 / 39.560.01 / < 0.001
sameaccuracy, 1 000 training reactions95.0793.830.06
sameall training reactions98.80 ± 0.0498.64 ± 0.090.01
samelarger molecules76.0782.830.08
with the gatelarger molecules81.3082.830.23

Table 19.

Enabling. With untrained weights on a set of 256 test reactions, none of the markings that the token game visits breaks the rule by more than half a token. As untrained weights do not know chemistry, the net and not the training keeps the products valid, while training alone does not avoid every violation. Without masks, the one-shot model exceeds the valence budget by more than half a token in 2.97 % of the predictions, the token game for none. Without the mask, the token game is as accurate and valence-valid in 99.98 % of predictions, meaning that the mask turns a learned regularity into a guarantee at no cost in accuracy because the rule removes orders but no product. On 5 000 random USPTO-MIT test reactions, the Schneider50k models without the mask break a valence budget in 0.16±0.070.16 \pm0.07 % of the predictions. The models with the mask in none at the same accuracy. The learned regularity therefore weakens where the data change, while the guarantee holds.

Readout and firing vector. Consider a methyl group attached to both sides of 4 000 test reactions, 9 or more bonds from every change. It changes no prediction of the pure readout, 0.12 % with a participation gate, and 0.27 % for a generic readout that pools each side. On the full training set, the pure readout is level with its generic counterpart (p=0.08p = 0.08). However, it trains it on test reactions larger than those in training (64.73 against 71.76 %, p=0.007p = 0.007, with the gate bringing it level to 71.55 %. On the full training set, the firing vector is ahead of its generic head (p=0.001p = 0.001) and not significantly behind it on larger molecules (p=0.08p = 0.08). However, both pay off on a stratified subsample of 250 training reactions, where the pure readout reaches 61.19 % against 32.14 % and the firing vector 81.19 % against 48.99 % for a generic mead on the same maps. On a larger subsample of 1 000, the readout stays ahead of its generic counterpart (p=0.002p = 0.002), while the lead of the firing vector is not significant with 95.07 against 93.83 % (p=0.06p = 0.06).

References

  1. [2]Alma Ademovic Tahirovic, David Angeli, Adnan Tahirovic, and Goran Strbac. Petri graph neural networks advance learning higher order multimodal complex interactions in graph structured data. Scientific Reports, 15 (1), May 2025. ISSN 2045-2322. doi:10.1038/s41598-025-01856-9. URL http://dx.doi.org/10.1038/s41598-025-01856-9.
  2. [3]Mohammad Ali, Yuta Mizuno, Seiji Akiyama, Yuya Nagata, and Tamiki Komatsuzaki. Enumeration approach to atom-to-atom mapping accelerated by using computing. Journal of Chemical Information and Modeling, 65(4): 1901–1910, February 2025. ISSN 1549-960X. doi:10.1021/acs.jcim.4c01871. URL http://dx.doi.org/10.1021/acs.jcim.4c01871.
  3. [4]Jakob L. Andersen, Sissel Banke, Rolf Fagerberg, Christoph Flamm, Daniel Merkle, and Peter F. Stadler. Pathway realizability in chemical networks. Journal of Computational Biology, 32(2):164–187, February 2025. ISSN 1557-8666. doi:10.1089/cmb.2024.0521. URL http://dx.doi.org/10.1089/cmb.2024.0521.
  4. [5]David Angeli, Patrick De Leenheer, and Eduardo Sontag. A Petri Net Approach to Persistence Analysis in Chemical Reaction Networks, page 181–216. Springer Berlin Heidelberg, 2007. ISBN 9783540719885. doi:10.1007/978-3-540-71988-5_9. URL http://dx.doi.org/10.1007/978-3-540-71988-5_9.
  5. [6]Maryam Astero and Juho Rousu. Enhancing atom mapping with multitask learning and symmetry-aware deep graph matching. Journal of Cheminformatics, 17(1), May 2025. ISSN 1758-2946. doi:10.1186/s13321-025-01030-3. URL http://dx.doi.org/10.1186/s13321-025-01030-3.
  6. [7]John C. Baez and Jacob Biamonte. Quantum techniques for stochastic mechanics. 2019. doi:10.48550/ARXIV.1209.3632. URL https://arxiv.org/abs/1209.3632.
  7. [8]Hangrui Bi, Hengyi Wang, Chence Shi, Connor Coley, Jian Tang, and Hongyu Guo. Non-autoregressive electron redistribution modeling for reaction prediction. In Marina Mella and Tong Zhang, editors, Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, pages 904–913. PMLR, 18–24 Jul 2021. URL https://proceedings.mlr.press/v139/bi21a.html.arxiv.org/abs/2106.07801
  8. [9]John Bradshaw, Matt J. Kusner, Brooks Paige, Marwin H. S. Segler, and José Miguel Hernández-Lobato. A generative model for electron paths, 2018. URL https://arxiv.org/abs/1805.10970.
  9. [10]Shuan Chen and Yousung Jung. A generalized-template-based graph neural network for accurate organic reactivity prediction. Nature Machine Intelligence, 9(4):772–780, 2022. ISSN 2522-5839. doi:10.1038/s42256-022-00526-z. URL http://dx.doi.org/10.1038/s42256-022-00526-z.
  10. [11]Shuan Chen, Sunggi An, Ramil Babazade, and Yousung Jung. Precise atom-to-atom mapping for organic reactions via human-in-the-loop machine learning. Nature Communications, 15(1), March 2024. ISSN 2041-1723. doi:10.1038/s41467-024-46364-y. URL http://dx.doi.org/10.1038/s41467-024-46364-y.
  11. [12]Shuan Chen, Kye Sung Park, Taewan Kim, Sunky u Han, and Yousung Jung. Predicting chemical reaction outcomes based on electron movements using machine learning, 2025. URL https://arxiv.org/abs/2503.10197.
  12. [13]Connor W. Coley, Wengong Jin, Luke Rogers, Timothy F. Jamison, Tommi S. Jaakkola, William H. Green, Regina Barzilay, and Klavs F. Jensen. A graph-convolutional neural network model for the prediction of chemical reactivity. Chemical Science, 10(2):370–377, 2019. ISSN 2041-6539. doi:10.1039/c8sc04228d. URL http://dx.doi.org/10.1039/c8sc04228d.
  13. [14]Gheorghe Craciun, Matthew D. Johnston, Gábor Szederkényi, Elisa Tonello, János Tóth, and Polly and Y. Yu. Realizations of kinetic differential equations. Mathematical Biosciences and Engineering, 17(1):862–892, 2020. ISSN 1551-0018. doi:10.3934/mbe.2020046. URL http://dx.doi.org/10.3934/mbe.2020046.
  14. [15]I. Csiszar. i-divergence geometry of probability distributions and minimization problems. The Annals of Probability, 3 (1), February 1975. ISSN 0091-1798. doi:10.1214/aop/1176996454. URL http://dx.doi.org/10.1214/aop/1176996454.
  15. [17]René David and Hassane Alla. Discrete, Continuous, and Hybrid Petri Nets. Springer Berlin Heidelberg, 2010. ISBN 9783642106699. doi:10.1007/978-3-642-10669-9. URL http://dx.doi.org/10.1007/978-3-642-10669-9.
  16. [18]Kien Do, Truyen Tran, and Svetha Venkatesh. Graph transformation policy network for chemical reaction prediction. In Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, KDD ’19, page 750–760, New York, NY, USA, 2019. Association for Computing Machinery. ISBN 9781450362016. doi:10.1145/3292500.3330958. URL https://doi.org/10.1145/3292500.3330958.
  17. [19]Felix A. Döppel and Martin Votsmeier. Robust mechanism discovery with atom conserving chemical reaction neural networks. Proceedings of the Combustion Institute, 40(1-4):105507, 2024. ISSN 1540-7489. doi:10.1016/j.proci.2024.105507. URL http://dx.doi.org/10.1016/j.proci.2024.105507.
  18. [21]Martin Feinberg. Foundations of Chemical Reaction Network Theory. Springer International Publishing, 2019. ISBN 978300038588. doi:10.1007/978-3-030-03858-8. URL http://dx.doi.org/10.1007/978-3-030-03858-8.
  19. [22]Eric L. First, Chrysanthos E. Gounaris, and Christodoulos A. Floudas. Stereochemically consistent reaction mapping and identification of multiple reaction mechanisms through integer linear optimization. Journal of Chemical Information and Modeling, 52(1):84–92, December 2011. ISSN 1549-960X. doi:10.1021/ci200351b. URL http://dx.doi.org/10.1021/ci200351b.
  20. [23]Luis L. Fonseca, Reinhard C. Laubenbacher, and Lucas Böttcher. Learning dynamical systems with biochemically informed neural ordinary differential equations, 2026. URL https://arxiv.org/abs/2605.24170.
  21. [24]Shinsaku Fujita. Description of organic reactions based on imaginary transition structures. 1. introduction of new concepts. Journal of Chemical Information and Computer Sciences, 26(4):205–212, November 1986. ISSN 1520-5142. doi:10.1021/ci00052a009. URL http://dx.doi.org/10.1021/ci00052a009.

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.

How machine contributions are recorded

Paper details

Citation

Cite
Published
Version
Latest

Data & code

Code, data, proofs and workflows the authors linked for testing, review and reproduction. These links are part of this work’s metadata and are released under the same license as the rest of that metadata. Valency doesn’t host the files; each keeps the license set where it’s hosted.

Contents

Pick where to look, or just type