Temperature, top-p, and top-k are inference parameters that influence how a foundation model selects the next token. They change response generation without retraining or fine-tuning the model. For AWS exam scenarios, focus on the trade-off between predictable output and response diversity—and remember that parameter support and valid ranges vary by model.

Temperature: control randomness

Temperature changes the probability distribution used when selecting the next token. A lower temperature makes the model more likely to choose high-probability tokens and generally produces more predictable responses. A higher temperature allows more variation and can produce more creative or less predictable output.

Use a lower temperature for tasks that benefit from consistent wording, such as structured extraction or deterministic-style responses. A higher temperature may be useful for brainstorming or creative generation. Low temperature does not guarantee factual correctness.

Top-p: nucleus sampling

Top-p limits token selection to a set of candidates whose cumulative probability reaches the configured threshold. A lower top-p narrows the candidate pool and tends to make output more focused. A higher top-p allows a broader range of candidates and more diversity.

Top-k: limit the number of candidates

Top-k restricts the next-token candidates to the k most likely options. A smaller k limits the choice set; a larger k allows more possible tokens. Top-k is model-specific: not every foundation model exposes the same inference parameters or uses the same request format.

Quick comparison

Parameter What it controls Lower setting generally means
Temperature Shape of the token probability distribution More predictable, less random output
Top-p Cumulative probability mass of candidate tokens Narrower candidate pool
Top-k Number of highest-probability candidate tokens Fewer candidate tokens

Do not confuse generation parameters

Practical tuning advice

Change one parameter at a time and evaluate the result against a representative prompt set. Record the model ID and parameter values because different models can have different defaults, supported parameters, and valid ranges. Do not assume that a parameter value accepted by one model will be accepted by another.

Exam traps

Test yourself

Question 1

A team wants more predictable, less random responses from a foundation model. Which parameter should it generally lower?

  1. Maximum output tokens
  2. Temperature
  3. Stop sequence length
  4. Prompt length
Reveal answer

Correct answer: B. Lower temperature generally makes token selection more deterministic.

Question 2

Which parameter limits the next-token candidate set to the k most likely tokens?

  1. Top-k
  2. Top-p
  3. Temperature
  4. Maximum new tokens
Reveal answer

Correct answer: A. Top-k uses a fixed number of highest-probability candidates. Top-p uses cumulative probability mass.

Key takeaway

Temperature controls randomness, top-p controls cumulative candidate probability, and top-k controls the number of candidate tokens. Always verify the exact parameter support for the model you invoke.

Related AWS topics

Amazon Bedrock Knowledge Bases · Foundation Model Hallucinations · Evaluating Foundation Models

✦ CloudExamPro Premium

Ready for the AWS Certified AI Practitioner (AIF-C01)?

Move beyond memorizing terms. Practice with realistic, scenario-based questions and detailed explanations that help you understand the AWS AI services and concepts behind each answer.

6 Full-Length Exams390 practice questions
Detailed ExplanationsLearn why answers are right or wrong
Scenario-Based PracticeOriginal questions, not dumps
6 Months of AccessReview at your own pace
Get the AIF-C01 Practice Exams →Try the free AIF-C01 exam first ↗

Original practice questions. No dumps. No shortcuts.