Implement generative AI and agentic solutions 2.3 Optimize and operationalize generative AI systems

A team generates contract clauses and needs focused, consistent wording rather than…

Study guide skill: Tune generation behavior, such as prompt engineering and adjusting model parameters

Question B1-019

A team generates contract clauses and needs focused, consistent wording rather than creative variation. Which two actions follow the guidance for sampling parameters? (Choose two.)

Select 2 answers.

  • A Increase max_tokens so the model has more room
  • B Use a lower temperature, such as 0.2 ✓ Correct answer
  • C Adjust either temperature or top_p, but not both at the same time ✓ Correct answer
  • D Raise presence penalty to the maximum
  • E Set temperature to 2 and top_p to 0 together for maximum control

Answer: B, C

Lower temperature values make output more focused and concrete, while higher values make it more random, which suits creative text. The general recommendation is to change temperature or top_p, not both. Penalties and max_tokens don't directly control the randomness of word choice.

Deep dive

How it works

Two sampling parameters control how random a model's word choices are. Temperature can be set between 0 and 2. A higher value, such as 0.7, makes output more random and divergent, while a lower value, such as 0.2, makes it more focused and concrete. The docs give a direct example: a fictional story suits a higher temperature, and for a legal document a much lower temperature is recommended. Contract clauses fall squarely in that second group.

top_p (top probability) also controls the randomness of the response, but in a different way. The general recommendation is to change one of these two parameters at a time, not both.

Beyond sampling settings, giving the model grounding data to draw its responses from is one of the most effective ways to get reliable answers.

The other options, and when you'd use them

  • Increase max_tokens: max_tokens is the maximum number of tokens that can be generated, and it helps control cost. In the Chat Completions API it's deprecated in favor of max_completion_tokens. It limits length, not randomness.
  • Raise presence penalty to the maximum: presence_penalty ranges from -2.0 to 2.0. Positive values penalize tokens that have already appeared, which makes the model more likely to talk about new topics. That pushes toward variety, not consistent wording.
  • Temperature 2 and top_p 0 together: Temperature 2 is the top of the 0 to 2 range, and higher values make output more random. Changing both parameters at once also goes against the one-at-a-time guidance.

Exam tip

Focused, factual or legal text means low temperature. Creative text means higher temperature. And tune temperature or top_p, not both at once.

References

Last reviewed:

Ready to test yourself? The quiz asks this and every other AI-103 question, with instant feedback. Practice this in a quiz →

All Generative AI & agents questions · AI-103 study guide

Thanks for your feedback!