InstructLab Experiment (BETA)¶
Using TuneExperiment, special InstructLab tuner can be created. The tuner is similar to fine tuner and prompt tuner in usage. InstructLab fine tuning is available only with IBM watsonx.ai for IBM Cloud.
Note
InstructLab fine tuning is in currently in closed beta stage. Feature available only for whitelisted users. Breaking changes in API may be introduced in the future.
ILabTuner¶
- class ibm_watsonx_ai.foundation_models.ILabTuner(name, api_client)[source]¶
Class of InstructLab fine tuner.
- get_data_connections()[source]¶
- Create DataConnection objects for further usage
(eg. to handle data storage connection).
- Returns:
list of DataConnections
- Return type:
list[‘DataConnection’]
Example:
from ibm_watsonx_ai.experiment import TuneExperiment experiment = TuneExperiment(credentials, ...) ilab_tuner = experiment.ilab_tuner(...) ilab_tuner.run(...) data_connections = ilab_tuner.get_data_connections()
- get_params()[source]¶
Get configuration parameters of ILabTuner.
- Returns:
ILabTuner parameters
- Return type:
dict
Example:
from ibm_watsonx_ai.experiment import TuneExperiment experiment = TuneExperiment(credentials, ...) ilab_tuner = experiment.ilab_tuner(...) ilab_tuner.get_params() # Result: # # {'name': 'ILab tuning'}
- get_run_details(include_metrics=False)[source]¶
Get details of an ilab tuning run.
- Parameters:
include_metrics (bool, optional) – indicates to include metrics in the training details output
- Returns:
details of the ilab tuning
- Return type:
dict
Example:
from ibm_watsonx_ai.experiment import TuneExperiment experiment = TuneExperiment(credentials, ...) ilab_tuner = experiment.ilab_tuner(...) ilab_tuner.run(...) ilab_tuner.get_run_details()
- get_run_status()[source]¶
Check the status/state of an initialized ilab tuning run if it was run in background mode.
- Returns:
status of the ILab Tuning run
- Return type:
str
Example:
from ibm_watsonx_ai.experiment import TuneExperiment experiment = TuneExperiment(credentials, ...) ilab_tuner = experiment.ilab_tuner(...) ilab_tuner.run(...) ilab_tuner.get_run_details() # Result: # 'completed'
- run(training_data_references, training_results_reference=None, background_mode=False)[source]¶
Run an ilab tuning process of a foundation model on top of the training data referenced by DataConnection.
- Parameters:
training_data_references (list[DataConnection]) – data storage connection details to inform where the training data is stored
training_results_reference (DataConnection, optional) – data storage connection details to store pipeline training results
background_mode (bool, optional) – indicator if the fit() method will run in the background, async or sync
- Returns:
run details
- Return type:
dict
Example:
from ibm_watsonx_ai.experiment import TuneExperiment from ibm_watsonx_ai.helpers import DataConnection, GithubLocation experiment = TuneExperiment(credentials, ...) ilab_tuner = experiment.ilab_tuner(...) taxonomy_import = ilab_tuner.taxonomies.run_import( name="my_taxonomy", data_reference=DataConnection( location=GithubLocation( secret_manager_url="...", secret_id="...", path="." ) ), results_reference=DataConnection( location=ContainerLocation(path=".")) ) taxonomy = taxonomy_import.get_taxonomy() sdg = ilab_tuner.synthetic_data.generate( name="my_sdg", taxonomy=taxonomy ) ilab_tuner.run( training_data_references=[sdg.get_results_reference()], training_results_reference=DataConnection( location=ContainerLocation( path="fine_tuning_result" ) ) )
Taxonomy import¶
This section contains classes used for taxonomy import step.
Taxonomy¶
- class ibm_watsonx_ai.foundation_models.ilab.taxonomies.Taxonomy(id, api_client)[source]¶
Class of InstructLab taxonomy.
- get_details()[source]¶
Get taxonomy import details
- Returns:
details of taxonomy import
- Return type:
dict
TaxonomyImport¶
- class ibm_watsonx_ai.foundation_models.ilab.taxonomies.TaxonomyImport(name, api_client)[source]¶
Class of InstructLab taxonomy import.
- get_run_details()[source]¶
Get details of taxonomy import run
- Returns:
details of taxonomy import
- Return type:
dict
TaxonomiesRuns¶
- class ibm_watsonx_ai.foundation_models.ilab.taxonomies.TaxonomiesRuns(api_client)[source]¶
Class of InstructLab taxonomy import runs.
Taxonomies¶
- class ibm_watsonx_ai.foundation_models.ilab.taxonomies.Taxonomies(ilab_tuner_name, api_client)[source]¶
Class of InstructLab taxonomy import module.
- run_import(*, data_reference, name=None, background_mode=False)[source]¶
Run a taxonomy import process using data_reference with taxonomy Github location to results_reference location.
- Parameters:
data_reference (DataConnection) – reference to github repo where taxonomy is stored
background_mode (bool, optional) – indicator if the method will run in the background, async or sync
- Returns:
taxonomy import object
- Return type:
Example:
from ibm_watsonx_ai.experiment import TuneExperiment from ibm_watsonx_ai.helpers import DataConnection, GithubLocation experiment = TuneExperiment(credentials, ...) ilab_tuner = experiment.ilab_tuner(...) taxonomy_import = ilab_tuner.taxonomies.run_import( name="my_taxonomy", data_reference=DataConnection( location=GithubLocation( secret_manager_url="...", secret_id="...", path="." ) ))
Document extraction¶
This section contains classes used for document extraction step.
DocumentExtraction¶
DocumentExtractionsRuns¶
- class ibm_watsonx_ai.foundation_models.ilab.documents.DocumentExtractionsRuns(api_client)[source]¶
Class of InstructLab document extraction runs.
DocumentExtractions¶
- class ibm_watsonx_ai.foundation_models.ilab.documents.DocumentExtractions(ilab_tuner_name, api_client)[source]¶
Class of InstructLab document extraction module.
- extract(*, name=None, document_references, results_reference, background_mode=False)[source]¶
Extract .md document from given .pdf document
- Parameters:
name (str) – document extraction run name
document_references (list[DataConnection]) – .pdf document location
results_reference (DataConnection) – .md file extraction location
background_mode (bool, optional) – indicator if the method will run in the background, async or sync
- Returns:
document extraction run
- Return type:
Synthetic data generation¶
This section contains classes used for synthetic data generation step.
SyntheticDataGeneration¶
- class ibm_watsonx_ai.foundation_models.ilab.synthetic_data.SyntheticDataGeneration(name, api_client)[source]¶
Class of InstructLab synthetic data generation run.
- get_results_reference()[source]¶
Get results reference to generated synthetic data.
- Returns:
data connection to generated synthetic data
- Return type:
SDGRuns¶
- class ibm_watsonx_ai.foundation_models.ilab.synthetic_data.SDGRuns(api_client)[source]¶
Class of InstructLab synthetic generation runs.
SyntheticData¶
- class ibm_watsonx_ai.foundation_models.ilab.synthetic_data.SyntheticData(ilab_tuner_name, api_client)[source]¶
Class of InstructLab synthetic data generation module.
- generate(*, name=None, taxonomy, background_mode=False)[source]¶
Generate synthetic data from updated taxonomy
- Parameters:
name (str) – name of synthetic data generation run
taxonomy (Taxonomy) – taxonomy object
background_mode (bool, optional) – indicator if the method will run in the background, async or sync
- Returns:
synthetic data generation run object
- Return type: