Підказки з кількома прикладами (few-shot) у Llama
Ви використовуєте модель Llama, щоб визначати тональність відгуків клієнтів із Google та Yelp як Positive або Negative. Щоб ці мітки були послідовними для кожного відгуку, ви створите few-shot підказку з трьома прикладами.
Ось приклади, які ви хочете надати моделі:
- 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
Інструкції до вправи
- Завершіть few-shot підказку, призначивши
PositiveабоNegativeнаведеним відгукам. - Надішліть підказку моделі зі стоп-словом
"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'])