MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Natural Language Processing (NLP) in Python

Lihat Kursus

Petunjuk latihan

  • Initialize a classifier pipeline with a suitable QNLI model, such as "cross-encoder/qnli-electra-base".
  • Use this pipeline to evaluate whether the given passage answers the question.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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)
Edit dan Jalankan Kode