Getting Started with Amazon Bedrock

In this hands-on tutorial, we will learn how to get started with Amazon Bedrock, a new Generative AI Service from AWS. Amazon Bedrock is Generally Available as of 28th Sep 2023.

Introduction

Amazon Bedrock makes it easy for developers to use a wide range of powerful FMs from Amazon and other leading AI companies, such as AI21 Labs, Anthropic, Cohere, Meta, and Stability AI. You can quickly try out different FMs in the playground, and use the same API for inference regardless of the model you choose. This gives you the flexibility to use FMs from different providers and keep up with the latest model versions with minimal code changes.

  • Amazon Bedrock is a developer-friendly service for using FMs.
  • It offers a wide range of high-performing FMs from multiple providers, including Amazon, AI21 Labs, Anthropic, Cohere, Meta, and Stability AI.
  • You can quickly experiment with different FMs in the playground.
  • You can use a single API for inference regardless of the model you choose.
  • This gives you the flexibility to use FMs from different providers and keep up with the latest model versions with minimal code changes.

Access Amazon Bedrock via AWS Console

Follow the steps to get access and to start interacting with Amazon Bedrock Foundation Models

Login to AWS Console: https://console.aws.amazon.com/ and perform the following steps to gain access to Amazon Bedrock foundation models. Currently the Amazon Bedrock is available in US East (N. Virginia), US West (Oregon), US East (Ohio), Asia Pacific (Singapore) and Asia Pacific (Tokyo).

US East (Ohio), Asia Pacific (Singapore) and Asia Pacific (Tokyo) regions has limited model availability.

Step 1: Under the Services menu navigate to -> Machine Learning -> Amazon Bedrock and click on it.

Amazon Bedrock Service on AWS - WowData.Science

Step 2: On the Landing Page of Amazon Bedrock, click Get started button.

Amazon Bedrock Product Detail Page - WowData.Science

Step 3:Navigate to Model access menu in the side navigation and click on Edit button. Select the Base models that you want access to.

Amazon Bedrock Model Access - WowData.Science

Note that this is one time activity for the models to which you need access to. Once you make a selection of base models, proceed to next step.

Step 4: Save Changes for the choice of models you have selected. The Access will be granted instantly for few models as shown below.

Amazon Bedrock Model Access Request Save Changes - WowData.Science

Step 5: Now let's move to interact with chat models. For that in the side navigation click on Chat menu and you will land on Chat playground for Amazon Bedrock chat models.

Amazon Bedrock Choice of Chat Models - WowData.Science

You can notice, currently it has AI21 Labs, Amazon, Anthropic, Cohere in the model category. These are Model providers and selection of one of those will populate the Select model dropdown which shows the chat models available from those respective AI startups and AI companies. Let's choose Anthropic for the sake of getting started.

Step 6: Lets select Claude v2 from Anthropic.

Amazon Bedrock Claude V2 Prompt - WowData.Science

Once you select the chat model, you will see the Add instructions link along with the text box below that get enabled.

Provide the Human: prompt in the textbox and press the Run button.

Human: Write a creative linkedin status post for a wonderful team lunch we had at BedRock Restaurant & Bar last Friday Night.

If you want to add instructions, go ahead and set the instructions before initiating the chat.

Update instructions to model on Amazon Bedrock Chat model playground - WowData.Science

Step 7: You can also Update inference configurations before you run the chat. Clicking on the Update inference configurations link lets you choose the inference parameters such as Temperature, Top P, Top K, Length.

The Inference configurations controlled by the inference parameters help you build the effective response from the chat models you are interacting with.

Step 8: Once you are done with Adding Instructions, Choosing Inference configuration &  providing Human input as your prompt, the response from the model will show up as demonstrated in the screen below.

Amazon Bedrock Chat Playground response - WowData.Science

You can choose to show response in Streaming and the response will be shown to you on the UI in the form of chunks of words one after the other till the end of response.

You have the option to copy the response from the chat model by just clicking on the copy button as shown in the above screenshot.

Next Steps

That's all about Getting Started with Amazon Bedrock. You can explore accessing the base models along with chat models on the play ground via UI of Amazon Bedrock service on AWS console, or you can also programmatically interact with these models via API via boto3.

Pricing:

Amazon Bedrock pricing