Data improvement
What it is
When you evaluate a model on your task, the evaluation gives you a score and a list of failing records. It does not tell you why the score misses your target, or what data would move it. Data improvement answers those questions for the evaluation metric that you want to optimize through data preparation. It starts from your definition of success, the evaluation criteria that say what a passing answer is, analyzes the gap between the model's actual performance and that target at the record level, groups the underperforming records into categories of failure, and turns the findings into prioritized data actions that you review and choose from.
Data improvement works in two steps:
-
Gap analysis. A SageMaker AI job (job category
GapAnalysis) reads 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, with each category's share, severity, and trend. With evaluations of other models, repeat evaluations, or the previous round's gap analysis, it puts the result in context: paired comparisons with their noise band, run-to-run variation, trends across rounds, and health checks on the shape of the answers. The current gap analysis job analyzes one metric per job. -
Recommendations. Your coding assistant reads the job's report and recommends, for the failure categories that you can address by fine-tuning on training data that data preparation generates or changes, the data action to take: generate records for a category with synthetic data generation, or repair, filter, or re-tag records with data transformation. Each recommended action names the category and the records it rests on, and the configuration to carry it out. When the evidence says the problem is not the data, for example answers cut off by the token limit or a scorer that marks correct answers wrong, the assistant says so and points you back to model evaluation instead of recommending a data action. The recommendations are returned to you for review; nothing changes your data until you act.
Data improvement does not evaluate models, score data, or change datasets. It consumes evaluation results and produces analysis and recommendations.
When to use it
Use data improvement when:
-
You are about to customize a base model for your domain. Evaluate the base model on your evaluation data and run data improvement on that evaluation. The analysis shows where the base model falls short on your task and which kinds of records it fails on, and the recommendations tell you what to generate first.
-
You customized a model on a dataset that you generated with synthetic data generation or prepared with data transformation, evaluated it, and the score is below your target.
-
You are iterating. Each round you improve the data, customize again, and evaluate, and you want to know whether the last change helped and what to change next. Each round's gap analysis job reads the round before it, so the report shows the trend and not only the current state.
-
You want evidence from individual records of the evaluation dataset (your validation data), not only an aggregate score, before you decide what training data to generate or change.
Both entry points, before and after model customization, use the same job and the same recommendations. What differs is the inputs: a base model's own evaluation has no prior round and no comparison model; a customized model's evaluation usually comes with the base model's evaluation for comparison and the previous round's gap analysis job as the prior.
Data improvement works on model evaluation jobs that scored one model on a text dataset and wrote a per-record score for the metric, whatever scorer produced it: a built-in evaluator, a custom evaluator, or an LLM-as-a-judge.
How it works
The job
You create a gap analysis job in one of three ways: ask your coding assistant with the
AI and ML skill, which finds the evaluation jobs and the criteria and submits the
job after you approve it; call DataPreparer.analyze() in the
Amazon SageMaker Python SDK; or call CreateJob with job category
GapAnalysis. The job configuration names the evaluation jobs to read, the metric
to analyze, the versioned evaluation criteria that hold the metric's threshold, and
the Amazon S3 location for the report. The job reads the evaluation jobs with your
execution role, sorts any contextual evaluations into repeats and comparisons,
applies the threshold, has an LLM judge label each failing record with a failure
category, compares and checks, and writes its report files to Amazon S3 with a
metadata.json index that DescribeJob returns as
MetadataS3Uri. The job produces the analysis; it does not
recommend. For the inputs, the output files, and how to read them, see Gap analysis.
The recommendations
The recommendations come from the AI and ML skill of the Agent Toolkit for AWS, running in your coding assistant. The assistant reads the gap analysis job's report (the category summary, the labeled failing records, and the passing samples), checks that the measurement can be trusted, and recommends the data actions for the categories that data can address, each with the category and records it rests on, what it should move, and the configuration to carry it out. It records the recommendation in your project and shows it to you; you choose what to act on. When the job derived a threshold because your criteria had none, the assistant presents the proposal with the evidence behind it, and you approve it, tune it, or give your own before the next round. For what the assistant reads, what it recommends, and how a round leads to the next, see Data improvement recommendations.
Prerequisites
Before you run data improvement, you need the following.
-
Completed model evaluation jobs (job category
GenAIEvaluation), in the same AWS account and Region, eachCompleted, each having scored one model with an LLM-as-a-judge or a custom scorer and written a per-record score for the metric you want to analyze. Depending on what you want from the analysis, you need up to four kinds. For each one's field, cardinality, and validation rules, see Inputs to the job.-
Required: the evaluation of the model you are analyzing. One job, or two when that model's records are split across two evaluation datasets.
-
Optional: evaluations of other models to compare with, usually the base model. Run with the same evaluation criteria (any version) on records with the same IDs, because the job pairs records by ID. One of them can also serve as the health-check reference.
-
Optional: repeat evaluations of the analyzed model, with the same settings, covering all of its development records. They let the first round measure the run-to-run variation that every later round reuses.
-
Optional: the previous round's gap analysis job (job category
GapAnalysis), when you are iterating. It gives the trends and fixes the threshold for the chain.
-
-
Evaluation criteria. The
EvaluationCriteriadocument in your hub that the evaluation jobs ran with, named by its versioned ARN. The gap analysis job reads the per-sample pass condition for your metric from itsPerSamplePassConditions, for exampleaccuracy >= 0.8. If the criteria have no such condition for the metric, the first round can derive one for you; see Where the threshold comes from. -
An execution role that SageMaker AI can assume, with permission to describe the referenced jobs and criteria, read their output in Amazon S3, write the report to your output path, write the job log, and invoke the judge model in Amazon Bedrock. The full list is in Permissions.
-
An Amazon S3 output path in the same Region, for the report.
-
For recommendations, the Agent Toolkit for AWS with its AI and ML skill installed in your coding assistant. The SDK alone runs the job and returns the report; the recommendations need the skill.
How the evaluation dataset's records are tagged
A gap analysis job treats records differently by their role in your workflow, which
you declare with a split tag on each record of the dataset that you
evaluate the analyzed model on (a top-level split field, or
metadata.split). The evaluation output carries each input record
as it was, so the job reads the tag from the evaluation job's results; you do not
tag anything after the evaluation. The tag is optional. If no record in an analyzed
evaluation has one, the job treats every record of that evaluation as
dev. If some records have a tag and others do not, the job fails,
because defaulting the untagged records would put held-out records into the
development results. Tag every record or none, per evaluation job.
Only the analyzed model's evaluations are read for tags. Evaluations of other models and repeat evaluations contribute scores paired by record ID; the analyzed model's tag decides which split a paired record belongs to, so those evaluations need no tags of their own, though they usually have the same ones because they ran on the same dataset.
| Tag | What the records are | How the job treats them |
|---|---|---|
dev |
The development set that you measure progress on. The default when no record is tagged. | Scored, labeled by the judge, and written to the failing-records
file. The headline score and the threshold derivation use
dev records only. Passing dev records
are never written to the passing-records sample file, because
dev is held out: it measures progress and is never
a source of training or generated data. |
seed |
Curated examples that define the task, from which you may originate new training data. | Scored, labeled, and written to the failing-records file. The
report also lists the IDs of every passing seed record
and writes a small sample of them, with prompt, answer, and expected
answer, to the passing-records sample file. A recommendation uses
them in two ways: as examples of what the model already does right,
to contrast with the failing records of a category, and as anchors
for synthetic data generation, since seed records may originate new
training data. |
train_probe |
A sample of your training records, evaluated to find failure modes on training data. Not a generalization score. | Analyzed like seed, with its own block in the
report. Excluded from the headline score and from the
round-to-round diff counts. |
test |
Held-out records that give the final, unbiased score of the
model: the set you report on, as opposed to dev, which
you look at and act on during iteration. Because you never inspect
or label test records, the score on them cannot be
inflated by data decisions made while looking at them. |
Scored for a pass rate and mean score in the report's
test block only, so you can see the held-out score
next to the dev score. Never labeled by the judge,
never written to any record file, never compared with the previous
round, never used to derive a threshold, and never a source of
training or generated data. |
selection |
Held-out records reserved for choosing between candidate models
trained in the same round; only the winner is then evaluated on
dev, so the dev score is not inflated
by the choice. Not needed if you train one candidate per
round. |
Sealed: scored and paired by ID, but reported as aggregates only. IDs and content are never written to any file, never labeled, never compared with the previous round, never used to derive a threshold. |
A value other than these five fails the job and names the record. Two tags on
one record that disagree (for example split and
metadata.split) fail the job.
Where you go next
-
Gap analysis – Create the job, read its report, and run the next round.
-
Data improvement recommendations – Turn the report into the next data step with your coding assistant.
Related information
The following pages of this guide describe the steps and the concepts around data improvement:
-
Preparing Data with SageMaker AI Data Preparation introduces the data preparation jobs and the hub that holds your datasets and evaluation criteria.
-
Get started with SageMaker AI Data Preparation and Set up and prerequisites describe the execution role, the default Amazon S3 bucket, and the permissions that the caller needs.
-
Synthetic data generation is the step that generates the records a recommendation asks for.
-
Data transformation is the step that filters, repairs, or re-tags records, and that merges new records into the training set.
-
Regions and limits for SageMaker AI Data Preparation lists the Regions and the quotas that apply to every capability.
-
Model evaluation describes the evaluation jobs and the evaluation criteria that a gap analysis job reads.
The following references document the SDK and the API:
-
The Amazon SageMaker Python SDK reference for the data preparation module,
sagemaker.ai_registry, documentsDataPreparer,DatasetJobConfig, andJobCategory. -
The Amazon SageMaker AI API Reference documents CreateJob, DescribeJob,
ListJobs,StopJob, andDeleteJob, and the schema discovery operationsListJobSchemaVersionsand DescribeJobSchemaVersion.
The following guide explains the tool that the recommendations use:
-
The Agent Toolkit for AWS User Guide explains how to install the toolkit and its AI and ML skill.