Detecting duplicate questions
A startup is developing a Q&A assistant to improve the user experience on their support forum. One key feature is to detect when users ask the same question using different words. You've been asked to implement a solution using a pre-trained QQP model that can determine whether two questions are duplicates.
Latihan ini adalah bagian dari kursus
Natural Language Processing (NLP) in Python
Petunjuk latihan
- Initialize a suitable
classifierpipeline with the"textattack/bert-base-uncased-QQP"model. - Use the pipeline to classify whether
question_1andquestion_2are paraphrases.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
from transformers import pipeline
# Initialize the pipeline
classifier = ____(task="____", model="____")
question_1 = "What's the process to change my password?"
question_2 = "How do I reset my account password?"
# Detect if the two questions are paraphrases
result = classifier({
"____": ____,
"____": ____
})
print(result)