I am trying to use a hugging face QA model with Squad2_es.
class QAInferencer:
def __init__(self, model, tokenizer):
self.pipeline: QuestionAnsweringPipeline = pipeline(
model=model,
tokenizer=(tokenizer, {"use_fast": False}),
device=0, task="question-answering"
)
def response_qas(self, ids, questions, contexts):
samples = self.pipeline.create_sample(questions, contexts)
zipped_answers = zip(ids, questions, self.pipeline(samples))
return [{
'id': qid,
"question": question,
"is_impossible": False,
"answers": [{
'answer_start': answer['start'],
'text': answer['answer']
}]} for qid, question, answer in zipped_answers]
I pass a to response_qas
three list of str's one of ids, one of question and ones contexts. The the create_sample(questions, contexts)
call return this error
TypeError: ord() expected a character, but string of length 1542 found
Like the function is expecting only string but the Docs says that it can accept str list, to produce several samples at once.