Build Your Own Generative AI Applications with AWS: Introduction to Amazon Bedrock
Tags: ai, cloudcomputing, aws, machinelearning
Published: 2023-11-23 08:04:50

In today’s tech world, AI is the superstar that’s changing the game. It’s not just about sci-fi movies anymore — it’s all around us, shaping our lives. One of the big players in this AI revolution is ChatGPT. You might have heard of it — it’s the cool tech that can chat with you almost like a human. However, ChatGPT is not the only player in the game. AWS recently announced general availability of [Amazon Bedrock](https://aws.amazon.com/bedrock/) — a fully managed service that will help you build and scale your own generative AI applications.

AWS is making continuous effort to democratize AI and enable broader access to its capabilities. With the launch of their new service, this exciting new technology is now attainable not just for research institutions or well-funded start-ups, but for organizations of all sizes and sectors. Amazon Bedrock enables you to quickly and easily access high-performing AI models and seamlessly integrate them into your applications in a cost-effective way and without managing any infrastructure. The service offers multiple foundational models to start with, but you can add your own custom data and further train the model for more specific tasks. This can be done without worrying about data security and without hiring an army of machine learning engineers. Regardless of the size of your business, you can take advantage of these models and go from an idea to a market-ready product in no time even if you’re on a budget.

**What are foundational models (FMs)?**

Foundation models are large deep learning neural networks trained on massive datasets. Instead of developing the traditional machine learning (ML) models that typically perform specific tasks from scratch, you can use foundational models as base models for developing more specialized applications, speeding up and optimizing the development of new ML models. FMs are trained on a broad spectrum of generalized and unlabeled data which gives them the ability to perform a wide range of general tasks out of the box, including text and image generation, natural language conversation and language understanding.

Foundational models are a form of generative AI so if you’ve used ChatGPT you already know how to use them. You provide one or more inputs (prompts) in the form of human language instructions, and the FM will generate output.

**What can foundation models do?**

The models can answer natural language questions. You can leverage this ability to engage in a dialogue and easily build a virtual assistant or a chatbot. Another handy capability is summarising, synthesizing or searching large amounts of text. These are generative models so of course, they are capable of creating content like articles or social media posts. The FMs can even generate or debug computer code in various programming languages. The ability to understand language also allows FMs to perform tasks such as transcribing a video or translating languages. Another capability is the generation of images from input text, as well as photo and video editing. FMs can also be used to identify images and physical objects which can be used in robotics.

If an off-the-shelf solution doesn’t suffice, you can use your own data to customize the model in order to improve the its performance on specific tasks. When you provide some labeled examples related to a specific task that needs to be carried out, you help the model learn. As a result, you can create a new model that is better capable of completing the tasks you need than the base model.


Now let’s take a closer look at the foundational models available in Amazon Bedrock.

**Titan**

A family of powerful, general-purpose models created by Amazon. Titan models were pretrained by AWS on large datasets and built to support a variety of use cases. Amazon Titan foundational models can help you generate or summarize text or hold open-ended conversations, but you can also use them for search and personalization.

There are currently three versions of the models. Titan Text Express, Titan Text Lite (both in preview) — these models can create and summarize text. The third one is Titan Embeddings (generally available, you can read the announcement [here](https://aws.amazon.com/about-aws/whats-new/2023/09/amazon-titan-embeddings-generally-available/)). Titan Embeddings is optimized for tasks such as search, personalization, and clustering based on semantic similarity.

**Jurassic**

Versatile foundational models by AI21 Labs, capable of generating nuanced text across a wide variety of industry sectors and which allow users to interact with the data in natural language and gain insights. Do you need to summarize a financial report, generate a product description or craft a bespoke marketing campaign? You got it. The models support English, as well as several other languages including Spanish, French, German, Portuguese, Italian and Dutch.

Bedrock offers Jurassic-2’s Ultra and Mid models. J2-Ultra is the largest and most powerful model in the Jurassic series. It is a great option for the very complex language processing tasks and generative text applications. J2-Mid is well-suited to complex language tasks and its fine-tuning options enable quality optimization without compromising affordability and high efficiency.

**Claude**

These foundational models by Anthropic excel at thoughtful dialogue, content creation, complex reasoning, creativity, and coding. Clause can process extensive amount of information such as legal documents or transcripts and it’s coding skills in a variety of programming languages are constantly improving.

You can opt for Claude Instant, which is a faster, more economical, yet very capable model that can manage various tasks, including casual conversation, text analysis, summarization, and document comprehension. Amazon Bedrock also offers Claude 2 and Claude 1.3. Claude 1.3 is an earlier version of Anthropic’s general-purpose large language model. Claude 2 is the newest and the most advanced version of the model which offers higher performance in math, reasoning, and coding tasks than its predecessor. The model was designed to be helpful, harmless, and honest within conversations and I have to say I really enjoyed interacting with it. If you want to try it for yourself, you can [talk to Claude here](https://www.anthropic.com/product).

**Command**

Command by Cohere is another text generation model but this time the focus is on business use cases. The text generation models can be used to automate creating content such as social media posts or product descriptions. Employee productivity can be enhanced with the use of virtual assistants which can perform routine tasks like scheduling meetings. Something that deserves to be highlighted here is the integrity — models are trained from known, purchased, or public data sources, and subjected to adversarial testing and bias mitigation.

There are two types of models available. Command — the text generation model which can summarize and generate text. You can either use Command or Command Light which is the smaller version of Command. Then there is the Embed model, which can be used for search, clustering, or classification tasks. There are two options available — an English only version and a multilingual version which supports over a hundred languages.

**Llama 2**

These models by Meta AI are optimized for dialogue use cases. When the second version of the model was being created, a lot of effort was put into preventing harmful, offensive or inappropriate responses which makes it ideal for customer service applications. Llama 2 can generate, translate and summarize text and even correct your grammar.

You can pick from two versions — Llama-2–13b-chat or Llama-2–70b-chat (coming soon). Llama-2–70b-chat will allow you to build a chatbot with the best accuracy. If your priority is to create a chatbot quickly and cost-effectively, even if that means sacrificing some precision, then Llama-2–13b-chat is a great option.

**Stable Diffusion XL**

This text-to-image model by Stability AI is capable of generating images of high quality in virtually any art style and is the best open model for photorealism. If you are in marketing, advertising, media, entertainment or gaming, this model might get your attention. You can use it to help you generate compelling ad campaigns and other assets.

Bedrock offers Stable Diffusion XL 0.8 and Stable Diffusion XL 1.0, both currently in preview. Stable Diffusion XL 1.0 is the most advanced text-to-image model from Stability AI, capable of producing images at a resolution of up to 1024×1024 pixels — much higher than the previous models. This upgrade allows Stable Diffusion XL to produce images with finer details like textures, patterns and facial features with much higher fidelity. You can read more and see some examples of the generated images [here](https://magai.co/stable-diffusion-xl-1-0/).


**Model access**

You can access the Amazon Bedrock API in all the familiar ways — using the AWS Command Line Interface, an AWS SDK, or a SageMaker Notebook. Bedrock is currently only supported in five regions, you can see the list [here](https://docs.aws.amazon.com/general/latest/gr/bedrock.html).

To use any of these foundational models, you need to request access (select the Model access link in the left side navigation panel in the Amazon Bedrock console). You will need to have the correct IAM permissions and for some of the models, you may need to submit use case details before you are able to request access.

On the Examples tab in the console, you will be able to find example prompts and API requests for each of the supported models. You can run these examples by choosing Open in playground.

**Pricing**

When you use Amazon Bedrock, you will be charged for model inference and customization. For inference, you can choose On Demand or Provisioned Throughput plan.

With On Demand mode, you will only pay for what you use. It will allow you to use FMs on a pay-as-you-go basis without the need to make fixed time commitments. What you are charged for will depend on whether you are using a text generation, image generation or embeddings models. You can read the details [here](https://aws.amazon.com/bedrock/pricing/).

Provisioned Throughput mode might be a better option if your application’s performance requirements are high and you need guaranteed throughput. You will be charged by the hour and you can choose between 1-month or 6-month commitment terms. Custom models can only be accessed using Provisioned Throughput.

If you decide to customize your model, you will also be charged for model training. To see the details of how you’re going to be charged for training an inference on custom models and also the breakdown of pricing for every provider and model, click [here](https://aws.amazon.com/bedrock/pricing/).

**Getting Started with Amazon Bedrock**

AWS SkillBuilder offers a [60-minute course](https://explore.skillbuilder.aws/learn/course/external/view/elearning/17508/amazon-bedrock-getting-started) that can help you understand Amazon Bedrock a bit better. You can access the documentation for the service [here](https://docs.aws.amazon.com/bedrock/).

**Summary**

Foundational models are unlocking new AI capabilities for enterprises across sectors. These robust, versatile models can provide the core technical building blocks companies need to bring innovative AI systems to market faster. For enterprises looking to harness AI’s benefits, foundational models provide proven, production-ready springboards to develop tailored solutions on budget and on time.

_________________________________________________________________

Are new to the world of cloud computing and want to learn more but don’t know where to start? I can help you out! I created an online course for people who are preparing for their first AWS Certification exam. It contains all the tips and tricks you’ll need to ace your exam. You can find more information [here](https://www.udemy.com/course/starting-with-aws-certification/?referralCode=F18702334AD436651D1A).