Responder library
##Settings To enable parallelization set the env variable ENABLE_PARALLELIZATION=True
machine_reader_model
: the machine reading model to use. Currentlybiattflow
threshold_reader
: the threshold for the machine readerthreshold_answer_in_document
: the threshold for the classifier predicting whether the answer is in the documenttop_k
: the number of answers to return per question. Default 1.
The Responder object should be initialised with a MachineReader configuration object as follows:
from machine_reader.machine_reader_core import MachineReader, MachineReaderConfiguration
machine_reader = MachineReader(configuration = MachineReaderConfiguration())
The main usage is through the respond
function which takes as inputs:
- list of
Document
objects, where eachDocument
has:id
: string - idtext
: string - representation of the document textorigin
: string - representation of the document origin
question
: string - representation of the question
The outputs are:
- iterable of
Answer
objects where eachAnswer
has:text
: string - representation of the answer textscore_reader
: float - the confidence of the machine reading modelscore_answer_in_document
: float - the confidence of the classifier which determines whether the answer is in a given document based on the last layer of the BiAttFlow modeldocument
: Document object of the document containing the answerspan
: Tuple - index 0 is the span start and index 1 is the span end
documents = ['Context 1', 'Context 2']
question = 'Is this my question?'
documents = [Document(text=document) for document in documents]
answer = next(machine_reader.respond(documents, question))