logo
Menu
AWS Bedrock - Learning Series - Blog 1

AWS Bedrock - Learning Series - Blog 1

AWS Bedrock Overview and Enable Bedrock

Published Dec 6, 2023

What is AWS Bedrock

Amazon Bedrock is a fully managed service and it is serverless in nature that provides a selection of high-performing foundation models (FMs) from leading AI companies, including AI21 Labs, Anthropic, Cohere, Meta, Stability AI, and Amazon itself. The service offers a unified API and a range of features to simplify the development of generative AI applications, making it accessible to a wider range of users without compromising on privacy and security.

Features in AWS Bedrock

  1. Agents for Amazon Bedrock:
    • Facilitates the creation and deployment of fully managed agents capable of executing complex business tasks.
    • Achieves this by dynamically invoking APIs, providing a seamless and efficient process for handling various tasks.
  2. Amazon Bedrock Developer Experience:
    • Simplifies the development process for developers by offering a user-friendly experience.
    • Enables easy collaboration with a diverse range of high-performing foundation models (FMs), providing flexibility in choosing and working with models.
  3. Knowledge Bases for Amazon Bedrock:
    • Allows users to connect foundation models (FMs) to data sources within the managed service.
    • This connection supports retrieval augmented generation (RAG), enhancing the FM's capabilities and making it more knowledgeable about specific domains and organisations.
  4. Amazon Bedrock Security and Compliance:
    • Ensures the development of generative AI applications that adhere to stringent data security and compliance standards.
    • Addresses standards such as GDPR and HIPAA, emphasizing the importance of privacy and compliance in the deployment of AI solutions.

Enable Model Access

Login to AWS Console
https://us-east-1.console.aws.amazon.com/bedrock/home?region=us-east-1#/
Go to Bedrock and Select —> Model Access

Enable Required Model Access

  • Select the Model you need an Access - Submit
  • You have to wait till it list as Access

Enable Logging for Troubleshooting

  • I want to enable logging for Text, Image, Embedding.
  • Like to Select only Cloudwatch logs, You can enable S3 and Cloudwatch Logs Also
  • Provided the Log group Name

Let us Test via AWS CLI

  • Hope you connected with AWS CLI with AccessKey/Secret Credential some Local IDE - Here I am using my Local Laptop with upgraded CLI
  • In case if you use —> Sagemaker Domain —> Launch App —> Studio -> Provide IAM Role (My Next Blog, I can share information on using Bedrock in Sagemaker Studio Notebook)
Upgrade AWS CLI, Boto and Boto-core
1
% pip install --no-build-isolation --force-reinstall "boto3>=1.28.57" "awscli>=1.29.57" "botocore>=1.31.57"
List Foundation Model Provider - AWS CLI
1
$ aws bedrock list-foundation-models | grep providerName | sort -u
"providerName": "AI21 Labs",
"providerName": "Amazon",
"providerName": "Anthropic",
"providerName": "Cohere",
"providerName": "Meta",
"providerName": "Stability AI",
List Foundation Models - AWS CLI
1
aws bedrock list-foundation-models | grep "modelId" | sort -nr | awk '{print $2}' | sed -e 's/,//g'
"stability.stable-diffusion-xl-v1"
"stability.stable-diffusion-xl-v0"
"stability.stable-diffusion-xl"
"meta.llama2-13b-chat-v1"
"cohere.embed-multilingual-v3"
"cohere.embed-english-v3"
"cohere.command-text-v14"
"cohere.command-light-text-v14"
"anthropic.claude-v2"
"anthropic.claude-v1"
"anthropic.claude-instant-v1"
"amazon.titan-tg1-medium"
"amazon.titan-tg1-large"
"amazon.titan-text-lite-v1"
"amazon.titan-text-express-v1"
"amazon.titan-embed-text-v1"
"amazon.titan-embed-g1-text-02"
"ai21.j2-ultra-v1"
"ai21.j2-ultra"
"ai21.j2-mid-v1"
"ai21.j2-mid"
"ai21.j2-jumbo-instruct"
"ai21.j2-grande-instruct"
Invoke a LLM Model - using Bedrock CLI
1
2
3
4
5
6
aws bedrock-runtime invoke-model \
--model-id ai21.j2-ultra-v1 \
--body "{\"prompt\":\"Write a Article about Cricket World Cup 2011\",\"maxTokens\":200,\"temperature\":0.7,\"topP\":1,\"stopSequences\":[],\"countPenalty\":{\"scale\":0},\"presencePenalty\":{\"scale\":0},\"frequencyPenalty\":{\"scale\":0}}" \
--cli-binary-format raw-in-base64-out \
--region us-east-1 \
invoke-model-output.txt
Explanation for CLI
Parse the Output using jq
1
$ cat invoke-model-output.txt| jq -r '.completions[].data.text'
The 2011 Cricket World Cup was the tenth edition of the Cricket World Cup, the premier international limited-overs cricket tournament. It was held from 19 February to 2 April 2011 in the Indian subcontinent.
The final was contested between India and Sri Lanka, with India winning by six wickets. India's victory marked the first time they had won the Cricket World Cup in home country.
Stay tuned…. for another blog on AWS Bedrock

Comments