SymFormer: Structural Biases in Transformers
- SymFormer is a family of transformer models that integrates explicit structural and symmetry priors for diverse tasks including symbolic regression, circuit structure learning, PDE solving, and TB diagnosis.
- In symbolic regression, it uniquely predicts both formula symbols and constants via an encoder–decoder architecture with local gradient refinement, achieving near-perfect R² scores.
- Other variants employ tree-relative self-attention, grammar-constrained decoding, and symmetry-aware mechanisms to improve inference efficiency and accuracy in their specific domains.
Searching arXiv for papers using the term "SymFormer" to ground the article. SymFormer is a model name used in multiple arXiv works for transformer-based architectures that encode domain structure directly into generation or perception pipelines. Existing uses include end-to-end symbolic regression, grammar-constrained generation of probabilistic-circuit structures inside SymCircuit, structure-aware symbolic PDE solving inside SymPlex, and bilateral-symmetry-aware chest X-ray diagnosis (Vastl et al., 2022, Ju, 20 Mar 2026, Park et al., 3 Feb 2026, Liu et al., 2023). The shared label does not denote a single canonical architecture; rather, it has been attached to several systems that replace or augment vanilla sequence modeling with explicit inductive biases such as joint symbol-and-constant prediction, tree-relative self-attention, grammar masking, traversal-aware positional encoding, or symmetry-constrained attention.
1. Scope of the name
A common source of confusion is that "SymFormer" refers to several distinct models rather than one standardized design. In the cited literature, the name appears in four technically separate settings: symbolic regression, tractable probabilistic circuits, symbolic PDE solving, and computer-aided tuberculosis diagnosis (Vastl et al., 2022, Ju, 20 Mar 2026, Park et al., 3 Feb 2026, Liu et al., 2023).
| Paper | Domain | Defining mechanism |
|---|---|---|
| "SymFormer: End-to-end symbolic regression using transformer-based architecture" (Vastl et al., 2022) | Symbolic regression | Encoder–decoder transformer that predicts formula symbols and corresponding constants simultaneously |
| "SymCircuit: Bayesian Structure Inference for Tractable Probabilistic Circuits via Entropy-Regularized Reinforcement Learning" (Ju, 20 Mar 2026) | Probabilistic circuit structure learning | Grammar-constrained autoregressive Transformer with tree-relative self-attention |
| "SymPlex: A Structure-Aware Transformer for Symbolic PDE Solving" (Park et al., 3 Feb 2026) | Symbolic PDE solving | Structure-aware Transformer with tree-relative self-attention and grammar-constrained autoregressive decoding |
| "Revisiting Computer-Aided Tuberculosis Diagnosis" (Liu et al., 2023) | Chest X-ray TB diagnosis | Unified two-head network with Symmetric Search Attention and Symmetric Positional Encoding |
This multiplicity is not merely terminological. Each SymFormer instantiation is tied to a different object of prediction: formula tokens and real constants, probabilistic-circuit structures, symbolic expression trees for PDEs, or chest X-ray feature maps and diagnosis heads. A plausible implication is that the name functions as a family resemblance marker for structure-aware or symmetry-aware Transformer variants rather than as a unique model specification.
2. SymFormer for symbolic regression
In symbolic regression, SymFormer is an encoder–decoder transformer that, in one forward pass, takes a bag of observed pairs and produces an autoregressive sequence of formula symbols together with a set of real-valued constants (Vastl et al., 2022). The encoder first projects each by a learned affine layer into a latent vector of dimension . It then applies several induced-set cross-attention blocks, following Lee et al. 2019, to compress the variable number of points into a fixed set of seed vectors, and a final cross-attention with a small set of trainable queries yields a matrix summarizing the dataset. The decoder is autoregressive, with masked self-attention over past tokens, and at each step receives the embedding of the previously generated symbol plus positional encoding and the latest real-valued constant after projection into the same model dimension. Two heads are placed on top of the final decoder layer: a symbol head, implemented as linear plus softmax over vocabulary , and a constant head, implemented as a linear layer outputting a scalar when the symbol head chooses a constant token.
The paper’s main architectural departure from earlier transformer-based symbolic regression is joint symbol-and-constant prediction. Formulae are represented in prefix notation, and every constant is replaced by a token with exponent index . A true constant 0 is decomposed approximately as
1
with 2 and 3, where 4. The decoder predicts 5 and outputs 6 as the real constant. Small integers 7 are directly in the vocabulary so that exact small constants need not pass through continuous regression.
The probabilistic factorization is defined over both token sequence and constants:
8
At constant positions, 9 is taken to be a Gaussian with mean given by the constant head. Training uses teacher forcing with a symbolic cross-entropy loss and a constant regression loss,
0
where 1 is ramped from 2 to 3 over the first 4 steps via a cosine schedule. Gaussian noise is added to each ground-truth constant during training and annealed to 5. The synthetic training corpus comprises 6 univariate and 7 bivariate formulas, simplified via SymPy and filtered if too large, numerically singular, or constant. Training uses Adam, batch size 8, a Vaswani-style learning-rate schedule divided by 9, and 0 epochs on 1A100 GPUs in approximately 2.
Inference is staged. Symbolic search uses Top-3 sampling with 4 to generate candidate token sequences. Constant initialization reads off the predicted mantissas directly. Local refinement then holds the tree structure fixed and optimizes real constants with BFGS or simple Adam to minimize MSE on the observed points. Final selection chooses the refined formula with the lowest MSE or highest 5.
Empirically, the paper reports on 6 in-domain test formulas: univariate SymFormer without refinement reaches 7 and 8, while adding local gradient search yields 9 and 0; bivariate SymFormer plus local gradient search yields 1 and 2. On standard benchmarks—Nguyen, R, Livermore, Koza, Keijzer, Constant, and Koza-2—the reported overall median is 3 at 4 per equation, compared with 5 at 6 for NSRS and 7 at 8 for DSO. The ablation on constant encoding reports that "Full SymFormer" (extended scientific encoding plus local gradient search) achieves 9 and 0. The paper states that SymFormer outperforms two state-of-the-art methods while having faster inference. Its listed limitations are a fixed sampling distribution, a maximum input dimension of 1, and difficulty with very deep or highly nested functions.
3. SymFormer inside SymCircuit
In SymCircuit, SymFormer is the core generative policy network for probabilistic-circuit structure learning (Ju, 20 Mar 2026). It implements a distribution 2 over PC structures 3 by emitting a pre-order traversal sequence of tokens from a fixed vocabulary derived from a context-free grammar 4. The grammar enforces the two PC invariants—decomposability and smoothness—by construction:
5
To eliminate arity ambiguity, each 6 and 7 is a distinct token.
Architecturally, SymFormer is a standard Transformer decoder with three key augmentations. First, tree-relative self-attention adds a learned scalar bias 8 to the standard attention score, where 9 is the tree relation in the partial parse:
0
Second, dynamic grammar masking maintains a grammar state 1 and computes the valid next-token set 2 in 3; all logits for invalid tokens are set to 4, so 5 for invalid choices. Third, traversal-aware positional encoding augments token embeddings with a sinusoidal encoding of depth in the partial tree rather than absolute sequence position. The paper states that these mechanisms ensure that SymFormer can represent any distribution over valid PC structures up to a bounded depth, citing Theorem 4.1 in Park et al. 2026, and that every sampled sequence is guaranteed to decode to a decomposable, smooth PC.
The training framework is entropy-regularized RL-as-inference. SymFormer is trained jointly with per-structure parameters 6 by maximizing
7
where 8 is an imitation-pretrained prior policy. The unique optimal policy under this objective is
9
with 0. Since 1, the policy may be written as
2
Setting 3 recovers exactly the Bayesian posterior, while the implementation uses 4 so that 5, yielding a tempered posterior that encourages exploration and smooths learning dynamics.
The paper’s main variance-reduction device is option-level REINFORCE. Rather than applying REINFORCE to all token decisions,
6
it restricts the estimator to structural decisions 7:
8
Under mild i.i.d. assumptions, the signal-to-noise ratio improves by a factor 9 over the token-level estimator. On NLTCS, the paper reports 0–1 and 2–3, implying a 4–5 SNR boost and a 6 sample-efficiency gain in circuits evaluated to reach a target likelihood. More concretely, option-level REINFORCE reaches the same held-out log-likelihood in approximately 7 circuits (8 epochs) that token-level methods require approximately 9 circuits to match. The paper also reports that adding an option-level critic head yields near-zero explained variance on NLTCS and brings no improvement.
The empirical characterization extends beyond likelihood. On NLTCS, SymCircuit closes 0 of the gap to LearnSPN. A three-layer uncertainty decomposition with 1 samples attributes 2 of total predictive variance to structural variance, approximately 3 to parameter variance, and 4 to leaf variance. On Plants, with 5 variables, the paper reports that after 6 epochs it closes 7 of the gap to LearnSPN and that the same option-level REINFORCE setup scales to token sequences of length approximately 8–9. Vocabulary expansion to larger-arity sum nodes slows convergence because of the larger action space, and preliminary results suggest scalability rather than full parity with greedy baselines.
4. SymFormer inside SymPlex
In SymPlex, SymFormer is a structure-aware Transformer for generating symbolic expression trees under PDE constraints (Park et al., 3 Feb 2026). The model is described as a Transformer-decoder stack with three modifications relative to a vanilla sequence-based Transformer: traversal-aware positional encoding that preserves prefix-order information, tree-relative multihead self-attention that injects discrete learnable biases based on the current partial AST, and grammar- and depth-constrained autoregressive decoding that guarantees every generated prefix is a valid partial syntax tree.
The partial AST is reconstructed from the current prefix by reading off node arities and filling frontier slots in prefix order. For every pair of token positions 00, SymFormer computes a discrete relation
01
Each relation type is embedded in a learnable vector 02, one per attention head. In head 03, the model uses projections 04, 05, and 06, and adds the relation bias to the keys before taking dot products:
07
The paper also gives an equivalent scalar-bias view, emphasizing that attention is conditioned on the evolving tree structure rather than on sequence order alone.
Autoregressive decoding is constrained in three ways. The arity grammar restricts the next choice to tokens of the required arity. The remaining depth budget ensures that the minimal subtree rooted at the chosen token fits within the maximum depth 08. Degeneracy filtering can reject trivial subtrees such as 09 or 10. Because only valid tokens survive the mask, every prefix remains a well-formed partial AST. The paper further states that the model’s hidden representations depend only on the underlying partial AST up to bounded depth, citing Theorem 3.1 in Appendix A.
Training is reinforcement learning without access to ground-truth symbolic solutions. A training iteration samples expression trees from the policy, optimizes continuous constants by gradient descent on the PDE and boundary-condition residuals, computes
11
with an additional 12 term if the PDE is time-dependent, and converts this to reward
13
The algorithm also updates a top-14 memory with structural and semantic diversity, applies a policy loss
15
and adds an imitation loss over the memory. The depth-weight 16 discourages overly deep trees, and 17 is the state-wise entropy.
The paper positions this design against numerical and neural approaches that approximate PDE solutions in discretized or implicit function spaces. SymPlex instead operates directly in symbolic expression space, and the abstract reports exact recovery of non-smooth and parametric PDE solutions using deep learning-based symbolic methods. This suggests a specific role for SymFormer in domains where grammatical validity and hierarchical symbolic dependencies are central, and where sparse, delayed rewards must be integrated into end-to-end learning.
5. SymFormer for computer-aided tuberculosis diagnosis
In chest X-ray analysis, SymFormer is a unified two-head network for TB infection-area detection and CXR-image classification (Liu et al., 2023). The architecture comprises a backbone plus Feature Pyramid Network, a Symmetric Abnormity Search module on every FPN output, and two diagnosis heads. The backbone may be CNN- or transformer-based, including ResNet-50 and P2T-Small, and the FPN produces four feature maps. Each SAS block shares weights across scales and contains Symmetric Positional Encoding, Symmetric Search Attention, and a small feed-forward network with MLP and residual connection. The detection head is based on RetinaNet or Deformable DETR and includes a box-classification branch for active TB and latent TB using Focal Loss and a box-regression branch using Smooth 18 Loss. The image-classification head consists of five 19 Conv20ReLU layers, global average pooling, one fully connected layer, and a softmax over healthy, sick non-TB, and TB.
The key inductive bias is bilateral symmetry. SymAttention is motivated by the observation that chest X-rays exhibit approximate left-right symmetry and that radiologists often compare symmetric locations to identify anomalies. Accordingly, each spatial location attends only to a small neighborhood around its bilaterally symmetric counterpart rather than to the whole image. If 21 is the reference position, the bilaterally symmetric center is
22
The module learns coordinate offsets and attention weights, samples around the symmetric center, and fuses the result with residual and MLP layers.
Because clinical chest X-rays are not perfectly symmetric, the model adds Symmetric Positional Encoding. SPE computes an absolute positional encoding, splits it into left and right parts, predicts a small affine transform with an STN, transforms and flips the right-side encoding, and reassembles a symmetry-aware positional prior that is added to the feature map. The STN micro-architecture is specified as two repetitions of MaxPool23Conv24ReLU, followed by flattening and a small MLP initialized to the identity transform.
Training proceeds in two stages. Stage 1 trains backbone, SAS, and detection head on TB images only and optimizes the detection loss. Stage 2 freezes the backbone and detection head, trains only the image-classification head on all images, and optimizes the image-level cross-entropy. At test time, images classified as non-TB have their detected boxes discarded, which the paper states reduces false positives. The implementation uses input resizing to 25, random horizontal flip, and Stage 2 augmentation with half of MC+Shenzhen and DA+DB data.
The empirical evaluation is centered on the TBX11K dataset. On the TBX11K test set, SymFormer with RetinaNet achieves 26 accuracy, 27 AUC, specificity 28, and AP/AR approximately 29; with Deformable DETR it achieves 30 accuracy and 31 AUC. The paper reports that this outperforms experienced radiologists at 32 accuracy. For detection, baseline RetinaNet yields category-agnostic 33 of approximately 34 on all images and 35 on TB images only, while SymFormer with RetinaNet reaches 36 and 37, respectively. Active TB 38 improves from 39 to 40 on all images and from 41 to 42 on TB images only; latent TB remains difficult, improving from 43 to 44 on all images and from 45 to 46 on TB images only. The ablation table reports the best validation result for category-agnostic TB as 47 48 with SymAttention plus SPE with STN. Four-fold cross-validation yields approximately 49 accuracy and approximately 50 51.
The limitations are domain-specific. The paper states that the method relies on roughly frontal, reasonably aligned CXR images; severe rotation or off-center crops may break the symmetry prior. Latent TB detection remains weak because of few training examples, and localization is coarse, with high 52 but low COCO-style AP.
6. Recurrent motifs and terminological ambiguity
Across the four works, "SymFormer" denotes different architectures, but each version introduces an explicit structural prior in place of unconstrained token or feature processing (Vastl et al., 2022, Ju, 20 Mar 2026, Park et al., 3 Feb 2026, Liu et al., 2023). In symbolic regression, the prior takes the form of joint symbol-and-constant prediction with a specialized constant encoding. In SymCircuit and SymPlex, it appears as tree-relative self-attention and grammar-constrained autoregressive decoding. In chest X-ray diagnosis, it appears as bilateral-symmetry-aware feature recalibration and sparse attention around mirrored coordinates.
The overlap between SymCircuit and SymPlex is especially close, though not identical. Both use tree-relative self-attention and grammar-constrained decoding for hierarchical symbolic objects. However, SymCircuit uses a learned scalar bias over five tree relations—parent, child, sibling, ancestor, and other—together with dynamic grammar masking over probabilistic-circuit productions, whereas SymPlex uses learnable relation vectors over six relation types, including self, and adds depth-budget and degeneracy constraints for expression trees. These are not interchangeable formulations, even though they share a related design vocabulary.
A common misconception is therefore that SymFormer names a single model family with stable semantics across papers. The literature summarized here does not support that view. A more accurate reading is that the label has been reused for transformer variants specialized to symbolic structure or symmetry structure. This suggests that any reference to "SymFormer" requires immediate disambiguation by domain and paper identifier: symbolic regression (Vastl et al., 2022), probabilistic circuits in SymCircuit (Ju, 20 Mar 2026), symbolic PDE solving in SymPlex (Park et al., 3 Feb 2026), or TB diagnosis on TBX11K (Liu et al., 2023).