from transformers import QuestionAnsweringPipeline, pipeline, AutoModelForQuestionAnswering, TFAutoModelForQuestionAnswering, AutoTokenizer class DemoQAPipeline(QuestionAnsweringPipeline): def postprocess(self, model_outputs): answers = super().postprocess(model_outputs) return {'guess': answers['answer'], 'confidence': answers['score']}