Lesson 1 of 4 Generative AI and Prompt Engineering

How Foundation Models Generate Content

Generative AI behaves differently from traditional software and from predictive ML. This lesson explains what foundation models are, how they generate text and the characteristics that business users must plan for.

Learning outcomes

After completing this lesson, you will be able to:

  • Explain what foundation models and large language models are.
  • Describe non-deterministic output, hallucination and knowledge cut-off.
  • Explain how to choose a model on quality, latency and cost.
  • Describe the stages in which a foundation model is built.
  • Distinguish text generation, image generation, embeddings and multimodal models.
  • Explain the effect of temperature, top P and maximum output tokens.

Foundation models and large language models

A foundation model (FM) is a very large model trained on broad data, such as much of the public web, books and code, so that it can be adapted to many tasks. A large language model (LLM) is a foundation model specialised in text. Multimodal models also accept or produce images, audio or video. Training a foundation model costs a great deal, so most organisations use models built by providers, accessed through services such as Amazon Bedrock.

An LLM generates text one token at a time. At each step it predicts which token is most likely to come next, given everything it has seen so far, adds it, and repeats. This simple mechanism, at enormous scale, produces fluent summaries, answers, translations and code.

How a foundation model is built

A foundation model is built in stages. In pre-training, it learns general language ability by predicting the next token across a vast body of text, which needs no manual labels. In instruction tuning, it is trained on examples of instructions and good responses, so that it follows requests rather than simply continuing text. In alignment, often using reinforcement learning from human feedback, it learns to prefer responses that people rate as helpful, accurate and safe. The lesson on learning from historical data introduces these methods. Organisations that use a provider's model inherit the results of all three stages, including the provider's choices about data and safety.

Put in order

Building a foundation model

Exam skills 1.1.5 · 1.3.3

Put the stages that produce a usable foundation model in order.

Log in to try this activity Interactive activities are free with an account.

Kinds of generative model

Different models are built for different kinds of content. The following terms describe the kinds most often met in business.

Text generation model
Produces text, including answers, summaries, translations and code. Most LLMs are of this kind.
Image generation model
Produces images from a text description, used for concept art, marketing drafts and product visualisation.
Embeddings model
Converts text or images into numerical representations of meaning, used to search by meaning and to power RAG rather than to produce readable output.
Multimodal model
Accepts more than one kind of input, such as a photograph with a question about it, and may produce more than one kind of output.

Characteristics business users must plan for

Because generation is based on probabilities rather than lookup of facts, generative AI has characteristics that differ from conventional software. The following terms describe the ones that matter most for business use.

Non-deterministic output
The same prompt can produce different responses. A setting called temperature controls how varied the output is: lower values give more consistent answers, higher values more creative ones.
Hallucination
A fluent, confident output that is false or not supported by any source. It is a consequence of generating plausible text rather than retrieving verified facts.
Knowledge cut-off
The model only knows what was in its training data, which ends at a point in time and excludes private company information.
Prompt sensitivity
Small changes in wording, order or examples can change the quality of the output.

Inference parameters

Applications can adjust a model's behaviour for each request through inference parameters. Business users meet them in playgrounds and in requirements discussions with technical teams. The following table describes the most common ones.

ParameterEffectTypical business setting
TemperatureControls randomness: low values choose the most likely tokens, high values allow less likely onesLow for factual answers, extraction and classification; higher for brainstorming and creative drafts
Top PLimits choices to the most likely tokens whose probabilities add up to a set shareUsually left at the default, or lowered with temperature for consistency
Maximum output tokensCaps the length of the responseSet to fit the required format; too low cuts answers off
Stop sequencesText that ends the response when generatedUsed to keep outputs to a defined structure

Lowering temperature makes output more consistent, but it does not make it correct. A model can produce the same wrong answer every time, so consistency settings do not replace grounding and review.

Scenario questions

Set the parameters

Exam skills 1.3.1 · 1.3.2

Choose the inference setting for each business requirement.

Log in to try this activity Interactive activities are free with an account.

Choosing a model

Models differ in capability, speed, cost, context window size, supported languages and modalities. Larger models are generally more capable at complex reasoning but slower and more expensive per token; smaller models are faster and cheaper and are often sufficient for focused tasks such as classification or extraction. Business teams should select models by evaluating them on their own tasks against quality, latency and cost requirements, rather than choosing the largest or best-known model by default.

Evaluation compares candidate models on a representative set of the organisation's own inputs, scored against agreed criteria. Scoring can use human reviewers, automatic metrics, or another model acting as a judge against a written rubric. Amazon Bedrock provides model evaluation capabilities that support these methods. The following table lists the criteria that typically matter.

CriterionWhat to check
Task qualityAccuracy, completeness and format on the organisation's own examples
LatencyResponse time, especially for customer-facing use
CostPrice per input and output token at the expected volume
Context windowWhether typical inputs and documents fit
Languages and modalitiesSupport for the languages, images or documents involved
Availability and termsAvailability in the required AWS Regions, data handling terms and lifecycle dates
Worked example

Setting expectations for a pilot

A marketing director plans a pilot in which a generative model writes product descriptions for 4,000 catalogue items. They expect identical output each time a description is regenerated and assume the model knows the specifications of next season's products. Which expectations need correcting?

Both. Generative output is non-deterministic: regenerating a description produces a different wording unless temperature is set low, and even then wording can vary, so approved descriptions should be stored rather than regenerated. The model has a knowledge cut-off and no access to private product data, so the specifications must be supplied in the prompt or retrieved from the product database. Otherwise the model will hallucinate plausible but wrong details. Human review of a sample, and of every safety-related claim, should be part of the process.

Worked example

A large model or a small one?

A telecommunications company plans to classify two million customer emails a month into 12 categories. In an evaluation on 1,000 of its own emails, a large model classifies 97% correctly and a small model 95%. The large model costs about ten times as much per token and responds more slowly. Which should it choose?

The decision depends on the cost of the additional errors. At two million emails, the two-point difference is about 40,000 more misclassified emails a month with the small model. If a misclassified email simply reaches the wrong queue and is redirected, that cost is probably far lower than a tenfold increase in model spending, so the small model is the better choice, perhaps with low-confidence cases sent to the large model or to a person. If misclassification caused regulatory complaints to be missed, the balance could change. Either way, the decision rests on evaluation on the company's own data and on business costs, not on model size.

Check yourself

What does lowering the temperature setting of a generative model do?

Show answer

It makes outputs more consistent and less varied, which suits factual tasks. Higher temperature produces more varied, creative output.

Exam Tips

Remember for the exam

  • Foundation models are trained on broad data and adapted to many tasks; LLMs are text foundation models.
  • LLMs generate one token at a time by predicting the most likely next token.
  • Expect non-deterministic output, hallucinations and a knowledge cut-off.
  • Choose models by evaluating quality, latency and cost on your own tasks.
  • Foundation models are pre-trained, instruction-tuned and aligned with human feedback.
  • Embeddings models convert content into numerical meaning for search and RAG; they do not write text.
  • Low temperature gives consistent output, not correct output.