Applications with foundation models · 11 min
How do you choose a foundation model and its parameters?
In this lesson you will learn which criteria are compared when choosing a foundation model in Amazon Bedrock, how the model chooses each word and what changes in the response when you adjust temperature, Top K, Top P, length, penalties or stop sequences.
Amazon Bedrock is the AWS service that lets you use foundation models from your application. It has dozens of models from several providers, and all of them are called with the same API, so switching models doesn't force you to rewrite the application. That is why, when you build an application, you make two different decisions: before sending the first prompt you choose which model to use, and in each call you choose how to configure it with the inference parameters, which are the settings that change how the model responds in that call.
For example, an online store that wants a chat assistant for its customers first chooses the model that will answer, and then decides in each call whether it wants responses that are always the same or more varied.
Criteria for choosing a model

The exam guide lists the criteria that are compared when choosing a model:
- Cost, which for text models is charged per input token, what you send it, and per output token, what the model writes.
- Modality, which is the type of data the model takes in or generates, so a text model does not generate images and to search by meaning you need an embeddings model.
- Latency, which is how long the model takes to respond and which matters a lot in a chat where the customer is waiting.
- Languages, which decide whether the model answers well in Spanish or in your users' languages.
- The size and complexity of the model, which change its quality, its cost and its speed.
- Input and output length, which is how many tokens fit in one call (the context window) and how many the model can generate.
- Customization, which is whether the model can be adapted to your use case, for example by training it a little more with your own texts.
- Prompt caching, which is whether the model can reuse the repeated part of a prompt instead of reading it again in each call.
No model wins on every criterion, so you choose based on what the application needs most. For example, the online store's assistant answers customers who are waiting in the chat and who write in Spanish, so for the store latency and language matter more than the size of the model.
Size and length have concrete figures in the AWS documentation. On size, the AWS decision guide on generative AI says that large models usually have more than 50 billion parameters, and that these models capture finer patterns and give better results, but they cost more, need more compute and tend to be slower. On length, the Amazon Nova 2 models, for example, accept up to 1 million tokens of context and generate up to 65,536 output tokens, so a very long document, such as a complete contract, fits in a single call.
Which criterion matters most?
A bank wants an assistant that answers by chat while the customer waits in the app. The questions are simple: balance, opening hours, how to block a card. Which criterion should matter most when choosing the model?
How does the model choose each word?
At each step, the model chooses the next word from several candidates, each with a probability. The Bedrock documentation uses the prompt "I hear the hoof beats of..." as an example, where the model has three candidates for the next word: horses, with a 70 % probability, zebras, with 20 %, and unicorns, with 10 %.

That list of candidates with their probabilities is called a distribution. From that distribution, the model draws a token, adds it to the text and repeats the process with the next word, and so on until the response is finished. Because the token is drawn at random according to those probabilities, just like a raffle where horses holds 70 tickets out of every 100, the same prompt can give different responses, and sometimes zebras comes out.
Inference parameters are the ones you adjust in each call to change that draw, without touching the model. Model parameters, on the other hand, are the billions of numbers it learned in training, which don't change here. Both are called parameters, so it is easy to confuse them in an exam question. For example, when the online store asks for less varied responses, it moves an inference parameter in its call, and the model it uses stays exactly the same.
What does temperature do?
Temperature is the parameter that decides how even the draw is. With a low temperature, the distribution becomes steeper, that is, the most likely candidate gets even more tickets, and the responses are more deterministic: the same prompt almost always gives the same response. With a high temperature the opposite happens, because the distribution flattens and unlikely tokens come out more often.

In the hoof beats example, with a low temperature horses wins almost every time, while with a high temperature unicorns gets a chance to come out. AWS describes this effect without giving percentages for each temperature.
For example, the online store uses a low temperature when its assistant explains the return policy, because it wants every customer to get the same answer. On the other hand, it uses a high temperature when it asks the model for name ideas for a promotion, because there it wants different options each time.
What do Top K and Top P do?
Top K and Top P trim the list of candidates before the model chooses, and each one trims it in a different way:
- Top K, which keeps a fixed number of candidates, so with Top K equal to 2 you are left with horses and zebras.
- Top P, which keeps the candidates that add up to a share of the cumulative probability, so with 0.7 only horses is left, since it already adds up to 70 %, and with 0.9 you are left with horses and zebras, which together add up to 90 %.

In both parameters, a lower value keeps fewer candidates and gives more predictable responses. However, the default values and the ranges depend on each model, and not every model accepts all three parameters. For example, with Top K equal to 1 only horses is left, so the model no longer has anything to draw and always writes that word.
Low or high temperature?
0 of 4Tap the column that suits each application.
An assistant that answers questions about an insurance policy
A name generator for a new brand
A classifier that sorts complaints into three categories
An assistant that suggests ideas for the copy of a campaign
Parameters that limit the response

Besides temperature, Top K and Top P, there are three parameters that control how much the model writes and where it stops, without changing which word it chooses:
- Response length, which is the minimum or maximum number of tokens the model generates and which, since output tokens are charged, also controls cost.
- Penalties, which penalize repetition, the frequency of certain tokens or length, so that it is harder for the model to repeat what it already wrote.
- Stop sequences, which are pieces of text that stop the generation when they appear.
Response length keeps the model from writing too much. For example, if the online store only wants a two-line summary of each review, a low maximum length keeps the model from writing a whole page and the bill from going up.
Stop sequences are useful when you ask for a format. For example, if the model answers a question and then makes up the next one, a stop sequence on "Question:" stops it before it writes it.
Match each problem with the parameter you adjust
0 of 4 pairsTap a problem and then the parameter.
0 of 4 pairs.
On the exam
When the question describes a symptom, that symptom tells you which parameter to adjust:
- "Inconsistent responses" or "the same input gives different results", which point to lowering the temperature or Top P.
- "More creativity" or "more variety", which point to raising the temperature.
- "Responses that are too long" or "the output cost goes up", which point to the maximum length.
To choose the model, "limited budget" or "immediate response" with a simple task point to a smaller model. On the other hand, "complex analysis of long documents" points to a large one with a wide context window, which is how much text fits in the model in one call. For example, if the question says that a law firm wants to review hundred-page contracts, look for a large model with a wide context window.
cloud path tip: in an account on the new AWS experience, Amazon Bedrock is on the free plan, but the account stays in the us-east-2 Region and does not support cross-Region features. Many models can only be called in us-east-2 with a geographic or global inference profile, which is cross-Region inference, so not every model you see in the documentation will work for you in that account. In a full account you choose the Region.
Review question
An insurance company uses an Amazon Bedrock model to classify complaints into three categories, and the same description sometimes gets different categories. Which change helps the most?
Next
- Influence response generation with inference parameters, in the Amazon Bedrock user guide.
- Choosing a generative AI service, the AWS decision guide with the criteria for choosing a model.
- Take an AI Practitioner practice exam at /examenes and review your result in domain 3.