Abstractive QA के साथ स्वाभाविक उत्तर जनरेट करना
कस्टमर सपोर्ट चैटबॉट्स का लक्ष्य मददगार और बातचीत जैसे उत्तर देना होता है, न कि सिर्फ सटीक टेक्स्ट स्निपेट्स लौटाना। इसके लिए वे abstractive question answering का उपयोग करते हैं, जो दिए गए संदर्भ के आधार पर संक्षिप्त और धाराप्रवाह प्रतिक्रियाएँ जनरेट करता है। आपका कार्य Hugging Face की "text2text-generation" पाइपलाइन को एक ऐसे मॉडल के साथ लागू करना है जो abstractive QA के लिए प्रशिक्षित है, ताकि प्रोडक्ट जानकारी से स्वाभाविक उत्तर बनाए जा सकें।
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Natural Language Processing (NLP)
अभ्यास निर्देश
"text2text-generation"टास्क के साथ"fangyuan/hotpotqa_abstractive"मॉडल का उपयोग करके एकqa_pipelineबनाएँ.- दिए गए
contextऔरquestionका उपयोग करके एक abstractiveanswerजनरेट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
from transformers import pipeline
# Create the abstractive 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?"
# Generate abstractive answer
result = qa_pipeline(f"____: {____} ____: {____}")
print(result)