Answering questions from product descriptions
An online retailer wants to improve its customer support by automatically answering common questions about products using their descriptions. Your task is to use a Hugging Face pipeline to extract precise answers from a product description based on customer queries.
Bu egzersiz
Natural Language Processing (NLP) in Python
kursunun bir parçasıdırEgzersiz talimatları
- Create a
qa_pipelineusing the"distilbert/distilbert-base-cased-distilled-squad"model for question answering. - Use the provided
context(product description) andquestionto get an answer.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
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)