Few-shot prompting cu Llama
Folosești un model Llama pentru a identifica sentimentul recenziilor clienților de pe Google și Yelp ca Positive sau Negative. Pentru a te asigura că aceste etichete sunt consecvente pentru fiecare recenzie, vei concepe un prompt few-shot care conține trei exemple.
Iată exemplele pe care vrei să le oferi modelului:
- 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
Acest exercițiu face parte din cursul
Lucrul cu Llama 3
Instrucțiuni pentru exercițiu
- Completează promptul few-shot atribuind
PositivesauNegativerecenziilor furnizate. - Trimite promptul către model cu cuvântul de oprire
"Review", astfel încât modelul să răspundă doar la o singură recenzie.
Exercițiu interactiv practic
Încearcă acest exercițiu completând acest cod de exemplu.
# 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'])