SageMakerTrainingSessionRuntime / Client / get_sampling_operation_result

get_sampling_operation_result

SageMakerTrainingSessionRuntime.Client.get_sampling_operation_result(**kwargs)

Retrieves the current status and result of a previously submitted sampling operation. Poll this operation until the status reaches a terminal state (Completed or Failed).

See also: AWS API Documentation

Request Syntax

response = client.get_sampling_operation_result(
    trainingSessionName='string',
    operationId='string'
)
Parameters:
  • trainingSessionName (string) –

    [REQUIRED]

    The name of the training session that owns the sample operation.

  • operationId (string) –

    [REQUIRED]

    The unique identifier of the sample operation to retrieve, returned by ExecuteSamplingOperation.

Return type:

dict

Returns:

Response Syntax

{
    'status': 'Pending'|'InProgress'|'Completed'|'Failed'|'Skipped',
    'operationResult': {
        'sample': {
            'sequences': [
                {
                    'stopReason': 'stop'|'length',
                    'tokens': [
                        123,
                    ],
                    'logprobs': [
                        123.0,
                    ],
                    'tokenUsage': {
                        'prefill': 123,
                        'decode': 123
                    }
                },
            ],
            'promptLogprobs': [
                123.0,
            ],
            'topkPromptLogprobs': [
                [
                    {
                        'tokenId': 123,
                        'logprob': 123.0
                    },
                ],
            ]
        },
        'computeLogprobs': {
            'logprobs': [
                123.0,
            ]
        },
        'loadWeightsForSampling': {}
    },
    'errorDetails': 'string'
}

Response Structure

  • (dict) –

    • status (string) –

      The current status of the sample operation. Possible values are Pending, InProgress, Completed, or Failed.

    • operationResult (dict) –

      The result payload of the sample operation. The service populates this field only when the status is Completed.

      Note

      This is a Tagged Union structure. Only one of the following top level keys will be set: sample, computeLogprobs, loadWeightsForSampling. If a client receives an unknown member it will set SDK_UNKNOWN_MEMBER as the top level key, which maps to the name or tag of the unknown member. The structure of SDK_UNKNOWN_MEMBER is as follows:

      'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
      
      • sample (dict) –

        The generated text samples from the model.

        • sequences (list) –

          The list of generated sequences.

          • (dict) –

            A single generated sequence from the model.

            • stopReason (string) –

              The reason why generation stopped. A value of stop indicates a stop sequence was encountered. A value of length indicates the maximum token limit was reached.

            • tokens (list) –

              The token IDs of the generated sequence.

              • (integer) –

            • logprobs (list) –

              The per-token log-probabilities for the generated tokens.

              • (float) –

            • tokenUsage (dict) –

              The token usage statistics for this individual sample.

              • prefill (integer) –

                The number of tokens in the input prompt (prefill phase).

              • decode (integer) –

                The number of tokens generated (decode phase).

        • promptLogprobs (list) –

          The per-token log-probabilities for the input prompt. Populated only when includePromptLogprobs is true.

          • (float) –

        • topkPromptLogprobs (list) –

          The top-k log-probabilities per prompt token, as a list of lists. Populated only when topkPromptLogprobs is greater than 0.

          • (list) –

            • (dict) –

              The log-probability for a single token.

              • tokenId (integer) –

                The vocabulary token ID.

              • logprob (float) –

                The log-probability of the token.

      • computeLogprobs (dict) –

        The computed log-probabilities for the prompt tokens.

        • logprobs (list) –

          The per-token log-probabilities for the input prompt.

          • (float) –

      • loadWeightsForSampling (dict) –

        The result from loading weights for sampling.

    • errorDetails (string) –

      A message describing why the sample operation failed. The service populates this field only when the status is Failed.

Exceptions

  • SageMakerTrainingSessionRuntime.Client.exceptions.ResourceNotFoundException

  • SageMakerTrainingSessionRuntime.Client.exceptions.ThrottlingException

  • SageMakerTrainingSessionRuntime.Client.exceptions.InternalServerException

  • SageMakerTrainingSessionRuntime.Client.exceptions.ValidationException