SageMaker / Client / add_candidate
add_candidate¶
- SageMaker.Client.add_candidate(**kwargs)¶
Adds a candidate and its evaluation metrics to a leaderboard, or adds evaluation metrics to an existing candidate.
The candidate configuration (
CandidateConfig) identifies the candidate. SageMaker derives theCandidateIdfrom the configuration, so the same configuration always produces the sameCandidateIdon a leaderboard. The display name and labels aren’t part of the identity.If a candidate with the same configuration already exists on the leaderboard,
AddCandidateupdates it as follows:Adds the evaluation metrics in the request to the candidate’s existing metrics.
Replaces the candidate’s labels if you specify
Labels. If you don’t specifyLabels, the existing labels are kept.Keeps the existing display name.
DisplayNametakes effect only when the candidate is created.
See also: AWS API Documentation
Request Syntax
response = client.add_candidate( LeaderboardArn='string', DisplayName='string', Labels={ 'string': 'string' }, CandidateConfig={ 'CustomerModelConfig': { 'ModelRef': 'string', 'DatasetArn': 'string', 'EvalCriteriaArn': 'string', 'PromptTemplateArn': 'string', 'Dimensions': [ { 'Key': 'string', 'Value': 'string' }, ] } }, EvaluationResults=[ { 'CriterionName': 'string', 'Metrics': { 'string': 123.0 }, 'Producer': 'MLFLOW'|'EXTERNAL', 'SourceId': 'string', 'SourceUrl': 'string', 'References': { 'string': 'string' }, 'RecordedAt': datetime(2015, 1, 1), 'IngestedAt': datetime(2015, 1, 1) }, ], ClientToken='string' )
- Parameters:
LeaderboardArn (string) –
[REQUIRED]
The Amazon Resource Name (ARN) of the leaderboard to add the candidate to.
DisplayName (string) – A display name for the candidate. SageMaker uses this value only when it creates the candidate. If the candidate already exists, SageMaker keeps its existing display name. The display name can’t contain control characters or format characters.
Labels (dict) –
Key-value pairs that describe the candidate. Labels aren’t part of the candidate’s identity. If the candidate already exists, these labels replace its existing labels. To remove all labels, specify an empty map. If you don’t specify labels, the existing labels are kept. Label keys and values can contain only Unicode letters, numbers, spaces, and the following characters:
_ . : / = + - @.(string) –
(string) –
CandidateConfig (dict) –
[REQUIRED]
The configuration that identifies the candidate. Candidates with the same configuration have the same
CandidateId.CustomerModelConfig (dict) –
The configuration of a candidate that is one of your models.
ModelRef (string) – [REQUIRED]
A reference to the model that was evaluated, such as the ARN of a SageMaker model package or a model identifier.
DatasetArn (string) –
The dataset the candidate was evaluated on: the ARN of a SageMaker hub content DataSet, or the S3 URI of the dataset. Optional.
EvalCriteriaArn (string) – [REQUIRED]
The ARN of the evaluation criteria that the candidate was evaluated with. Specify the ARN of a SageMaker hub content document of type
JsonDoc, optionally with its version, for examplearn:aws:sagemaker:aa-example-3:111122223333:hub-content/my-hub/JsonDoc/my-criteria/1.0.0. For content in a public hub, the account isaws.PromptTemplateArn (string) –
The Amazon Resource Name (ARN) of the prompt template that you use with the model. Optional. Specify the ARN of a SageMaker hub content document or of an Amazon Bedrock prompt, such as a prompt version ARN.
Dimensions (list) –
Additional key-value pairs that define the candidate, such as the retrieval-augmented generation (RAG) Knowledge Base, RAG prompt template, and RAG number of results. Dimensions are part of the candidate’s identity: two candidates that differ only in their dimensions are distinct candidates. Each key can appear at most once.
(dict) –
A key-value pair that, together with the other fields of the customer model configuration, defines a leaderboard candidate.
Key (string) – [REQUIRED]
The dimension key.
Value (string) – [REQUIRED]
The dimension value. The required format depends on the key.
EvaluationResults (list) –
[REQUIRED]
The evaluation metrics to add to the candidate, grouped by evaluation criterion.
(dict) –
The result of evaluating a candidate against one evaluation criterion.
CriterionName (string) – [REQUIRED]
The name of the evaluation criterion.
Metrics (dict) – [REQUIRED]
The metric values for the criterion, as a map of metric name to value.
(string) –
(float) –
Producer (string) –
The source that produced the evaluation result.
SourceId (string) –
The ID that the producer’s system, such as MLflow, assigns to the evaluation run that produced the result. The ID must begin with a letter or number and can contain only letters, numbers, hyphens (-), and underscores (_).
SourceUrl (string) –
A URL where you can view the evaluation run that produced the result. The URL must begin with
https://.References (dict) –
Key-value pairs that link the result to related resources. Keys can contain only Unicode letters, numbers, spaces, and the following characters:
_ . : / = + - @. Values can’t contain control characters or format characters.(string) –
(string) –
RecordedAt (datetime) – [REQUIRED]
When the evaluation result was produced.
ListCandidatesuses this value to find the candidate’s most recent evaluation run.IngestedAt (datetime) –
When SageMaker added the result to the leaderboard. SageMaker sets this value. If you specify it in
AddCandidate, SageMaker ignores it.
ClientToken (string) –
A unique, case-sensitive identifier for the request. If you don’t specify a client token, the Amazon Web Services SDKs and the Amazon Web Services CLI generate one for you.
This field is autopopulated if not provided.
- Return type:
dict
- Returns:
Response Syntax
{ 'CandidateId': 'string' }
Response Structure
(dict) –
CandidateId (string) –
The ID of the candidate. If the candidate already existed, this is its existing ID.
Exceptions