SaveMyCert
Log in
5 of 5 free questions left today·for 30 a day
Applications of Foundation Models

Foundation Model Design: Selection, RAG, and Customization (AIF-C01)

20 min readAIF-C01 · Applications of Foundation ModelsUpdated

Designing an application around a foundation model (FM) means making a series of practical choices: which model to use, how to control its responses, how to feed it your own data, how to keep it affordable, and how far to go in customizing it. This lesson covers Task 3.1 of the AIF-C01 exam, the cornerstone of the heaviest-weighted domain. You will learn the criteria for selecting a foundation model, including why modality and the context window are hard limits rather than preferences, and how the context window, the output-token cap, and prompt caching behave at run time. You will learn the inference parameters that shape output and what they cannot do, and Retrieval Augmented Generation (RAG), the technique that lets a model answer from current or private data without retraining, including its trade-offs and how Amazon Bedrock Knowledge Bases keeps its index in sync. You will also learn which AWS services store the embeddings that power RAG, the cost trade-offs of customization from prompt engineering to pre-training, how model distillation and batch inference cut running cost, and the role of AI agents compared with fixed workflows. These are recognition-level concepts: the exam rewards knowing which approach fits a described need, not building the system yourself.

What you’ll learn
  • Identify the criteria used to select a foundation model, and recognize modality, language support, and the context window as hard limits checked before cost and latency.
  • Explain how the context window, the maximum output tokens setting, and prompt caching each affect what a request can hold, how long an answer can be, and what it costs.
  • Describe how inference parameters such as temperature, top-p, top-k, and output length affect model responses, and what they cannot change.
  • Define Retrieval Augmented Generation (RAG), its trade-offs and business applications, including how Amazon Bedrock Knowledge Bases ingests and syncs data.
  • Name the AWS services that store embeddings in vector databases, and tell them apart from data services that do not perform vector similarity search.
  • Compare FM customization and cost-reduction approaches, including in-context learning, RAG, fine-tuning, pre-training, model distillation, prompt caching, and batch inference.
  • Explain the role of AI agents and their business applications, and distinguish an agent from a predefined workflow.

Selecting a Foundation Model: The Criteria That Matter

Choosing a foundation model means matching the model to the job, because no single model is best for every application. The selection criteria the exam names are summarized below.

CriterionWhat to consider
CostPrice per input and output token; larger, more capable models usually cost more per request.
ModalityThe data types the model accepts and produces, such as text, image, audio, or multi-modal input.
LatencyHow quickly the model responds; real-time chat needs low latency.
Multi-lingualWhether the model supports the languages your users speak.
Model size and complexityLarger models (more parameters) are often more capable but slower and more expensive.
CustomizationWhether the model can be adapted through fine-tuning, distillation, or other methods.
Input/output lengthThe context window (how many tokens one request can hold) and the maximum output the model can generate.
Prompt cachingWhether the model supports reusing a repeated prompt prefix to cut cost and latency (covered in the next section).

Some criteria are hard limits, others are trade-offs. Modality, language support, and the context window are pass-or-fail: a text-only model cannot accept a photo, however cheap or fast it is, and a model whose context window is smaller than your document cannot read it in one request. Check those first and discard models that fail. Only then weigh the trade-offs among the models left: cost, latency, and size and complexity, where a smaller model is usually faster and cheaper per token and a larger one handles harder reasoning.

Keep each criterion to its own job. Price per token, latency, and parameter count tell you how much a request costs, how fast it returns, and how capable the model is, but only the context window decides whether a long document fits into a single request. A scenario usually stresses one constraint: fast responses for a chatbot point to latency, keeping spend low at high volume points to cost and a smaller model, users in several languages point to multi-lingual support, and image input points to modality.

Context Window, Output Cap, and Prompt Caching

The context window, the output cap, and prompt caching are three different things that are easy to confuse: the context window limits how much one request can hold, the maximum output tokens setting limits how long the reply can be, and prompt caching makes a repeated part of the prompt cheaper and faster to process.

The context window is a run-time limit

The context window is the total number of tokens a model can work with in one request: the prompt (instructions, conversation history, any retrieved or pasted documents) plus the output it generates must fit inside it. If the input alone exceeds the window, Amazon Bedrock rejects the request with a validation error saying the input is too long; nothing is generated. A common way to hit this is a chat application that resends the whole conversation history on every turn: each turn makes the prompt longer until requests start failing. The fixes are to trim or summarize older turns, to retrieve only the relevant passages instead of sending everything, or to choose a model with a larger window. A larger window does not shorten answers or reduce cost; it only raises the ceiling on what one request can carry.

The output cap truncates instead of failing

The maximum output tokens setting caps how many tokens the model generates. When a reply reaches the cap, generation simply stops, so a cap set too low returns answers cut off mid-sentence, while a lower cap is also how you bound both the length and the output-token cost of each reply. Compare the two symptoms: a request rejected as too long is a context-window problem on the input side; a reply that stops mid-sentence is an output-cap problem.

Prompt caching reuses a repeated prefix

Prompt caching stores the processed form of a prompt prefix that many requests share, such as a long system prompt, a set of examples, or a reference document, so later requests that start with the same prefix read it from the cache instead of processing it again. On Amazon Bedrock, cached input tokens are billed at a reduced rate and the model returns its first token sooner, so caching lowers input cost and latency for live requests while keeping the same model and the same prompt. Know its limits:

  • It works only on the identical prefix. Prompts that share no common opening content gain little or nothing.
  • It applies to input only. Output tokens are billed as normal, and on some models the first request that writes the cache costs more than a normal request.
  • It changes nothing about the model. Weights, answer quality, and behaviour stay the same.
  • It does not enlarge the context window. Cached tokens still count toward the window, so a document too big to fit is still too big when cached.
  • It is supported only on some models, so check before relying on it.

That last pair of points is why caching is not a scaling answer for a growing document set. Caching makes a large, repeated prompt cheaper, and a larger-window model moves the limit further out, but in both cases every call still carries the whole document. Retrieval Augmented Generation (RAG), covered below, is what keeps prompts small as the content grows.

Inference Parameters: Controlling the Model's Output

Inference parameters are per-request settings that steer how a model produces its answer without changing the model itself. Inference is the act of generating an answer from a prompt, and these settings adjust that generation. The exam focuses on a few key levers.

ParameterEffect on the responseWhat it does not set
TemperatureControls randomness. Lower values make output more focused and repeatable; higher values make it more diverse and creative.A length limit, or whether the facts are correct.
Top-p (nucleus sampling)Limits word choices to the smallest set whose combined probability reaches p. Lower p means safer, more predictable wording.A length limit.
Top-kLimits word choices to the k most likely next tokens. Smaller k narrows the options.A length limit.
Max tokens / output lengthCaps how many tokens the answer can contain, which bounds its length and output cost.Word choice or randomness.
Input lengthHow much prompt and context you can send, bounded by the model's context window.Not a sampling setting at all; it is a limit of the model.

The most tested lever is temperature. To make output more consistent, such as for a support answer or data extraction, lower the temperature. To make output more creative and varied, such as for brainstorming marketing ideas, raise it. Top-p and top-k are alternative ways to control randomness. Temperature, top-p, and top-k change which words are chosen; they do not set or cap the length. They can shift length indirectly, because the end of the reply is itself a sampled token, but only the output cap puts a hard limit on length.

Repeatable is not the same as correct. A low temperature makes the model give the same answer each time, but if the model does not know a fact, such as your company's current return policy, it will repeat the same wrong answer consistently. Hallucination caused by missing knowledge is fixed by grounding the model in the right content (RAG), not by sampling settings. These settings change behavior per request; they do not retrain or permanently alter the model.

Retrieval Augmented Generation (RAG)

Retrieval Augmented Generation (RAG) is a technique that retrieves relevant information from an external knowledge source at query time and adds it to the prompt, so the model answers from current or proprietary data instead of only what it learned during training. The flow is simple: the user asks a question, the system searches a knowledge source for the most relevant passages, those passages are inserted into the prompt as context, and the model generates an answer grounded in them. The model's weights never change.

RAG matters because a foundation model's built-in knowledge is frozen at training time and does not include your company's private documents. Without RAG, a model asked about your internal policy either cannot answer or may hallucinate, meaning it produces a confident but wrong answer. Grounding the response in retrieved facts reduces hallucination and keeps answers current, and because the answer comes from specific passages, the application can cite the source documents it used.

Why not just paste everything into the prompt?

Putting all your source material directly into the prompt, called in-context learning or prompt stuffing, works for a few short documents and needs no extra infrastructure. It stops working as the collection grows, for two reasons: the content no longer fits in the model's context window, and every request pays for every token of it, even the parts irrelevant to the question. RAG sends only the few passages that match each question, which is what keeps prompts small as the document set grows into thousands of pages.

RAG trade-offs

  • It adds tokens. Retrieved passages are extra input, so a RAG request costs more than the bare question; RAG saves money compared with stuffing everything into the prompt or with retraining, not compared with no context at all.
  • Passages must still fit. The retrieved content plus the question and the answer must fit within the context window.
  • It reduces hallucination but does not eliminate it. If retrieval returns the wrong passage, or none, the model can still answer badly.

Amazon Bedrock Knowledge Bases

On AWS, Amazon Bedrock Knowledge Bases is the managed RAG capability. You connect a data source, such as an Amazon S3 bucket, and it handles chunking, creating embeddings, storing them in a vector store, retrieving the relevant pieces at query time, and passing them to the model, so you do not build the retrieval pipeline yourself. A knowledge base does not watch the source for changes on its own: after documents are added, changed, or deleted, the data source must be synced, which runs an ingestion job that you start from the console or API (StartIngestionJob). Knowledge Bases has no built-in sync schedule; to automate syncing, build your own trigger, for example an Amazon EventBridge schedule or an S3 event that calls StartIngestionJob through AWS Lambda. Syncing re-indexes content; it is not training, and the model is unchanged.

Do not confuse Knowledge Bases with Amazon Bedrock Guardrails. Guardrails' contextual grounding check evaluates whether a response is supported by the source content supplied with the request and relevant to the query, and can block one that is not. It checks answers; it does not find or retrieve the content. Retrieval is the knowledge base's job.

Business applications are broad: internal knowledge assistants that answer from company wikis, customer-support bots grounded in product manuals, and research tools that cite source documents.

Vector Databases: Where Embeddings Are Stored

A vector database stores embeddings and finds the ones closest in meaning to a query, which is how RAG retrieves passages by meaning rather than exact keywords. Each chunk of your documents is converted into an embedding, a numerical representation of meaning expressed as a vector. When a user asks a question, the question is embedded too, and the database returns the stored chunks whose vectors are closest, meaning the passages most similar in meaning.

The AWS services the exam names for storing embeddings are:

ServiceHow it stores and searches vectorsNatural fit
Amazon OpenSearch ServiceBuilt-in vector (k-NN) search alongside full-text search.Search-heavy workloads and a common RAG vector store.
Amazon Aurora PostgreSQL-Compatible EditionThe pgvector extension stores embeddings in tables next to your relational data.Teams already running Aurora PostgreSQL who want vectors beside existing tables.
Amazon RDS for PostgreSQLThe same pgvector extension on managed PostgreSQL.Existing RDS PostgreSQL workloads.
Amazon Neptune (Neptune Analytics)Vector similarity search is a feature of Neptune Analytics, the analytics engine for graph data.Applications that combine graph relationships with vector search.

Being a data service is not enough. Amazon Athena (SQL queries over S3), Amazon Kinesis (streaming), the AWS Glue Data Catalog (metadata), and AWS Lake Formation (data-lake permissions) store, move, or govern data but do not perform vector similarity search. You do not need to configure any of these services for the exam; the point is recognizing which ones can hold embeddings for similarity search. Amazon Bedrock Knowledge Bases can use such a store behind the scenes as its vector database.

Customizing a Foundation Model: The Cost-and-Effort Spectrum

Customization approaches range from cheap and quick to expensive and involved, and the right choice is the lightest one that meets the need. Learn the ladder.

ApproachWhat you doData neededCost and effort
Prompt engineering / in-context learningImprove wording and put examples or context in the prompt; no training.None beyond the promptLowest to start, but every request pays for the extra prompt tokens
RAGRetrieve your data into the prompt at query time; no retraining.Your documentsLow to moderate (retrieval infrastructure plus added input tokens)
Model distillation (a cost-reduction lever, not a rung)Train a smaller student model on a larger teacher model's responses for your task.Prompts (the teacher generates the responses)A one-off training cost that lowers ongoing inference cost
Fine-tuningFurther train the model on your labeled examples to specialize its behavior or style.Labeled prompt-response pairsHigher
Continuous pre-trainingKeep training on large amounts of unlabeled domain text so the model learns its language.Large unlabeled corpusVery high
Pre-training from scratchBuild and train a brand-new foundation model.Massive datasetsHighest

Model distillation sits in the table for comparison, but it is not a step on the adaptation ladder. The ladder ranks ways to change what a model knows or how it behaves; distillation is a cost-reduction lever that makes an already adequate task cheaper and faster to run, so its cost is not ranked against RAG or fine-tuning.

Start at the top and move down only if you must. Fine-tuning teaches a task or style and needs labeled examples. Continuous pre-training on unlabeled text teaches domain vocabulary and language, not a specific task. Neither keeps answers current as documents change; that is RAG's job.

Model distillation: teacher and student

Model distillation transfers a large model's skill on a specific task into a smaller, cheaper, faster model. The large model is the teacher; the small model is the student, which is trained on the teacher's responses until it handles that task nearly as well. Because the teacher writes the responses, you do not need a labeled dataset: Amazon Bedrock Model Distillation accepts your prompts, or your existing invocation logs, generates the teacher's responses, and fine-tunes the student. The result is lower inference cost and latency for that task, at the price of some quality and a training step, and the application then calls a different, smaller model.

Cutting running cost without customizing

Some cost levers keep the same model and the same prompt. Compare them by what they cost you:

LeverKeeps the model?Effect on live response timeBest for
Prompt cachingYesFaster (shorter time to first token)Live requests that share a long, identical prompt prefix
Amazon Bedrock batch inferenceYesMuch slower; requests are processed asynchronously and results arrive laterOffline jobs, such as summarizing a large archive overnight
Smaller modelNoUsually fasterTasks a smaller model handles well enough
Model distillationNo (a trained student replaces it)FasterA high-volume task where a training step is acceptable

Batch inference is priced lower than on-demand inference, but because it is asynchronous it suits work nobody is waiting for and makes interactive response time worse. Prompt caching is the lever that lowers both cost and latency for live requests, but only when there is a repeated prefix.

AI Agents: Foundation Models That Take Action

An AI agent is an application that uses a foundation model as its reasoning engine and can take actions to complete a goal, not just return text. An agent combines three ingredients: the FM for reasoning, tools it can call (such as looking up an order, querying a database, or triggering an API), and orchestration that plans the steps, reads each result, and decides what to do next. This lets an agent interpret a free-form request, break it into steps, call the right tool at each step, and adapt when a result changes the plan.

In Amazon Bedrock Agents, the tools are defined as action groups: each action group describes the API operations the agent may call (with an API schema or function details) and the AWS Lambda function or application code that carries them out. An agent can also be given a knowledge base so it can answer from documents as well as act. Tools can also be connected through open standards such as the Model Context Protocol (MCP), which defines a common way for agents to discover and call tools.

Consider a customer-service example. A shopper asks an agent to change a delivery address. The agent interprets the request, calls a tool to look up the order, calls another tool to update the address, confirms the change, and replies in natural language. A RAG chatbot could only explain how to change the address; the agent actually does it.

Agent or predefined workflow?

AI agent (for example, Amazon Bedrock Agents)Predefined workflow (for example, AWS Step Functions)
InputFree-form natural-language requestsKnown, structured inputs
Who decides the next stepThe model plans it at run time from the results so farThe designer, in advance; every branch is designed and coded
Can call APIs or invoke a model?Yes, through action groupsYes, but only along the paths it was built with
Best forVaried requests where the steps differ from case to caseRepeatable processes with fixed, auditable steps

Business applications of agents include automating customer-service tasks, handling booking, order, or IT requests that span several systems, retrieving and combining information from those systems, and assisting employees with routine operations. The defining idea is that an agent is a foundation model plus tools plus orchestration that takes actions. Deeper agentic-AI design belongs to other tasks; here you need the role and the business value.

Putting It Together: Choosing the Right Approach

Task 3.1 questions usually describe a need and ask which design choice fits, and the method is to find the scenario's constraint and pick the lightest approach that satisfies it. Suppose a company wants an assistant that answers employee questions from its constantly changing internal HR documents, gives consistent factual replies, keeps cost low, and needs no data-science team.

Work through the decisions. Because the answers must come from current, private documents that are far too large to paste into every prompt, the right technique is RAG, not fine-tuning, since RAG adds your data without retraining and stays up to date as documents change. On AWS, Amazon Bedrock Knowledge Bases provides this as a managed service, storing the document embeddings in a vector database such as Amazon OpenSearch Service; after HR updates a document, the data source is synced so the change becomes retrievable. To keep replies consistent, set a low temperature, remembering that grounding, not temperature, is what keeps them correct. For model selection, check that the model handles the needed languages and fits the retrieved passages in its context window, then favor a smaller, lower-cost, low-latency model with adequate quality. If every request starts with the same long system prompt, prompt caching cuts its cost and latency. If the assistant also needs to take actions, such as submitting a leave request, add an agent with the right action groups.

Notice the order of preference throughout: reach for the cheapest, least invasive option that meets the need. Prompt engineering and RAG come before fine-tuning; fine-tuning comes before continuous pre-training; and pre-training from scratch is almost never the answer for a business application.

Tip. Expect scenario questions that map a described need to a design choice. "Answer from current or private data without retraining" points to RAG through Amazon Bedrock Knowledge Bases, which must be synced after documents change; a growing document set that no longer fits the prompt also points to RAG, not caching or a bigger window. Know the run-time limits apart: input too long for the context window is rejected, a low output cap truncates replies, and temperature, top-p, and top-k change word choice but do not cap length or make answers correct. A long identical prompt prefix on the same model points to prompt caching; a cheaper offline job to batch inference; a smaller model trained on a larger model's outputs to distillation. Check modality before cost, recognize the vector stores (OpenSearch Service, Aurora PostgreSQL or RDS for PostgreSQL with pgvector, Neptune Analytics), and tell an agent with action groups from a fixed Step Functions workflow.

Key takeaways
  • Select a foundation model by first checking hard limits (modality, language support, context window), then trading off cost, latency, and model size and complexity.
  • The context window limits what one request can hold (prompt plus output); input that exceeds it is rejected, while the maximum output tokens setting truncates replies and bounds output cost.
  • Prompt caching reuses an identical prompt prefix to cut input cost and latency on the same model; it does not change answers, does not affect output-token cost, and cached tokens still count toward the context window.
  • Temperature, top-p, and top-k change word choice and do not set or cap length (only the output cap does); a low temperature makes answers repeatable, not correct, and grounding with RAG is what supplies missing facts.
  • RAG retrieves relevant passages into the prompt at query time without retraining; it reduces (not eliminates) hallucination, adds input tokens, and keeps prompts small as a document set grows.
  • Amazon Bedrock Knowledge Bases is the managed RAG capability and must be synced after source documents change; Guardrails' contextual grounding check validates answers but does not retrieve content.
  • Embeddings can be stored in Amazon OpenSearch Service, Aurora PostgreSQL or RDS for PostgreSQL (pgvector), or Neptune Analytics.
  • Customization runs cheapest to most expensive: prompt engineering / in-context learning, RAG, fine-tuning, continuous pre-training, pre-training from scratch; distillation trains a smaller student on a teacher's responses to cut inference cost.
  • An AI agent is a foundation model plus tools (Bedrock Agents action groups) plus orchestration that plans steps at run time, unlike a predefined workflow such as AWS Step Functions.

Frequently asked questions

What is RAG in AWS?

Retrieval Augmented Generation (RAG) is a technique that retrieves relevant information from an external knowledge source at query time and adds it to the model's prompt, so the foundation model answers from current or proprietary data instead of only what it learned during training. This keeps answers up to date, lets the application cite its sources, and reduces (but does not eliminate) hallucination, all without retraining the model. On AWS, Amazon Bedrock Knowledge Bases is the managed RAG capability: you connect a data source and it handles chunking, embedding, storing the vectors, retrieving the relevant passages, and passing them to the model. When source documents change, the data source must be synced before the changes can be retrieved. The embeddings can be stored in a vector database such as Amazon OpenSearch Service, Aurora PostgreSQL or RDS for PostgreSQL with pgvector, or Neptune Analytics.

What is the cheapest way to customize a foundation model?

The cheapest way to start customizing a foundation model is prompt engineering, also called in-context learning, because it requires no training at all. You improve the wording of the prompt and include instructions, context, or examples so the model performs better on your task. Every request pays for those extra prompt tokens, though, and source material stops fitting once it outgrows the context window, which is when RAG becomes the better choice: it retrieves only the relevant passages and still does not retrain the model. Only after those do you consider fine-tuning, which needs labeled examples and costs more, followed by continuous pre-training and, most expensive of all, pre-training a new model from scratch.

How does temperature affect a model's output?

Temperature is an inference parameter that controls the randomness of a model's word choices. A lower temperature makes output more focused and repeatable, which suits support answers and data extraction; a higher temperature makes it more diverse and creative, which suits brainstorming. Temperature does not set or cap length, which is bounded by the maximum output tokens, and it does not make answers correct: a model that lacks a fact will repeat the same wrong answer at a low temperature. Supplying missing facts is the job of grounding with RAG. Temperature changes behavior per request and does not retrain the model.

Which AWS services store embeddings for vector search?

The AWS services the exam names for storing embeddings in vector databases are Amazon OpenSearch Service, Amazon Aurora, Amazon Neptune, and Amazon RDS for PostgreSQL. A vector database holds embeddings, which are numerical representations of meaning, and finds the closest matches to a query by similarity, which powers semantic search and RAG. OpenSearch Service has built-in vector search; Aurora PostgreSQL-Compatible Edition and RDS for PostgreSQL store vectors next to relational tables with the pgvector extension; and Neptune's vector search is a feature of Neptune Analytics. Services such as Amazon Athena, Amazon Kinesis, and the AWS Glue Data Catalog do not perform vector similarity search.

What is an AI agent?

An AI agent is an application that uses a foundation model as its reasoning engine and can take actions to accomplish a goal, rather than only returning text. It combines the foundation model, tools it can call such as APIs or database lookups, and orchestration that plans each step from the results so far. In Amazon Bedrock Agents, the tools are defined as action groups that map to API operations carried out by a Lambda function or your own code. Unlike a predefined workflow such as AWS Step Functions, where every branch is designed in advance, an agent interprets free-form requests and decides the next step at run time. Business applications include automating customer-service actions, booking or IT requests, and combining information from several systems.

What is prompt caching in Amazon Bedrock?

Prompt caching is a feature that stores a repeated prompt prefix, such as a long system prompt or reference document, so later requests that begin with the same prefix reuse it instead of processing it again. Cached input tokens are billed at a reduced rate and the first token of the reply arrives sooner, so caching lowers input cost and latency while keeping the same model and prompt. It does not change the model's answers, does not reduce output-token cost, gives little benefit when prompts share no common prefix, and is supported only on some models. Cached tokens still count toward the context window, so caching does not let an oversized document fit.

How is model distillation different from fine-tuning?

Model distillation trains a smaller student model to reproduce a larger teacher model's responses on a specific task, so the application can run a cheaper, faster model with most of the quality. Because the teacher generates the responses, distillation can start from prompts alone; Amazon Bedrock Model Distillation accepts prompts or existing invocation logs. Fine-tuning instead trains a model on labeled prompt-response pairs that you provide, to specialize its behavior or style. Continuous pre-training is different again: it uses unlabeled domain text to teach domain language rather than a task.

Why use RAG instead of putting all documents in the prompt?

Putting all source documents in the prompt, known as in-context learning, works only while the material is small. Once a document set grows, it no longer fits in the model's context window, and every request pays for every token of it even when most is irrelevant. RAG retrieves only the passages that match each question, which keeps prompts small and costs predictable as the collection grows. Prompt caching or a larger-window model can delay the problem, but every call still carries the whole document and cached tokens still count toward the window.

Source

This lesson covers the "Applications of Foundation Models" domain of the official AIF-C01 exam guide. Vendors revise their guides — check the source for the current version.

Test yourself on this topic
Practice now

Sign up free to mark lessons complete, bookmark topics and track your exam readiness.

Spotted a mistake in this lesson?