Simple Question Answering over Knowledge Graphs
This repo contains code for the following paper:
- Salman Mohammed, Peng Shi, and Jimmy Lin. Strong Baselines for Simple Question Answering over Knowledge Graphs with and without Neural Networks. Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 2 (Short Papers), pages 291-296, May 2018, New Orleans, Louisiana.
Running the Code
Install the following Python 3 packages:
- PyTorch (version 0.4.0)
- torchtext (version 0.2.3)
- NLTK data (tokenizers, stopwords list)
If you use PyTorch version 0.2.0, please checkout to
Run the setup script. This takes a long time. It fetches dataset, other files, processes them and creates indexes:
There are four main components to our formulation of the problem, as detailed in the paper: entity detection, entity linking, relation prediction and evidence integration. Each of these components is contained in a separate directory, with an associated README.
relation_predictioncan be run independently.
entity_detectionneeds to be run before
relation_predictionneeds to be run before
Running the Code with Docker (GPU, Ubuntu 16, Cuda 9.0 base)
Make sure you have the Docker daemon running
Build the image from Dockerfile
cp docker_files/Dockerfile_gpu Dockerfile docker build -t buboqa .
- Run the Docker image on GPU with nvidia-docker installed. Notice that we are mounting the current directory so that data persists.
nvidia-docker run -it --rm \ -v "$(pwd)":/code \ buboqa
- OR ... Run the Docker image on CPU (not tested)
docker run -it --rm \ -v "$(pwd)":/code \ buboqa
- Exit shell when needed