Zacznij terazZacznij za darmo

Few-shot prompting z Llamą

Używasz modelu Llama do określania wydźwięku recenzji klientów z Google i Yelp – jako Positive lub Negative. Aby etykiety były spójne dla każdej recenzji, zaprojektujesz prompt few-shot zawierający trzy przykłady.

Oto przykłady, które chcesz przekazać modelowi:

  • 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

To ćwiczenie jest częścią kursu

Praca z Llama 3

Zobacz kurs

Instrukcje do ćwiczenia

  • Uzupełnij prompt few-shot, przypisując Positive lub Negative do podanych recenzji.
  • Wyślij prompt do modelu ze słowem zatrzymującym "Review", tak aby model odpowiadał tylko na jedną recenzję.

Interaktywne ćwiczenie praktyczne

Spróbuj tego ćwiczenia, uzupełniając ten przykładowy kod.

# 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'])
Edytuj i uruchom kod