AWS Logo
Menu
Generative AI Serverless - Build a Social Media Analytics using Bedrock RAG Knowledge base, Lambda and API!

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

This article guides you through building a serverless social media analytics solution using Amazon Bedrock’s RAG Knowledge Base, AWS Lambda, and API. It explains how to leverage Generative AI to analyze six months of social media data, providing insights for informed decision-making. The article also covers deployment options, including AWS Console and Infrastructure as Code approaches.

Published Aug 11, 2024
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:
Social Media Sample Data
Social Media Sample Data
Here is the architecture diagram for our use case.
Architecture Diagram
Architecture Diagram
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:
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:
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:
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
𝒢𝒾𝓇𝒾𝓈𝒽 ℬ𝒽𝒶𝓉𝒾𝒶
𝘈𝘞𝘚 𝘊𝘦𝘳𝘵𝘪𝘧𝘪𝘦𝘥 𝘚𝘰𝘭𝘶𝘵𝘪𝘰𝘯 𝘈𝘳𝘤𝘩𝘪𝘵𝘦𝘤𝘵 & 𝘋𝘦𝘷𝘦𝘭𝘰𝘱𝘦𝘳 𝘈𝘴𝘴𝘰𝘤𝘪𝘢𝘵𝘦
𝘊𝘭𝘰𝘶𝘥 𝘛𝘦𝘤𝘩𝘯𝘰𝘭𝘰𝘨𝘺 𝘌𝘯𝘵𝘩𝘶𝘴𝘪𝘢𝘴𝘵
 

Comments