Run an evaluation job - Amazon SageMaker AI
Services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the AWS European Sovereign Cloud Region, see the AWS European Sovereign Cloud User Guide.

Run an evaluation job

You run an evaluation by creating a job with the CreateJob API. The job category is GenAIEvaluation. The job runs in your account and writes its results to the location that you choose.

Prerequisites

Create an evaluation job

  1. Call ListJobSchemaVersions and DescribeJobSchemaVersion with the job category GenAIEvaluation to get the current configuration schema version.

  2. Write the job configuration document. The first code block after these steps shows a sample document, and the second shows the CLI command that uses it.

  3. Call CreateJob with a unique JobName, the job category, the schema version, the configuration document as a string in JobConfigDocument, and your role ARN in RoleArn.

  4. Note the job ARN in the response.

The following JSON shows a sample job configuration document for a model on Amazon Bedrock:

{ "EvaluationCandidate": { "Models": [ { "InferenceProvider": "BEDROCK", "ModelIdentity": { "ModelId": "us.amazon.nova-lite-v1:0" }, "InferenceParams": { "temperature": "0.2", "max_tokens": "512" } } ] }, "EvaluationMethod": { "EvaluationCriteria": "arn:aws:sagemaker:us-west-2:111122223333:hub-content/my-hub/JsonDoc/support-answer-quality/1.0.0" }, "OutputDataConfig": { "S3OutputPath": "s3://amzn-s3-demo-bucket/eval-output/" } }

The job configuration has no dataset, because the job reads the dataset from the Evaluation Criteria.

The following command creates the job from that document:

aws sagemaker create-job \ --job-name support-eval-1 \ --job-category GenAIEvaluation \ --job-config-schema-version 1.0.0 \ --job-config-document file://job-config.json \ --role-arn arn:aws:iam::111122223333:role/GenAIEvaluationRole

Replace the Region, account ID, hub name, resource names, bucket name, and role name with your own values.

Name the candidate

Set EvaluationCandidate.Models to one model. A job evaluates one model.

Field Description
InferenceProvider Optional. The default is BEDROCK, for a model on Amazon Bedrock. SAGEMAKER for a fine-tuned model, a model on an endpoint, or a JumpStart base model. BEDROCK_MANTLE for a base model that Amazon Bedrock hosts by Mantle model ID.
ModelIdentity.ModelId The base model. For SAGEMAKER with a JumpStart base model, use the hub content ARN of the model. For BEDROCK_MANTLE, use the Mantle model ID, for example google.gemma-4-31b, and not an ARN.
ModelIdentity.InputModelPackageArn A fine-tuned model package. Use it together with ModelId, which names the base model.
ModelIdentity.EndpointArn An existing SageMaker AI endpoint. Use it alone.
InferenceParams Up to 50 inference parameters, such as temperature and max_tokens, as string values. The accepted names depend on the provider and the model.
AcceptEula Set to true to accept the end-user license agreement of a gated model.

Choose the judge model

An LLM judge uses the judge model in its Evaluator document. To use one judge model for all Evaluators that don't name one, set EvaluationMethod.JudgeModelConfig.ModelIdentity.ModelId. The judge model must be a Amazon Bedrock model.

Evaluate with retrieval

To evaluate a retrieval-augmented generation (RAG) setup, add EvaluationCandidate.RagConfiguration. For each sample, the job retrieves passages from an Amazon Bedrock knowledge base by using the sample prompt, fills a prompt template with the passages and the prompt, and sends the result to the model.

Field Description
KnowledgeBaseId Required. The ID or ARN of a knowledge base in the same account and Region as the job.
RetrievalConfiguration.VectorSearchConfiguration.NumberOfResults Passages to retrieve for each sample, 1 to 100. Default 5.
PromptTemplateArn A version of an Amazon Bedrock prompt. The template text must contain {{search_results}} and {{prompt}} once each, and can contain {{current_time}}. It can be up to 4,000 characters. When you omit it, the job uses a default template.

RAG settings aren't supported with benchmark Evaluation Criteria.

Set output and job options

Field Description
OutputDataConfig.S3OutputPath Optional. Where the job writes its results. If you omit it, the job writes the results to the output location in your Evaluation Criteria. The job needs an output location in one of the two.
OutputDataConfig.MlflowConfig The ARN of a SageMaker AI managed MLflow app, an experiment name, and a run name prefix. When you omit it, the job writes results to Amazon S3 and records no MLflow experiment.
StoppingCondition.MaxRuntimeInSeconds The maximum run time, 60 to 32,400 seconds (9 hours). The default is 60 seconds.

Manage jobs

  • DescribeJob returns the status and configuration of a job.

  • ListJobs lists your jobs.

  • StopJob stops a running job.

  • DeleteJob deletes a job.

Next steps