Alternatively, you can use graphical tools from the watsonx.ai UI to tune foundation models. See Tuning Studio.
REST API
Copy link to section
Prompt tuning a foundation model by using the API is a complex task. The sample Python notebooks simplify the process. You can use a sample notebook as a template for writing your own notebooks for prompt tuning. See Tuning a foundation model programmatically.
At a high level, prompt tuning a foundation model by using the API involves the following steps:
Create a training data file to use for tuning the foundation model.
You will use the connection ID and training data file details when you add the training_data_references section to the request.json file that you create in the next step.
Data asset
To create a data asset, use the Data and AI Common Core API to define a data asset.
You will use the asset ID and training data file details when you add the training_data_references section of the REST request that you create in the next step.
For more information about the supported ways to reference a training data file, see Data references.
Use the watsonx.ai API to create a training experiment.
You can specify parameters for the experiment in the TrainingResource payload. For more information about available parameters, see Parameters for tuning foundation models.
For the task_id, specify one of the tasks that are listed as being supported for the foundation model in the response to the List the available foundation models method.
Save the tuned model to the repository service to generate an asset_id that points to the tuned model.
To save the tuned model, use the watsonx.ai Runtime (formerly Watson Machine Learning) API to create a new model.
Use the watsonx.ai API to create a deployment for the tuned model.
To inference a tuned model, you must use the inference endpoint that includes the unique ID of the deployment that hosts the tuned model. For more information, see the inference methods in the Deployments section.
About cookies on this siteOur websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising.For more information, please review your cookie preferences options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.