Bedrock / Client / create_model_customization_job

create_model_customization_job#

Bedrock.Client.create_model_customization_job(**kwargs)#

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.

See also: AWS API Documentation

Request Syntax

response = client.create_model_customization_job(
    jobName='string',
    customModelName='string',
    roleArn='string',
    clientRequestToken='string',
    baseModelIdentifier='string',
    customizationType='FINE_TUNING'|'CONTINUED_PRE_TRAINING'|'DISTILLATION',
    customModelKmsKeyId='string',
    jobTags=[
        {
            'key': 'string',
            'value': 'string'
        },
    ],
    customModelTags=[
        {
            'key': 'string',
            'value': 'string'
        },
    ],
    trainingDataConfig={
        's3Uri': 'string',
        'invocationLogsConfig': {
            'usePromptResponse': True|False,
            'invocationLogSource': {
                's3Uri': 'string'
            },
            'requestMetadataFilters': {
                'equals': {
                    'string': 'string'
                },
                'notEquals': {
                    'string': 'string'
                },
                'andAll': [
                    {
                        'equals': {
                            'string': 'string'
                        },
                        'notEquals': {
                            'string': 'string'
                        }
                    },
                ],
                'orAll': [
                    {
                        'equals': {
                            'string': 'string'
                        },
                        'notEquals': {
                            'string': 'string'
                        }
                    },
                ]
            }
        }
    },
    validationDataConfig={
        'validators': [
            {
                's3Uri': 'string'
            },
        ]
    },
    outputDataConfig={
        's3Uri': 'string'
    },
    hyperParameters={
        'string': 'string'
    },
    vpcConfig={
        'subnetIds': [
            'string',
        ],
        'securityGroupIds': [
            'string',
        ]
    },
    customizationConfig={
        'distillationConfig': {
            'teacherModelConfig': {
                'teacherModelIdentifier': 'string',
                'maxResponseLengthForInference': 123
            }
        }
    }
)
Parameters:
  • jobName (string) –

    [REQUIRED]

    A name for the fine-tuning job.

  • customModelName (string) –

    [REQUIRED]

    A name for the resulting custom model.

  • roleArn (string) –

    [REQUIRED]

    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.

  • clientRequestToken (string) –

    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.

    This field is autopopulated if not provided.

  • baseModelIdentifier (string) –

    [REQUIRED]

    Name of the base model.

  • customizationType (string) – The customization type.

  • customModelKmsKeyId (string) – The custom model is encrypted at rest using this key.

  • jobTags (list) –

    Tags to attach to the job.

    • (dict) –

      Definition of the key/value pair for a tag.

      • key (string) – [REQUIRED]

        Key for the tag.

      • value (string) – [REQUIRED]

        Value for the tag.

  • customModelTags (list) –

    Tags to attach to the resulting custom model.

    • (dict) –

      Definition of the key/value pair for a tag.

      • key (string) – [REQUIRED]

        Key for the tag.

      • value (string) – [REQUIRED]

        Value for the tag.

  • trainingDataConfig (dict) –

    [REQUIRED]

    Information about the training dataset.

    • s3Uri (string) –

      The S3 URI where the training data is stored.

    • invocationLogsConfig (dict) –

      Settings for using invocation logs to customize a model.

      • usePromptResponse (boolean) –

        Whether to use the model’s response for training, or just the prompt. The default value is False.

      • invocationLogSource (dict) – [REQUIRED]

        The source of the invocation logs.

        Note

        This is a Tagged Union structure. Only one of the following top level keys can be set: s3Uri.

        • s3Uri (string) –

          The URI of an invocation log in a bucket.

      • requestMetadataFilters (dict) –

        Rules for filtering invocation logs based on request metadata.

        Note

        This is a Tagged Union structure. Only one of the following top level keys can be set: equals, notEquals, andAll, orAll.

        • equals (dict) –

          Include results where the key equals the value.

          • (string) –

            • (string) –

        • notEquals (dict) –

          Include results where the key does not equal the value.

          • (string) –

            • (string) –

        • andAll (list) –

          Include results where all of the based filters match.

          • (dict) –

            A mapping of a metadata key to a value that it should or should not equal.

            • equals (dict) –

              Include results where the key equals the value.

              • (string) –

                • (string) –

            • notEquals (dict) –

              Include results where the key does not equal the value.

              • (string) –

                • (string) –

        • orAll (list) –

          Include results where any of the base filters match.

          • (dict) –

            A mapping of a metadata key to a value that it should or should not equal.

            • equals (dict) –

              Include results where the key equals the value.

              • (string) –

                • (string) –

            • notEquals (dict) –

              Include results where the key does not equal the value.

              • (string) –

                • (string) –

  • validationDataConfig (dict) –

    Information about the validation dataset.

    • validators (list) – [REQUIRED]

      Information about the validators.

      • (dict) –

        Information about a validator.

        • s3Uri (string) – [REQUIRED]

          The S3 URI where the validation data is stored.

  • outputDataConfig (dict) –

    [REQUIRED]

    S3 location for the output data.

    • s3Uri (string) – [REQUIRED]

      The S3 URI where the output data is stored.

  • hyperParameters (dict) –

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

    • (string) –

      • (string) –

  • vpcConfig (dict) –

    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.

    • subnetIds (list) – [REQUIRED]

      An array of IDs for each subnet in the VPC to use.

      • (string) –

    • securityGroupIds (list) – [REQUIRED]

      An array of IDs for each security group in the VPC to use.

      • (string) –

  • customizationConfig (dict) –

    The customization configuration for the model customization job.

    Note

    This is a Tagged Union structure. Only one of the following top level keys can be set: distillationConfig.

    • distillationConfig (dict) –

      The distillation configuration for the custom model.

      • teacherModelConfig (dict) – [REQUIRED]

        The teacher model configuration.

        • teacherModelIdentifier (string) – [REQUIRED]

          The identifier of the teacher model.

        • maxResponseLengthForInference (integer) –

          The maximum number of tokens requested when the customization job invokes the teacher model.

Return type:

dict

Returns:

Response Syntax

{
    'jobArn': 'string'
}

Response Structure

  • (dict) –

    • jobArn (string) –

      Amazon Resource Name (ARN) of the fine tuning job

Exceptions

  • Bedrock.Client.exceptions.ResourceNotFoundException

  • Bedrock.Client.exceptions.AccessDeniedException

  • Bedrock.Client.exceptions.ValidationException

  • Bedrock.Client.exceptions.ConflictException

  • Bedrock.Client.exceptions.InternalServerException

  • Bedrock.Client.exceptions.TooManyTagsException

  • Bedrock.Client.exceptions.ServiceQuotaExceededException

  • Bedrock.Client.exceptions.ThrottlingException