시작하기무료로 시작하기

top_p 실험하기

출시는 그대로, 제품은 새롭게! Luna Gear는 신규 액세서리 세 가지의 이름이 필요합니다. 바로 내장형 휴대폰 충전 뚜껑, 보온 물병 홀더, 그리고 클립형 사이드 포켓입니다. 하나는 안정적이고 정제된 느낌의 이름 목록으로, 다른 하나는 눈에 띄는 개성 있는 이름 목록으로 만들고 싶어 합니다.

anthropic 라이브러리, client, 그리고 addons_list 문자열이 미리 로드되어 있습니다.

이 연습은 강의의 일부입니다

Claude 모델 입문

강의 보기

연습 안내

  • 집중적이고 일반적인 어휘를 위해 낮은 top_p 값을 설정하세요 (0.1~0.3).
  • 다양하고 창의적인 어휘를 위해 높은 top_p 값을 설정하세요 (0.7~0.9).
  • 생성된 이름이 보이도록 두 응답 내용을 모두 출력하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

 # Focused naming with low top_p
focused_response = client.messages.create(
    model="claude-sonnet-4-6", top_p=____, max_tokens=50,
    messages=[{"role": "user",
        "content": f"Generate feature names for each of these TerraPack add-ons: {addons_list}"}])

# Diverse naming with high top_p
diverse_response = client.messages.create(
    model="claude-sonnet-4-6", top_p=____, max_tokens=50,
    messages=[{"role": "user",
        "content": f"Generate feature names for each of these TerraPack add-ons: {addons_list}"}])

print("Focused names:", ____)
print("\nDiverse names:", ____)
코드 편집 및 실행