प्रोडक्ट विवरणों से प्रश्नों के उत्तर देना
एक ऑनलाइन रिटेलर अपने कस्टमर सपोर्ट को बेहतर बनाना चाहता है ताकि प्रोडक्ट के विवरणों के आधार पर आम सवालों के जवाब अपने-आप दिए जा सकें। आपका कार्य है Hugging Face पाइपलाइन का उपयोग करके कस्टमर की क्वेरी के अनुसार प्रोडक्ट विवरण से सटीक उत्तर निकालना.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Natural Language Processing (NLP)
अभ्यास निर्देश
- प्रश्न-उत्तर (question answering) के लिए
"distilbert/distilbert-base-cased-distilled-squad"मॉडल का उपयोग करते हुए एकqa_pipelineबनाएँ. - दिए गए
context(प्रोडक्ट विवरण) औरquestionका उपयोग कर एक उत्तर प्राप्त करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
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)