0 / 0
Quick start: Try the watsonx.ai end-to-end use case
Last updated: Jan 23, 2025
Quick start: Try the watsonx.ai end-to-end use case

This tutorial focuses on a sample use case in the finance industry. Golden Bank needs to implement a process to analyze marketing promotions to boost sales of their investment products.

Required services
watsonx.ai including watsonx.ai Runtime and watsonx.ai Studio

Scenario: Bank marketing promotions process

To accomplish this goal, the typical process might be as follows:

  1. The data engineer visualizes and prepares the bank marketing data to verify the correct format to train the model.
  2. The ML engineer build a machine learning model to predict the effectiveness of their promotions.
  3. The ML engineer deploys and tests the model.
  4. The data scientist writes Python code to find similar promotions for the bank's competitors.
  5. The prompt engineer:
    • Constructs prompt templates to perform summarization and question-answering tasks.
    • Compares the performance of multiple prompts to determine whether retraining is necessary.
    • Tunes the foundation model with retraining data to provide the best performance and cost effectiveness.
    • Creates a pipeline to simplify the retraining process.

Basic task workflow using watsonx.ai

Watsonx.ai can help accomplish each phase of this process. Your basic workflow includes these tasks:

  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 add CSV files or data from a remote data source through a connection.
  3. Prepare the training data in Data Refinery.
  4. Train a model with the training data. You can use various tools, such as AutoAI, SPSS Modeler, or Jupyter notebooks to train the model.
  5. Deploy and test your model in a project or deployment space.
  6. Gather and analyze data that is related to the model in a Jupyter notebook.
  7. Prompt a foundation model in Prompt Lab.
  8. Compare prompt performance in Evaluation Studio.
  9. Tune the foundation model in Tuning Studio.
  10. Automate the lifecycle for a model with Pipelines.

Read about watsonx.ai

To transform your business processes with AI-driven solutions, your enterprise needs to integrate both machine learning and generative AI into your operational framework. Watsonx.ai provides the processes and technologies to enable your enterprise to develop and deploy machine learning models and generative AI solutions.

Learn more about watsonx.ai

Read more about watsonx.ai use cases

Watch a video about watsonx.ai

Watch Video 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 watsonx.ai

In this tutorial, you will complete these tasks:





Tips for completing this tutorial
Here are some tips for successfully 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

Get help in the community

If you need help with this tutorial, you can ask a question or find an answer in the watsonx Community discussion forum.

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

Tip: If you encounter a guided tour while completing this tutorial in the user interface, click Maybe later.



Task 1: Create the sample project

preview tutorial video To preview this task, watch the video beginning at 00:51.

This tutorial uses a sample project that contains the data set, notebook, and prompt templates to perform the analysis. Follow these steps to create a project based on a sample:

  1. From the home screen, click the Create a new project icon Create a new project.

  2. Select Sample.

  3. Search for Getting started with watsonx.ai, select that sample project, and click Next.

  4. Choose an existing object storage service instance or create a new one.

  5. Click Create.

  6. Wait for the project import to complete, and then click View new project.

  7. Associate a watsonx.ai Runtime service with the project. For more information, see watsonx.ai Runtime.

    1. When the project opens, click the Manage tab, and select the Services and integrations page.

    2. On the IBM services tab, click Associate service.

    3. Select your watsonx.ai Runtime instance. If you don't have a watsonx.ai Runtime service instance that is provisioned yet, follow these steps:

      1. Click New service.

      2. Select watsonx.ai Runtime.

      3. Click Create.

      4. Select the new service instance from the list.

    4. Click Associate service.

    5. If necessary, click Cancel to return to the Services & Integrations page.

  8. Click the Assets tab in the project to see the sample assets.

For more information or to watch a video, see Creating a project.

For more information on associated services, see Adding associated services.

Checkpoint icon Check your progress

The following image shows the project Assets tab. You are now ready to visualize the training data.

alt text




Task 2: Visualize and prepare the data

The data represents direct marketing campaigns (phone calls) of a Portuguese banking institution. The classification goal is to predict if the client will subscribe (yes/no) to a term deposit (column current_outcome). This dataset is based on a data set sourced from the UCI Machine Learning Repository.

Task 2a: Visualize the data

preview tutorial video To preview this task, watch the video beginning at 01:24.

First, you visualize the data to see if there are any obvious anomalies. Follow these steps to visualize the data:

  1. Open the bank-marketing-data.csv data set. The columns contain information about potential customers.
  2. Click the View asset info icon View asset info to close the About this asset pane.
  3. Click the Visualization tab.
    1. Select the current_outcome column as the Columns to visualize. This column indicates if the person contacted accepted the current offer; this column is the target column when you build the model.
    2. Click Add another column, and then select the previous_outcome column. This column indicates if the person contacted accepted the previous offer. Notice that the chart types with a blue dot are the suggested charts.
    3. Select the Tree chart type. This chart shows a comparison of people who accepted a previous offer and whether those same people accepted the current offer.
    4. Hover over the root node to see the total number of records in the data set.
    5. Similarly, hover over the no and yes nodes to see those totals.
    6. Hover over the unlabeled node to see the total number of records in the data set where the current_outcome field is null.

Checkpoint icon Check your progress

The following image shows a visualization of the bank-marketing-data.csv file. Now you are ready to prepare thetraining data.

Visualization of the training data

Task 2b: Prepare the data

preview tutorial video To preview this task, watch the video beginning at 02:40.

Since current_outcome is the target column, you need to prepare the data set to remove the rows with null values. Follow these steps to prepare the data set:

  1. Click Prepare data to open Data Refinery.
  2. Close the About this asset pane.
  3. Select the current_outcome column.
  4. Click New step > Remove empty rows.
  5. Click Apply.
  6. Click the Profile tab to verify the action.
  7. Scroll to the current_outcome column to see that all of the values are either "yes" or "no".

Checkpoint icon Check your progress

The following image shows the current_outcome column on the Profile tab. Now you are ready to build the model using this training data.

The current_outcome column on the Profile tab

Task 2c: Save the refined data

preview tutorial video To preview this task, watch the video beginning at 03:08.

To save the refined data, you specify the file name for the target data set, and then create and run a job. Follow these steps to save the refined data:

  1. Specify the file name:

    1. Click the Settings icon Settings.
    2. Click the Target data set page.
    3. Click Edit properties.
    4. Change the Data asset name* to bank-marketing-data-prepared.csv.
    5. Click Save.
    6. Click Apply.
  2. Create and run the job:

    1. From the toolbar, click the Jobs icon, and select Save and create a job.
      Save and create a job

    2. Type the following name, Bank marketing data, and click Next.

    3. On the Configure page, select a runtime environment, and click Next.

    4. On the Schedule page, accept the default values, and click Next.

    5. On the Notify page, keep notifications turned off for this job, and click Next.

    6. Review the details, and click Create and run to run the job immediately.

  3. When the job is created, click the job details link in the notification to view the job in your project. Alternatively, you can navigate to the Jobs tab in the project, and click the job name to open it.

  4. When the Status for the job is Completed, use the project navigation trail to navigate back to the Assets tab in the project.

  5. Click the Data > Data assets section to see the output of the Data Refinery flow, and open the bank-marketing-data-prepared.csv to verify the values.

Checkpoint icon Check your progress

The following image shows the bank-marketing-data-prepared.csv file. Now you are ready to build the model using this training data.

Preview of the bank-marketing-data-prepared.csv file




Task 3: Train the model

preview tutorial video To preview this task, watch the video beginning at 03:58.

You can use various tools, such as AutoAI, SPSS Modeler, or Jupyter notebooks to train the model. In this tutorial, you will train a predictive binary classification model model with AutoAI. Follow these steps to create the AutoAI experiment:

  1. Return to the project's Assets tab, and then click New asset > Build machine learning models or Retrieval-augmented generation patterns automatically.

  2. On the Build machine learning models or Retrieval-augmented generation patterns automatically page, type the name: Bank marketing experiment

  3. Click Create.

  4. Select Build machine learning models as the task for this experiment.

  5. On the Add data source page, add the training data:

    1. Click Select from project.

    2. Select Data asset > bank-marketing-data-prepared.csv, and click Select asset.

  6. For Create a time series analysis?, select No.

  7. Select current-outcome for the Prediction column.

  8. Click Run experiment. As the model trains, you see an infographic that shows the process of building the pipelines.
    Build model pipelines

    For a list of algorithms, or estimators, available with each machine learning technique in AutoAI, see: AutoAI implementation details.

  9. After the experiment run is complete, view the ranked pipelines in a leaderboard.

    Pipeline leaderboard

  10. Click Pipeline comparison to see how they differ.

    Pipeline comparison metric chart

  11. In the Pipeline leaderboard, click the highest ranked pipeline to see the pipeline details.

  12. Review the Model evaluation page to see the model performance in the ROC curve chart and Model evaluation measure table.

  13. Save the model.

    1. Click Save as.

    2. Select Model.

    3. For the model name, type: Bank marketing prediction model

    4. Click Create. This saves the pipeline as a model in your project.

  14. When the model is saved, click the View in project link in the notification to view the model in your project. Alternatively, you can navigate to the Assets tab in the project, and click the model name in the Models section.

Checkpoint icon Check your progress

The following image shows the model.

The following image shows the model.




Task 4: Deploy the model

The next task is to promote the model to a deployment space, and then create an online deployment.

Task 4a: Promote the test data to a deployment space

preview tutorial video To preview this task, watch the video beginning at 05:34.

The sample project includes test data. You promote that test data to a deployment space, so you can use the test data to test the deployed model. Follow these steps to promote the test data to a deployment space:

  1. Return to the project's Assets tab.

  2. Click the Overflow menu Overflow menu for the bank-marketing-test-data.csv data asset, and choose Promote to space.

  3. Choose an existing deployment space. If you don't have a deployment space:

    1. Click Create a new deployment space.

    2. For the name, type: Bank marketing promotion space

    3. Select a storage service.

    4. Select a machine learning service.

    5. Click Create.

    6. Close the notification when the space is ready.

  4. Select your new deployment space from the list.

  5. Click Promote.

  6. Click Close to return to the project's Assets tab.

Checkpoint icon Check your progress

The following image shows the Promote to space page.

The following image shows the Promote to space page.

Task 4b: Promote the model to a deployment space

preview tutorial video To preview this task, watch the video beginning at 06:11.

Before you can deploy the model, you need to promote the model to a deployment space. Follow these steps to promote the model to a deployment space:

  1. Click the Overflow menu Overflow menu for the Bank marketing prediction model data asset, and choose Promote to space.

  2. Select the same deployment space from the list.

  3. Click Promote.

  4. Select the Go to the model in the space after promoting it option.

  5. Click Promote.

Note: If you didn't select the option to go to the model in the space after promoting it, you can use the navigation menu to navigate to Deployments to select your deployment space and model.

Checkpoint icon Check your progress

The following image shows the model in the deployment space.

The following image shows the model in the deployment space.

Task 4c: Create and test a model deployment

preview tutorial video To preview this task, watch the video beginning at 06:21.

Now that the model is in the deployment space, follow these steps to create the model deployment:

  1. With the model open, click New deployment.

    1. Select Online as the Deployment type.

    2. For the deployment name, type: Bank marketing model deployment

    3. Click Create.

  2. When the deployment is complete, click the deployment name to view the deployment details page.

  3. On the API reference tab, review the scoring endpoint, which you can use to access this model programmatically in your applications.

  4. Test the model.

    1. Click the Test tab. You can test the deployed model from the deployment details page in two ways: test with a form or test with JSON code. In this case, you select the CSV file that you promoted from the sample project to the deployment space.

    2. To locate the test data, click Search in space.

    3. Select Data asset > bank-marketing-test-data.csv.

    4. Click Confirm.

    5. Click Predict, and review the predictions for the 60 records in the test data. The model returns yes for every customer for which the model predicts the bank customer will subscribe to a term deposit.

Checkpoint icon Check your progress

The following image shows the test results from the deployed model.

The following image shows the test results from the deployed model.




Task 5: Gather competitors marketing programs

preview tutorial video To preview this task, watch the video beginning at 07:01.

Although the Prompt Lab can work with structured and unstructured text, it is essential to ensure that you input the right data that the model can process. You can do this in a Jupyter notebook with Python code.

Since the foundation models have a limit on the number of tokens they can process in a single prompt (known as the context window), you may need to chunk or summarize the data to fit within this limit. This step ensures that the input data is in a format that the foundation model can effectively process without losing essential information.

Follow these steps to run the notebook:

  1. From the Navigation Menu Navigation menu, choose Projects > View all projects.
  2. Open the Getting started with watsonx.ai project.
  3. Click the Assets tab.
  4. Click the Overflow menu Overflow menu for the Extract and chunk text from competitors programs notebook, and choose Edit.
  5. Complete the Setup section.
    1. Click the Run icon Run for the first cell to import the libraries.
    2. Obtain the necessary API keys:
      1. Follow the link to create an account and API key at TheNewsAPI.
      2. Paste the API key in the thenewsapi_key variable.
      3. Follow the link to create an account and API key at ArticlExtractor.
      4. Paste the API key in the extract_key variable.
    3. Run the cell to set the two API key variables.
  6. Run the cells in the Define the function to get news article URLs section.
    • The first cell in this section defines a function to get data from TheNewsAPI's Top Stories and set up parameters to make sure that you can get relevant news.
    • The second cell in this section defines a function to get a list of URLs based on the response.
  7. Run the cells in the Define the function to extract news text section.
    • The first cell defines a function to extract news text from a specific news URL using ArticlExtractor API.
    • The second cell defines a function to combine news text from all of the article URLs obtained from TheNewsAPI.
  8. Run the cell in the Define the function to chunk news text section.
    • The first cell in this section defines a function to use LangChain to split the character text by taking into account the context of the news text. To make sure the foundation model can take on the information from the text, you need to make sure the token doesn't exceed the context token window limitations.
    • The second cell in this section shows the response. You can see that the final output of data is ready to be fed into the Prompt Lab. LangChain’s text splitter splits the long text up into semantically meaningful chunks, or sentences, and combines them again as a whole text to be processed. You can adjust the maximum size of the chunks.

Checkpoint icon Check your progress

The following image shows the completed notebook. You now have the chunked text to use to prompt the foundation model.

The completed notebook




Task 6: Prompt the foundation model

Now that you have the relevant news article appropriately chunked, you can construct your own prompt templates in the Prompt Lab, or you can use the sample prompt templates in the sample project. The sample project includes sample prompt templates for summarization and question answering tasks. Follow these steps to prompt the foundation model in the Prompt Lab:

Task 6a: Summarization task

preview tutorial video To preview this task, watch the video beginning at 09:32.

First, try the summarization prompt template.

  1. Return to the project's Assets tab.

  2. Click the Summarize Bank Promotions prompt template. This opens the prompt template in the Prompt Lab.

  3. Click Edit to open the prompt template in edit mode.

    For the summarization task, you use the chunked news article text as the input example, and notes that the marketing professional usually manually writes to explain promotional offers as the output example. This is to make sure that the output is similar to what the marketing team might write themselves.

  4. Notice the foundation model used for this prompt is XX.

  5. Click Generate to see the summary results.

  6. Experiment with different input and output text from the chunked news article in the notebook.

Task 6b: Question answering task

preview tutorial video To preview this task, watch the video beginning at 10:15.

Next, try the question answering prompt template.

  1. Click the Saved prompts Saved prompts to see saved prompt from your project.

  2. Click the Question Answer Bank Promotions prompt template from the list of saved prompts.

  3. Click Edit to open the prompt template in edit mode.

    For the question-answering task, you use questions as the input example, and answers in the level of detail required and preferred format as the output example.

  4. Notice the foundation model used for this prompt is flan-t5-xxl-11b.

  5. Click Generate to see the summary results.

  6. Experiment with different input and output text.

Task 6c: Adjust the model parameters

preview tutorial video To preview this task, watch the video beginning at 10:37.

In the Prompt Lab, you can adjust the decoding settings to optimize the model's output for the specific task:

  • Decoding
    • Greedy: always select words with the highest probability
    • Sampling: customize the variability of word selection
  • Repetition Penalty: how much repetition is allowed
  • Stopping Criteria: one or more strings that will cause the text generation to stop if produced

This flexibility allows for a high degree of customization, making sure that the model operates with parameters best suited to the task's requirements and constraints.

In the Prompt Lab, you can set token limitations to make sure that the tasks remain within the operational scope of the model. This setting helps balance the response's comprehensiveness with the technical limitations of the model, resulting in an efficient and effective processing of tasks.

Task 6d: Chat with documents

preview tutorial video To preview this task, watch the video beginning at 10:45.

You can also use Chat mode to prompt a foundation model using a sample PDF document that provides facts. Adding one or more documents creates an in-memory vector index that the foundation model will use to answer the question.

  1. Click New prompt.
  2. Click Chat.
  3. Optional: Select a model, for example, llama-3-1-8b-instruct.
  4. Click Upload documents icon Upload documents, and choose Add documents.
  5. Click Select from project.
    1. Select Bank CD Rates.pdf.
    2. Click Select.
  6. Back on the Ground gen AI with vectorized documents page, verify the name, and click Create.
  7. In the Type something field, type Which bank has the best APY for a term deposit and what is the rate?, and click the Send icon Send to see the answer.

Checkpoint icon Check your progress

The following image shows the Prompt Lab.

The Prompt Lab



Next steps

Experiment with prompt notebooks

From the Prompt Lab, you can save your work in notebook format:

  1. Load a saved prompt template.
  2. Click Save work > Save as.
  3. Select Standard notebook. Note that you can also save your work as a deployment notebook which you can deploy as an AI service.
  4. Type a name.
  5. Click Save, and then explore the prompt notebook.
  6. Repeat these steps for the other prompt template.

Tune a foundation model

You might want to tune the foundation model to enhance the model performance compared to prompt engineering alone or reduce costs by deploying a smaller model that performs similarly to a bigger model. See the Tune a foundation model tutorial.

Compare prompt performance

You might want to use Evaluation Studio to compare multiple prompts. With Evaluation Studio, you can evaluate and compare your generative AI assets with quantitative metrics and customizable criteria that fit your use cases. Evaluate the performance of multiple assets simultaneously and view comparative analyses of results to identify the best solutions. See the Compare prompt performance tutorial.

Automate the lifecycle for a model with Pipelines

You can create an end-to-end pipeline to deliver concise, pre-processed, and up-to-date data stored in an external data source. The Orchestration Pipelines editor provides a graphical interface for orchestrating an end-to-end flow of assets from creation through deployment. Assemble and configure a pipeline to create, train, deploy, and update machine learning models and Python scripts. See the Automate the lifecycle for a model with pipelines tutorial.

Additional resources

Parent topic: Quick start tutorials