Few-shot-Prompting mit Llama
Du verwendest ein Llama-Modell, um die Stimmung von Kundenrezensionen von Google und Yelp als Positive oder Negative zu erkennen. Damit diese Labels für jede Rezension konsistent sind, erstellst du einen Few-shot-Prompt mit drei Beispielen.
Hier sind die Beispiele, die du dem Modell geben möchtest:
- 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
Diese Übung ist Teil des Kurses
<Kurs>Arbeiten mit Llama 3</Kurs>Übungsanweisungen
- Vervollständige den Few-shot-Prompt, indem du den gegebenen Rezensionen
PositiveoderNegativezuweist. - Sende den Prompt an das Modell mit dem Stoppwort
"Review", damit das Modell nur auf eine Rezension antwortet.
Interaktive praktische Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# 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'])