Skip to content

Nightfurex/pyqna

 
 

Repository files navigation

img


TESTS pypi last-commit license


PyQnA is a simple package that aims to provide a consistent and unified API for all Question Answering related tasks in Python.

Installation

  • Currently we provide a PyPi package:
    $ pip install pyqna
  • In future we'd also have a Conda package.

Example:

# Import a specific model
from pyqna.models.reading_comprehension.transformer_models import TransformerQnAModel

# Instantiate the model
model = TransformerQnAModel(
    {"model_name": "distilbert-base-uncased-distilled-squad", "pre_trained": True}
)

# Take a context 
context = """ 
New Zealand (Māori: Aotearoa) is a sovereign island country in the southwestern Pacific Ocean.
It has a total land area of 268,000 square kilometres (103,500 sq mi), and a population of
4.9 million. New Zealand's capital city is Wellington, and its most populous city is Auckland.
"""

# Make a list of your queries
questions = ["How many people live in New Zealand?", "What's the largest city?"]

# Run inference using the instantiated models
answers = model.get_answer(context, questions)

# Print the output
print(answers)

Output:

['4. 9 million', 'auckland']

License

PyQnA is distributed under the BSD 3-Clause License.

About

A simple python package for question answering.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%