Semantic Strengthening of Neuro-Symbolic Learning

Kareem Ahmed, Kai-Wei Chang, Guy Van den Broeck

Abstract

Numerous neuro-symbolic approaches have recently been proposed typically with the goal of adding symbolic knowledge to the output layer of a neural network. Ideally, such losses maximize the probability that the neural network’s predictions satisfy the underlying domain. Unfortunately, this type of probabilistic inference is often computationally infeasible. Neuro-symbolic approaches therefore commonly resort to fuzzy approximations of this probabilistic objective, sacrificing sound probabilistic semantics, or to sampling which is very seldom feasible. We approach the problem by first assuming the constraint decomposes conditioned on the features learned by the network. We iteratively strengthen our approximation, restoring the dependence between the constraints most responsible for degrading the quality of the approximation. This corresponds to computing the mutual information between pairs of constraints conditioned on the network’s learned features, and may be construed as a measure of how well aligned the gradients of two distributions are. We show how to compute this efficiently for tractable circuits. We test our approach on three tasks: predicting a minimum-cost path in Warcraft, predicting a minimum-cost perfect matching, and solving Sudoku puzzles, observing that it improves upon the baselines while sidestepping intractability.

Introduction: The Challenge of Logical Constraints

Neural networks excel at feature extraction from raw data but often struggle with rigid symbolic rules, such as ensuring every number in a Sudoku row is unique. Neuro-symbolic (NeSy) learning attempts to bridge this gap by incorporating logical constraints into the training objective. The ideal goal is to maximize the probability that a network's output satisfies these rules. However, exact probabilistic inference for complex constraints is often #P-hard, forcing researchers to choose between computationally expensive exact methods or imprecise "fuzzy" approximations.

To maintain efficiency, many NeSy methods assume that different logical constraints are independent. For example, in a Sudoku puzzle, one might assume the constraint for a row is independent of the constraint for a column. However, these constraints often overlap at specific decision points (cells). When the network receives conflicting signals—where one constraint pushes for a '3' and another for a '4'—the resulting "misaligned gradients" hinder effective learning.

Conflicting constraints in a Sudoku puzzle illustrate the gradient conflict problem.

Proposed Method: Semantic Strengthening

The authors introduce Semantic Strengthening, an iterative framework that balances efficiency with semantic rigor. Instead of trying to compile the entire massive logic of a problem upfront, the method uses the neural network's current state to guide which parts of the logic need to be joined. The process follows three key steps:

  1. Initial Independence: The process begins by assuming all logical constraints are independent, allowing for fast initial training.
  2. Identifying Dependencies: The model uses Conditional Mutual Information (CMI) to detect which pairs of constraints are most strongly dependent given the current features learned by the network. High CMI indicates that the independence assumption is significantly degrading the model's logical consistency.
  3. Iterative Merging: Periodically, the algorithm selects the top dependent constraint pairs and merges them into a single joint constraint.

To ensure these computations remain tractable, the method utilizes Sentential Decision Diagrams (SDDs). These are a type of tractable probabilistic circuit that allows for exact and efficient calculation of probabilities and CMI, provided the circuits share a compatible structure.

A tractable probabilistic circuit (SDD) used to compute exact probabilities for logical constraints.

Experimental Results

Semantic Strengthening consistently outperformed both standard neural networks and common NeSy baselines (like Product t-norms) across three structurally demanding tasks:

  • Warcraft Shortest Path: Predicting optimal paths on 12x12 terrain grids. The method achieved 61.20% exact accuracy, significantly outperforming the 50.40% baseline.
  • Sudoku: Solving puzzles with missing entries. Semantic Strengthening reached 28.00% accuracy, compared to 22.10% for fuzzy logic baselines.
  • MNIST Perfect Matching: Finding minimum-cost matchings based on digit values.

Despite the added logical rigor, the computational overhead remained minimal. For the Warcraft task, the process added only about 2-3 seconds per training iteration.

Conclusion

Semantic Strengthening offers a middle ground in neuro-symbolic learning. By using the neural network's state to guide the selective merging of logical constraints, it avoids the computational explosion of exact inference while maintaining sound probabilistic semantics. This approach effectively mitigates gradient conflict, allowing deep learning models to master complex symbolic tasks more reliably.

Summary updated

BibTeX
@inproceedings{ahmed2023semantic,
  author = {Kareem Ahmed and Kai-Wei Chang and Guy Van den Broeck},
  title = {{Semantic Strengthening of Neuro-Symbolic Learning}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2023},
  url = {https://openreview.net/forum?id=VQIKKAWAHE},
}
Figure