test-demo-qa / demo_qa_pipe.py
houyu0930's picture
Upload DemoQAPipeline
e9f2c57 verified
raw
history blame contribute delete
401 Bytes
import numpy as np
from transformers import QuestionAnsweringPipeline
class DemoQAPipeline(QuestionAnsweringPipeline):
def postprocess(self, model_outputs):
# Format: {'score': 1.3321573119791374e-13, 'start': 70, 'end': 90, 'answer': 'Hopkins was featured'}
answers = super().postprocess(model_outputs)
return {'guess': answers['answer'], 'confidence': answers['score']}