0 / 0
Tuning a foundation model
Last updated: Feb 03, 2025
Tuning a foundation model

You can programmatically tune a set of foundation models in watsonx.ai to customize then for your use case.

Ways to develop

You can tune foundation models by using these programming methods:

Alternatively, you can use graphical tools from the watsonx.ai UI to tune foundation models. See Tuning Studio.

REST API

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:

  1. Create a training data file to use for tuning the foundation model.

    For more information about the training data file requirements, see Data formats for tuning foundation models.

  2. Upload your training data file.

    You can choose to add the file by creating one of the following asset types:

    • Connection asset

      Note: Only a Cloud Object Storage connection type is supported for prompt tuning training currently.

      See Referencing files from the API.

      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 to the request.json file that you create in the next step.

    For more information about the supported ways to reference a training data file, see Data references.

  3. Use the watsonx.ai API to create a training experiment.

    See create a training.

    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.

  4. 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.

  5. Use the watsonx.ai API to create a deployment for the tuned model.

    See create a deployment

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.

Parent topic: Coding generative AI solutions