Abstract
Neural networks often struggle to adhere to logical constraints or "common sense" rules, such as hierarchical relationships in classification. This paper introduces Semantic Conditioning at Inference (SCI), a neurosymbolic technique that enforces logical constraints exclusively during the inference stage. By decoupling logical rules from the training process, SCI guarantees semantically consistent outputs and improves accuracy across model scales—from tiny networks to large-scale architectures—without the computational rigidity of traditional neurosymbolic training.
Introduction
While neural networks excel at pattern recognition, they frequently produce logically inconsistent predictions. For instance, in hierarchical tasks, a model might identify an image as a "Husky" but fail to classify it as a "Dog." Existing neurosymbolic AI methods often attempt to integrate logic into the training process via specialized loss functions or architectures. However, this approach introduces significant computational complexity (often NP-hard) and creates a rigid "entanglement" between logical knowledge and neural weights, necessitating full retraining if background knowledge changes.
The authors propose a framework that leverages background knowledge efficiently, guarantees consistent outputs, and maintains the flexibility required for large-scale foundation models.
Methods: The SCI Framework
The proposed "pseudo-functional" framework decomposes a classification system into three distinct modules: a Parametric Model (the neural network), a Loss Module, and an Inference Module.
The study evaluates four primary approaches:
- Independent Multi-label Classification (IMC): A standard baseline where labels are predicted independently.
- Semantic Regularization (SR): Logic is added as a penalty term in the loss function (Semantic Loss), encouraging but not guaranteeing consistency.
- Semantic Conditioning (SC): Logic is applied to both the loss function and the inference step.
- Semantic Conditioning at Inference (SCI): The primary contribution. Training remains standard (like IMC), but the inference module uses Maximum A Posteriori (MAP) estimation to find the most likely state satisfying logical constraints.
SCI ensures semantic consistency, meaning the output is guaranteed to follow defined rules, a significant advantage over regularization methods.
Experimental Evaluation
The researchers evaluated these methods across three datasets of increasing complexity: MNIST (one-and-only-one constraint), CIFAR-100 (hierarchical), and ImageNet (complex 271-class WordNet hierarchy).
Key Results and Insights
The empirical results highlight the effectiveness of decoupling logic from training.
Consistency and Accuracy
SCI and SC achieved 100% semantic consistency, whereas IMC and SR frequently produced logically impossible outputs. On ImageNet, SCI provided a consistent accuracy boost over the baseline. Notably, as model size increased, the neurosymbolic models maintained a lead of approximately 2-3% in exact match accuracy.
Scalability and Modularity
By applying logic only at inference, SCI allows for frugality and modularity. Pre-trained models can be enhanced with different logical constraints at runtime without retraining. Furthermore, SCI avoids the "counting problem" during training, making it significantly more scalable for complex logical formulas than training-integrated logic.
The Scale Factor
Testing across a multi-scale methodology revealed that while the relative benefit of logic decreases as models grow larger, the performance gain never vanishes. This suggests that logical background knowledge remains a valuable asset even for high-capacity models.
Conclusion
Semantic Conditioning at Inference (SCI) offers a robust path forward for neurosymbolic AI. By ensuring logical consistency at the inference stage, it provides accuracy gains and architectural flexibility without the overhead of complex training regimes. Future work may explore automated knowledge extraction to learn rules directly from data and investigate the framework's performance under weak supervision.
Reference: Ledaguenel, A., Hudelot, C., & Khouadjia, M. (2024). Improving Neural-based Classification with Logical Background Knowledge. arXiv:2402.13019v1 [cs.AI].
Summary updated