# Quick start: Tune a foundation model #

There are a couple of reasons to tune your foundation model\. By tuning a model on many labeled examples, you can enhance the model performance compared to prompt engineering alone\. By tuning a base model to perform similarly to a bigger model in the same model family, you can reduce costs by deploying that smaller model\.

**Required services** : Watson Studio : Watson Machine Learning

Your basic workflow includes these tasks:

<!-- <ol> -->

1.  Open a project\. Projects are where you can collaborate with others to work with data\.
2.  Add your data to the project\. You can upload data files, or add data from a remote data source through a connection\.
3.  Create a Tuning experiment in the project\. The tuning experiment uses the Tuning Studio experiment builder\.
4.  Review the results of the experiment and the tuned model\. The results include a Loss Function chart and the details of the tuned model\.
5.  Deploy and test your tuned model\. Test your model in the Prompt Lab\.

<!-- </ol> -->

## Read about tuning a foundation model ##

Prompt tuning adjusts the content of the prompt that is passed to the model\. The underlying foundation model and its parameters are not edited\. Only the prompt input is altered\. You tune a model with the Tuning Studio to guide an AI foundation model to return the output you want\.

[Read more about Tuning Studio](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-tuning-studio.html)

## Watch a video about tuning a foundation model ##

![Watch Video](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/lc-video.png) Watch this video to preview the steps in this tutorial\. There might be slight differences in the user interface that is shown in the video\. The video is intended to be a companion to the written tutorial\.

This video provides a visual method to learn the concepts and tasks in this documentation\.

## Try a tutorial to tune a foundation model ##

In this tutorial, you will complete these tasks:

<!-- <ul> -->

 *  [Task 1: Open a project](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-tuning-studio.html?context=cdpaas&locale=en#step01)
 *  [Task 2: Test your base model](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-tuning-studio.html?context=cdpaas&locale=en#step02)
 *  [Task 3: Add your data to the project](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-tuning-studio.html?context=cdpaas&locale=en#step03)
 *  [Task 4: Create a Tuning experiment in the project](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-tuning-studio.html?context=cdpaas&locale=en#step04)
 *  [Task 5: Configure the Tuning experiment](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-tuning-studio.html?context=cdpaas&locale=en#step05)
 *  [Task 6: Deploy your tuned model to a deployment space](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-tuning-studio.html?context=cdpaas&locale=en#step06)
 *  [Task 7: Test your tuned model](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-tuning-studio.html?context=cdpaas&locale=en#step07)

<!-- </ul> -->

Expand all sections

<!-- <ul> -->

 *  Tips for completing this tutorial
    
    \#\#\# Use the video picture-in-picture Tip: Start the video, then as you scroll through the tutorial, the video moves to picture-in-picture mode. Close the video table of contents for the best experience with picture-in-picture. You can use picture-in-picture mode so you can follow the video as you complete the tasks in this tutorial. Click the timestamps for each task to follow along.The following animated image shows how to use the video picture-in-picture and table of contents features: ![How to use picture-in-picture and chapters](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/pip-and-chapters.gif)\{: width="560px" height="315px" data-tearsheet="this"\} \#\#\# Get help in the community If you need help with this tutorial, you can ask a question or find an answer in the [Cloud Pak for Data Community discussion forum](https://community.ibm.com/community/user/cloudpakfordata/communities/community-home/digestviewer?communitykey=c0c16ff2-10ef-4b50-ae4c-57d769937235)\{: new\_window\}. \#\#\# Set up your browser windows For the optimal experience completing this tutorial, open Cloud Pak for Data in one browser window, and keep this tutorial page open in another browser window to switch easily between the two applications. Consider arranging the two browser windows side-by-side to make it easier to follow along. ![Side-by-side tutorial and UI](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/tutorial-side-by-side.png)\{: width="560px" height="315px" data-tearsheet="this"\} Tip: If you encounter a guided tour while completing this tutorial in the user interface, click **Maybe later**.  
    [Back to the top](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-tuning-studio.html?context=cdpaas&locale=en#video-preview)  
    
<!-- </ul> -->

<!-- <ul> -->

 *  Task 1: Open a project
    
    ![preview tutorial video](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/lc-video.png) To preview this task, watch the video beginning at 00:04. You need a project to store the tuning experiment. Watch a video to see how to create a sandbox project and associate a service. Then follow the steps to verify that you have an existing project or create a sandbox project.
    
    This video provides a visual method to learn the concepts and tasks in this documentation.
    
    \#\#\# Verify a existing project or create a new project 1. From the watsonx home screen, scroll to the *Projects* section. If you see any projects that are listed, then skip to [Associate the Watson Machine Learning service](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-tuning-studio.html?context=cdpaas&locale=en#associate). If you don't see any projects, then follow these steps to create a project. 1. Click **Create a sandbox project**. When the project is created, you see the sandbox in the *Projects* section. 1. Open an existing project or the new sandbox project. \#\#\# Associate the Watson Machine Learning service with the project You use Watson Machine Learning to tune the foundation model, so follow these steps to associate your Watson Machine Learning service instance with your project. 1. In the project, click the **Manage** tab. 1. Click the **Services & Integrations** page. 1. Check whether this project has an associated Watson Machine Learning service. If there is no associated service, then follow these steps: 1. Click **Associate service**. 1. Check the box next to your **Watson Machine Learning** service instance. 1. Click **Associate**. 1. If necessary, click **Cancel** to return to the *Services & Integrations* page. For more information or to watch a video, see [Creating a project](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/projects.html)\{: new\_window\} and [Adding associated services to a project](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/assoc-services.html). \#\#\# ![Checkpoint icon](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/checkmark--filled-blue.svg)\{: iih\} Check your progress The following image shows the *Manage* tab with the associated service. You are now ready to add the sample notebook to your project.  
      
    ![Manage tab in the project](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/wx-fm-associated-service.png)\{: width="100%" \}  
    [Back to the top](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-tuning-studio.html?context=cdpaas&locale=en#video-preview)  
    
<!-- </ul> -->

<!-- <ul> -->

 *  Task 2: Test your base model
    
    ![preview tutorial video](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/lc-video.png) To preview this task, watch the video beginning at 00:19. You can test your tuned model in the Prompt Lab. Follow these steps to test your tuned model: 1. Return to the watsonx home screen. 1. Verify that your sandbox project is selected. ![Select the sandbox project](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/wx-select-sandbox.png)\{: biw\} 1. Click the **Experiment with foundation models and build prompts** tile. 1. Select your tuned model. 1. Click the model drop-down list, and select **View all foundation models**. 1. Select the **flan-t5-xl-3b** model. 1. Click **Select model**. 1. On the *Structured mode* page, type the *Instruction*: `txt Summarize customer complaints` 1. Provide the examples and test input. \| Example input \| Example output \| \| ----- \| ----- \| \| I forgot in my initial date I was using Capital One and this debt was in their hands and never was done. \| Debt collection, sub-product: credit card debt, issue: took or threatened to take negative or legal action sub-issue \| \| I am a victim of identity theft and this debt does not belong to me. Please see the identity theft report and legal affidavit. \| Debt collection, dub-product, I do not know, issue. attempts to collect debt not owed. sub-issue debt was a result of identity theft \|  
    1. In the *Try* text field, copy and paste the following prompt: `txt After I reviewed my credit report, I am still seeing information that is reporting on my credit file that is not mine. please help me in getting these items removed from my credit file.` 1. Click **Generate**, and review the results. 1. Click **Save work > Save as**. 1. Select **Prompt template**. 1. For the name, type `Base model prompt`\{: .cp\}. 1. Click **Save**. \#\#\# ![Checkpoint icon](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/checkmark--filled-blue.svg)\{: iih\} Check your progress The following image shows results in the Prompt Lab.  
      
    ![The following image shows results in the Prompt Lab.](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/wx-ts-base-prompt-lab.png)\{: width="100%" \}  
    [Back to the top](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-tuning-studio.html?context=cdpaas&locale=en#video-preview)  
    
<!-- </ul> -->

<!-- <ul> -->

 *  Task 3: Add your data to the project
    
    ![preview tutorial video](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/lc-video.png) To preview this task, watch the video beginning at 01:12. You need to add the training data to your project. On the Samples page, you can find the customer complaints data set. This data set includes fictitious data of typical customer complaints regarding credit reports. Follow these steps to add the data set from the Samples to the project: 1. Access the [Customer complaints data set](https://dataplatform.cloud.ibm.com/exchange/public/entry/view/725afa8c-0f58-47ac-b88c-26961c4f20a0)\{: new\_window\} on the Samples page. 1. Click **Add to project**. 1. Select your sandbox project. 1. Click **Add**. \#\#\# ![Checkpoint icon](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/checkmark--filled-blue.svg)\{: iih\} Check your progress The following image shows the Samples asset added to the project. The next step is to create the Tuning experiment.  
      
    ![The following image shows the Samples asset added to the project. The next step is to create the Tuning experiment.](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/wx-ts-sample-data.png)\{: width="100%" \}  
    [Back to the top](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-tuning-studio.html?context=cdpaas&locale=en#video-preview)  
    
<!-- </ul> -->

<!-- <ul> -->

 *  Task 4: Create a Tuning experiment in the project
    
    ![preview tutorial video](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/lc-video.png) To preview this task, watch the video beginning at 01:32. Now you are ready to create a tuning experiment in your sandbox project that uses the data set you just added to the project. Follow these steps to create a Tuning experiment: 1. Return to the watsonx home screen. 1. Verify that your sandbox project is selected. ![Select the sandbox project](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/wx-select-sandbox.png)\{: biw\} 1. Click **Tune a foundation model with labeled data**. 1. For the name, type: `txt Summarize customer complaints tuned model` 1. For the description, type: `txt Tuning Studio experiment to tune a foundation model to handle customer complaints.` 1. Click **Create**. The Tuning Studio displays. \#\#\# ![Checkpoint icon](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/checkmark--filled-blue.svg)\{: iih\} Check your progress The following image shows the Tuning experiment open in Tuning Studio. Now you are ready to configure the tuning experiment.  
      
    ![The following image shows the Tuning experiment open in Tuning Studio. Now you are ready to configure the tuning experiment.](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/wx-ts-new-exp.png)\{: width="100%" \}  
    [Back to the top](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-tuning-studio.html?context=cdpaas&locale=en#video-preview)  
    
<!-- </ul> -->

<!-- <ul> -->

 *  Task 5: Configure the Tuning experiment
    
    ![preview tutorial video](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/lc-video.png) To preview this task, watch the video beginning at 01:47. In the Tuning Studio, you can configure the tuning experiment. The foundation model to tune is completed for you. Follow these steps to configure the tuning experiment: 1. For the foundation model to tune, select **flan-t5-xl-3b**. 1. Select **Text** for the method to initialize the prompt. There are two options: - Text: Uses text that you specify. - Random: Uses values that are generated for you as part of the tuning experiment. 1. For the *Text* field, type: `txt Summarize the complaint provided into one sentence.` The following table shows example text for each task type: \| Task type \| Example \| \| ----- \| ----- \| \| Classification \| Classify whether the sentiment of each comment is Positive or Negative \| \| Generation \| Make the case for allowing employees to work from home a few days a week \| \| Summarization \| Summarize the main points from a meeting transcript \|  
    1. Select **Summarization** for the task type that most closely matches what you want the model to do. There are three task types: - *Summarization* generates text that describes the main ideas that are expressed in a body of text. - *Generation* generates text such as a promotional email. - *Classification* predicts categorical labels from features. For example, given a set of customer comments, you might want to label each statement as a question or a problem. When you use the classification task, you need to list the class labels that you want the model to use. Specify the same labels that are used in your tuning training data. 1. Select your training data from the project. 1. Click **Select from project**. 1. Click **Data asset**. 1. Select the **customer complaints training data.json** file. 1. Click **Select asset**. 1. Click **Start tuning**. \#\#\# ![Checkpoint icon](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/checkmark--filled-blue.svg)\{: iih\} Check your progress The following image shows the configured tuning experiment. Next, you review the results and deploy the tuned model.  
      
    ![The following image shows the configured tuning experiment.](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/wx-ts-configured-exp.png)\{: width="100%" \}  
    [Back to the top](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-tuning-studio.html?context=cdpaas&locale=en#video-preview)  
    
<!-- </ul> -->

<!-- <ul> -->

 *  Task 6: Deploy your tuned model to a deployment space
    
    ![preview tutorial video](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/lc-video.png) To preview this task, watch the video beginning at 03:17. When the experiment run is complete, you see the tuned model and the Loss function chart. Loss function measures the difference between predicted and actual results with each training run. Follow these steps to view the loss function chart and the tuned model: 1. Review the Loss function chart. A downward sloping curve means that the model is getting better at generating the expected output. ![Completed tuning experiment](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/wx-ts-exp-complete.png)\{: biw\} 1. Below the chart, click the **Summarize customer complaints** tuned model. 1. Scroll through the model details. 1. Click **Deploy**. 1. For the name, type: `txt Summarize customer complaints tuned model` 1. For the *Target deployment space*, select an existing deployment space. If you don't have an existing deployment space, follow these steps: 1. For the *Target deployment space*, select **Create a new deployment space**. 1. For the deployment space name, type: `txt Foundation models deployment space` 1. Select a storage service from the list. 1. Select your provisioned machine learning service from the list. 1. Click **Create**. 1. Click **Close**. 1. For the *Target deployment space*, verify that **Foundation models deployment space** is selected. 1. Check the **View deployment in deployment space after creating** option. 1. Click **Create**. 1. On the *Deployments* page, click the **Summarize customer complaints tuned mode** deployment to view the details. \#\#\# ![Checkpoint icon](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/checkmark--filled-blue.svg)\{: iih\} Check your progress The following image shows the deployment in the deployment space. You are now ready to test the deployed model.  
      
    ![The following image shows the deployment in the deployment space.](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/wx-ts-deployment.png)\{: width="100%" \}  
    [Back to the top](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-tuning-studio.html?context=cdpaas&locale=en#video-preview)  
    
<!-- </ul> -->

<!-- <ul> -->

 *  Task 7: Test your tuned model
    
    ![preview tutorial video](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/lc-video.png) To preview this task, watch the video beginning at 04:04. You can test your tuned model in the Prompt Lab. Follow these steps to test your tuned model: 1. From the model deployment page, click **Open in prompt lab**, and then select your sandbox project. The Prompt Lab displays. 1. Select your tuned model. 1. Click the model drop-down list, and select **View all foundation models**. 1. Select the **Summarize customer complaints tuned model** model. 1. Click **Select model**. 1. On the *Structured mode* page, type the *Instruction*: `Summarize customer complaints`\{: .cp\} 1. On the *Structured mode* page, provide the examples and test input. \| Example input \| Example output \| \| ----- \| ----- \| \| I forgot in my initial date I was using Capital One and this debt was in their hands and never was done. \| Debt collection, sub-product: credit card debt, issue: took or threatened to take negative or legal action sub-issue \| \| I am a victim of identity theft and this debt does not belong to me. Please see the identity theft report and legal affidavit. \| Debt collection, dub-product, I do not know, issue. attempts to collect debt not owed. sub-issue debt was a result of identity theft \|  
    1. In the *Try* text field, copy and paste the following prompt: `txt After I reviewed my credit report, I am still seeing information that is reporting on my credit file that is not mine. please help me in getting these items removed from my credit file.` 1. Click **Generate**, and review the results. \#\#\# ![Checkpoint icon](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/checkmark--filled-blue.svg)\{: iih\} Check your progress The following image shows results in the Prompt Lab.  
      
    ![The following image shows results in the Prompt Lab.](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/wx-ts-prompt-lab.png)\{: width="100%" \}  
    [Back to the top](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-tuning-studio.html?context=cdpaas&locale=en#video-preview)  
    
<!-- </ul> -->

## Next steps ##

Try these other tutorials:

<!-- <ul> -->

 *  [Prompt a foundation model in the Prompt Lab tutorial](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-prompt-lab.html)
 *  [Prompt a foundation model with retrieval\-augmented generation pattern](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/get-started-fm-notebook.html)

<!-- </ul> -->

## Additional resources ##

<!-- <ul> -->

 *  [Foundation models](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-models.html)
 *  [Prompt Lab](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-lab.html)
 *  [Python library](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-python-lib.html)
 *  [Security and privacy for foundation models](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-security.html)
 *  View more [videos](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/videos-wx.html)\.
 *  Find sample data sets, projects, models, prompts, and notebooks in the Samples to gain hands\-on experience:
    
    ![Notebook icon](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/notebook.svg)[Notebooks](https://dataplatform.cloud.ibm.com/gallery?context=wx&format=notebook) that you can add to your project to get started analyzing data and building models.
    
    ![Project icon](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/ibm-cloud--projects.svg)[Projects](https://dataplatform.cloud.ibm.com/gallery?context=wx&format=project-template) that you can import containing notebooks, data sets, prompts, and other assets.
    
    ![Data set icon](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/data--set.svg)[Data sets](https://dataplatform.cloud.ibm.com/gallery?context=wx&format=dataset) that you can add to your project to refine, analyze, and build models.
    
    ![Prompt icon](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/prompt.svg)[Prompts](https://dataplatform.cloud.ibm.com/gallery?context=wx&format=example-prompt) that you can use in the Prompt Lab to prompt a foundation model.
    
    ![Model icon](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/images/model.svg)[Foundation models](https://dataplatform.cloud.ibm.com/gallery?context=wx&format=foundation-model) that you can use in the Prompt Lab.

<!-- </ul> -->

**Parent topic:**[Quick start tutorials](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/quickstart-tutorials.html)

<!-- </article "role="article" "> -->