Posts

Showing posts from March, 2021

DBPedia Natural Language Interface Using Huggingface Transformer

I prototyped a simple natural language question answering demo in about 90 minutes. I accept a query like “where does Bill Gates work?”, find the likely URI for Bill Gates, collect some comment text for this DBPedia entity, and then pass the original query to the transformer model with the “context” being the comment text collected via a SPARQL query. I run this on Google Colab. Note that I saved my Jupyter Notebook as a python file that is in the listing below. Note the use of ! to run shell commands (e.g., !pip install transformers). # -*- coding: utf-8 -*- """DbPedia QA system.ipynb Automatically generated by Colaboratory. Original file is located at      https://colab.research.google.com/drive/1FX-0eizj2vayXsqfSB2ONuJYG8BaYpGO **DBPedia Question Answering System** Copyright 2021 Mark Watson. All rights reserved. License: Apache 2 """ !pip install transformers !pip install SPARQLWrapper from transformers import pipeline qa = pipeli