temperature로 창의성 조절하기
여러분은 친환경 배낭 TerraPack을 출시하는 Luna Gear의 제품 담당자입니다. 팀에서는 A/B 테스트용 문구 두 가지가 필요합니다. 하나는 세련되고 정보 전달에 충실한 버전, 다른 하나는 재미있고 흥미를 유발하는 버전입니다.
anthropic 라이브러리와 client, product_info 문자열은 미리 로드되어 있습니다.
이 연습은 강의의 일부입니다
Claude 모델 입문
연습 안내
- 일관되고 전문적인 출력을 위해 낮은
temperature값을 설정하세요 (0.1~0.3). - 창의적이고 다양한 출력을 위해 높은
temperature값을 설정하세요 (0.7~0.9). - 보수적인 응답과 창의적인 응답의 내용을 모두 출력하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
conservative_response = client.messages.create(
# Conservative caption with low temperature
model="claude-sonnet-4-6", temperature=____, max_tokens=150,
messages=[{"role": "user",
"content": f"Write a professional caption for this product: {product_info}"}])
creative_response = client.messages.create(
# Creative caption with high temperature
model="claude-sonnet-4-6", temperature=____, max_tokens=150,
messages=[{"role": "user",
"content": f"Write a fun, engaging caption for this product: {product_info}"}])
# Print the Conservative and Creative Responses
print("Conservative caption:", ____)
print("\nCreative caption:", ____)