aixplain.factories.finetune_factory
__author__
Copyright 2022 The aiXplain SDK authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Author: Duraikrishna Selvaraju, Thiago Castro Ferreira, Shreyas Sharma and Lucas Pavanelli Date: June 14th 2023 Description: Finetune Factory Class
FinetuneFactory Objects
class FinetuneFactory()
Factory class for creating and managing model fine-tuning operations.
This class provides static methods to create and manage fine-tuning jobs for machine learning models. It handles cost estimation, dataset preparation, and fine-tuning configuration.
Attributes:
backend_url
str - Base URL for the aiXplain backend API.
create
@classmethod
def create(cls,
name: Text,
dataset_list: List[Union[Dataset, Text]],
model: Union[Model, Text],
prompt_template: Optional[Text] = None,
hyperparameters: Optional[Hyperparameters] = None,
train_percentage: Optional[float] = 100,
dev_percentage: Optional[float] = 0) -> Finetune
Create a new fine-tuning job with the specified configuration.
This method sets up a fine-tuning job by validating the configuration, estimating costs, and preparing the datasets and model. It supports both direct Dataset/Model objects and their IDs as inputs.
Arguments:
name
Text - Name for the fine-tuning job.dataset_list
List[Union[Dataset, Text]] - List of Dataset objects or dataset IDs to use for fine-tuning.model
Union[Model, Text] - Model object or model ID to be fine-tuned.prompt_template
Text, optional - Template for formatting training examples. Use <<COLUMN_NAME>> to reference dataset columns. Defaults to None.hyperparameters
Hyperparameters, optional - Fine-tuning hyperparameters configuration. Defaults to None.train_percentage
float, optional - Percentage of data to use for training. Must be > 0. Defaults to 100.dev_percentage
float, optional - Percentage of data to use for validation. train_percentage + dev_percentage must be <= 100. Defaults to 0.
Returns:
Finetune
- Configured fine-tuning job object, or None if creation failed.
Raises:
AssertionError
- If train_percentage <= 0 or train_percentage + dev_percentage > 100.