Experimenting with top_p
Same launch, new products! Luna Gear needs three names for upcoming add-ons: a built-in phone-charger lid, an insulated water-bottle holder, and a clip-on side pocket. They want one focused list that sounds established and one quirky list that stands out.
The anthropic library, client and addons_list string are preloaded.
Este exercício faz parte do curso
Introduction to Claude Models
Instruções do exercício
- Set a low
top_pvalue for focused, conventional vocabulary (0.1-0.3). - Set a high
top_pvalue for diverse, creative vocabulary (0.7-0.9). - Print both response contents to display the generated names.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Focused naming with low top_p
focused_response = client.messages.create(
model="claude-3-7-sonnet-latest", 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-3-7-sonnet-latest", 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:", ____)