रेस्तरां समीक्षाओं की एम्बेडिंग
क्लासिफिकेशन के जिन कार्यों में एम्बेडिंग्स बहुत कारगर होती हैं, उनमें से एक है sentiment analysis. इस अभ्यास और अगले अभ्यासों में, आप एम्बेडिंग्स का उपयोग करके sentiment analysis के वर्कफ़्लो से गुजरेंगे.
आपको रेस्तरां समीक्षाओं का एक छोटा सैंपल reviews में दिया गया है, और उनके sentiment लेबल sentiments में हैं:
sentiments = [{'label': 'Positive'},
{'label': 'Neutral'},
{'label': 'Negative'}]
reviews = ["The food was delicious!",
"The service was a bit slow but the food was good",
"The food was cold, really disappointing!"]
आप zero-shot classification का उपयोग करते हुए, reviews और class labels दोनों को embed करके इन समीक्षाओं के sentiment को वर्गीकृत करेंगे.
आपके द्वारा पहले बनाया गया create_embeddings() फंक्शन भी उपयोग के लिए उपलब्ध है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
OpenAI API के साथ Embeddings परिचय
अभ्यास निर्देश
sentimentsdictionary में मौजूद labels से list comprehension के जरिए class descriptions की एक list बनाएँ.create_embeddings()फंक्शन का उपयोग करकेclass_descriptionsऔरreviewsको embed करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Create a list of class descriptions from the sentiment labels
class_descriptions = ____
# Embed the class_descriptions and reviews
class_embeddings = ____
review_embeddings = ____