Gap analysis - 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.

Gap analysis

What it is

A gap analysis job (job category GapAnalysis) takes the completed evaluation jobs of the model you are analyzing, applies the per-sample pass/fail threshold for your metric from your evaluation criteria to every scored record, or helps derive that threshold when the criteria do not define one, and reports which records fail, how far they fall short, and what kinds of failure they share. The model can be a base model that you have not customized yet, or a model that you have.

The job does three kinds of work on the evaluation results:

  • Scores and verdicts. For every record, it reads the score that the evaluation's scorer wrote for the metric you optimize on and decides pass or fail against the threshold. It never recomputes the score. It records how far each failing record falls short (the margin), and for records that barely pass, whether the pass is real or a scorer leak.

  • Failure categories. It checks every failing answer for structural problems (placeholder output, a type mismatch, an answer far too long or far too short), checks the label distribution of the whole split for skew, and has an LLM judge assign one semantic category to each labeled failing record, from a fixed vocabulary or, when none fits, a judge-proposed extended.name category, with a one-sentence explanation. The judge labels every regressed failure and a bounded number of other failures per split; when a split has more failures than that, it labels a stratified random sample of them and the report says so. It aggregates the categories by count, share, mean score, and severity, so that a list of failing records becomes a statement such as "most failures are an incomplete multipart extraction".

  • Context. With evaluations of other models, it reports paired score differences with a confidence interval and a noise band. With repeat evaluations of the analyzed model, it measures run-to-run variation. With the previous round's gap analysis job, it reports which failing records were resolved, which persist, and which regressed, and how each category trends. With a reference model known to be healthy, it checks the shape of the answers for problems that a score does not show: answers in the wrong format, repetition, a single repeated answer, answers cut off by the token limit.

The job runs as a managed SageMaker AI job. It reads the referenced jobs and writes the report with your execution role, and it invokes the judge model in Amazon Bedrock with your credentials. The job produces the analysis. It does not recommend, and it does not change your data.

When to use it

Within data improvement, run a gap analysis job whenever you have a completed evaluation of a model and want to know, at the record level, where and why it misses the threshold:

  • On the base model's evaluation before you customize, to find the kinds of records to generate first. This is the first round: no prior job and no comparison model.

  • On a customized model's evaluation after each round, usually with the base model's evaluation as a comparison and health reference and the previous round's gap analysis job as the prior, to see whether the customization helped, what still fails, and what regressed.

  • On any evaluated model, with or without comparisons, when the aggregate score is not enough to decide what to change.

For when to use data improvement as a whole, see When to use it in Data improvement.

How it works

The job runs as follows.

  1. Reads the evaluation jobs. With your execution role, the job reads each referenced evaluation job's configuration (model, inference settings, dataset, criteria) and the analyzed jobs' per-record results: ID, prompt, answer, expected answer, split, and the metric's score as the scorer wrote it. It never recomputes a score.

  2. Sorts the contextual evaluations. If the request has contextual evaluations, the service reads each one's configuration and sorts it into a repeat of the analyzed model (same model, same settings, covering all dev records), a comparison (another model), or a refusal with a reason. A refused evaluation is reported and left out; the job continues unless the refused one is the health-check reference.

  3. Applies the threshold. The job takes the per-sample pass condition for the metric from the criteria version in EvaluationCriteriaArn, or derives one when the criteria have none and this is the base model's own first analysis (see Where the threshold comes from). A record passes when the condition holds for its score; failing records also get a margin, the distance from the score to the threshold.

  4. Categorizes the failures. The job checks every failing answer for structural problems and records them as structural_flags, then has the LLM judge assign one semantic category to every regressed failure and to a bounded sample of the others per split. On a graded metric the judge also says whether each near-threshold pass is real or a scorer leak.

  5. Compares and checks. With comparison models, the job reports paired score differences per split with a confidence interval and, on dev, a noise band; with a prior job, which records were resolved, persist, or regressed and how each category trends; with a reference model, the health checks. The budget check for answers cut off by the token limit runs on every job.

  6. Writes the report. The job writes the report files under S3OutputPath/gap-analysis/job-name/creation-time/ and, last, the metadata.json index that lists them, which DescribeJob returns as MetadataS3Uri.

Rounds

Customization is usually iterative, so gap analysis is too. A typical chain is: analyze the base model's evaluation, generate data and customize, evaluate and analyze again, improve the data and customize again, and so on until the metric meets its target or stops moving. One gap analysis job runs per round, and each round reads the round before it.

  • The first round has no prior. It is usually the analysis of the base model before you customize it. If you pass repeat evaluations of the base model in ContextualEvaluationJobArns, this job measures the run-to-run variation that every later round reuses.

  • Each later round passes the previous round's job in PriorGapAnalysisJobArns and the run-to-run variation that the first round measured in KeyMetrics[].RunToRunVariation. It usually also passes the base model's evaluation as a comparison and as the health reference. With a prior, the report adds the trend: the change in the development score against the previous round, which failing records were resolved, which persist, and which regressed, and whether each failure category grew, shrank, appeared, or disappeared. A category whose share has stayed flat or grown for several consecutive rounds is marked data_addressable: false: the data changes tried so far have not moved it, which is a signal to change the approach, not by itself a reason to stop.

A chain of rounds analyzes the same metric, on evaluations of the same evaluation dataset, with the same evaluation criteria entity, so that the rounds are comparable. The criteria version may change once in a chain: in the round right after the service derived a threshold, when you register the approved threshold as a new version. To analyze a different metric, dataset, or threshold, start a new chain by omitting PriorGapAnalysisJobArns.

Where the threshold comes from

A record passes or fails by the per-sample pass condition for your metric in the evaluation criteria: the entry of PerSamplePassConditions whose expression uses the metric, for example accuracy >= 0.8. The expression is the success condition: with the record's score bound to the metric name, true means pass. Its operator also gives the metric's direction: >= and > mean higher is better, <= and < mean lower is better. The job reads the criteria at the exact version in EvaluationCriteriaArn; it never reads a threshold from the evaluation job's own criteria, and it never takes a threshold from the request.

"PerSamplePassConditions": [ { "Name": "accuracy_gate", "Language": "CEL", "ReturnType": "boolean", "Value": "accuracy >= 0.8" } ]

The threshold is set once, on the base model's own development records, and every later job in the chain applies the same one, so that failure counts stay comparable across rounds and models. What the job does with the criteria depends on whether the request names a previous gap analysis job in PriorGapAnalysisJobArns.

No previous job

This is the first job of a chain. EvaluationCriteriaArn names a version of the evaluation criteria that the evaluation jobs in ModelEvaluationJobArns ran with.

  • If that criteria version has a pass condition for the metric, the job applies it.

  • If that criteria version has no pass condition for the metric, and the contextual evaluations include no other model, the job derives a pass condition from the dev records: it samples them, has the judge label each sampled record as a success or a failure, finds the score that best separates the two, applies that threshold to this job, and writes the proposal with its evidence to threshold_derivation_metric_name.json. Before the next round, you review the proposal and register it as a new version of the same criteria; see Approving a derived threshold. The job fails if the evaluation has no dev records, or the judge labels every sampled record the same way.

  • If that criteria version has no pass condition for the metric, and the contextual evaluations include another model, the job fails. A threshold is never derived while comparing models, because deriving it on a comparison would move the bar. Repeat evaluations of the analyzed model do not count as another model; a contextual job refused for two_models, live_traffic, different_criteria, or different_judge_model does.

The service has no "this is the base model" flag: the job that may derive a threshold is the one with no previous job and no other model, which in practice is the base model's own first analysis.

A previous job given

The job continues that job's chain. The evaluation jobs in ModelEvaluationJobArns must have run with the previous job's evaluation criteria, on the same evaluation dataset as the evaluations the previous job analyzed. What EvaluationCriteriaArn must be depends on where the previous job's threshold came from, which the job reads from the previous report's provenance.threshold_source:

  • The previous job derived its threshold: EvaluationCriteriaArn must name the same evaluation criteria, but the version may differ. This is how the approved threshold arrives: you registered it as a new version after the first job. The named version must have a pass condition for the metric. Only the job right after the first job of a chain can be in this situation, because a threshold is derived only on a job with no previous job.

  • The previous job read its threshold from the criteria: EvaluationCriteriaArn must equal the previous job's exactly, version included, and that version must have a pass condition for the metric.

So a chained job cannot change the threshold by pointing at a new criteria version: the job fails before compute. To change the threshold, start a new chain by omitting PriorGapAnalysisJobArns.

Inputs to the job

The job configuration is the JobConfigDocument of CreateJob for job category GapAnalysis, schema version 1.0.0. Its syntax is the following; the fields are described after it.

{ "ModelEvaluationJobArns": [ "string" ], "KeyMetrics": [ { "MetricName": "string", "RunToRunVariation": number } ], "EvaluationCriteriaArn": "string", "OutputDataConfig": { "S3OutputPath": "string" }, "ContextualEvaluationJobArns": [ "string" ], "HealthCheckReferenceEvaluationJobArn": "string", "PriorGapAnalysisJobArns": [ "string" ], "MlflowConfig": { "MlflowResourceArn": "string", "MlflowExperimentName": "string", "MlflowRunName": "string" } }
ModelEvaluationJobArns

ARNs of completed GenAIEvaluation jobs of the one model being analyzed. Send multiple evaluation ARNs only when that model's records are split across corresponding multiple evaluation datasets with no record ID in common.

Validation: all jobs must be Completed, must have evaluated the same model with the same inference settings, and must have run with a version of the criteria in EvaluationCriteriaArn (same hub and name, same document schema, benchmark, datasets, and versioned evaluator for the analyzed metric).

Type: Array of strings

Array Members: Minimum 1, maximum 2. Items must be unique.

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: arn:aws[a-z-]*:sagemaker:[a-z0-9-]{9,16}:[0-9]{12}:job/GenAIEvaluation/[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?

Required: Yes

KeyMetrics

The metric that the gap analysis focuses on. The job applies this metric's pass condition, labels the records that fail it, and writes its report for it; every output file name carries the metric name.

Validation: if PriorGapAnalysisJobArns is present in the current request, the MetricName must match the prior job's metric.

Type: Array of KeyMetric objects

Array Members: Exactly 1.

Required: Yes

A KeyMetric object has the following members.

MetricName

The metric's name as the evaluation criteria and the evaluation's scorer name it, for example accuracy or squad_f1.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Required: Yes

RunToRunVariation

How much this metric's mean development score moves by chance between repeated evaluations of the same model with the same settings, in the metric's units, 0 or more. The job uses it as the floor of the noise band of every development comparison (the noise band is the larger of the comparison's confidence-interval half-width and this value), so that a change smaller than the model's own variation is not reported as real. The first round of a chain measures this value from the repeat evaluations you pass in ContextualEvaluationJobArns and writes it to its report as run_to_run_variation[].value; copy that value into RunToRunVariation on every later round, because later rounds normally run no repeats. When a job both receives a value and measures one from its own repeats, it uses the larger.

Type: Number

Valid Range: Minimum value of 0.

Required: No

EvaluationCriteriaArn

The versioned ARN of the EvaluationCriteria hub-content document whose per-sample threshold the job applies. The version of the document is required so that the job always applies one fixed criteria version. The job reads the criteria at exactly that version and takes the metric's pass condition from PerSamplePassConditions; see Where the threshold comes from. It also reads the evaluators the criteria's scorers name, for the metric's definition.

Validation: a versioned hub-content ARN with content type JsonDoc that references an EvaluationCriteria document. It must be a version of the same criteria entity (same hub and name) that every job in ModelEvaluationJobArns ran with, and the versions used together must keep the same document schema, benchmark, datasets, and the same versioned evaluator for the analyzed metric; they may differ in their thresholds, and in scorers that do not produce the analyzed metric. Contextual jobs that ran with another criteria entity are refused during compute rather than failing the job. With a prior job, the chain rules in Where the threshold comes from apply. The PerSamplePassConditions entry for the metric must be a single comparison, metric op number with op one of >, >=, <, <=; two entries for the same metric, or an expression of another form, fail the job.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: arn:[^:/]+:sagemaker:[^:/]+:[^:/]+:hub-content/[^/]+/JsonDoc/[^/]+/[^/]+

Required: Yes

OutputDataConfig

Where the gap analysis results are written.

Type: OutputDataConfig object

Required: Yes

An OutputDataConfig object has the following member.

S3OutputPath

The Amazon S3 URI for the report, s3://bucket/prefix. The job writes under S3OutputPath/gap-analysis/job-name/creation-time/.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: (https|s3)://([^/]+)/?(.*)

Required: Yes

ContextualEvaluationJobArns

Up to 6 other completed model evaluation jobs that give the analysis context. You do not say what each one is. The job reads each one's configuration and sorts it:

  • A job that evaluated the analyzed model with the same inference settings and covers every development record of the analyzed jobs is a repeat. The job measures run-to-run variation from the repeats.

  • A job that evaluated another model is a comparison. All contextual jobs of one other model are grouped into a single comparison model, and the report pairs its records with the analyzed model's by record ID.

  • A job the service cannot use is refused with a reason, and left out: it ran with a different criteria entity or a different judge model, evaluated the analyzed model with different inference settings, does not cover all of the analyzed model's development records, evaluated two models or an agent, named its model only by an endpoint, scored bring-your-own responses with no model, or read live traffic from CloudWatch Logs. A refused job does not fail the gap analysis job unless it is the health-check reference; the report says how every contextual job was treated in contextual_evaluations.

Type: Array of strings

Array Members: Minimum 0, maximum 6. Items must be unique.

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: arn:aws[a-z-]*:sagemaker:[a-z0-9-]{9,16}:[0-9]{12}:job/GenAIEvaluation/[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?

Required: No

HealthCheckReferenceEvaluationJobArn

The ARN of one evaluation job of the reference model: a model known to be healthy, usually the base model before fine-tuning. Fine-tuning can break a model in ways its score does not show: answers in the wrong format, repeating itself, always giving the same answer, or getting cut off. The job compares the analyzed model's answers with the reference model's, using every contextual evaluation of that model, and reports the result under health. Without a reference, the checks against a healthy model do not run; the budget check for answers cut off by the token limit always runs.

Validation: the ARN must be one of ContextualEvaluationJobArns, its model must not be the analyzed model, and it must not be refused. When the analyzed model has selection records, the reference must hold them.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: arn:aws[a-z-]*:sagemaker:[a-z0-9-]{9,16}:[0-9]{12}:job/GenAIEvaluation/[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?

Required: No

PriorGapAnalysisJobArns

The ARN of at most one earlier gap analysis job: the previous round's job on the same chain. The job reads the prior's report to compare the analyzed model with the previous round's model, to compute the diff of failing records (resolved, persistent, regressed) and each category's trend, and to decide where the threshold comes from.

Validation: the prior job must be Completed, its KeyMetrics must name the same metric, and the analyzed jobs must have run with the prior's criteria entity on the same evaluation dataset. The EvaluationCriteriaArn rules in Where the threshold comes from apply.

Type: Array of strings

Array Members: Minimum 0, maximum 1.

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: arn:aws[a-z-]*:sagemaker:[a-z0-9-]{9,16}:[0-9]{12}:job/GapAnalysis/[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?

Required: No

MlflowConfig

A SageMaker AI managed MLflow app to log the job's parameters and the report's flat metrics to.

Type: MlflowConfig object

Required: No

An MlflowConfig object has the following members.

MlflowResourceArn

The Amazon Resource Name (ARN) of the MLflow app resource.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: arn:aws[a-z-]*:sagemaker:[a-z0-9-]{9,16}:[0-9]{12}:mlflow-app/.+

Required: Yes

MlflowExperimentName

The name of the MLflow experiment.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [-A-Za-z0-9_]+

Required: No

MlflowRunName

The name of the MLflow run. Defaults to job-name-GapAnalysis-timestamp when omitted.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [-A-Za-z0-9_]+

Required: No

Permissions

The execution role

The following permissions policy grants what a gap analysis job needs. Replace the Region, hub name, and bucket with your own; the Amazon S3 statements must cover every bucket that the referenced evaluation jobs wrote their results to, as well as S3OutputPath.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "sagemaker:DescribeJob", "Resource": [ "arn:aws:sagemaker:region:111122223333:job/GenAIEvaluation/*", "arn:aws:sagemaker:region:111122223333:job/GapAnalysis/*" ] }, { "Effect": "Allow", "Action": "sagemaker:DescribeHubContent", "Resource": [ "arn:aws:sagemaker:region:111122223333:hub/hub-name", "arn:aws:sagemaker:region:111122223333:hub-content/hub-name/JsonDoc/*" ] }, { "Effect": "Allow", "Action": ["s3:GetObject", "s3:PutObject"], "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*" }, { "Effect": "Allow", "Action": ["s3:ListBucket", "s3:GetBucketLocation"], "Resource": "arn:aws:s3:::amzn-s3-demo-bucket" }, { "Effect": "Allow", "Action": ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents"], "Resource": "arn:aws:logs:region:111122223333:log-group:/aws/sagemaker/Job/GapAnalysis/*" }, { "Effect": "Allow", "Action": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"], "Resource": "*" } ] }

Each grant is for the following:

  • A trust policy that lets sagemaker.amazonaws.com call sts:AssumeRole; it is the one shown in Required permissions.

  • sagemaker:DescribeJob on every job the request names (job/GenAIEvaluation/* and job/GapAnalysis/*), including the evaluation jobs that a prior gap analysis job analyzed.

  • sagemaker:DescribeHubContent on the evaluation criteria in EvaluationCriteriaArn, on the criteria that each referenced evaluation job ran with, and on every evaluator that the criteria's scorers name, each at the version in its ARN.

  • s3:GetObject, s3:ListBucket, and s3:GetBucketLocation on the output locations of every referenced job (the evaluation results and a prior job's metadata.json), and s3:PutObject, s3:ListBucket, and s3:GetBucketLocation on S3OutputPath. The job does not delete objects. If a bucket uses SSE-KMS default encryption, the role also needs kms:GenerateDataKey and kms:Decrypt on that key.

  • logs:CreateLogGroup, logs:CreateLogStream, and logs:PutLogEvents on the log group /aws/sagemaker/Job/GapAnalysis/, where the job writes its log. No delete or retention permission is needed.

  • bedrock:InvokeModel and bedrock:InvokeModelWithResponseStream on the judge model. The job labels failures with your credentials, so the model must be enabled in your account and Region and its quotas apply. The file token_usage_report.json in the output folder records the models the job called and the tokens it used.

  • With MlflowConfig (not in the policy above): permission to call the MLflow app in MlflowResourceArn (the sagemaker-mlflow actions that app grants). The job looks up the experiment and creates one run.

The identity that submits the job

  • sagemaker:CreateJob on the job ARN, and iam:PassRole for the execution role to job.sagemaker.amazonaws.com.

The identity that manages jobs

  • sagemaker:DescribeJob and sagemaker:StopJob on the job ARN, sagemaker:DeleteJob, and sagemaker:ListJobs. To read the report, s3:GetObject and s3:ListBucket on S3OutputPath.

The shared permissions for every capability are in Required permissions.

Use the gap analysis job

You can run the job from the SDK or through a coding assistant. Both submit the same job and write the same report. The recommendations that follow the report are made by the coding assistant; see Data improvement recommendations.

Amazon SageMaker Python SDK

Use DataPreparer.analyze(). The configuration carries references to jobs rather than a dataset ARN. The call returns the job handle when the job completes; the report location is in the job's MetadataS3Uri. The following example analyzes a customized model against its base model, using the base model's evaluation as the health reference. For a base model before customization, pass only its own evaluation in model_evaluation_job_arns and omit the contextual and health-reference fields.

from sagemaker.core.helper.session_helper import Session from sagemaker.ai_registry import DataPreparer, DatasetJobConfig, JobCategory import json session = Session() preparer = DataPreparer( sagemaker_session=session, role="arn:aws:iam::111122223333:role/role-name", ) # 1. List every field that a gap analysis job accepts. DatasetJobConfig.print_schema(JobCategory.GAP_ANALYSIS) # 2. Describe the job: the evaluation of the model to analyze, the metric, # the criteria that hold its threshold, and the evaluation of the base # model for comparison and health checks. eval_arn = "arn:aws:sagemaker:region:111122223333:job/GenAIEvaluation/" config = DatasetJobConfig( job_category=JobCategory.GAP_ANALYSIS, model_evaluation_job_arns=[eval_arn + "support-ft-round1-eval"], contextual_evaluation_job_arns=[eval_arn + "support-base-eval"], health_check_reference_evaluation_job_arn=eval_arn + "support-base-eval", key_metrics=[{"MetricName": "accuracy"}], evaluation_criteria_arn=( "arn:aws:sagemaker:region:111122223333:hub-content/" "hub-name/JsonDoc/support-criteria/1.0.0" ), output_data_config={ "S3OutputPath": "s3://amzn-s3-demo-bucket/gap-analysis/round1/", }, ) # 3. Submit the job and wait for it. The job returns a report, not a dataset. job = preparer.analyze(config, base_job_name="support-round1-gap", wait=True) # 4. Read the report index. It lists the report files for the metric. metadata_uri = json.loads(job.job_config_document)["MetadataS3Uri"] print(metadata_uri) # 5. For the next round, pass this job as the prior and the run-to-run # variation that the first round's report measured: # config = DatasetJobConfig( # job_category=JobCategory.GAP_ANALYSIS, # model_evaluation_job_arns=[eval_arn + "support-ft-round2-eval"], # prior_gap_analysis_job_arns=[job.job_arn], # key_metrics=[{"MetricName": "accuracy", "RunToRunVariation": 0.02}], # ... # )
Coding assistant with the AI and ML skill

With the AI and ML skill in your coding assistant, describe the model you evaluated and what you want to know. The assistant finds the evaluation jobs and the criteria, checks the request before anything is billed, submits the gap analysis job after you approve it, reads the report, and continues with the recommendations.

I evaluated the base model; the evaluation job is arn:aws:sagemaker:region:account-id:job/GenAIEvaluation/evaluation-job-name and it ran with the support-criteria evaluation criteria. Accuracy is below my 0.90 target. Run a gap analysis on that evaluation and tell me which kinds of records it fails on and what data to generate first.

Results

A completed job writes the following files under its own folder in the output location, S3OutputPath/gap-analysis/job-name/creation-time/, where creation-time is the job's creation time without colons. In the file names, metric_name is the MetricName you passed in KeyMetrics, made file-name safe (characters other than letters, digits, ., _, and - become -). For a job with MetricName accuracy, the summary is gap_analysis_accuracy.json. The index, metadata.json, is written last, and DescribeJob returns its location as MetadataS3Uri; read the other files' locations from it rather than from a name pattern.

DescribeJob returns two fields in the job's configuration document that you do not send:

  • MetadataS3Uri: the Amazon S3 URI of the report index, metadata.json, set when the job completes.

  • ReferencedJobOutputs: one entry per referenced job (analyzed, contextual, and prior) with its JobArn and OutputManifestS3Uri, the results manifest of an evaluation job or the metadata.json of a prior gap analysis job. Recorded when the job starts, so that lineage links every upstream output to this job.

File What it holds When the job writes it
The index file metadata.json The starting point: the job's identity, the job references and the metric from the request, the criteria version the job applied, and under Reports the location of every other file for the metric. It does not carry OutputDataConfig or MlflowConfig. The next round's job and the control plane read it. Every completed job.
The category summary gap_analysis_metric_name.json The analysis: the development score against the threshold and the prior round, the diff counts, the failure categories with count, share, mean score, severity, and trend, one block per split, the pass verdicts, the comparisons with other models, how each contextual evaluation was treated, the run-to-run variation, the health checks and the budget gate, and the provenance. This file is the contract. Every completed job. Blocks whose input the job lacks are absent, for example comparisons without a comparison model.
The failing-records file gap_rows_metric_name.jsonl One line per failing seed, dev, or train_probe record that the judge labeled: its ID, split, score, margin, semantic category, structural flags, whether it is persistent or regressed, the prompt, the model's answer, the expected answer, the prior round's answer when the prior had the record, and the judge's explanation. Every completed job. Empty when no seed, dev, or train_probe record fails. Never holds test, selection, passing, or resolved records.
The pass-labels file gap_pass_labels_metric_name.jsonl One line per passing record whose score is within a small margin above the threshold, with the judge's verdict on whether the pass is real: pass_confirmed, or scorer_false_positive when the answer is wrong and the scorer let it through. The margin is a fraction of the range of scores the evaluation produced. For example, with the pass condition accuracy >= 0.8 and a margin of 0.05, passing records with a score from 0.8 up to 0.85 are in this file; records below 0.8 fail and are in the failing-records file instead. It exists to catch scorer leaks: a graded scorer letting a wrong answer through just above the threshold. Every completed job. Empty when no passing record's score is within the margin of the threshold, which is always the case for a binary metric: a score of 0 or 1 is never close to the threshold.
The pass-samples file gap_pass_samples_metric_name.jsonl A small random sample of passing seed records and of passing train_probe records, stratified over the split's scores and the same on every rerun, with the prompt, the model's answer, the answer with any reasoning trace stripped, and the expected answer. It shows what the model gets right on the splits from which you may originate training data. Every completed job. Empty when the job has no seed or train_probe records, for example an all-dev or untagged evaluation. dev passes are never written here.
The report gap_analysis_metric_name.md A readable rendering of the summary for people: the development score, the failure taxonomy table, the health table, the budget gate. It carries nothing the JSON lacks and is not part of the contract. Every completed job today; read its location from metadata.json, and fall back to the JSON summary if the entry is empty.
The token usage report token_usage_report.json The Amazon Bedrock models the judge called and the tokens it used: aggregate totals and one per_model entry per Region and model, each with input, output, cache-read, and cache-write tokens and their total. These tokens are billed to your account's Amazon Bedrock usage. Every completed job that called the judge. It sits next to metadata.json and is not listed under Reports.
The threshold proposal threshold_derivation_metric_name.json How the job derived the threshold and the pass condition it proposes, with the method, precision, recall, and F1 against the judge's labels, the records judged, and boundary examples, for you to review before you register it. Only when the job derived the threshold. Its location is Reports[].ThresholdDerivationReportS3Uri.

The difference between the two pass files: the pass-labels file is about the scorer, and asks whether each record that barely passed deserved to; the pass-samples file is about the model, and shows a sample of what it does right on seed and train_probe records so that a recommendation can point at good examples. Both can be empty on the same job, and both are always listed in metadata.json.

The index file, metadata.json

{ "SchemaVersion": "1.0", "JobArn": "arn:aws:sagemaker:us-west-2:111122223333:job/GapAnalysis/support-round2-gap", "JobName": "support-round2-gap", "CreationTime": "2026-12-01T18:00:00Z", "ModelEvaluationJobArns": ["arn:aws:sagemaker:us-west-2:111122223333:job/GenAIEvaluation/support-ft-round2-eval"], "EvaluationCriteriaArn": "arn:aws:sagemaker:us-west-2:111122223333:hub-content/hub-name/JsonDoc/support-criteria/1.1.0", "PriorGapAnalysisJobArns": ["arn:aws:sagemaker:us-west-2:111122223333:job/GapAnalysis/support-round1-gap"], "ContextualEvaluationJobArns": ["arn:aws:sagemaker:us-west-2:111122223333:job/GenAIEvaluation/support-base-eval"], "HealthCheckReferenceEvaluationJobArn": "arn:aws:sagemaker:us-west-2:111122223333:job/GenAIEvaluation/support-base-eval", "KeyMetrics": [{"MetricName": "accuracy", "RunToRunVariation": 0.02}], "Reports": [{ "MetricName": "accuracy", "GapAnalysisReportS3Uri": "s3://amzn-s3-demo-bucket/gap-analysis/round2/gap-analysis/support-round2-gap/2026-12-01T180000Z/gap_analysis_accuracy.json", "GapRowsS3Uri": ".../gap_rows_accuracy.jsonl", "GapAnalysisProfileS3Uri": ".../gap_analysis_accuracy.md", "GapPassLabelsS3Uri": ".../gap_pass_labels_accuracy.jsonl", "GapPassSamplesS3Uri": ".../gap_pass_samples_accuracy.jsonl" }] }
Key Present Meaning
SchemaVersion Always The version of this file's schema, 1.0. A later job refuses a prior whose major version it does not know.
JobArn, JobName, CreationTime Always The job's identity. CreationTime is the job's creation time as YYYY-MM-DDTHH:MM:SS[.fraction]Z; the output folder name is this value without colons.
ModelEvaluationJobArns Always The analyzed evaluation jobs. The next round reads them as the previous model's evaluations for its source: prior comparison.
EvaluationCriteriaArn Always The criteria version this job applied. The next round's reads it to decide what its own EvaluationCriteriaArn must be.
KeyMetrics Always The metric, with RunToRunVariation when the request had it.
PriorGapAnalysisJobArns, ContextualEvaluationJobArns, HealthCheckReferenceEvaluationJobArn When the request had them Carried over from the request.
Reports[] Always, one entry For the metric: MetricName and the URI of each file above. ThresholdDerivationReportS3Uri is present exactly when this job derived its threshold; the control plane reads its presence to allow the criteria version to change on the next job.

Reading the analysis

Read gap_analysis_metric_name.json in this order. Unless an entry says otherwise, "records" means the analyzed model's evaluation records after the test split is set aside.

scoring_method (always). The metric's name.

overall_comparison (always; null when the job has no dev records). The headline, on dev records only.

  • current_score: the mean score of this job's dev records.

  • prior_score, delta, relative_improvement: the prior round's dev score and the change against it; null without a prior.

  • total_examples: the number of dev records scored.

  • total_failures, failure_rate: how many of them failed the threshold, and the ratio.

diff_counts (always). Over every scored seed and dev record, how each record moved against the prior round. Without a prior, every failure is persistent and every pass maintained.

  • resolved: failed in the prior round, passes now.

  • persistent: fails in both.

  • regressed: passed in the prior round, fails now.

  • maintained: passes in both.

  • total: the records counted.

gap_taxonomy (always). The failure categories over the failing seed and dev records. This is where a data decision starts.

  • total_categorized_failures: the number of unique failing records that were categorized; the denominator of every category's frac.

  • categories[]: one entry per category that occurred, semantic and structural alike. A record has exactly one semantic category and any number of structural flags, so counts across entries can add up to more than the total.

    • category, type: the category's name, and semantic, extended (a judge-proposed category), or structural.

    • count, frac, percentage: records in the category, and their share of the categorized failures.

    • labeled_count: present when the judge labeled a sample; the records it actually labeled in the category.

    • mean_score: the mean score of the category's failing records.

    • severity: the share weighted by how badly the records fail; rank categories on it.

    • trend: new, persistent_rate, worsening, improving, newly_broken, or newly_fixed, against the prior round.

    • trend_streak, delta_vs_prior: how many consecutive rounds the category has stayed flat or worsened, and the change in its share.

    • data_addressable: false only when the category has stayed flat or worsened for several consecutive rounds, meaning the data changes tried so far have not moved it. It says nothing about whether the category is a data problem.

    • rationale: one sentence on why the category looks the way it does.

splits (in practice always). One block per split present: seed always, dev, train_probe, and selection when the job has them. selection holds aggregates only.

  • n, n_pass, n_fail, pass_rate, mean_score: the split's counts and means.

  • score_sd, score_range: the spread of the split's scores.

  • categories: the per-split view of the taxonomy, with each category's share of the split's failures.

  • near_threshold_passes: passing records close to the threshold; null for a binary metric.

  • labeling: whether the judge sampled this split's failures, how many it labeled, and unlabeled_ids, the failing records it did not label.

  • passing_ids (seed and train_probe only): every passing record ID, minus the scorer false positives.

  • mde (dev only): the smallest change in the mean that this many records can tell from noise.

pass_verdicts (optional). Per split, how many near-threshold passes were pass_confirmed and how many scorer_false_positive. All zero for a binary metric.

excluded, test (optional; present only when the evaluation has test records).

  • excluded.test: how many test records were set aside.

  • test.n, test.n_pass, test.pass_rate, test.mean_score: the held-out score, for the report only.

comparisons[] (optional). One entry per other model: the prior round's model first (source: prior), then each comparison model (source: contextual). A difference within the noise band is not evidence of a change.

  • key, source, model, evaluation_job_arns: which model, and the evaluations it was read from.

  • splits.split.n_paired, missing: records scored on both sides, and this model's records with no pair.

  • splits.split.mean_score, other_mean_score, delta: the two means and their difference, this model minus the other.

  • splits.split.ci95, half_width: the confidence interval of delta and its half-width.

  • splits.split.resolved, persistent, regressed, maintained, resolved_ids, regressed_ids: how the paired records moved, and which ones; IDs never on selection.

  • splits.dev.noise_band, noise_band_source: the larger of the half-width and the run-to-run variation, and which one set it.

  • splits.dev.within_noise: true when the difference is inside the noise band.

contextual_evaluations[] (optional). Each contextual job in request order. Check this first when a comparison you expected is missing.

  • evaluation_job_arn, model: the job and the model it evaluated.

  • treated_as: repeat, comparison, or refused.

  • reason, detail: for a refusal, why; null otherwise.

repeats[] (optional) and run_to_run_variation[] (always). The repeats the job measured from, and the metric's run-to-run variation. Copy value into the next round's request.

  • repeats[].evaluation_job_arn, paired_with, dev.n_paired, dev.delta: each repeat, the analyzed jobs it paired with, and its mean dev difference.

  • run_to_run_variation[].MetricName, value: the metric and the variation used.

  • run_to_run_variation[].how, set_by: measured from this job's repeats, given from KeyMetrics[].RunToRunVariation, or none; and which repeat or field set it.

health (always). The shape of the answers, not their correctness. Without a reference model, every check except the budget gate is unknown.

  • current.split: this model's response profile per split: extraction rate, wrapper rate, loop rate, truncation rate, response length, label distribution.

  • reference: the same profile for the reference model, when you named one.

  • checks[]: one entry per check and split, with value, other_value, delta, outcome (passed, tripped, warned, or unknown), and reason.

  • budget_gate: per split, the share of answers cut off by the token limit, and passed. A failed gate means those failures are a token-limit problem, not a data problem.

provenance (always). The record of how this analysis was produced, kept here so that you, and the next round's job, can tell what the numbers rest on. The next round reads threshold_source from here to decide which threshold rule applies.

  • sample_threshold: the pass condition the job applied, in its normalized form.

  • threshold_source: evaluation_criteria or derived.

  • threshold_derivation_report: present when derived; the proposal file's name.

  • metric_direction, direction_source: whether higher or lower is better, and where that came from.

  • defaulted_split_rows: per analyzed evaluation, how many records were read as dev for lack of a tag.

  • judge_model: the Amazon Bedrock model ID the job labeled failures and pass verdicts with.

  • tokens_consumed: the tokens those judge calls used, the aggregate total of token_usage_report.json. The judge runs on Amazon Bedrock with your credentials, so these tokens count against your account's Amazon Bedrock usage and quotas. 0 when no record needed the judge: no seed, dev, or train_probe record failed and no pass was near the threshold.

The categories the judge labels with:

Type Categories How they appear
Structural (checked by rule) placeholder_output, type_mismatch, length_too_verbose (far longer than the expected answer), length_too_terse, class_distribution_skew In gap_taxonomy.categories[] with type: structural; on each failing record in gap_rows as structural_flags, zero or more per record.
Semantic (LLM judge) parametric_knowledge_leakage, entity_misattribution, temporal_fiscal_confusion, math_error_correct_extraction, miscalibrated_refusal, incomplete_multipart_extraction, incomplete_required_work, span_boundary_mismatch, surface_cue_overreliance, low_freq_label_undercoverage, ambiguous_edgecase_routing, ground_truth_noise, output_contract_violation, scorer_false_negative, or a judge-proposed extended.name In gap_taxonomy.categories[] with type: semantic or extended; on each failing record in gap_rows as category, exactly one per record.

Two semantic categories point away from data: scorer_false_negative (the answer is right and the scorer missed it) and ground_truth_noise (the expected answer is wrong). Fix the scorer or the evaluation data before you generate records for them. The data_addressable flag does not mark them; it only tracks whether a category has moved across rounds.

Then open gap_rows_metric_name.jsonl and read the records in the largest category. The prompt, the model's answer, the expected answer, and the judge's explanation on each line show what the category means in your data. When an evaluation has many failures, the judge labels a stratified random sample of them (every regressed record, and a bounded number of other failing records per split) rather than all. The failure counts in overall_comparison, diff_counts, and each split's n_fail cover every failing record; the semantic categories' counts and shares are then estimates from the labeled sample, labeled_count says how many records were actually labeled, the failing-records file lists the labeled ones, and splits.split.labeling.unlabeled_ids lists the rest.

Limits and quotas

Item Limit Adjustable
Concurrent gap analysis jobs per account in each Region (Service Quotas: Maximum number of concurrent gap analysis jobs) 3 Yes
Evaluation jobs of the analyzed model (ModelEvaluationJobArns) 1–2 No
Contextual evaluation jobs (ContextualEvaluationJobArns) 0–6 No
Metrics per job (KeyMetrics) 1 No
Prior gap analysis jobs (PriorGapAnalysisJobArns) 0–1 No
Failing records the judge labels Every regressed record, plus a bounded number of other failing records per split; the rest are counted but not labeled No

For supported Regions and the limits that apply to every capability, see Regions and limits for SageMaker AI Data Preparation. A gap analysis job invokes Amazon Bedrock models with your credentials to label failures and to derive a threshold, so the on-demand quotas for those models in your account also apply. For more information, see Quotas for Amazon Bedrock in the Amazon Bedrock User Guide.

Troubleshooting

A gap analysis job can be refused at three points, and the message you get differs at each.

CreateJob rejects the request

No job is created. The error names the field. Examples:

  • ModelEvaluationJobArns[0] references a job in region 'us-east-1', but this endpoint is in 'us-west-2'. Referenced jobs must be in the same region as the Gap Analysis job.

  • ModelEvaluationJobArns[0] must reference a job owned by the caller's account

  • ModelEvaluationJobArns and ContextualEvaluationJobArns must not contain the same job ARN

  • HealthCheckReferenceEvaluationJobArn must be one of the ContextualEvaluationJobArns

Fix the field and call CreateJob again.

The job fails during Validating

The job's FailureReason starts with ClientError: and names the field, the resource, and the fix. The common failures:

Failure What to do
Evaluation criteria or evaluator cannot be read Add sagemaker:DescribeHubContent on the criteria, on the criteria the evaluation jobs ran with, and on the evaluators the criteria name.
Output path not writable Grant s3:PutObject on S3OutputPath and, for an SSE-KMS bucket, use of the KMS key. The same failure on a read points at a referenced job's output location.
Criteria is not the one the evaluation ran with Pass a version of the criteria the evaluation ran with, or rerun the evaluation with yours.
Criteria versions differ in more than thresholds The two versions differ in benchmark, scorers, or datasets. Use a version that differs only in its thresholds.
Criteria document schema not supported Register the criteria at a document schema version the message lists as supported.
Metric produced by more than one evaluator Fix the criteria's evaluators so the metric has one producer.
Metric differs from the prior job's Match the prior round's MetricName, or start a new chain by omitting PriorGapAnalysisJobArns.
Criteria version differs from the prior job's The prior job read its threshold from the criteria, so pass the prior's exact criteria ARN. To change the threshold, start a new chain.
Criteria entity differs from the prior job's The version may change after a derived threshold, but the criteria must be the prior job's.
Evaluation dataset differs from the prior job's Rerun the evaluation on the prior round's dataset, or start a new chain.
Prior job's report cannot be used as a prior Start a new chain.

The job fails during Executing

The job's FailureReason is a generic ClientError that points you to the job's log. The exact cause is in the CloudWatch Logs group /aws/sagemaker/Job/GapAnalysis/, in the stream named job-name/gap-analysis-creation-time; the last line of the log says why. The common failures:

Failure What to do
Records are missing a split tag Some records of an analyzed evaluation carry a split tag and others do not. Tag every record of the evaluation dataset or none, and rerun the evaluation.
Unsupported split value, or two tags on one record disagree Use only seed, dev, train_probe, test, or selection, and make split and metadata.split agree.
The analyzed evaluation jobs share a record ID Analyze one of them, or split the records between the two datasets.
Criteria define no pass condition for the metric Only the base model's own first analysis (no prior, no comparison model) derives a threshold. Register the pass condition in a new version of the criteria and pass that version; if the previous round derived a threshold, its threshold_derivation_metric_name.json holds the proposal. See Approving a derived threshold.
Pass condition in an unsupported form Two PerSamplePassConditions entries for the metric, or an expression other than metric op number. Fix the criteria.
Threshold could not be derived The evaluation has no dev records, or the judge labeled every sampled record the same way. Set a pass condition in the criteria yourself.
Judge model refused the call The model is not enabled in your account and Region, the execution role lacks bedrock:InvokeModel on it, or your Amazon Bedrock quota was exceeded. Throttling by Amazon Bedrock counts against your account's quota.
Health-check reference was refused HealthCheckReferenceEvaluationJobArn names a job the service could not use as a comparison; the log gives the reason. Name an evaluation of another model that ran with the same criteria on the same records.

A comparison you expected is missing from the report

The job is Completed; the service refused that contextual evaluation and left it out. Read contextual_evaluations in the summary for the reason, such as different_criteria, different_settings, or dev_rows_not_covered, and rerun that evaluation to match the analyzed model's job. Only a refused health-check reference fails the job.

Where you go next

  • Data improvement recommendations – Have your coding assistant read this job's report and recommend the next data step: which failure categories to generate records for with synthetic data generation, which records to repair or filter with data transformation, when the scorer or the evaluation data is the problem, and when to stop. If this job derived a threshold, approve it there before the next round.

  • Then customize the model on the improved data, evaluate it, and run the next round of gap analysis with this job as the prior.

The following pages of this guide describe the steps and the concepts around the gap analysis job:

The following references document the SDK and the API:

  • The Amazon SageMaker Python SDK reference for the data preparation module, sagemaker.ai_registry, documents DataPreparer, DatasetJobConfig, and JobCategory.

  • The Amazon SageMaker AI API Reference documents CreateJob, DescribeJob, ListJobs, StopJob, and DeleteJob, and the schema discovery operations ListJobSchemaVersions and DescribeJobSchemaVersion.

The following guides explain the tools that this page uses: