from transformers import pipeline class QAEngine: def __init__(self, model_path='timpal0l/mdeberta-v3-base-squad2'): self.qa_model = pipeline('question-answering', model=model_path) def answer(self, question, context): result = self.qa_model(question=question, context=context) return result['answer']