dbpedia / neural-qa

πŸ“š A Neural QA Model for DBpedia using Neural SPARQL Machines.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ€– Neural SPARQL Machines

Python 3.7

A Machine-Translation Approach for Question Answering over Knowledge Graphs.

What does a NSpM do?

IMPORTANT

If you are looking for the code for papers "SPARQL as a Foreign Language" and "Neural Machine Translation for Query Construction and Composition" please checkout tag v0.1.0-akaha or branch v1.

Install

Via pip

Coming soon!

Local setup

Clone the repository.

pip install -r requirements.txt

Example of usage

The Generator module

Pre-generated data

You can extract pre-generated data and model checkpoints from here (1.1 GB) in folders having the respective names.

Manual Generation (Alternative to using pre-generated data)

The template used in the paper can be found in a file such as Annotations_F30_art.csv. data/art_30 will be the ID of the working dataset used throughout the tutorial. To generate the training data, launch the following command.

mkdir -p data/art_30
python nspm/generator.py --templates data/templates/Annotations_F30_art.csv --output data/art_30

Launch the command if you want to build dataset seprately else it will internally be called while training.

python nspm/data_gen.py --input data/art_30 --output data/art_30

The Learner module

Now go back to the initial directory and launch learner.py to train the model.

python nspm/learner.py --input data/art_30 --output data/art_30

This command will create a model checkpoints in data/art_30 and some pickle files in data/art_30/pickle_objects.

The Interpreter module

Predict the SPARQL query for a given question it will store the detailed output in output_query.

python nspm/interpreter.py --input data/art_30 --output data/art_30 --query "yuncken freeman has architected in how many cities?"

or, if you want to use NSpM with airml to install pre-trained models, follow these steps,

  1. Install airML latest version from here
  2. Navigate to the table.kns here and check if your model is listed in that file.
  3. Then copy the name of that model and use it with the interpreter.py as follows
python interpreter.py --airml http://nspm.org/art --output data/art_30 --inputstr "yuncken freeman has architected in how many cities?"

Use cases & integrations

Publications

SPARQL as a Foreign Language (2017)

@inproceedings{soru-marx-2017,
    author = "Tommaso Soru and Edgard Marx and Diego Moussallem and Gustavo Publio and Andr\'e Valdestilhas and Diego Esteves and Ciro Baron Neto",
    title = "{SPARQL} as a Foreign Language",
    year = "2017",
    journal = "13th International Conference on Semantic Systems (SEMANTiCS 2017) - Posters and Demos",
    url = "https://arxiv.org/abs/1708.07624",
}

Neural Machine Translation for Query Construction and Composition (2018)

@inproceedings{soru-marx-nampi2018,
    author = "Tommaso Soru and Edgard Marx and Andr\'e Valdestilhas and Diego Esteves and Diego Moussallem and Gustavo Publio",
    title = "Neural Machine Translation for Query Construction and Composition",
    year = "2018",
    journal = "ICML Workshop on Neural Abstract Machines \& Program Induction (NAMPI v2)",
    url = "https://arxiv.org/abs/1806.10478",
}

Exploring Sequence-to-Sequence Models for SPARQL Pattern Composition (2020)

@inproceedings{panchbhai-2020,
    author = "Anand Panchbhai and Tommaso Soru and Edgard Marx",
    title = "Exploring Sequence-to-Sequence Models for {SPARQL} Pattern Composition",
    year = "2020",
    journal = "First Indo-American Knowledge Graph and Semantic Web Conference",
    url = "https://arxiv.org/abs/2010.10900",
}

Liber AI on Medium (2020)

Contact

Questions?

Follow us

Liber AI logo

About

πŸ“š A Neural QA Model for DBpedia using Neural SPARQL Machines.

License:MIT License


Languages

Language:Jupyter Notebook 71.5%Language:Python 28.0%Language:Shell 0.5%