How to Integrate AWS Bedrock via Boto3 and Langchain in Large Language Model Applications
— With Python Notebooks of Boto3 and Langchain Versions, a Brief Comparison of OpenAI and AWS LLM Solutions, and Potential Gotchas/Traps
OpenAI GPT model series, especially gpt-3.5-turbo (ChatGPT) has achieved the dominating position among Large Language Models (LLMs). However, the concerns of data privacy and security have been constantly brought up since the release of OpenAI GPT 3. Many unicorn players in IT have been trying to mitigate the problems around data privacy and security. AWS Bedrock and AWS SageMaker JumpStart are the two key services AWS has provided to mitigate the above issues and compete with OpenAI GPT in LLM applications. We will review CVs on a weekly base, and get back to you.
Brief comparison among OpenAI GPT, AWS Bedrock and AWS SageMaker JumpStart

AWS Bedrock is a direct competitor to the OpenAI GPT series as both of them provide APIs for developers to access shared LLMs. However, AWS Bedrock focuses more on data protection, access controls via AWS Identity and Access Management (IAM), and security. On the other hand, AWS SageMaker JumpStart provides an effortless approach to provisioning LLMs inside the user’s AWS account. This means the LLM is dedicated to the AWS user instead of the shared LLM methodology of AWS Bedrock and OpenAI GPT. The major drawback of SageMaker JumpStart is the high cost, which may not be affordable for small businesses. For example, the cost of hosting the smallest Llama 2 model (Llama 2 7b) in the Sydney region is a bit more than US$1.1k (g5.2xlarge — $1.57584/hour * 24 * 30). In contrast, for small businesses, OpenAI costs could be as low as less than US$100.
Great support in Boto3
In terms of the implementation, AWS Boto3 will provide perfect support for Bedrock similar to other AWS services such as s3 and lambda functions. The following notebook shows how straightforward to use boto3 to make a call to the AWS Bedrock Titan model.






