Skip to content

Is posible to filter which data can be retrieved from knowledge bases using aurora postgres as vector database?

0

I have a bedrock knowledge base that use aurora as a vector database, using plain text files as source in s3.

As i read here amazon-bedrock-knowledge-bases-now-supports-metadata-filtering-to-improve-retrieval-accuracy

that there are some ways to filter the data that is being retrieved even to the point to a S3 prefix as seen:

publisher_filter = {
    "startsWith": {
                    "key": "x-amz-bedrock-kb-source-uri",
                    "value": "s3://$bucket_name/video_game/neo_tokyo_games/"
                }
}

this works well with opensearch but not with RDS aurora as the vector database. Is there a way to filter in this case? in my case i have projects and i want different users ask only questions about some projects. For example user 1 can only ask from projects 50, 60; user 2 from 70, 80.

I seen a column metadata in the aurora that have the full route to the file, but i couldnt manage to getting to work, could this be of help?

2 Answers
0
Accepted Answer

I would like to inform you, at runtime, an embedding model is used to convert the user's query to a vector. The vector index is then queried to find chunks that are semantically similar to the user's query by comparing document vectors to the user query vector. In the final step, the user prompt is augmented with the additional context from the chunks that are retrieved from the vector index. The prompt alongside the additional context is then sent to the model to generate a response for the user.[1]

Please note that since Bedrock is a managed service, we cannot query the vector database based on additional filters/SQL to select the required users’ access to the documents provided during the ingestion.

I would suggest you to further explore on the second approach which seems to have more promise. Alternatively, if possible, you could think of creating multiple knowledge bases based on specific domains the documents are based on and then providing the access to the users based on their roles.

=============== For instance:

User 1: projects 50,60

User 2: projects 70,80

KnowledgeBase 1: Consists of projects 50,60 KnowledgeBase 2: Consists of projects 70,80

The you can allow the User 1 to only access KnowledgeBase 1, User 2 to only access KnowledgeBase 2.

I could see there is an existing feature request submitted to our internal team for the same. At the moment, I do not have any visibility on the ETA as in when this feature will be available for RDS, as you might already be aware that any new request has to go through a development cycle and rigorous testing before it can be released to the customers.

[1] https://docs.aws.amazon.com/bedrock/latest/userguide/kb-how-it-works.html

answered 2 years ago

EXPERT

reviewed a year ago

0

Based on the information provided in the sources, there isn't a specific mention of filtering capabilities for Amazon Aurora PostgreSQL when used as a vector database for Amazon Bedrock Knowledge Bases. The metadata filtering feature is primarily discussed in the context of Amazon OpenSearch Serverless vector stores.

However, it's important to note that the metadata filtering feature for Knowledge Bases is a relatively new addition to Amazon Bedrock. The feature allows for pre-filtering retrievals based on document metadata, which can improve retrieval accuracy and reduce the number of chunks that need to be searched.

While the sources don't explicitly mention Aurora PostgreSQL support for this feature, they do indicate that metadata can be provided for documents in the knowledge base. This metadata can include string, number, or Boolean values.

In your specific case, where you want to filter projects for different users, you might be able to leverage this metadata feature if it's supported for Aurora PostgreSQL. You could potentially add metadata to your documents that indicates which project they belong to (e.g., project_id: 50, 60, 70, 80).

The column metadata in Aurora that you mentioned, which contains the full route to the file, could potentially be useful. However, without specific documentation or confirmation from AWS about Aurora PostgreSQL support for metadata filtering in Knowledge Bases, it's difficult to say definitively how you could implement this filtering.

Given the lack of specific information about Aurora PostgreSQL in this context, it would be advisable to consult the latest AWS documentation or reach out to AWS support for the most up-to-date information on filtering capabilities with Aurora PostgreSQL as the vector database for Bedrock Knowledge Bases. They would be able to provide you with the most accurate and current information about implementing project-based filtering in your specific setup.
Sources
Knowledge Bases for Amazon Bedrock now supports metadata filtering
Amazon Bedrock Knowledge Bases now supports metadata filtering to improve retrieval accuracy | AWS Machine Learning Blog
Knowledge Bases for Amazon Bedrock now supports metadata filtering to improve retrieval accuracy | AWS Machine Learning Blog

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.