Training and building the NLP model in an IVA for Web Chatbot

Develop a Pega Intelligent Virtual Assistant™ (IVA) for Web Chatbot by training the model. You create sample training data and map entities, add the training data to the model, and when ready, rebuild the model.

Use case

In this tutorial, learn how to add several instances of same user input to train the model so that IVA for Web Chatbot improves how it responds to the text you enter, using artificial intelligence. You can perform similar steps to add training data and build the model for IVA for Facebook, IVA for Alexa, and Pega Email Bot™.

The tutorial covers the following topics:

This walk-through takes approximately 20 minutes to complete.

Before you begin

In the Pega Platform™ application test environment for this tutorial, perform the following actions:

  1. Create the Insurance Quote case type that is related to a car insurance quote:
    Thumbnail
    Case Types Explorer
    1. Add data types for a car insurance quote such as color, make, model, registration date, VIN (vehicle identification number), and model year.
      Data types for an Insurance Quote case type
    2. Enable Web Chatbot channel specific conversations for a stage of the Insurance Quote case type.
      Thumbnail
      Stage configuration for the Insurance Quote case type
    3. Configure conversation questions for a stage process of the Insurance Quote case type by adding three sample questions for data types about the make, model, and VIN number of a car.
      Sample questions for the Insurance Quote case type
  2. Configure a Web Chatbot channel that has the following settings:
    1. In the behavior configuration section of the channel, enable the advanced text analyzer configuration.
      Sample create case command for a case type
    2. Configure the chatbot to use the text analyzer that is generated by Pega NLP, to interpret text in the context of a case and outside of a case context.
      Enabled text analyzer types
    3. Map entities to the Insurance Quote case data properties: .carMake, .carModel, and .carVIN.
      Thumbnail
      Entity mapping for the Insurance Quote case type
  3. In the preview console, verify that IVA for Web Chatbot does not understand text that you enter to request a car insurance quote.
    Thumbnail
    Chat conversation in the preview console

Creating training data records

Create training data records that contain sample user input for inquiries about a car insurance quote so that you can later add this sample data to the model for IVA for Web Chatbot. After you add sufficient instances of the same training data and build the model, IVA for Web Chatbot will improve its responses to user input about a car insurance quote. In addition, create five more instances of the same training data records where you ask about an insurance quote for a Ford Mustang GT car. This car make and model will be later mapped to entities so that the system learns how to extract car make and model information and add it automatically to the Insurance Quote case type properties.

It is not sufficient to add only a few instances of the same training data. For each topic, create at least 20 records in the training sample so that the system learns how to correctly respond to the entered text. Distribute records evenly across topics; otherwise, the model will be biased toward the overrepresented topic. For more information, see Best practices for creating categorization models.
  1. Log in to Pega Platform.
  2. In Dev Studio, click the name of your application, and click Channels and interfaces.
  3. Click the name of the Web Chatbot channel that includes the Insurance Quote case type.
  4. Click the Training data tab, and then click Actions > Create records.
  5. In the Topic field, press the Down arrow key and select: insurance
  6. In the next field, enter sample user input inquiring about car insurance:
    I need a car quote
    Thumbnail
    Creating new training data record
  7. Click Create record.
  8. Repeat steps 6 and 7 five more times to add instances of the same training data records.
  9. In the next field, enter sample user input inquiring about a specific car make and model insurance:
    I need a car insurance quote for my Ford Mustang GT 2017
    Thumbnail
    Creating new training data record
  10. Click Create record.
  11. Repeat steps 9 and 10 five more times to add instances of the same training data records.
  12. Click Close.

Mapping entities in the training data

Map training data to entities so that the car make and model information is later automatically extracted from the text that you enter to the Insurance Quote case properties. After adding the training data and building the model, you will verify in the preview console that the car make and model from the user input is automatically copied to the Insurance Quote case properties.

In this example, you will associate the #Carmakeent and #Carmodelent entities with the car make and model in the user input. These entities are already mapped to the .carMake and .carModel properties that are defined for the Insurance Quote case.

From the Training data correction pane, you can also create entities to represent the user input.
  1. On the Training data tab, select a training data record with the text:
    I need a car insurance quote for my Ford Mustang GT 2017
  2. In the Training data correction pane, select and right-click Ford, and then click #Carmakeent.
  3. Select and right-click Mustang GT, and then click #Carmodelent.
    Thumbnail
    Adding entities to training data
  4. Repeat steps 1 to 3 five more times to map entities in the other five instances of the training data with the same text.

Adding training data to the model

Add sample training data to the model so that IVA for Web Chatbot improves future responses to user inquiries about a car insurance quote. Update the model with sample data and associate it with the insurance topic. You can also help the system learn to recognize entities from user input such as the car make or model, so that this information is automatically mapped to the Insurance Quote case properties.

Instead of using the Training data tab, you can also add sample training data and build the model directly by chatting with the chatbot in the preview console. For more information, see Building an IVA for Web Chatbot in the preview console.
  1. On the Training data tab, select the check boxes for the six instances of the text:
    I need a car quote
    Thumbnail
    Sample training data records in Training data tab
  2. Click Add training data to model.
  3. Select the check boxes for the six instances of the text:
    I need a car insurance quote for my Ford Mustang GT 2017
  4. Click Add training data to model.

Building the model

Build the model with sufficient sample training data so that IVA for Web Chatbot can recognize a user request for a car insurance quote. In such a case, the Insurance Quote case is automatically started and the system asks more information about the car make, model, and VIN number.

  1. On the Training data tab, click Actions > Build model.
    Thumbnail
    Updating the model in the Training data tab.
    The system successfully updates the model with the six training data records of each type.
  2. Click Save.

Testing model changes in the chatbot

Test the changes in the model for IVA for Web Chatbot from the preview console. Enter the same training data that was used to train the model to verify that the system responds correctly to a request for a car insurance quote.

  1. On the Behavior tab, in the preview console, enter the following text:
    I need a car quote
  2. Display more information about the conversation and the case by turning on the Show analysis switch.
    Thumbnail
    Sample user input analysis with started case
    IVA for Web Chatbot correctly responds by associating the text that you entered with the insurance topic with a confidence of 100 percent. The system also starts the I-122 case and asks the first question about the make of the car.
  3. Click Reset.
  4. Enter the following text:
    I need a car insurance quote for my Ford Mustang GT 2017
    Thumbnail
    Sample user input analysis with mapped entities and skipped questions
    IVA for Web Chatbot responds correctly by associating the text that you entered with the insurance topic with a confidence of 100 percent. The system also starts the I-123 case. In addition, the car make and model that you entered, Ford and Mustang GT, are extracted and automatically mapped to the car make and model properties for the case. As a result, the requests for information about the car make and model are skipped.

Conclusions

You have successfully added new training data to the model and rebuilt the model. As a result, you have trained and improved how IVA for Web Chatbot responds to user requests about car insurance by using artificial intelligence. After you ensure that IVA for Web Chatbot responds correctly to user requests for car insurance, move it to the production environment.

Suggest Edit

100% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.