퓨샷 프롬프트를 활용한 감성 분석
여러분은 시장 조사를 진행하고 있으며, 퓨샷 프롬프트를 사용해 고객 리뷰의 감성 분석을 수행하려고 해요. 고객 대화에 대해 감성 점수를 부여합니다: 부정이면 -1, 긍정이면 1이에요. 모델이 학습할 수 있도록 이전 대화 예시를 다음과 같이 제공합니다.
- The product quality exceeded my expectations -> 1
- I had a terrible experience with this product's customer service -> -1
OpenAI 패키지는 미리 로드되어 있어요.
이 연습은 강의의 일부입니다
OpenAI API로 배우는 프롬프트 엔지니어링
연습 안내
- 예시를 이전 대화로 제공하되, 텍스트는
user역할의 컨텍스트로, 숫자는assistant역할의 컨텍스트로 지정하세요. - 모델이 분류할 다음 텍스트를 제공하고 적절한 역할을 사용하세요:
The price of the product is really fair given its features.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
client = OpenAI(api_key="")
response = client.chat.completions.create(
model = "gpt-4o-mini",
# Provide the examples as previous conversations
messages = [{"role": "____", "content": "____"},
{"role": "____", "content": "____"},
{"role": "____", "content": "____"},
{"role": "____", "content": "____"},
# Provide the text for the model to classify
{"role": "____", "content": "____"}
],
temperature = 0
)
print(response.choices[0].message.content)