Set up permissions and storage for GenAI Evaluation
Before you create a GenAI Evaluation job, set up an AWS Identity and Access Management (IAM) role, an Amazon S3 bucket, and access to the models that your job uses.
Prerequisites
-
An Amazon S3 bucket that holds your evaluation dataset, any judge prompts, and the job output.
-
Access to the models in Amazon Bedrock that your job invokes. The job invokes the candidate model when the candidate runs on Amazon Bedrock, and it invokes the judge model for every LLM judge.
-
If you use a custom scorer, a Lambda function that returns a score for each sample. For more information, see Create an AWS Lambda function Evaluator.
The job, the Amazon S3 bucket with your dataset and judge prompts, the Evaluators, the Evaluation Criteria, and the Amazon Bedrock models that you use must all be in the same AWS Region. For example, a judge prompt in a bucket in another Region causes the job to be rejected when you create it.
Create the job execution role
You pass the Amazon Resource Name (ARN) of an IAM role in the RoleArn parameter of CreateJob. SageMaker AI assumes this role to run the job. The following command creates a role that SageMaker AI can assume, and attaches the managed policies that the job needs:
aws iam create-role \ --role-name GenAIEvaluationRole \ --assume-role-policy-document '{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Principal": {"Service": "sagemaker.amazonaws.com"}, "Action": "sts:AssumeRole" }] }' && \ aws iam attach-role-policy \ --role-name GenAIEvaluationRole \ --policy-arn arn:aws:iam::aws:policy/AmazonBedrockFullAccess && \ aws iam attach-role-policy \ --role-name GenAIEvaluationRole \ --policy-arn arn:aws:iam::aws:policy/AmazonSageMakerAIUnifiedEvaluationAccess
The managed policies provide the following permissions:
-
AmazonBedrockFullAccess– Access to invoke Amazon Bedrock models, including models that are served through Mantle, for the candidate and for the judge. It also lets Amazon Bedrock subscribe your account to third-party models in AWS Marketplace, so you don't need to request model access separately. For more information, see AmazonBedrockFullAccess in the AWS Managed Policy Reference Guide. -
AmazonSageMakerAIUnifiedEvaluationAccess– The permissions that SageMaker AI evaluation jobs need, including reading the Evaluators and Evaluation Criteria that the job references, and invoking the SageMaker AI inference endpoint when the candidate is a SageMaker AI inference endpoint.
If your job reads or writes data outside the SageMaker AI default bucket, or uses a custom scorer, add the following permissions to the role:
-
Amazon S3 –
s3:GetObjecton the dataset and on each judge prompt, ands3:PutObjecton the output location. If you encrypt these objects with a customer managed AWS Key Management Service (AWS KMS) key, also allowkms:Decryptandkms:GenerateDataKeyon the key. -
Lambda –
lambda:InvokeFunctionon each function that a custom scorer uses.
For more information about creating roles, see Creating IAM roles in the IAM User Guide.
Next steps
-
For instructions on preparing the evaluation dataset, see Prepare an evaluation dataset.