This is the implementation of NeurASP: Embracing Neural Networks into Answer Set Programming.
Lab page
NeurASP is a simple extension of answer set programs by embracing neural networks. By treating the neural network output as the probability distribution over atomic facts in answer set programs, NeurASP provides a simple and effective way to integrate sub-symbolic and symbolic computation. This repository includes examples to show
- how NeurASP can make use of pretrained neural networks in symbolic computation and how it can improve the perception accuracy of a neural network by applying symbolic reasoning in answer set programming; and
- how NeurASP is used to train a neural network better by training with rules so that a neural network not only learns from implicit correlations from the data but also from the explicit complex semantic constraints expressed by ASP rules.
- We assume Anaconda is installed. One can install it according to its installation page.
- Clone this repo:
git clone https://github.com/azreasoners/NeurASP
cd NeurASP
- Create a virtual environment
neurasp
. Install clingo (ASP solver) and tqdm (progress meter).
conda create --name neurasp python=3.9
conda activate neurasp
conda install -c potassco clingo=5.5 tqdm
- Install Pytorch according to its Get-Started page. Below is an example command we used on Linux with cuda 10.2. (PyTorch version 1.12.0 is tested.)
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
We provide 3 inference and 5+4 learning examples as shown below. Each example is stored in a separate folder with a readme file.
- MNIST Addition
- Shorstest Path
- Sudoku Solving
- Top-k
- Most Reliable Path
- Examples from NeuroLog paper: add2x2, apply2x2, member3, member5
You may also be interested in our work Injecting Logical Constraints into Neural Networks via Straight-Through-Estimators. Its codes are available here.
Please cite our paper as:
@inproceedings{ijcai2020p243,
title = {NeurASP: Embracing Neural Networks into Answer Set Programming},
author = {Yang, Zhun and Ishay, Adam and Lee, Joohyung},
booktitle = {Proceedings of the Twenty-Ninth International Joint Conference on
Artificial Intelligence, {IJCAI-20}},
publisher = {International Joint Conferences on Artificial Intelligence Organization},
editor = {Christian Bessiere},
pages = {1755--1762},
year = {2020},
month = {7},
note = {Main track},
doi = {10.24963/ijcai.2020/243},
url = {https://doi.org/10.24963/ijcai.2020/243},
}