|
| 1 | +# Boolean Question |
| 2 | + |
| 3 | +[](https://pypi.org/project/boolean_question) |
| 4 | +[](https://hits.seeyoufarm.com) |
| 5 | +[](https://www.codefactor.io/repository/github/saadmairaj/boolean-question/overview/master) |
| 6 | +[](https://pepy.tech/project/boolean_question) |
| 7 | + |
| 8 | +Get accurate answer prediction for True / False question using this python pytorch model. The model takes a passage and question as input and returns either "True" or "False" as predicted answer. Model used is [RoBERTa](https://arxiv.org/abs/1907.11692) that is further trained on [BoolQ](https://arxiv.org/abs/1905.10044) dataset. |
| 9 | + |
| 10 | +## Installation |
| 11 | + |
| 12 | +Install it with python package installer pip |
| 13 | + |
| 14 | +```bash |
| 15 | +pip install boolean_question |
| 16 | +``` |
| 17 | + |
| 18 | +or install the latest master branch |
| 19 | + |
| 20 | +```bash |
| 21 | +pip install git+https://github.com/Saadmairaj/boolean-question |
| 22 | +``` |
| 23 | + |
| 24 | +## Usage |
| 25 | + |
| 26 | +The usage is simple and straight forward, import `BoolQ` class model and pass arguments to the `BoolQ.predict(passage: str, question: str)` method to predict the boolean answer "True" or "False" |
| 27 | + |
| 28 | +```python |
| 29 | +import pprint |
| 30 | +from boolean_question import BoolQ |
| 31 | + |
| 32 | +bq = BoolQ() |
| 33 | + |
| 34 | +passage = """ |
| 35 | +A red dwarf is the smallest and coolest kind of star on the main sequence. |
| 36 | +Red dwarfs are by far the most common type of star in the Milky Way, at |
| 37 | +least in the neighborhood of the Sun, but because of their low luminosity, |
| 38 | +individual red dwarfs cannot be easily observed.""" |
| 39 | + |
| 40 | +question = "Coolest star in the Milky way is a Red dwarf" |
| 41 | + |
| 42 | +# Predict the answer from the passage and the question |
| 43 | +ans = bq.predict(passage, question) |
| 44 | +print(ans) |
| 45 | + |
| 46 | +# After prediction extra details of the prediction can be seen with the below command |
| 47 | +pprint.pprint(bq.prediction_details()) |
| 48 | +``` |
| 49 | + |
| 50 | +<details> |
| 51 | +<summary>View output</summary> |
| 52 | +<p> |
| 53 | + |
| 54 | + True |
| 55 | + {'answer': True, |
| 56 | + 'confidence': None, |
| 57 | + 'false confidence': 0.01, |
| 58 | + 'passage': '\n' |
| 59 | + 'A red dwarf is the smallest and coolest kind of star on the main ' |
| 60 | + 'sequence. Red dwarfs are by far the most common type of star in \n' |
| 61 | + 'the Milky Way, at least in the neighborhood of the Sun, but ' |
| 62 | + 'because of their low luminosity, individual red dwarfs cannot ' |
| 63 | + 'be \n' |
| 64 | + 'easily observed.', |
| 65 | + 'question': 'Coolest star in the Milky way is a Red dwarf', |
| 66 | + 'true confidence': 0.99} |
| 67 | + |
| 68 | +</p> |
| 69 | +</details> |
0 commit comments