createModelCustomizationJob method

Future<CreateModelCustomizationJobResponse> createModelCustomizationJob({
  1. required String baseModelIdentifier,
  2. required String customModelName,
  3. required String jobName,
  4. required OutputDataConfig outputDataConfig,
  5. required String roleArn,
  6. required TrainingDataConfig trainingDataConfig,
  7. String? clientRequestToken,
  8. String? customModelKmsKeyId,
  9. List<Tag>? customModelTags,
  10. CustomizationConfig? customizationConfig,
  11. CustomizationType? customizationType,
  12. Map<String, String>? hyperParameters,
  13. List<Tag>? jobTags,
  14. ValidationDataConfig? validationDataConfig,
  15. VpcConfig? vpcConfig,
})

Creates a fine-tuning job to customize a base model.

You specify the base foundation model and the location of the training data. After the model-customization job completes successfully, your custom model resource will be ready to use. Amazon Bedrock returns validation loss metrics and output generations after the job completes.

For information on the format of training and validation data, see Prepare the datasets.

Model-customization jobs are asynchronous and the completion time depends on the base model and the training/validation data size. To monitor a job, use the GetModelCustomizationJob operation to retrieve the job status.

For more information, see Custom models in the Amazon Bedrock User Guide.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw TooManyTagsException. May throw ValidationException.

Parameter baseModelIdentifier : Name of the base model.

Parameter customModelName : A name for the resulting custom model.

Parameter jobName : A name for the fine-tuning job.

Parameter outputDataConfig : S3 location for the output data.

Parameter roleArn : The Amazon Resource Name (ARN) of an IAM service role that Amazon Bedrock can assume to perform tasks on your behalf. For example, during model training, Amazon Bedrock needs your permission to read input data from an S3 bucket, write model artifacts to an S3 bucket. To pass this role to Amazon Bedrock, the caller of this API must have the iam:PassRole permission.

Parameter trainingDataConfig : Information about the training dataset.

Parameter clientRequestToken : A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error. For more information, see Ensuring idempotency.

Parameter customModelKmsKeyId : The custom model is encrypted at rest using this key.

Parameter customModelTags : Tags to attach to the resulting custom model.

Parameter customizationConfig : The customization configuration for the model customization job.

Parameter customizationType : The customization type.

Parameter hyperParameters : Parameters related to tuning the model. For details on the format for different models, see Custom model hyperparameters.

Parameter jobTags : Tags to attach to the job.

Parameter validationDataConfig : Information about the validation dataset.

Parameter vpcConfig : The configuration of the Virtual Private Cloud (VPC) that contains the resources that you're using for this job. For more information, see Protect your model customization jobs using a VPC.

Implementation

Future<CreateModelCustomizationJobResponse> createModelCustomizationJob({
  required String baseModelIdentifier,
  required String customModelName,
  required String jobName,
  required OutputDataConfig outputDataConfig,
  required String roleArn,
  required TrainingDataConfig trainingDataConfig,
  String? clientRequestToken,
  String? customModelKmsKeyId,
  List<Tag>? customModelTags,
  CustomizationConfig? customizationConfig,
  CustomizationType? customizationType,
  Map<String, String>? hyperParameters,
  List<Tag>? jobTags,
  ValidationDataConfig? validationDataConfig,
  VpcConfig? vpcConfig,
}) async {
  final $payload = <String, dynamic>{
    'baseModelIdentifier': baseModelIdentifier,
    'customModelName': customModelName,
    'jobName': jobName,
    'outputDataConfig': outputDataConfig,
    'roleArn': roleArn,
    'trainingDataConfig': trainingDataConfig,
    'clientRequestToken': clientRequestToken ?? _s.generateIdempotencyToken(),
    if (customModelKmsKeyId != null)
      'customModelKmsKeyId': customModelKmsKeyId,
    if (customModelTags != null) 'customModelTags': customModelTags,
    if (customizationConfig != null)
      'customizationConfig': customizationConfig,
    if (customizationType != null)
      'customizationType': customizationType.value,
    if (hyperParameters != null) 'hyperParameters': hyperParameters,
    if (jobTags != null) 'jobTags': jobTags,
    if (validationDataConfig != null)
      'validationDataConfig': validationDataConfig,
    if (vpcConfig != null) 'vpcConfig': vpcConfig,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/model-customization-jobs',
    exceptionFnMap: _exceptionFns,
  );
  return CreateModelCustomizationJobResponse.fromJson(response);
}