Out-of-Distribution Generalization by Neural-Symbolic Joint Training

Anji Liu, Hongming Xu, Guy Van den Broeck, Yitao LiangAAAI 2023 · OpenReview

Abstract

This paper develops a novel methodology to simultaneously learn a neural network and extract generalized logic rules. Different from prior neural-symbolic methods that require background knowledge and candidate logical rules to be provided, we aim to induce task semantics with minimal priors. This is achieved by a two-step learning framework that iterates between optimizing neural predictions of task labels and searching for a more accurate representation of the hidden task semantics. Notably, supervision works in both directions: (partially) induced task semantics guide the learning of the neural network and induced neural predictions admit an improved semantic representation. We demonstrate that our proposed framework is capable of achieving superior out-of-distribution generalization performance on two tasks: (i) learning multi-digit addition, where it is trained on short sequences of digits and tested on long sequences of digits; (ii) predicting the optimal action in the Tower of Hanoi, where the model is challenged to discover a policy independent of the number of disks in the puzzle.

Introduction

Standard deep learning models are notorious for failing when they encounter data outside their training distribution. For example, a neural network trained to add three-digit numbers often fails completely when asked to add twenty-digit numbers, even though the underlying logic of addition remains the same. While Neuro-Symbolic (NeSy) methods attempt to fix this by combining neural perception with symbolic reasoning, most existing approaches require humans to provide ground-truth logic rules upfront or struggle with the bidirectional supervision gap between perception and reasoning.

This paper introduces NTOC (Neural to Circuit), a framework that induces task semantics with minimal priors, allowing the model to discover the underlying logic of a task while learning to perceive its inputs.

Methodology: The NTOC Framework

The authors propose a two-step iterative framework that creates a virtuous cycle between perception and reasoning.

The Logic Circuit (LC) framework for joint neural-symbolic training
  1. Neural Model Learning: The neural network ($f_\phi$) predicts "probabilistic facts" (e.g., identifying a digit in an image). These facts are fed into a Logic Circuit (LC) ($g_\theta$), which represents a weighted set of logical rules. The system is trained by minimizing a modified Semantic Loss, encouraging the neural network to make predictions that satisfy the currently learned rules.
  2. Symbolic Rule Search: This is the discovery phase. Instead of picking from a predefined list of rules, the algorithm performs structure learning on the Logic Circuit. It starts with a "tautology" and iteratively uses a SPLIT operation to refine the circuit, pruning away logical possibilities that do not fit the training data.

Unlike standard logic engines, Logic Circuits are differentiable computation graphs. This allows the model to backpropagate gradients from the reasoning layer back to the perception layer, enabling efficient joint training.

Experimental Evaluation

The NTOC model was evaluated on two primary tasks designed to test out-of-distribution (OOD) generalization:

Overview of the multi-digit addition and Tower of Hanoi tasks
  • Multi-digit Addition: The model is trained on sequences of MNIST images representing 3-digit numbers and tested on sequences of 5, 10, and 20 digits.
  • Tower of Hanoi: The model must predict the optimal next move. It is trained on puzzles with 5 disks and tested on 7 or 9 disks. MNIST digits represent disk sizes to ensure the model must learn to perceive relative sizes.

Key Results and Insights

NTOC significantly outperformed standard neural architectures (LSTM and DNC) and remained competitive with models provided with ground-truth rules.

  • OOD Performance: On 20-digit addition, NTOC maintained 68.6% accuracy, while standard LSTMs dropped to 35.1%. In the Tower of Hanoi task, NTOC achieved 84.3% accuracy, compared to 65.4% for the Differentiable Neural Computer (DNC).
  • Invariant Features: The core insight is that while the input scale changes (more digits or disks), the underlying logic is invariant. By forcing the neural network to provide facts for a symbolic reasoner, the network is incentivized to learn invariant features (like digit identity) that generalize across any task scale.
  • Efficiency: Because Logic Circuits are represented as computation graphs, NTOC avoids the expensive compilation steps required by other symbolic methods, making it more scalable.

Conclusion

NTOC demonstrates that joint neural-symbolic training can effectively induce task semantics and achieve robust OOD generalization. While the model currently requires minimal primitive pretraining, future work will explore more complex structure learning and application to diverse scenarios like robotic manipulation or complex planning.

Summary updated

Abstract

This paper develops a novel methodology to simultaneously learn a neural network and extract generalized logic rules. Different from prior neural-symbolic methods that require background knowledge and candidate logical rules to be provided, we aim to induce task semantics with minimal priors. This is achieved by a two-step learning framework that iterates between optimizing neural predictions of task labels and searching for a more accurate representation of the hidden task semantics. Notably, supervision works in both directions: (partially) induced task semantics guide the learning of the neural network and induced neural predictions admit an improved semantic representation. We demonstrate that our proposed framework is capable of achieving superior out-of-distribution generalization performance on two tasks: (i) learning multi-digit addition, where it is trained on short sequences of digits and tested on long sequences of digits; (ii) predicting the optimal action in the Tower of Hanoi, where the model is challenged to discover a policy independent of the number of disks in the puzzle.
BibTeX
@inproceedings{liu2023out,
  author = {Anji Liu and Hongming Xu and Guy Van den Broeck and Yitao Liang},
  title = {{Out-of-Distribution Generalization by Neural-Symbolic Joint Training}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2023},
  url = {https://openreview.net/forum?id=Uo8B2EPRtt},
}
Figure