Generative AI Serverless – Build a Social Media Analytics using Bedrock RAG Knowledge base, Lambda and API!

Generative AI continues to accelerate the pace and imagination of large enterprises. Providers of large language models (LLMs) are continuously developing bigger and better foundation models, while cloud providers push the boundaries by offering servic…


This content originally appeared on DEV Community and was authored by Girish Bhatia

Generative AI continues to accelerate the pace and imagination of large enterprises. Providers of large language models (LLMs) are continuously developing bigger and better foundation models, while cloud providers push the boundaries by offering services that integrate seamlessly with these LLMs.

Amazon Bedrock is at the forefront of cloud services, providing an easy and consistent way to integrate with multiple LLMs.

While LLMs excel at providing generic responses, one area where they fall short is delivering contextual responses. Retrieval-Augmented Generation (RAG) is becoming increasingly popular in the world of Generative AI to address this gap. RAG allows organizations to overcome the limitations of LLMs by utilizing contextual data for their Generative AI solutions.

Amazon Bedrock features a knowledge base to support the RAG function. With this feature, you can provide your own data in the form of documents and use it for your Generative AI solution without the need to set up a vector database.

This knowledge base feature is particularly useful for building use cases where users need quick access to information from large documents. For example, technical support teams can extract information from user manuals to quickly resolve customer inquiries, HR can answer questions based on policy documents, developers can reference technical documentation to find information about specific functions, and call center teams can efficiently address customer inquiries using these documents.

In my use case, I am using Amazon Bedrock and its knowledge base feature to create a social media analytics assistant. This use case assumes that you have six months of social media data from various platforms like Instagram, Twitter (X), Facebook, and LinkedIn, including metrics such as followers and likes. By using this data as the knowledge base, a Generative AI solution in the form of an API can answer questions about trends, engagement rates, etc., allowing marketing and media teams to make informed decisions about strategy and content for these platforms.

Sample data is as follows:

sample data

Here is the architecture diagram for our use case.

architecture

The AWS services used are:

  • Amazon Bedrock
  • Amazon Bedrock Knowledge Base
  • AWS Lambda
  • AWS Rest API
  • AWS S3
  • AWS CloudWatch

The LLM used is Anthropic Sonnet.

The solution can be built using either the AWS Console or an Infrastructure as Code approach using AWS SAM and CloudFormation. Whenever I use Lambda, my preferred approach is to utilize AWS SAM; however, the function can also be deployed using the AWS Console.

To use the AWS Console, log in to your account and follow the screen prompts after clicking on the Knowledge Base:

KB1

KB2

Select a model and provide the document. You can either upload the document using the AWS Console or point to a document hosted in an S3 bucket.

That's all for the AWS Console-based solution. Once you select the model and upload the document, you are ready to ask questions, and the answers provided will be contextual, based on the data in your document.

Alternatively, you can use a code-based approach using AWS Lambda, API, S3, and Bedrock services and then integrate the API with your applications. I have outlined the solution in the workshop video posted in the link below.

Here are a few examples of prompts and the responses provided by this Generative AI solution:

Prompt: Please provide a summary of new followers.
Response:

response1

Prompt: Compare the monthly engagement metrics (e.g., total engagements, likes, comments, shares) across all platforms. Identify any noticeable spikes or drops in engagement and speculate on possible causes.
Response:

response2

AWS continues to add new features to its Generative AI services. I am staying connected and will be posting content on some of these new features soon!

Thanks for reading!

Click here to watch the YouTube video for this solution:
https://www.youtube.com/watch?v=oRNizGNwBi8

π’’π’Ύπ“‡π’Ύπ“ˆπ’½ ℬ𝒽𝒢𝓉𝒾𝒢
𝘈𝘞𝘚 𝘊𝘦𝘳𝘡π˜ͺ𝘧π˜ͺ𝘦π˜₯ 𝘚𝘰𝘭𝘢𝘡π˜ͺ𝘰𝘯 𝘈𝘳𝘀𝘩π˜ͺ𝘡𝘦𝘀𝘡 & π˜‹π˜¦π˜·π˜¦π˜­π˜°π˜±π˜¦π˜³ 𝘈𝘴𝘴𝘰𝘀π˜ͺ𝘒𝘡𝘦
𝘊𝘭𝘰𝘢π˜₯ π˜›π˜¦π˜€π˜©π˜―π˜°π˜­π˜°π˜¨π˜Ί 𝘌𝘯𝘡𝘩𝘢𝘴π˜ͺ𝘒𝘴𝘡


This content originally appeared on DEV Community and was authored by Girish Bhatia


Print Share Comment Cite Upload Translate Updates
APA

Girish Bhatia | Sciencx (2024-08-11T01:04:05+00:00) Generative AI Serverless – Build a Social Media Analytics using Bedrock RAG Knowledge base, Lambda and API!. Retrieved from https://www.scien.cx/2024/08/11/generative-ai-serverless-build-a-social-media-analytics-using-bedrock-rag-knowledge-base-lambda-and-api/

MLA
" » Generative AI Serverless – Build a Social Media Analytics using Bedrock RAG Knowledge base, Lambda and API!." Girish Bhatia | Sciencx - Sunday August 11, 2024, https://www.scien.cx/2024/08/11/generative-ai-serverless-build-a-social-media-analytics-using-bedrock-rag-knowledge-base-lambda-and-api/
HARVARD
Girish Bhatia | Sciencx Sunday August 11, 2024 » Generative AI Serverless – Build a Social Media Analytics using Bedrock RAG Knowledge base, Lambda and API!., viewed ,<https://www.scien.cx/2024/08/11/generative-ai-serverless-build-a-social-media-analytics-using-bedrock-rag-knowledge-base-lambda-and-api/>
VANCOUVER
Girish Bhatia | Sciencx - » Generative AI Serverless – Build a Social Media Analytics using Bedrock RAG Knowledge base, Lambda and API!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/11/generative-ai-serverless-build-a-social-media-analytics-using-bedrock-rag-knowledge-base-lambda-and-api/
CHICAGO
" » Generative AI Serverless – Build a Social Media Analytics using Bedrock RAG Knowledge base, Lambda and API!." Girish Bhatia | Sciencx - Accessed . https://www.scien.cx/2024/08/11/generative-ai-serverless-build-a-social-media-analytics-using-bedrock-rag-knowledge-base-lambda-and-api/
IEEE
" » Generative AI Serverless – Build a Social Media Analytics using Bedrock RAG Knowledge base, Lambda and API!." Girish Bhatia | Sciencx [Online]. Available: https://www.scien.cx/2024/08/11/generative-ai-serverless-build-a-social-media-analytics-using-bedrock-rag-knowledge-base-lambda-and-api/. [Accessed: ]
rf:citation
» Generative AI Serverless – Build a Social Media Analytics using Bedrock RAG Knowledge base, Lambda and API! | Girish Bhatia | Sciencx | https://www.scien.cx/2024/08/11/generative-ai-serverless-build-a-social-media-analytics-using-bedrock-rag-knowledge-base-lambda-and-api/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.