Document embeddings for Amazon Bedrock using Amazon S3/AWS Lambda/Amazon OpenSearch Serverless

Amazon S3 → AWS Lambda → Amazon Bedrock → Amazon OpenSearch

Generate vector embeddings for the documents uploaded to S3 and store them in OpenSearch serverless vector collection

When a new document is uploaded to S3, EventBridge receives an S3 Object Created event. An Event rule is configured to match the S3 Object Created and trigger a Lambda function. The Lambda function downloads the document, extracts content of each page in the document. The Lambda function code then iterates through the pages, invokes Amazon Titan Embeddings model to create embeddings for each page. The embeddings along with the page content are then stored in a vector index in a OpenSearch Serverless collection.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/s3-lambda-bedrock-aoss

Deploy

sam buildsam deploy --guided


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: sam delete.

Created by:

Raja Vaidyanathan

Raja Vaidyanathan

Solutions Architect @ AWS

Follow on LinkedIn