INNER CODE UNIT · Python
QuestionGenerator
AMontgomerie/question_generator · questiongenerator.py:15
class QuestionGenerator:
"""A transformer-based NLP system for generating reading comprehension-style questions from
texts. It can generate full sentence questions, multiple choice questions, or a mix of the
two styles.
To filter out low quality questions, questions are assigned a score and ranked once they have
been generated. Only the top k questions will be returned. This behaviour can be turned off
by setting use_evaluator=False.
"""
def __init__(self) -> None:
QG_PRETRAINED = "iarfmoose/t5-base-question-generator"
self.ANSWER_TOKEN = "<answer>"
self.CONTEXT_TOKEN = "<context>"
self.SEQ_LENGTH = 512
self.device = torch.device(