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']}