Llama로 퓨샷 프롬프트 만들기
Google과 Yelp의 고객 리뷰 감성을 Positive 또는 Negative로 분류하기 위해 Llama 모델을 사용하고 있어요. 각 리뷰에 대해 라벨이 일관되게 나오도록, 세 가지 예시를 포함한 퓨샷 프롬프트를 만들어 보세요.
모델에 제공하려는 예시는 다음과 같아요:
- 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를 할당해 퓨샷 프롬프트를 완성하세요. - 모델이 한 개의 리뷰에만 응답하도록,
"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'])