Generative AI with Amazon Bedrock
Tags: aws, ai, bedock, genai
Published: 2024-02-19 16:46:23

>**Note:** ✋ This post was originally published on my blog [wiki-cloud.co](https://wiki-cloud.co/en/2024/01/generative-ai-with-amazon-bedrock/)

## **Introduction**

According to our previous [article](https://dev.to/aws-builders/discovering-the-power-of-generative-ai-on-aws-29dg) where an introduction to the **Generative Artificial Intelligence (GenAI)** at AWS, we commented on a series of services available from AWS to make use of this GenAI technology, among which was **Amazon Bedrock**. In this article we will focus on this particular service.

In April 2023, AWS announced the incorporation of the Amazon Bedrock service, enabling its use privately for startups such as _Coda_, _Hurone AI_ and _Nexxiot_, and for large companies as _Adidas_, _GoDaddy_, _Clariant_ and _Broadridge_, allowing them to securely build and scale GenAI applications using Amazon Bedrock. However, on September 28, 2023, AWS announced its [general availability (GA)](https://aws.amazon.com/es/about-aws/whats-new/2023/09/amazon-bedrock-generally-available) being more accessible to more users and customers, offering a set of GenAI models from Amazon and third-party providers through an application programming interface (API).

> _“Generative AI is at an inflection point, generating new ideas that could transform entire industries and reimagine how work gets done.” (Swami Sivasubramanian, VP of Data & ML at AWS)._

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aiaytokannvrf4tcck5u.png)

## **Amazon Bedrock**

I had mentioned that Amazon Bedrock is a fully managed service that makes Foundation Models – FM) from leading AI startups and Amazon are available through an application programming interface (API), giving users the flexibility to select from a variety of FMs, allowing them to find the option that best suits them of specific use case.

To date, the Amazon Bedrock service is available in the following AWS regions with all features enabled:

- US East (N. Virginia)
- US West (Oregon)
- Asia Pacific (Singapore)
- Asia Pacific (Tokyo)
- Europe (Frankfurt)

The following table shows limited features in each of the available regions:

| Region                   | Model Evalution | Knowledge Base | Agents | Fine Tuning | Continued pre-training | Provisioned Performance                                   |
|--------------------------|-----------------|----------------|--------|-------------|------------------------|-----------------------------------------------------------|
| US East (N. Virginia)    | Yes             | Yes            | Yes    | Yes         | Yes                    | Yes                                                       |
| US West (Oregon)         | Yes             | Yes            | Yes    | Yes         | Yes                    | Yes                                                       |
| Asia Pacific (Singapore) | No              | No             | No     | No          | No                     | No                                                        |
| Asia Pacific (Tokyo)     | No              | No             | Np     | Np          | No                     | No                                                        |
| Europe (Frankfurt)       | No              | No             | No     | No          | No                     | No                                                        |
| AWS GovCloud (US-West)   | No              | No             | No     | No          | No                     | Yes (only for fine-tuned models, with no commitment term) |

In the following [link](https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-bedrock.html) you will find the description of endpoints and quotas in the regions where they are available.

**Benefits**

- Accelerate GenAI application development using FM through an API.
- It is a serverless service, which means that users and/or clients do not have to manage any infrastructure.
- Allows you to choose FM from leading AI startups such as AI21 Labs, Anthropic, Cohere, Stability AI, Amazon and Meta.
- Allows you to personalize FMs privately using corporate or organization data.
- Amazon Bedrock is designed to scale and meet the needs of organizations of all sizes.
- It offers security features such as encryption of data in transit and at rest.
- AWS provides private connectivity between Amazon Bedrock and the Virtual Private Cloud (VPC).

## **Foundational Models available**

Let us remember that FMs are very large models that are pre-trained on large data collections and that there are three types of FMs available on the market: Text to Text, Text to Embeddings and Multimodal.

With these FM and other services, companies can create GenAI applications for tasks such as content creation, data analysis, image generation, text translation, and much more.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ibhg5xylqxzta3dbrrms.png)

The FMs available on Amazon Bedrock are described below:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/urc33ckzbvrxc1nwq3wr.png)

| Foundational Models                | Description |
|------------------------|-------------|
|![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bv2r37wnsx06790k5uc3.png)[Amazon Titan](https://aws.amazon.com/bedrock/titan/?nc1=h_ls)              | Amazon Titan FMs are a family of FMs pre-trained by AWS on large data sets, making them powerful, general-purpose models built to support a variety of use cases such as text generation, summarization, semantic search, and increased recovery generation. The current available model versions that are compatible with Amazon Bedrock are: _Titan Text – Lite (Preview)_, _Titan Text – Express (Preview)_, _Titan Embeddings G1 – Text (GA)_  |
|![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qmm0vnotpcedaxh0biee.png)[Jurassic-2](https://aws.amazon.com/bedrock/jurassic/?nc1=h_ls)          | The startup [AI21 Labs](https://www.ai21.com/) introduces the Jurassic series of Large Language Models (LLM) that are designed to follow natural language instructions including summarizing, writing articles and emails, answering questions from a provided knowledge base and more. These models support English, as well as other languages, including Spanish, French, German, Portuguese, Italian, and Dutch. Customers can choose between models of different sizes depending on the complexity of the task at hand, allowing them to optimize costs and performance accordingly. AI21 Labs offers the following models that are compatible on Amazon Bedrock: _Jurassic-2 Ultra_, _Jurassic-2 Mid_  |
|![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/56115vb6kcrfq8jpwxou.png)[Claude 2](https://aws.amazon.com/bedrock/claude/)  | [Anthropic](https://www.anthropic.com/) is an AI research and security laboratory that creates trustworthy, interpretable and targetable AI systems, it is the creator of the next-generation Claude LLM. The new version of the LLM, Claude 2, can process large amounts of text and can perform reflective dialogue, content creation, complex reasoning and coding, where its main use cases are: _**Customer Service**_ (Claude can act as a virtual sales representative), _**Operations**_ (Claude can extract relevant information from emails and business documents), _**Legal**_ (Claude can analyze legal documents and answer questions about them), _**Coding**_ (Claude's models are constantly improving in coding, mathematics, and reasoning). Anthropic offers the following models that are compatible on Amazon Bedrock: _Claude v1.x_, _Claude v2.x_, _Claude Instant v1.x_         |
|![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xnjwd9d5eu1tgqdmllyy.png)[Cohere Command](https://aws.amazon.com/bedrock/cohere-command-embed/?nc1=h_ls)  | [Cohere](https://cohere.com/) is a leading startup and developer of next-generation enterprise AI and FM platforms, and its FMs help unlock more intuitive ways to generate, search, and summarize information. Command, Cohere's flagship text generation model, is trained to follow user commands and be instantly useful in practical business applications such as summarization, copywriting, dialog, extraction, and question answering. Cohere offers the following models that are compatible on Amazon Bedrock: _Command v14.7_, _Command Light v14.7_, _Embed English v3.0_, _Embed Multilingual v3.0_.         |
|![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ob36oxpcnwiex98lf5ev.png)[Stable Diffusion XL (SDXL)](https://aws.amazon.com/bedrock/llama-2/?nc1=h_ls)  | [Stability AI](https://stability.ai/) is an open community-driven AI company, offering FMs that create text, images, audio, video, code, and more from simple text instructions. With Stable Diffusion XL, you can create descriptive images with shorter prompts and generate words within the images. The model is a significant advancement in imaging capabilities, offering improved image compositing and face generation resulting in stunning images and realistic aesthetics. Its main use cases are: _**Advertising and marketing**_ (Allows you to create personalized advertising campaigns and unlimited marketing assets), _**Media & Entertainment**_ (Develop unlimited creative assets and ideas with images), _**Games and Metaverse**_ (Allows you to create new characters, scenes and worlds). Stability AI offers the following models that are supported on Amazon Bedrock: _Stable Diffusion XL 0.x_, _Stable Diffusion XL 1.x (Only available with provisioned performance)_.         |
|![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/twr5dmqsomiwm5p854pm.png)[Llama 2](https://aws.amazon.com/bedrock/llama-2/?nc1=h_ls)  | [Meta](https://about.meta.com/) is an American technology and social media conglomerate. It is the parent company of Facebook, Instagram, WhatsApp and other subsidiaries. Meta has developed [Llama 2](https://ai.meta.com/llama/) which is a collection of large language models (LLM) that are pre-trained and tuned and optimized for dialog use cases. Meta offers the following model that is compatible on Amazon Bedrock: _Llama 2 Chat 13B_.         |

**Amazon Bedrock Agents**

In the latest news, AWS launched agents for Amazon Bedrock that allows developers to configure an agent to complete actions based on organization data and user input. Agents orchestrate interactions between foundational models, data sources, software applications, and user conversations, and automatically call APIs to take action. Developers can easily integrate agents and accelerate the delivery of generative AI applications, saving weeks of development effort by producing up-to-date responses based on their own data.

Additionally, they allow you to automate complex tasks for a model without the need for a developer to manually write the code necessary to do so. Specifically, developers can use agents to connect base models to their proprietary data sources so that the applications they create produce updated responses based on their own data. When a user uses a generative AI application built with Bedrock, an agent makes API calls that retrieve the necessary data from proprietary sources to respond to the user's requests or queries.

## **Pricing Model**

Amazon Bedrock present the following pricing models:

- **On demand**: Pay per use, without time commitments. For the text generation model, you will be charged for each input token processed and each output token generated. For the embedding model, you will be charged for each input token processed. For image generation models, you will be charged for each image generated.
- **Provisioned Performance**: With this pricing model, it is possible to purchase model units for a specific or custom base model. The provisioned performance model is primarily designed for large, consistent inference workloads that need guaranteed performance.
- **Model customization (fine tuning)**: Amazon Bedrock allows you to customize the selected FM with corporate data to improve accuracy, enable customization, and optimize solutions tailored to business needs. For customization of a text generation model, you will be charged for model training based on the number of tokens processed by the model (number of tokens in the training data corpus x number of epochs) and model storage charged per month per model.

> **Note:** A _**token**_ is made up of a few characters and refers to the basic unit that a model learns to understand user input and request it to generate results. An _**epoch**_ refers to a complete scan through the training data set during the fitting process.

## **Conclusions**

Amazon Bedrock is an innovative GenAI service built on the AWS platform and promises to revolutionize how organizations leverage GenAI by providing numerous benefits, including access to a variety of FMs that will continue to grow over time, scalability, and security. An interesting point is that the service can be used in a wide range of use cases, making Amazon Bedrock a valuable service for organizations of any size and in any industry.

## **Resources**

Review the following resources to learn more about Amazon Bedrock:

- [Amazon Bedrock](https://aws.amazon.com/es/bedrock/), the easiest way to build and scale generative AI applications with FM.
- [Amazon Bedrock Workshop](https://catalog.us-east-1.prod.workshops.aws/workshops/a4bdb007-5600-4368-81c5-ff5b4154f518/en-US), hands-on experience to learn how to leverage foundational models (FM) through Amazon Bedrock.
- [Amazon Bedrock pricing models](https://aws.amazon.com/es/bedrock/pricing/), summary and pricing breakdown by model.
- [Bedrock API Reference](https://docs.aws.amazon.com/bedrock/latest/APIReference/welcome.html), document that provides detailed information about Bedrock API actions and their parameters.
- [Anthropic Claude Model documentation](https://docs.anthropic.com/claude/docs)
- [AI21 Labs Jurassic Model documentation](https://docs.ai21.com/docs/jurassic-2-models)
- [Cohere Command Model documentation](https://docs.cohere.com/docs/the-cohere-platform)
- [Model Stable Diffusion XL (SDXL) documentation](https://platform.stability.ai/docs/getting-started)

I hope this information is useful.

Best Regards,

**Follow me:**

> 👉[Wiki Cloud](http://wiki-cloud.co/) | 👉[Twitter](https://twitter.com/johnbulla) | 👉[LinkedIn](https://www.linkedin.com/in/johnbulla) | 👉[Github](https://github.com/johnbulla) | 👉[Youtube](https://www.youtube.com/user/johnbulla)