Skip to content

Latest commit

 

History

History
723 lines (504 loc) · 28.9 KB

File metadata and controls

723 lines (504 loc) · 28.9 KB

cms_client.TrainingApi

All URIs are relative to http://localhost

Method HTTP request Description
cancel_training POST /cancel_training Cancel Training
get_evaluation_with_trainer_export POST /evaluate Get Evaluation With Trainer Export
train_eval_info GET /train_eval_info Train Eval Info
train_eval_metrics GET /train_eval_metrics Train Eval Metrics
train_metacat POST /train_metacat Train Metacat
train_supervised POST /train_supervised Train Supervised
train_unsupervised POST /train_unsupervised Train Unsupervised
train_unsupervised_with_hf_dataset POST /train_unsupervised_with_hf_hub_dataset Train Unsupervised With Hf Dataset

cancel_training

object cancel_training()

Cancel Training

Cancel the in-progress training job (this is experimental and may not work as expected)

Example

  • OAuth Authentication (OAuth2PasswordBearer):
  • Api Key Authentication (APIKeyCookie):
import cms_client
from cms_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = cms_client.Configuration(
    host = "http://localhost"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

configuration.access_token = os.environ["ACCESS_TOKEN"]

# Configure API key authorization: APIKeyCookie
configuration.api_key['APIKeyCookie'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['APIKeyCookie'] = 'Bearer'

# Enter a context with an instance of the API client
with cms_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cms_client.TrainingApi(api_client)

    try:
        # Cancel Training
        api_response = api_instance.cancel_training()
        print("The response of TrainingApi->cancel_training:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling TrainingApi->cancel_training: %s\n" % e)

Parameters

This endpoint does not need any parameter.

Return type

object

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful Response -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_evaluation_with_trainer_export

object get_evaluation_with_trainer_export(trainer_export, tracking_id=tracking_id)

Get Evaluation With Trainer Export

Evaluate the model being served with a trainer export

Example

  • OAuth Authentication (OAuth2PasswordBearer):
  • Api Key Authentication (APIKeyCookie):
import cms_client
from cms_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = cms_client.Configuration(
    host = "http://localhost"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

configuration.access_token = os.environ["ACCESS_TOKEN"]

# Configure API key authorization: APIKeyCookie
configuration.api_key['APIKeyCookie'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['APIKeyCookie'] = 'Bearer'

# Enter a context with an instance of the API client
with cms_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cms_client.TrainingApi(api_client)
    trainer_export = None # List[bytearray] | One or more trainer export files to be uploaded
    tracking_id = 'tracking_id_example' # str | The tracking ID of the requested task (optional)

    try:
        # Get Evaluation With Trainer Export
        api_response = api_instance.get_evaluation_with_trainer_export(trainer_export, tracking_id=tracking_id)
        print("The response of TrainingApi->get_evaluation_with_trainer_export:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling TrainingApi->get_evaluation_with_trainer_export: %s\n" % e)

Parameters

Name Type Description Notes
trainer_export List[bytearray] One or more trainer export files to be uploaded
tracking_id str The tracking ID of the requested task [optional]

Return type

object

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful Response -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

train_eval_info

object train_eval_info(train_eval_id)

Train Eval Info

Get the training or evaluation job information by its ID

Example

  • OAuth Authentication (OAuth2PasswordBearer):
  • Api Key Authentication (APIKeyCookie):
import cms_client
from cms_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = cms_client.Configuration(
    host = "http://localhost"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

configuration.access_token = os.environ["ACCESS_TOKEN"]

# Configure API key authorization: APIKeyCookie
configuration.api_key['APIKeyCookie'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['APIKeyCookie'] = 'Bearer'

# Enter a context with an instance of the API client
with cms_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cms_client.TrainingApi(api_client)
    train_eval_id = 'train_eval_id_example' # str | The training or evaluation ID

    try:
        # Train Eval Info
        api_response = api_instance.train_eval_info(train_eval_id)
        print("The response of TrainingApi->train_eval_info:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling TrainingApi->train_eval_info: %s\n" % e)

Parameters

Name Type Description Notes
train_eval_id str The training or evaluation ID

Return type

object

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful Response -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

train_eval_metrics

object train_eval_metrics(train_eval_id)

Train Eval Metrics

Get the training or evaluation metrics by its ID (Each metric may contain multiple values for multiple epochs)

Example

  • OAuth Authentication (OAuth2PasswordBearer):
  • Api Key Authentication (APIKeyCookie):
import cms_client
from cms_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = cms_client.Configuration(
    host = "http://localhost"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

configuration.access_token = os.environ["ACCESS_TOKEN"]

# Configure API key authorization: APIKeyCookie
configuration.api_key['APIKeyCookie'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['APIKeyCookie'] = 'Bearer'

# Enter a context with an instance of the API client
with cms_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cms_client.TrainingApi(api_client)
    train_eval_id = 'train_eval_id_example' # str | The training or evaluation ID

    try:
        # Train Eval Metrics
        api_response = api_instance.train_eval_metrics(train_eval_id)
        print("The response of TrainingApi->train_eval_metrics:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling TrainingApi->train_eval_metrics: %s\n" % e)

Parameters

Name Type Description Notes
train_eval_id str The training or evaluation ID

Return type

object

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful Response -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

train_metacat

object train_metacat(trainer_export, epochs=epochs, log_frequency=log_frequency, tracking_id=tracking_id, description=description)

Train Metacat

Upload one or more trainer export files and trigger the metacat training

Example

  • OAuth Authentication (OAuth2PasswordBearer):
  • Api Key Authentication (APIKeyCookie):
import cms_client
from cms_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = cms_client.Configuration(
    host = "http://localhost"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

configuration.access_token = os.environ["ACCESS_TOKEN"]

# Configure API key authorization: APIKeyCookie
configuration.api_key['APIKeyCookie'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['APIKeyCookie'] = 'Bearer'

# Enter a context with an instance of the API client
with cms_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cms_client.TrainingApi(api_client)
    trainer_export = None # List[bytearray] | One or more trainer export files to be uploaded
    epochs = 1 # int | The number of training epochs (optional) (default to 1)
    log_frequency = 1 # int | The number of processed documents or epochs after which training metrics will be logged (optional) (default to 1)
    tracking_id = 'tracking_id_example' # str | The tracking ID of the requested task (optional)
    description = 'description_example' # str |  (optional)

    try:
        # Train Metacat
        api_response = api_instance.train_metacat(trainer_export, epochs=epochs, log_frequency=log_frequency, tracking_id=tracking_id, description=description)
        print("The response of TrainingApi->train_metacat:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling TrainingApi->train_metacat: %s\n" % e)

Parameters

Name Type Description Notes
trainer_export List[bytearray] One or more trainer export files to be uploaded
epochs int The number of training epochs [optional] [default to 1]
log_frequency int The number of processed documents or epochs after which training metrics will be logged [optional] [default to 1]
tracking_id str The tracking ID of the requested task [optional]
description str [optional]

Return type

object

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

HTTP response details

Status code Description Response headers
202 Successful Response -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

train_supervised

object train_supervised(trainer_export, epochs=epochs, lr_override=lr_override, test_size=test_size, early_stopping_patience=early_stopping_patience, log_frequency=log_frequency, tracking_id=tracking_id, description=description)

Train Supervised

Upload one or more trainer export files and trigger the supervised training

Example

  • OAuth Authentication (OAuth2PasswordBearer):
  • Api Key Authentication (APIKeyCookie):
import cms_client
from cms_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = cms_client.Configuration(
    host = "http://localhost"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

configuration.access_token = os.environ["ACCESS_TOKEN"]

# Configure API key authorization: APIKeyCookie
configuration.api_key['APIKeyCookie'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['APIKeyCookie'] = 'Bearer'

# Enter a context with an instance of the API client
with cms_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cms_client.TrainingApi(api_client)
    trainer_export = None # List[bytearray] | One or more trainer export files to be uploaded
    epochs = 1 # int | The number of training epochs (optional) (default to 1)
    lr_override = 3.4 # float | The override of the initial learning rate (optional)
    test_size = 3.4 # float | The override of the test size in percentage. (For a 'huggingface-ner' model, a negative value can be used to apply the train-validation-test split if implicitly defined in trainer export: 'projects[0]' is used for training, 'projects[1]' for validation, and 'projects[2]' for testing) (optional)
    early_stopping_patience = 56 # int | The number of evaluations to wait for improvement before stopping the training. (Non-positive values disable early stopping) (optional)
    log_frequency = 1 # int | The number of processed documents or epochs after which training metrics will be logged (optional) (default to 1)
    tracking_id = 'tracking_id_example' # str | The tracking ID of the requested task (optional)
    description = 'description_example' # str |  (optional)

    try:
        # Train Supervised
        api_response = api_instance.train_supervised(trainer_export, epochs=epochs, lr_override=lr_override, test_size=test_size, early_stopping_patience=early_stopping_patience, log_frequency=log_frequency, tracking_id=tracking_id, description=description)
        print("The response of TrainingApi->train_supervised:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling TrainingApi->train_supervised: %s\n" % e)

Parameters

Name Type Description Notes
trainer_export List[bytearray] One or more trainer export files to be uploaded
epochs int The number of training epochs [optional] [default to 1]
lr_override float The override of the initial learning rate [optional]
test_size float The override of the test size in percentage. (For a 'huggingface-ner' model, a negative value can be used to apply the train-validation-test split if implicitly defined in trainer export: 'projects[0]' is used for training, 'projects[1]' for validation, and 'projects[2]' for testing) [optional]
early_stopping_patience int The number of evaluations to wait for improvement before stopping the training. (Non-positive values disable early stopping) [optional]
log_frequency int The number of processed documents or epochs after which training metrics will be logged [optional] [default to 1]
tracking_id str The tracking ID of the requested task [optional]
description str [optional]

Return type

object

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

HTTP response details

Status code Description Response headers
202 Successful Response -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

train_unsupervised

object train_unsupervised(training_data, epochs=epochs, lr_override=lr_override, test_size=test_size, log_frequency=log_frequency, tracking_id=tracking_id, description=description)

Train Unsupervised

Upload one or more files each containing a list of plain texts and trigger the unsupervised training

Example

  • OAuth Authentication (OAuth2PasswordBearer):
  • Api Key Authentication (APIKeyCookie):
import cms_client
from cms_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = cms_client.Configuration(
    host = "http://localhost"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

configuration.access_token = os.environ["ACCESS_TOKEN"]

# Configure API key authorization: APIKeyCookie
configuration.api_key['APIKeyCookie'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['APIKeyCookie'] = 'Bearer'

# Enter a context with an instance of the API client
with cms_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cms_client.TrainingApi(api_client)
    training_data = None # List[bytearray] | One or more files to be uploaded and each contains a list of plain texts, in the format of [\\\"text_1\\\", \\\"text_2\\\", ..., \\\"text_n\\\"]
    epochs = 1 # int | The number of training epochs (optional) (default to 1)
    lr_override = 3.4 # float | The override of the initial learning rate (optional)
    test_size = 3.4 # float | The override of the test size in percentage (optional)
    log_frequency = 1000 # int | The number of processed documents or epochs after which training metrics will be logged (optional) (default to 1000)
    tracking_id = 'tracking_id_example' # str | The tracking ID of the requested task (optional)
    description = 'description_example' # str |  (optional)

    try:
        # Train Unsupervised
        api_response = api_instance.train_unsupervised(training_data, epochs=epochs, lr_override=lr_override, test_size=test_size, log_frequency=log_frequency, tracking_id=tracking_id, description=description)
        print("The response of TrainingApi->train_unsupervised:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling TrainingApi->train_unsupervised: %s\n" % e)

Parameters

Name Type Description Notes
training_data List[bytearray] One or more files to be uploaded and each contains a list of plain texts, in the format of [\"text_1\", \"text_2\", ..., \"text_n\"]
epochs int The number of training epochs [optional] [default to 1]
lr_override float The override of the initial learning rate [optional]
test_size float The override of the test size in percentage [optional]
log_frequency int The number of processed documents or epochs after which training metrics will be logged [optional] [default to 1000]
tracking_id str The tracking ID of the requested task [optional]
description str [optional]

Return type

object

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

HTTP response details

Status code Description Response headers
202 Successful Response -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

train_unsupervised_with_hf_dataset

object train_unsupervised_with_hf_dataset(hf_dataset_repo_id=hf_dataset_repo_id, hf_dataset_config=hf_dataset_config, trust_remote_code=trust_remote_code, text_column_name=text_column_name, epochs=epochs, lr_override=lr_override, test_size=test_size, log_frequency=log_frequency, description=description, tracking_id=tracking_id, hf_dataset_package=hf_dataset_package)

Train Unsupervised With Hf Dataset

Upload or specify an existing Hugging Face dataset and trigger the unsupervised training

Example

  • OAuth Authentication (OAuth2PasswordBearer):
  • Api Key Authentication (APIKeyCookie):
import cms_client
from cms_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = cms_client.Configuration(
    host = "http://localhost"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

configuration.access_token = os.environ["ACCESS_TOKEN"]

# Configure API key authorization: APIKeyCookie
configuration.api_key['APIKeyCookie'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['APIKeyCookie'] = 'Bearer'

# Enter a context with an instance of the API client
with cms_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cms_client.TrainingApi(api_client)
    hf_dataset_repo_id = 'hf_dataset_repo_id_example' # str | The repository ID of the dataset to download from Hugging Face Hub, will be ignored when 'hf_dataset_package' is provided (optional)
    hf_dataset_config = 'hf_dataset_config_example' # str | The name of the dataset configuration, will be ignored when 'hf_dataset_package' is provided (optional)
    trust_remote_code = False # bool | Whether to trust the remote code of the dataset (optional) (default to False)
    text_column_name = 'text' # str | The name of the text column in the dataset (optional) (default to 'text')
    epochs = 1 # int | The number of training epochs (optional) (default to 1)
    lr_override = 3.4 # float | The override of the initial learning rate (optional)
    test_size = 3.4 # float | The override of the test size in percentage will only take effect if the dataset does not have predefined validation or test splits (optional)
    log_frequency = 1000 # int | The number of processed documents or epochs after which training metrics will be logged (optional) (default to 1000)
    description = 'description_example' # str | The description of the training or change logs (optional)
    tracking_id = 'tracking_id_example' # str | The tracking ID of the requested task (optional)
    hf_dataset_package = None # bytearray |  (optional)

    try:
        # Train Unsupervised With Hf Dataset
        api_response = api_instance.train_unsupervised_with_hf_dataset(hf_dataset_repo_id=hf_dataset_repo_id, hf_dataset_config=hf_dataset_config, trust_remote_code=trust_remote_code, text_column_name=text_column_name, epochs=epochs, lr_override=lr_override, test_size=test_size, log_frequency=log_frequency, description=description, tracking_id=tracking_id, hf_dataset_package=hf_dataset_package)
        print("The response of TrainingApi->train_unsupervised_with_hf_dataset:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling TrainingApi->train_unsupervised_with_hf_dataset: %s\n" % e)

Parameters

Name Type Description Notes
hf_dataset_repo_id str The repository ID of the dataset to download from Hugging Face Hub, will be ignored when 'hf_dataset_package' is provided [optional]
hf_dataset_config str The name of the dataset configuration, will be ignored when 'hf_dataset_package' is provided [optional]
trust_remote_code bool Whether to trust the remote code of the dataset [optional] [default to False]
text_column_name str The name of the text column in the dataset [optional] [default to 'text']
epochs int The number of training epochs [optional] [default to 1]
lr_override float The override of the initial learning rate [optional]
test_size float The override of the test size in percentage will only take effect if the dataset does not have predefined validation or test splits [optional]
log_frequency int The number of processed documents or epochs after which training metrics will be logged [optional] [default to 1000]
description str The description of the training or change logs [optional]
tracking_id str The tracking ID of the requested task [optional]
hf_dataset_package bytearray [optional]

Return type

object

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

HTTP response details

Status code Description Response headers
202 Successful Response -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]