Amazon S3 Vectors + Bedrock: RAG at 90% Lower Cost

πŸš€ Add to Chrome – It’s Free - YouTube Summarizer

Category: Cloud Computing

Tags: AWScost-savingdatabasesS3vectors

Entities: Amazon BedrockAWSOpenSearchRickyS3 bucketsS3 vectorsTitan embeddings

Building WordCloud ...

Summary

    Introduction to S3 Vectors
    • Ricky explains S3 vectors, a new feature by AWS, currently in preview and not yet GA.
    • S3 vectors allow the use of S3 buckets as vector stores, offering significant cost savings compared to traditional vector databases like OpenSearch.
    Setting Up S3 Vectors
    • Ricky demonstrates how to create a knowledge base using S3 vectors in AWS.
    • He shows how to select a data source, choose an embeddings model, and create a vector store.
    Using S3 Vectors
    • Ricky illustrates how to sync data from an S3 bucket and generate embeddings stored in a vector bucket.
    • He demonstrates querying the knowledge base and retrieving summarized information from indexed documents.
    Managing S3 Vector Buckets
    • Ricky explains the process of deleting vector store buckets using the AWS API, as the console does not currently support this action.
    • He highlights the use of the new S3 vectors API for managing vector buckets.
    Actionable Takeaways
    • Consider using S3 vectors for cost-effective vector storage, especially for RAG workflows.
    • Familiarize yourself with the S3 vectors API for managing vector buckets.
    • Ensure you have access to necessary models before testing your knowledge base.
    • Expect more functionalities in the future as S3 vectors is currently in preview.
    • Utilize AWS documentation and community resources for additional support.

    Transcript

    00:00

    Hi, this is Ricky from data mastery and in today's video we are going to talk about S3 vectors. So S3 vectors is a fairly new feature or a service which was recently announced by AWS and it is

    00:15

    not GA right now. It is still in preview.

    So uh be very cautious if you want to use this in prod. But in today's video, we are going to understand what is S3 vectors and how we can use that in our rag workflows.

    00:33

    So as you probably already figured out S3 vectors is based on the S3 service and instead of using very costly vector search or vector store databases like open search you can simply use S3

    00:48

    buckets uh as your vector search or vector store databases and since it's backed by S3 you can definitely see cost reduction around 80 to 90% as compared to open search or any other vector store database. So if

    01:06

    you're building rag workflow and if you're on AWS, this is fairly kind of uh easy integration that you can have in your rag workflows. So let's go ahead and see how we can use S3 buckets as our vector stores.

    01:22

    So I'm logged into my AWS account and this is Amazon Bedrock service. I'm going to go ahead and create a new knowledge base.

    But before I do so, I will take a moment to go to S3 and I will show you a bucket which is already

    01:39

    there that contains some of the documents that I'm going to ingest into S3 vector. So I have a bucket called data mastery can draw demo and I have few PDFs here.

    Code of conduct policy, employee

    01:55

    benefits and a vocation policy. So I'll go ahead and create a new knowledge base.

    And when you create a new knowledge base, you have to select knowledge base with vector store. And here you can give any name to your

    02:11

    knowledge base. I will just keep is this random name that it generated automatically.

    And then you have to select the IM role. If you have existing IM role, you can select that or you can create a new uh service role.

    And then

    02:26

    you have to select your data source. Now this is the data source where your data is like in my case I have this bucket.

    This is my data source. This is not the vector store.

    So choose S3 as your data source or any

    02:42

    other data source where your data is. And click on next.

    So then we have to give a name to our data source. You can give any meaningful name or just keep the randomly generated name.

    And here we have to specify uh the

    03:00

    data source bucket. So I just going to select my data mastery Kendra demo bucket and I will keep other options as is.

    Now I have to select the embeddings

    03:16

    model. Embeddings model is required to create the embeddings and store in your vector store.

    And here I'm going to pick the Titan embeddings from Amazon. For the vector store, now you have two options here.

    You can select a quick

    03:34

    create uh for this PC. I'm just going to use this first option.

    And if you look at the options here for the quick create vector stores, you have all the options which are Amazon or AWS services. So you have open search and here you see Amazon

    03:50

    S3 vectors as a new option. You have Aurora Postgress, you have Neptune Analytics.

    And if you want to pick an existing vector store, for example, if you have already created a vector store bucket, then you can pick that. And in the

    04:06

    drop-down list, you can see that you will get an option of S3 vectors. And here you have to specify the bucket ARN and the index.

    So I'm just going to quickly create a new vector store. And I'm going to

    04:24

    select S3 vectors. Click on next.

    And you can review all of your options here. And then click on create knowledge base.

    Okay. Now the knowledge base has been created.

    And this is my data source. If

    04:40

    I click on this data source and you can see that we have not indexed or synced it with actual data. So what I'm going to do now is I'm going to click on sync.

    So it is going to sync the data from my data source bucket. And you can see that

    04:55

    the sync was very fast and it has already completed. I had three files and all the three files have been added.

    And if I just refresh it once

    05:12

    and here you see these three documents, these three PDFs are indexed. So basically what happened the data which was there in my data source bucket the three documents those are synced and indexed and the embeddings are generated

    05:28

    and stored in the vector store bucket. Now if we go to S3 you see this new option here called vector buckets.

    Now this is not a generalpurpose bucket it's a vector

    05:44

    bucket. So you can click on vector buckets and you see that a new bucket has been created for you and if you click on the bucket and this is the default index which has been created.

    Now this index stores the embeddings about those three PDFs that we have

    06:00

    ingested. Now let's go back to the knowledge base and if I click on the knowledge base you can see all the details of the knowledge base the data source name and if you scroll down you can see the embeddings model that we have selected and also the Amazon S3

    06:17

    vector as our vector store and you can see the ARN of the vector store bucket which is what we have seen here already. Now once you have your knowledge base created and your data source has been synced, you can go ahead and test your

    06:34

    uh knowledge base right in the console. So there's this link here called test knowledge base.

    You can simply click this and here you have to select the model that you want to use for query and response. You can go ahead and click on select model and let's say I'm going to

    06:51

    select entropic and I'm going to select claw 3.5. You need to have the access to these models first.

    If you don't have the access to these models, you can go ahead and click on this model access link and then you can request for access for the

    07:07

    model that you want to use. So I'm going to keep all other options as is.

    I'm not going to change anything. And here I'm just going to ask a question based on the documents that I ingested.

    So let's say I'm going to ask can you summarize

    07:24

    the uh let's say vacation policy. So here you can see that the vacation policy has been summarized and you can see that the employees are entitled to 20 working days of paid vacation per

    07:40

    year. And if you click on the details you will also see where this data is coming from.

    So you can see this is coming from the vacation policy PDF. So this is working pretty good.

    And you can

    07:57

    go ahead and ask another question. Let's say summarize the health benefits.

    08:14

    And here it is summarizing the health benefits for you. And if you click on details again and you will see that this information is coming from employeebenefits.pdf.

    So this is working pretty good. Now if you look at this workflow it is very

    08:30

    similar to your normal rag workflow like there is nothing fancy about this. The only change that we have made in this case is to use s3 vector store instead of open search vector store.

    And this is going to help you save a lot of money

    08:46

    almost about 90% as compared to open search. Now one more thing I would like to show you is how you can let's say delete the uh the vector store buckets.

    So, if I go ahead and

    09:03

    click on my knowledge base and I'm going to delete it. So, it's going to delete the knowledge base.

    It's going to take a few minutes,

    09:19

    but it will not delete the S3 vector store bucket. And if you go to S3, you don't see any option to delete the vector bucket.

    So how you going to do that? If you have to clean up the vector

    09:34

    buckets. Well, for now you you can do that using the API.

    So if I let's say open my cloud shell. Now this is not a normal S3 bucket.

    This is not general purpose. So AWS has released a new API for S3 vector which

    09:53

    is called S3 vectors. So let's see how that looks like.

    So I have AWS S3 and if I just hit on tab you can see that we have S3 we have S3 API we have S3 control and S3 vectors

    10:11

    is the new one for the vector buckets. So click on S3 vectors and let's say I'm going to say list vector buckets.

    And here you see this is my vector

    10:29

    bucket that you can see in the console as well. And if I have to list indexes and the vector

    10:45

    bucket name is going to be this. And you can see this is the index ARN.

    And if you click on this basically it is

    11:02

    referring this index arn right here. Now in order to delete or clean up this vector bucket first we have to delete anything which is there in the bucket.

    So right now we have the index which is

    11:18

    in the bucket. So if I let's say go ahead and say delete index.

    So I have to provide index name which is

    11:35

    this and the vector bucket name which is this.

    11:54

    And here you go. If you refresh you can see that there's no index anymore.

    And finally, you can clean up the vector bucket as well. Say delete vector bucket.

    12:11

    Vector bucket name. And here you go.

    So you go back to your vector buckets.

    12:27

    And now you can see that there is no vector bucket anymore. And go to the knowledge bases.

    So it is still getting deleted. It's going to take a few minutes before uh it finishes.

    But keep in mind one thing that you will not be able to delete the

    12:42

    vector buckets from the console as of today as of the time of recording of this video. Since this is in preview, you can expect more functionalities around this both in API as well as console.

    12:58

    But however, the takeaway uh from this video is that you can use S3 vector store instead of the costly options like open search and other vector store databases and you can immediately cut the cost by 85 to 90% for your rag

    13:16

    workflows. So I hope you find this video helpful and whenever you get a chance you can just play with this.

    If you have any question whatsoever, you can ask that in the comment section. And thanks again for watching the video.

    Do subscribe to our channel if you haven't

    13:32

    done that. And I'm going to meet you next time with a similarformational video.

    Thanks for watching. Cheers.