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.
This exercise is part of the course
Natural Language Processing (NLP) in Python
Exercise instructions
- Initialize a suitable
classifier
pipeline with the"textattack/bert-base-uncased-QQP"
model. - Use the pipeline to classify whether
question_1
andquestion_2
are paraphrases.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
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)