# Citation
If you find our code useful or use it in your own projects, please cite our paper:
```bibtex
@inproceedings{abdessaied22_coling,
author = {Abdessaied, Adnen and Bâce, Mihai and Bulling, Andreas},
title = {{Neuro-Symbolic Visual Dialog}},
booktitle = {COLING},
year = {2022},
url = {https://aclanthology.org/2022.coling-1.17},
}
```
# Abstract
We propose Neuro-Symbolic Visual Dialog (NSVD) —the first method to combine deep learning and symbolic program execution for multi-round visually-grounded reasoning. NSVD significantly outperforms existing purely-connectionist methods on two key challenges inherent to visual dialog: long-distance co-reference resolution as well as vanishing question-answering performance. We demonstrate the latter by proposing a more realistic and stricter evaluation scheme in which we use predicted answers for the full dialog history when calculating accuracy. We describe two variants of our model and show that using this new scheme, our best model achieves an accuracy of 99.72% on CLEVR-Dialog —a relative improvement of more than 10% over the state
of the art —while only requiring a fraction of training data. Moreover, we demonstrate that our neuro-symbolic models have a higher mean first failure round, are more robust against incomplete dialog histories, and generalise better not only to dialogs that are up to three times longer than those seen during training but also to unseen question types and scenes.
# Method
# Requirements
- PyTorch 1.3.1
- Python 3.6
- Ubuntu 18.04
# Raw Data
## Scene Data
We used CLEVR and Minecraft images in this project. The raw images have a large footprint and we won't upload them. However, we provide their json file as well as their derendedred versions:
- Original clevr-dialog training and validation raw scenes: [⬇](https://dl.fbaipublicfiles.com/clevr/CLEVR_v1.0.zip)
- Raw scenes we used in our experiments: [⬇](https://1drv.ms/u/s!AlGoPLjLV-BOh1fdB30GscvRnFAt?e=Xtorzr)
- All derendered scenes: [⬇](https://1drv.ms/u/s!AlGoPLjLV-BOh0d00ynwnXQO14da?e=Ub6k33)
## Dialog Data
The dialog data we used can be found here [⬇](https://1drv.ms/u/s!AlGoPLjLV-BOhzaYs3s2qSLbGTL_?e=oGGrxr)
You can also create your own data using the ``generate_dataset.py`` script.
# Preprocessing
## Scenes
The derendered scenes do not need any further preprocessing and can be directly used with our neuro-symbolic executor.
## Dialogs
To preprocess the dialogs, follow these steps:
```bash
cd preprocess_dialogs
```
For the stack encoder, execute
```bash
python preprocess.py --input_dialogs_json --input_vocab_json '' --output_vocab_json --output_h5_file --split --mode stack
```
For the concat encoder, execute
```bash
python preprocess.py --input_dialogs_json --input_vocab_json '' --output_vocab_json --output_h5_file --split --mode concat
```
# Training
First, change directory
```bash
cd ../prog_generator
```
## Caption Program Parser
To train the caption parser, execute
```bash
python train_caption_parser.py --mode train --run_dir --res_path --dataPathTr --dataPathVal --dataPathTest --vocab_path
```
## Question Program Parser
To train the question program parser with the stack encoder, execute
```bash
python train_question_parser.py --mode train --run_dir --text_log_dir --dataPathTr --dataPathVal --dataPathTest --scenePath --vocab_path --encoder_type 2
```
To train the question program parser with the concat encoder, execute
```bash
python train_question_parser.py --mode train --run_dir --text_log_dir --dataPathTr --dataPathVal --dataPathTest --scenePath --vocab_path --encoder_type 1
```
## Baselines
- [MAC-XXX](https://github.com/ahmedshah1494/clevr-dialog-mac-net/tree/dialog-macnet)
- [HCN](https://github.com/jojonki/Hybrid-Code-Networks)
# Evaluation
To evaluate using the *Hist+GT* scheme, execute
```bash
python train_question_parser.py --mode test_with_gt --run_dir --text_log_dir --dataPathTr --dataPathVal --dataPathTest --scenePath --vocab_path --encoder_type <1/2> --questionNetPath --captionNetPath --dialogLen --last_n_rounds
```
To evaluate using the *Hist+Pred* scheme, execute
```bash
python train_question_parser.py --mode test_with_pred --run_dir --text_log_dir --dataPathTr --dataPathVal --dataPathTest --scenePath --vocab_path --encoder_type <1/2> --questionNetPath --captionNetPath --dialogLen --last_n_rounds
```
# Results
We achieve new state-of-the-art performance on clevr-dialog.
## Hist+GT
|