Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Natural Language Processing (NLP) in Python

Cursus bekijken

Oefeninstructies

  • Create a qa_pipeline using the "distilbert/distilbert-base-cased-distilled-squad" model for question answering.
  • Use the provided context (product description) and question to get an answer.

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