# NSVD
This repository contains the official code of the paper:
## Neuro-Symbolic Visual Dialog [[PDF](TODO)]
[Adnen Abdessaied](https://adnenabdessaied.de), [Mihai Bace](https://perceptualui.org/people/bace/), [Andreas Bulling](https://perceptualui.org/people/bulling/)
**Oral Presentaion / Poster**
International Conferenc on Computational Linguistics (COLING), 2022 / Gyeongju, Republic of Korea.
If you find our code useful or use it in your own projects, please cite our paper:
``TODO``
# 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. They can be found in :
- ``data/scenes/raw``
- ``data/scenes/derendered``
## Dialog Data
The dialog data we used can be found in ``data/dialogs``.
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 diretly used with our neuro-symbolic executor.
## Dialogs
To preprocess the dialogs, follow these steps:
- ```cd preprocess_dialogs```
For the stack encoder, execute
- ```python preprocess.py --input_dialogs_json --input_vocab_json '' --output_vocab_json --output_h5_file --split --mode stack```
For the concat encoder, execute
- ```python preprocess.py --input_dialogs_json --input_vocab_json '' --output_vocab_json --output_h5_file --split --mode concat```
# Training
First, change directory
- ```cd ../prog_generator```
## Caption Program Parser
To train the caption parser, execute
- ```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
- ```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
- ```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
- ```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
- ```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
|
|
| :---: | :---: | :---: |
| MAC-CQ | 41.10 | 0.15 |
| + CAA | 89.39 | 0.75 |
| + MTM | 70.39 | 0.46 |
| HCN | 74.42 | 0.32 |
| **NSVD-concat (Ours)** | 99.59 | 0.98 |
| **NSVD-stack (Ours)** | **99.72** | **0.99** |
We refer to our paper for more results and experiments.
# Acknowledgements
We thank [Ahmed Shah](https://www.linkedin.com/in/mahmedshah/) for his MAC-XXX implemetation, [Junki Ohmura](https://www.linkedin.com/in/junki/) for his HCN implemantation, [Jiayuan Mao](https://jiayuanm.com/) for providing us with the minecraft images, and finally [Satwik Kottur](https://satwikkottur.github.io/) for his clevr-dialog [codebase](https://github.com/satwikkottur/clevr-dialog).
# Contributors
- [Adnen Abdessaied](https://adnenabdessaied.de)
For any questions or enquiries, don't hesitate to contact the above contributor.