File size: 401 Bytes
536f457
 
 
 
 
 
e9f2c57
536f457
1
2
3
4
5
6
7
8
9
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']}