Llama के साथ फ्यू-शॉट प्रॉम्प्टिंग
आप Google और Yelp के कस्टमर रिव्यूज़ की सेंटिमेंट पहचानने के लिए Llama मॉडल का उपयोग कर रहे हैं, और उन्हें Positive या Negative के रूप में लेबल करना है। हर रिव्यू के लिए लेबल एकसमान रहें, इसके लिए आप तीन उदाहरणों वाला एक few-shot prompt तैयार करेंगे.
ये वे उदाहरण हैं जो आप मॉडल को देना चाहते हैं:
- I ordered from this place last night, and I'm impressed! → Positive
- My order was delayed by over an hour without any updates. Disappointing! → Negative
- The food quality is top-notch. Highly recommend! → Positive
यह अभ्यास पाठ्यक्रम का हिस्सा है
Llama 3 के साथ काम करना
अभ्यास निर्देश
- दिए गए रिव्यूज़ के लिए
PositiveयाNegativeअसाइन करके few-shot प्रॉम्प्ट को पूरा करें. - प्रॉम्प्ट को
"Review"स्टॉप वर्ड के साथ मॉडल को भेजें, ताकि मॉडल केवल एक रिव्यू का जवाब दे.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Complete the few-shot prompt
prompt="""Review 1: I ordered from this place last night, and I'm impressed!
Sentiment 1: ____,
Review 2: My order was delayed by over an hour without any updates. Disappointing!
Sentiment 2: ____,
Review 3: The food quality is top-notch. Highly recommend!
Sentiment 3: ____,
Review 4: Delicious food, and excellent customer service!
Sentiment 4:"""
# Send the prompt to the model with a stop word
output = llm(prompt, max_tokens=2, stop=["____"])
print(output['choices'][0]['text'])