Vragen beantwoorden op basis van productbeschrijvingen
Een online retailer wil zijn klantenservice verbeteren door automatisch veelgestelde vragen over producten te beantwoorden met behulp van hun beschrijvingen. Jouw taak is om een Hugging Face-pipeline te gebruiken om precieze antwoorden uit een productbeschrijving te halen op basis van klantvragen.
Deze oefening maakt deel uit van de cursus
Natural Language Processing (NLP) in Python
Oefeninstructies
- Maak een
qa_pipelinemet het model"distilbert/distilbert-base-cased-distilled-squad"voor question answering. - Gebruik de meegeleverde
context(productbeschrijving) enquestionom een antwoord te krijgen.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
from transformers import pipeline
# Create the question-answering pipeline
qa_pipeline = pipeline(
task="____",
model="____"
)
context = """This smartphone features a 6.5-inch OLED display, 128GB of storage, and a 48MP camera with night mode. It supports 5G connectivity and has a battery life of up to 24 hours."""
question = "What is the size of the smartphone's display?"
# Get the answer
result = ____
print(result)