← AI Practitioner study path

Generative AI basics · 13 min

What is a foundation model?

In this lesson you will learn what a foundation model is and how it differs from a traditional ML model, what a transformer and an LLM are, and how to recognize a multimodal model or a diffusion model in a question.

A foundation model is the type of model on which all the generative AI assessed on the AWS Certified AI Practitioner (AIF-C01) exam is built. Generative AI is the kind that creates new content, such as a text, an image or a summary, from what you ask it. A foundation model differs from models trained for a single task because one foundation model can be used for many tasks.

What is a foundation model?

The Amazon Bedrock documentation defines a foundation model (FM) as an AI model with a large number of parameters, trained on a massive amount of diverse data, that can generate responses for a wide variety of use cases. These responses can be text or images, and an FM can also convert an input into an embedding, which is a list of numbers that represents its meaning. For example, an online store can use the same foundation model to write a product description, answer a customer's question and summarize the week's reviews.

A model's parameters are the internal values that the model learned during its training and that decide how it responds. These parameters are controlled by the model provider, and you only change them if you customize the model. What you do adjust on each call are the inference parameters, which are the options for that particular response, such as its length. For example, the store can't change what the model knows about English, but it can ask that a product description be no longer than a few lines.

When a provider packages an FM and makes it ready to use, AWS calls it a base model. For example, if the store chooses a model in Amazon Bedrock that another company already trained and uses it as is, without changing anything, it is using a base model.

Differences from a traditional ML model

A traditional ML model performs a single task, such as telling whether a transaction is fraud, classifying a photo or forecasting sales. This model is trained with labeled data for that task, that is, with examples where a person already wrote the correct answer. For example, for a model to detect fraud, a bank gives it thousands of past transactions, each one marked by hand as "fraud" or "not fraud".

A foundation model differs from it in two ways:

  • Training, which uses general unlabeled data through self-supervised learning, where the model derives its own labels from the data and nobody has to label millions of examples by hand. For example, the model reads a sentence with the last word hidden, tries to guess it and then compares it with the real word, so the text itself gives it the answer.
  • Adaptability, which AWS describes as the unique feature of FMs and which consists of performing very different tasks depending on the , so that you can summarize, translate or classify with the same model. For example, the store asks the same model to translate a review into Spanish and, in the next request, to say whether that review is positive or negative.

That adaptability comes at a high training cost. According to AWS, building a foundation model from scratch costs millions of dollars, and the Generative AI Lens adds that pretraining requires clusters of running for weeks. That is why almost every company takes a base model that someone else already trained and adapts it to what it needs. For example, the store doesn't train its own model: it uses one that already exists and gives it its own instructions.

Foundation model or traditional ML?

0 of 4

Tap the column that best describes each case.

  1. A bank trains a model with years of labeled transactions to flag fraud.

  2. The same model summarizes contracts in the morning and translates emails in the afternoon.

  3. The model learned from general text without anyone labeling it.

  4. A model forecasts a store's demand from its past sales.

Transformers and LLMs

The exam guide talks about "transformer-based LLMs", and that phrase combines two different terms: the transformer is an architecture, that is, the way the model is built on the inside, and the LLM is a type of model built with it.

Comparison between a model that reads word by word and a transformer that reads the whole sequence and relates its parts with self-attention

The models that came before the transformer read one word after another and, by the time they reached the end of a paragraph, had already lost the beginning. AWS uses this example: to write "I speak Italian", the model has to remember that the sentence started with "I am from Italy". For example, if one of the store's customers writes a long message that starts with "I bought some red sneakers" and ends with "can I exchange them?", a model of that kind could forget what "them" referred to.

The transformer solved that problem. It is a architecture that transforms an input sequence into an output sequence by learning the context and the relationships between its parts. The transformer reads the whole sequence at once and, with a mechanism called self-attention, decides which parts matter for each word. For example, when it reads "can I exchange them?", self-attention links "them" with "red sneakers", even though they are far apart in the message. In addition, because it processes everything in parallel, it trains much faster, and that made it possible to train huge models.

An LLM (large language model) is exactly one of those huge models: a model, pretrained on vast amounts of text, that is a transformer on the inside. During training, the LLM adjusts its parameters until it predicts the next well from the previous ones. For example, after "Thank you for your", the LLM learns that "purchase" is a very likely continuation.

So all LLMs are foundation models, but not all foundation models are LLMs. For example, a model that generates images is an FM and doesn't work with language, so it isn't an LLM.

True or false?

0 of 3
  1. Every foundation model is an LLM.

  2. A transformer reads the complete sequence and relates each part to the others.

  3. When you use a base model in Amazon Bedrock, you adjust its parameters on each call.

Multimodal models

A multimodal model is a foundation model that processes several types of data in the same request, such as text, images, video, documents or speech. It is useful when the input and the output aren't the same type, or when several types have to be mixed. For example, one of the store's customers sends a photo of a product that arrived broken and the model answers with a text that describes the damage.

The Amazon Nova 2 models with their input and output types

The Amazon Nova 2 family has multimodal models that differ in the types of data they receive and return. Nova 2 Lite receives text, images, video and documents and responds in text, while Nova 2 Sonic receives speech and text and responds with speech and text. Nova Multimodal Embeddings converts any of those data types into a , so with it you can search for a video by typing a sentence. For example, the store could search its product videos by typing "running shoes in the rain" and find the video that shows that, even if the video doesn't have those words in its name.

Diffusion models

A diffusion model is a foundation model that generates images from noise, and AWS uses Stable Diffusion as an example. Noise is an image made only of random dots, like the static on a TV with no signal.

Forward diffusion, which adds noise to an image, and reverse diffusion, which removes it to generate a new image

A diffusion model works in two directions. In forward diffusion, the model takes real images and adds noise to them little by little, until only noise remains. In reverse diffusion it does the opposite to generate an image: it starts from random noise and removes it in several steps, guided by the prompt, until a new image comes out. For example, the store writes "a blue backpack on a wooden table" and the model keeps cleaning up the noise until a blue backpack that never existed appears. The same technique is also used to generate video and animations.

What are foundation models used for?

The exam guide lists these use cases for generative AI: image, video and audio generation, summarization, AI assistants, translation, code generation, customer service agents, search and recommendation engines. In a question, the use case helps you decide which type of model is needed, based on the data that goes in and the data that comes out. For example, if text goes in and an image comes out, you look for a diffusion model, and if an image goes in and text comes out, you look for a multimodal model.

Which type of model are you looking for?

An insurance company wants its customers to send a photo of a car crash and receive a written description of the damage. Which type of model does it need?

In both accounts

Foundation models work the same way in the full AWS account and in the new experience account. If you want to see a foundation model working, Amazon Bedrock is in the free plan of the new experience, and using a model in its gives you 20 USD in credit. In that account, choose a model available within us-east-2, because the new experience doesn't support cross-Region inference, which is sending your request to a model that runs in another AWS Region. For example, if a model can only be used by sending the request to another Region, you won't be able to try it in that account.

On the exam

A question on this topic can describe a model and ask you for its name, or describe a task and ask you for the type of model that solves it. Some words in the question point to the answer:

  • "Unlabeled data", "many tasks" and "pretrained model", which point to a foundation model.
  • "Relationships between words" and "self-attention", which point to a transformer.
  • "Remove noise", which points to a diffusion model.
  • "Describe this image" or "search these videos with a sentence", which mix data types and point to a multimodal model.

For example, if the question says a model "learned from large amounts of unlabeled text and now summarizes, translates and classifies", the answer is a foundation model.

Review question

An agency wants to create product images from a text description. The model provider explains that, during training, the model learned to remove noise from images step by step. What type of model is it?

Next

  • Key terminology, the Amazon Bedrock page with the definitions of foundation model, base model, token and embedding.
  • Take an AI Practitioner practice exam at /examenes and review your result in domain 2.