Giter Club home page Giter Club logo

lasagne's Introduction

Conversational Question Answering over Knowledge Graphs with Transformer and Graph Attention Networks

This paper addresses the task of (complex) conversational question answering over a knowledge graph. For this task, we propose LASAGNE (muLti-task semAntic parSing with trAnsformer and Graph atteNtion nEtworks). It is the first approach, which employs a transformer architecture extended with Graph Attention Networks for multi-task neural semantic parsing. LASAGNE uses a transformer model for generating the base logical forms, while the Graph Attention model is used to exploit correlations between (entity) types and predicates to produce node representations. LASAGNE also includes a novel entity recognition module which detects, links, and ranks all relevant entities in the question context. We evaluate LASAGNE on a standard dataset for complex sequential question answering, on which it outperforms existing baseline averages on all question types. Specifically, we show that LASAGNE improves the F1-score on eight out of ten question types; in some cases, the increase in F1-score is more than 20% compared to the state of the art.

LASAGNE

LASAGNE (Multi-task Semantic Parsing with Transformer and Graph Attention Networks) architecture. It consists of three modules: 1) A semantic parsing-based transformer model, containing a contextual encoder and a grammar guided decoder using the proposed grammar. 2) An entity recognition module, which identifies all the entities in the context, together with their types, linking them to the knowledge graph. It filters them based on the context and permutes them, in case of more than one required entity. Finally, 3) a graph attention-based module that uses a GAT network initialised with BERT embeddings to incorporate and exploit correlations between (entity) types and predicates. The resulting node embeddings, together with the context hidden state and decoder hidden state, are used to score the nodes and predict the corresponding type and predicate.

Requirements and Setup

Python version >= 3.7

PyTorch version >= 1.6.0

PyTorch Geometric (PyG) >= 1.6.1

# clone the repository
git clone https://github.com/endrikacupaj/LASAGNE.git
cd LASAGNE
pip install -r requirements.txt

CSQA dataset

Download

We evaluate LASAGNE on CSQA dataset. You can download the dataset from here.

Wikidata Knowlegde Graph

CSQA dataset is based on Wikidata Knowlegde Graph, the authors provide a preproccesed version of it which can be used when working with the dataset. You can download the preprocessed Wikidata knowlegde graph files from here. After dowloading you will need to move them under the knowledge_graph directory.

We prefer to merge some JSON files from the preprocessed Wikidata, for accelerating the process of reading all the knowledge graph files. In particular, we create three new JSON files using the script prepare_data.py. Please execute the script as below.

# prepare knowlegde graph files
python scripts/prepare_data.py

Inverted index on Wikidata entities

For building an inverted index on wikidata entities we use elastic search. Consider the script file csqa_elasticse.py for doing so.

Annotate Dataset

Next, using the preproccesed Wikidata files we can annotate CSQA dataset with our grammar. At the same time we also annotate the entity spans for all utterances.

# annotate CSQA dataset with entity spans and our grammar
python annotate_csqa/preprocess.py --partition train --annotation_task all --read_folder /path/to/CSQA --write_folder /path/to/write

BERT embeddings

Before training the framework, we need to create BERT embeddings for the knowledge graph (entity) types and relations. You can do that by running.

# create bert embeddings
python scripts/bert_embeddings.py

Train Framework

For training you will need to adjust the paths in args file. At the same file you can also modify and experiment with different model settings.

# train framework
python train.py

Test

For testing we have two steps.

Generate Actions

First, we generate the actions and save then in JSON file using the trained model.

# generate actions for a specific question type
python inference.py --question_type Clarification

Execute Actions

Second, we execute the actions and get the results from Wikidata files.

# execute actions for a specific question type
python action_executor/run.py --file_path /path/to/actions.json --question_type Clarification

License

The repository is under MIT License.

Cite

@inproceedings{kacupaj-etal-2021-conversational,
    title = "Conversational Question Answering over Knowledge Graphs with Transformer and Graph Attention Networks",
    author = "Kacupaj, Endri  and
      Plepi, Joan  and
      Singh, Kuldeep  and
      Thakkar, Harsh  and
      Lehmann, Jens  and
      Maleshkova, Maria",
    booktitle = "Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume",
    month = apr,
    year = "2021",
    address = "Online",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/2021.eacl-main.72",
    pages = "850--862",
    abstract = "This paper addresses the task of (complex) conversational question answering over a knowledge graph. For this task, we propose LASAGNE (muLti-task semAntic parSing with trAnsformer and Graph atteNtion nEworks). It is the first approach, which employs a transformer architecture extended with Graph Attention Networks for multi-task neural semantic parsing. LASAGNE uses a transformer model for generating the base logical forms, while the Graph Attention model is used to exploit correlations between (entity) types and predicates to produce node representations. LASAGNE also includes a novel entity recognition module which detects, links, and ranks all relevant entities in the question context. We evaluate LASAGNE on a standard dataset for complex sequential question answering, on which it outperforms existing baselines averaged on all question types. Specifically, we show that LASAGNE improves the F1-score on eight out of ten question types; in some cases, the increase is more than 20{\%} compared to state of the art (SotA).",
}

lasagne's People

Contributors

endrikacupaj avatar joanplepi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lasagne's Issues

Questions about devices

Hi~

This work is really great.

However, there is no mention in the paper or in the repository about what kind of GPU LASAGNE uses for training, so if you could provide me with some details about it, it would help me a lot.

cheers

Package utilize error

Hi, I have tried to run the whole code base by python=3.7 on Ubuntu 20.04 with cuda=117 and RTX 3090 in anaconda env.
I have go through many library update error especially in the torch-geometric.
I finally successful run all the preprocess step and start to train the model. However I encounter
geometric runtimeError: philox_cuda_state for an unexpected CUDA generator used during capture.
which related to issue and it seems suggest me to update the fix version of torch-geometric you put into the source code, which would ruin all the building by dependency issue. Do you have any idea of this? or do I need to offer more information?

what is ROOT_PATH ?

Hello, thanks for your sharing and contributions.
When I tried to reproduce the code, I encountered an error which said that “ROOT_PATH is not defined” in prepare_data.py. I tried to specify it as the dataset address, but the error did not change.
What does ROOT_PATH.parent mean ?And how to specify the value of ROOT_PATH ?

Why use next context when question type is "Clarification" ?

Hi,
When question type is "Clarification", you concat the next context tokens after current context in dataset._prepare_data and dataset.get_inference_data function, and treat the next system golden action as the currenct golden action, why are you doing this ? I think it will reduce the question number with "Clarification" type, and lead to a unfair compare with others.

Waiting for your responds.
Best,

elasticsearch.exceptions.NotFoundError

Hello, thanks for your sharing and contributions.
When I run the test code (python inference.py --question_type Clarification), I get the following error.
How should I handle it?

elasticsearch.exceptions.NotFoundError: NotFoundError(404, 'index_not_found_exception', 'no such index', csqa_wikidata, index_or_alias)

torch1.6 report OSError

torch1.6 report this error
OSError: /home/admin/anaconda3/lib/python3.7/site-packages/torch_sparse/_convert.so: undefined symbol: _ZN6caffe28TypeMeta21_typeMetaDataInstanceIdEEPKNS_6detail12TypeMetaDataEv

how to solve it, thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.