AI / Claude Models Basics Interview Questions
What is the temperature parameter in Claude and how does it affect responses?
The temperature parameter controls the randomness of Claude's output. Higher temperatures produce more varied, creative responses; lower temperatures produce more focused, deterministic responses.
| Value | Behaviour | Best for |
|---|---|---|
| 0 | Deterministic — same input almost always gives same output | Factual Q&A, data extraction, classification |
| 0.1–0.5 | Low randomness — mostly consistent with slight variation | Code generation, technical analysis, structured output |
| 0.7 (default) | Balanced — the API default | General conversation, most tasks |
| 1.0 | High randomness — diverse, creative outputs | Creative writing, brainstorming |
| 1.0 (max for most tasks) | Maximum randomness | Highly experimental creative tasks |
# Setting temperature in an API call
response = client.messages.create(
model="claude-opus-4-8",
max_tokens=1024,
temperature=0, # deterministic — best for factual tasks
messages=[{"role": "user", "content": "What is the capital of France?"}]
)
# For creative writing
creative_response = client.messages.create(
model="claude-opus-4-8",
max_tokens=2048,
temperature=1.0, # more creative variation
messages=[{"role": "user", "content": "Write a poem about the ocean."}]
)Temperature range: 0 to 1 for standard tasks. Values above 1 are available but not recommended for most use cases as they can produce incoherent output. When using extended thinking, Anthropic recommends keeping temperature at 1 (the default for thinking-enabled requests).
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
