I am working on a French Question-Answering model using huggingface transformers library. I'm using a pre-trained CamemBERT model which is very similar to RoBERTa but is adapted to french.
Currently, i am able to get the best answer candidate for a question on a text of my own, using the QuestionAnsweringPipeline from the transformers library.
Here is an extract of my code.
QA_model = "illuin/camembert-large-fquad"
CamTokQA = CamembertTokenizer.from_pretrained(QA_model)
CamQA = CamembertForQuestionAnswering.from_pretrained(QA_model)
device_pipeline = 0 if torch.cuda.is_available() else -1
q_a_pipeline = QuestionAnsweringPipeline(model=CamQA,
tokenizer=CamTokQA,
device=device_pipeline)
ctx = open("text/Sample.txt", "r").read()
question = 'Quel est la taille de la personne ?'
res = q_a_pipeline({'question': question, 'context': ctx})
print(res)
I am currently getting this :{'score': 0.9630325870663725, 'start': 2421, 'end': 2424, 'answer': '{21'}
, which is wrong.
Therefore, i would like to get the 5 best candidates for the answer. Does anyone have an idea how to do that ?