Diagram 10 of 12

Generative AI with RAG on Amazon Bedrock

An assistant that answers from your own documents. Lambda searches OpenSearch for the relevant chunks and sends them to an Amazon Bedrock model together with the question. Documents are ingested from S3.

Amazon API GatewayAWS LambdaAmazon BedrockAmazon OpenSearch ServerlessAmazon S3

Diagram

Diagram 10: generative AI with RAG (Bedrock + OpenSearch + Lambda)AWS CloudUsersAPIAmazon APIGatewayλAWS Lambda(orchestrates RAG)BDKAmazon Bedrock(model and embeddings)OSAmazon OpenSearch(vectors)S3Amazon S3(documents)12345ingestion1. The user sends the question to Amazon API Gateway.2. API Gateway invokes the Lambda function that orchestrates the RAG flow.3. Lambda searches OpenSearch for the most similar document chunks.4. Lambda sends the question and the retrieved context to an Amazon Bedrock model.5. Bedrock returns the answer, and the result reaches the user through API Gateway.

Comments

Information flow

  1. Amazon API Gateway

    The user sends the question to API Gateway.

  2. AWS Lambda

    API Gateway invokes the Lambda function that orchestrates the RAG flow.

  3. Amazon OpenSearch Serverless

    Lambda searches the vector index for the most similar document chunks.

  4. Amazon Bedrock

    Lambda sends the question and the retrieved context to the Bedrock model.

  5. Amazon Bedrock + API Gateway

    Bedrock returns the answer, and the result reaches the user through API Gateway.