DEV Community

Cover image for Bedrock Jumpstart Series: Bedrock Overview

Bedrock Jumpstart Series: Bedrock Overview

## Bedrock Series

The Bedrock Jumpstart Series will go through the fundamentals of Bedrock for the AWS developer who already knows the fundamentals of AWS. Each article besides this one will come with a Python code example in which will be contained in an AWS Lambda function.

  1. Bedrock Overview
  2. Foundational Models
  3. Knowledge Bases (RAG)
  4. Langchain and Bedrock
  5. Bedrock Agents
  6. Fine-tuning Models

So in this article we will go over the basics in a quick overview of Bedrock and then take a close look at Foundational Models. Then onto Knowledge bases and RAG which are innovations on top of generative AI and are seeing significant development in the world of AI. Then onto Langchain, a python-based framework that simplifies foundational model app development, especially LLMs (Large Language Models), and that can be used in conjunction with the Amazon Bedrock API. This will enable us to go onto building a Bedrock Agent in a better way. Agents will also likely have very significant development in AI. Lastly we will go into the mechanics of fine-tuning of models in Bedrock in which one deeply customizes the model for specific use cases.

What is Generative AI?

In 2017, the Transformer architecture revolutionized NLP (Natural Language Process) and led to a new subset of deep learning called Generative AI. Generative AI (GenAI) is being adopted quickly and many are heralding it as a disruptive force across industries. It is indeed a subset of deep learning which in turn is a subset of Machine Learning, which is the ability of computers to see and remember patterns in data by learning without explicit programming. So it’s important to conceptualize a bit how it enriches traditional deep learning and machine learning.

In GenAI the Transformer Architecture through its Attention Mechanism allows us to see patterns in data in a greater way than traditional deep learning by creating interconnections between discrete parts of the data through vectors of numbers. It's like instead of examining pairs of words it examines the relationship of each word to every other word. In that way, through vectors of numbers, it can in some way understand the semantics of the words through fine-grained comparisons along with a very large body of data. And it can do this dynamically, re-examining a set of new data to make even better predictions, generate more creative text outputs, or provide deeper insights than ever before.

Generative AI is called Generative AI because in understanding so much of the semantics of language (or other data) through comparisons of vectors it's able to not just predict but to create, it facilitates not just simple predictions but complex predictions.

What is Bedrock?

Here is the Webster definition of ‘Bedrock’:

“: the solid rock underlying unconsolidated surface materials (such as soil)”

Similar to the natural bedrock, AWS Bedrock provides a foundational layer in which surface materials can be integrated with. A natural bedrock provides stability but also variety and in the same way AWS Bedrock provides the stability of FMs with not just one type but a variety of choices.

Bedrock vs. SageMaker

Bedrock is an abstraction above SageMaker for foundational models. Those FMs don’t need to deal with Generative AI but Bedrock is mostly targeted for FMs that cater to Generative AI.

Bedrock Security & Governance

In Bedrock there is comprehensive monitoring and logging capabilities. CloudWatch can track usage metrics and build customized dashboards for enhanced visibility. CloudTrail to monitor API activity to help to identify and troubleshoot issues.

Data is always encrypted at transit and at rest and you can use your own keys to encrypt. You can use PrivateLink to connect Bedrock to on-prem networks without wandering through the internet. Your content is never shared with Third-party providers and is never used to better the models. With its many AWS tools and configurations, AWS Bedrock allows you to maintain compliance with standards like GDPR compliance and HIPPA eligibility.

Bedrock Guardrails

As part of ‘Responsible AI’, AWS Bedrock implements Guardrails which allow certain restrictions that could be harmful to the user experience. These guardrails can be customized for user queries and responses and even integrated into agents. You can have fine-grained control having multiple guardrails for an application with each guardrail having unique control combinations. Most FMs already have built-in protections so these Bedrock Guardrails allow even finer safeguards over queries and responses.

Bedrock Guardrails Abilities

  • restrict topics
  • filter harmful content
  • (Soon) Redact PII in inputs and responses

Boto3 Bedrock API

Boto3 is the AWS SDK for Python which is one implementation of the Amazon Bedrock API. With it, you can interact with different AWS services including Bedrock, at least in newer versions. And of course python is the most used programming language for ML/AI.

There are two bedrock clients:

Bedrock = creating and managing models

Bedrock-runtime = for inference requests

Boto3 Bedrock Modules

Below are the Boto3 Bedrock Modules containing python classes. The modules ‘Bedrock’ and ‘AgentsforBedrockRuntime’ contain classes to deal with creating and managing models and agents respectively. The ‘Runtime’ modules contain classes for invoking and querying models and running the agents.

  • Bedrock
  • AgentsforBedrock
  • AgentsforBedrockRuntime
  • BedrockRuntime


Amazon Bedrock playgrounds provide a way to experiment with models before deciding to use them in your apps. There are three types of playgrounds:

  • Chat Models
  • Text Models
  • Image Models

You can enter prompts and adjust the inference parameters, and also view the API request in order to use the same correct set and formatting of inference parameters in your code.

AWS Playground

Further References

Amazon Bedrock (Official)

Getting started with Lambda

Boto3 documentation

Top comments (0)