executeSamplingOperation
abstract suspend fun executeSamplingOperation(input: ExecuteSamplingOperationRequest): ExecuteSamplingOperationResponse
Submits an asynchronous sampling operation to generate text or compute log-probabilities from the model associated with the specified training session. The session must be in Running or Blocked state. Use GetSamplingOperationResult to poll for the result.
Samples
// Generates completions for a tokenized prompt using the session s current weights. Generation
// behavior is controlled by samplingParams and the operation is dispatched asynchronously.
val resp = sageMakerTrainingSessionRuntimeClient.executeSamplingOperation {
trainingSessionName = "my-training-session"
operationConfig = SampleOperationConfig.Sample(SampleConfig {
prompt = ModelInput {
chunks = listOf<EncodedTextChunk>(
EncodedTextChunk {
tokens = listOf<Int>(
791,
6864,
315,
9822,
374
)
type = EncodedTextChunkType.fromValue("encoded_text")
}
)
}
numSamples = 4
samplingParams = SamplingParams {
maxTokens = 1024
temperature = 0.7.toDouble()
topP = 0.9.toDouble()
}
}
)
}Content copied to clipboard