Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Natural Language Processing (NLP) in Python

Cursus bekijken

Oefeninstructies

  • Initialize a suitable classifier pipeline with the "textattack/bert-base-uncased-QQP" model.
  • Use the pipeline to classify whether question_1 and question_2 are paraphrases.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

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)
Code bewerken en uitvoeren