Abstract
Sum-Product-Attention Networks (SPAN) combine the tractable, exact reasoning of Probabilistic Circuits (PCs) with the representational power of Transformer self-attention. By using attention to dynamically select relevant sub-structures for a given input, SPAN achieves state-of-the-art density estimation with smaller, more efficient architectures. This hybrid approach preserves probabilistic guarantees while leveraging the "gating" capabilities of modern deep learning.
Introduction
Machine learning often faces a fundamental trade-off between expressivity and tractability. Deep learning models like Transformers are highly expressive, capturing complex dependencies through self-attention, but they lack the ability to perform exact probabilistic queries such as marginalization. Conversely, Probabilistic Circuits (PCs), like Sum-Product Networks (SPNs), offer tractability but require massive structures to model complex data, leading to high memory and training costs.
SPAN addresses this by asking whether self-attention can guide a PC to focus on the most relevant parts of its structure for a specific input.
Architecture and Methodology
The core of SPAN is the augmentation of a standard Sum-Product Network—specifically an "Einsum Network" (EiNet)—with Transformer encoders.
The Gating Mechanism
For every product layer in the SPN, a corresponding Transformer encoder processes the input $x$ to generate attention weights. These weights are used to dynamically re-calculate the weights of the "sum nodes" in the circuit. In effect, the Transformer acts as a smart gate, directing the circuit to prioritize specific sub-structures based on the input features.
Training Regime
The authors employ a three-phase training strategy:
- Warm-up: Initial training of the SPN alone.
- Coordinate Descent: Iterative updates to both the Transformer and SPN components.
- Fine-tuning: Final optimization of SPN weights with a fixed Transformer.
Experimental Setup
SPAN was evaluated across several benchmarks:
- 20 Binary Datasets: Standard density estimation tasks (e.g., NLTCS, Netflix) with variable counts ranging from 16 to 1,500.
- SVHN (Street View House Numbers): A complex image dataset for real-world testing.
- Out-of-Distribution (OOD) Detection: Testing model robustness by evaluating SVHN-trained models on MNIST, Semeion, and CIFAR10.
Discussion: Visualizing Focus
A key insight from the study is that SPAN creates a sparse, focused activation pattern compared to traditional EiNets, which tend to spread weights more uniformly across child nodes.
This visualization confirms that the attention mechanism is effectively "selecting" specific sub-circuits, allowing a "thinner" model to match or exceed the performance of much larger traditional networks.
Results
- Density Estimation: SPAN outperformed baseline EiNets on 17 of 20 binary datasets, setting new state-of-the-art results on 7 of them.
- Efficiency: Even in "thin" configurations with fewer internal nodes, SPAN maintained superior performance, demonstrating that attention is a powerful substitute for raw model size.
- Generative Quality: On SVHN, SPAN achieved higher log-likelihoods and produced cleaner image reconstructions than the baseline.
- OOD Robustness: The model reliably assigned lower probabilities to unseen "alien" datasets, proving effective for anomaly detection.
Conclusion and Future Work
While SPAN successfully bridges the gap between Transformers and PCs, some limitations remain. Currently, the Transformer encoder is deactivated during marginalization to maintain tractability. Future research will focus on keeping the attention mechanism active during all inference types and optimizing the embedding layer for datasets with thousands of variables.
Summary updated