This Amazon Step Functions workflow ingests data into multiple Knowledge Bases and evaluates the performance of your Knowledge Bases with your test suite of prompts.
Learn more about this workflow at Step Functions workflows collection: << Add the live URL here >>
Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the AWS Pricing page for details. You are responsible for any AWS costs incurred. No warranty is implied in this example.
- Create an AWS account if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources.
- AWS CLI installed and configured
- Git Installed
- AWS Serverless Application Model (AWS SAM) installed
-
Create a new directory, navigate to that directory in a terminal and clone the GitHub repository:
git clone https://github.com/aws-samples/step-functions-workflows-collection
-
Change directory to the pattern directory:
cd step-functions-workflows-collection/bedrock-evaluations
-
From the command line, use AWS SAM to deploy the AWS resources for the workflow as specified in the template.yaml file:
sam deploy --guided --capabilities CAPABILITY_NAMED_IAM
-
During the prompts:
- Enter a stack name
- Enter the desired AWS Region
- Allow SAM CLI to create IAM roles with the required permissions.
Once you have run
sam deploy --guided --capabilities CAPABILITY_NAMED_IAM
mode once and saved arguments to a configuration file (samconfig.toml), you can usesam deploy
in future to use these defaults. -
Note the outputs from the SAM deployment process. These contain the resource names and/or ARNs which are used for testing.
This workflow creates multiple Knowledge Bases, performs an ingestion job into a vector database, and runs evaluation jobs for you to assess the effectiveness of your ingestion jobs. This is done by making use of Step Functions Parallel state to run multiple testing flows in parallel."
- Upload raw documents to the S3 Documents Bucket. These will act as the data source for your Knowledge Bases.
- Create "input" and "output" folders in your S3 Evaluations bucket.
- In the "input" folder, upload your test suite of prompts and ground truth responses. For more info on the format of these files, see the documentation.
- Create your Opensearch Vector Indices. Create one vector index for each knowledge base configuration you are testing. You can use the "setup_opensearch" file or build your own custom script to do so.
- Start a new execution of the deployed state machine.
- You can view the evaluation reports in the Bedrock console when the workflow is complete.
- Delete the documents uploaded to both S3 buckets.
- Delete the stack
aws cloudformation delete-stack --stack-name STACK_NAME
- Confirm the stack has been deleted
aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus"
Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0