Knowledge Base Question Answering (KBQA)

Description

The Knowledge Base Question Answering model uses Wikidata to answer question. To find the answer the following components are used: NER component performs entity discovery. In a given question it finds a substring which is an entity, possible mentioned in a Knowledge Base. Classification component classifies the question into a set of predefined relations from Wikidata. Substring extracted by the NER model is used for entity linking. Entity linking preforms matching the substring with one of the Wikidata entities. Matching is based on Levenshtein distance between the substring and an entity description. The result of the matching procedure is a set of candidate entities. The reset is search of the entity among this set with one of the top-k relations predicted by classification component.

Use the model

Any pre-trained model can be used for inference from both Command Line Interface (CLI) and Python. Before using the model make sure that all required packages are installed using the command:

python -m deeppavlov install kbqa_mix_lowercase

To use a pre-trained model from CLI use the following command:

python deeppavlov/deep.py interact kbqa_mix_lowercase [-d]

where kbqa_mix_lowercase is the name of the config and -d is an optional download key. The key -d is used to download the pre-trained model along with embeddings and all other files needed to run the model. Also command download is possible,

Available config:

Model

Dataset

Embeddings Size

Model Size

kbqa

Simple Questions and Zero-Shot IE

7.7 GB

8.9 MB

Models can be used from Python using the following code:

from deeppavlov import configs, build_model

kbqa_model = build_model(configs.kbqa.kbqa_mix_lowercase, download=True)
kbqa_model(['Когда родился Пушкин?'])
>>> ["26 May 1799"]