Does the text answer the question?
A content moderation team in a large tech company needs to automatically validate whether a passage from a knowledge base answers a customer query. They want to speed up the process using a pre-trained QNLI model to assess the relevance of each response. Your goal is to implement a solution that can classify whether a given passage contains the answer to a specific question.
Deze oefening maakt deel uit van de cursus
Natural Language Processing (NLP) in Python
Oefeninstructies
- Initialize a
classifierpipeline with a suitable QNLI model, such as"cross-encoder/qnli-electra-base". - Use this pipeline to evaluate whether the given
passageanswers thequestion.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
from transformers import pipeline
# Initialize the QNLI pipeline
classifier = ____
passage = "Our refund policy allows customers to return any item within 30 days of purchase, provided the item is in its original condition and accompanied by the receipt. Refunds are issued to the original payment method within 5–7 business days."
question = "Can I get a refund if I return a product after 20 days?"
# Get the result
result = ____
print(result)