AI Model Tutorial 1 - Build and Train an Intent Detection Model

This tutorial is a guide to walk you through an example building an AI model.


The Problem to Solve

You want to build an Intent Detection AI Model to test if emails you receive are requesting a change of address.

Required Materials

To follow along with this tutorial, you will need:

A Dropbox account from https://www.dropbox.com/login

Download: Address Change Dataset

Video - Build and Train an Intent Detection AI Model

The data set we provide for free with this tutorial is relatively small. With more extensive data, the AI model could recognize and respond to more complex requests. This data set is meant for training and demo purposes.

Guide Outline

The steps to complete for this guide are as follows:

  1. Set Up the Data.
  2. Set Up Dropbox.
  3. Create a Connection to Dropbox.
  4. Create an Input.
  5. Build an Intent Detection AI model. 
  6. Configure AI Model.
  7. Train AI Model.
  8. View the Results of the Trained AI Model.

Set Up the Data

This section links to the steps explained in a previous tutorial. 

  1. Log in or create a Dropbox account.
  2. Create a Connection and upload the CSV file to Dropbox
    1. The file to upload into Dropbox is titled: address-change-dataset-mid.csv

Set Up Dropbox 

Hero_Flow has many pre-built Connectors. This example uses a connector for the file system app Dropbox.

  1. Go to Dropbox.com and login or create a Dropbox account.
  2. After signing in, go to https://www.dropbox.com/developers/apps and click the button Create app.
  3. On the Create a New App page:
    1. Select the option Dropbox API.
    2. Select the option App folder.
    3. Enter a name for the app. In this example, the name "Hero_Flow" is entered.
    4. Click Create app.
  4. In the Dropbox Hero Flow settings:
    1. Open Hero_Flow to the Home screen on your computer.
    2. Copy the URL in your address bar except for the text "home".
    3. In the Dropbox field Redirect URIs, paste the copied Hero_Flow URL without the tab name after the automationhero.ai/ and add the text "oauth2" at the end.
    1. Make a note of your App key and App secret.
    2. Enter your Hero_Flow redirect URI for the OAuth 2 setting.
      How to find the redirect URI for the OAuth2 setting:
    3. Click Add.

Keep this browser tab open to reference your App key and App secret when prompted for this information in Hero_Flow.

Create a Connection to Dropbox

  1. Log into your Hero_Flow environment. 
  2. Click Connections.
  3. Click CREATE NEW CONNECTION.
  4. When creating a new Connection:
    1. Enter a name for the Connection. (Example: Dropbox Connection)
    2. Select File System for the Connection type.
    3. Select DropBox File System for the Input file system.
    4. Enter your Dropbox App Key and App Secret.
    5. Click the button SIGN IN WITH DROPBOX. (When successful, your User Name is automatically filled in.)
  5. Click Continue to to confirm that you trust the app (Hero_Flow)
  6. Click Allow to create a new folder for your app in Dropbox.
  7. Go to Dropbox.com:
    1. Click the folder titled Apps.
    2. Click the name of the folder you created for Hero_Flow.
    3. Click the option New Folder.
    4. Enter a name for the new folder. In this example, it is called DemoData.
  8. In the DemoData folder, upload the Dropbox_Demo_Data.csv file.
  9. Go back to Hero_Flow.
    1. The file path must start with a slash character "/"
    2. The file path is case sensitive.
    1. In the File path field, enter the folder name you created in the app. (Example: /DemoData)
    2. Click TEST CONNECTION.
    3. A notification box is displayed showing that the connection was successful.

Click OK to finish saving the connection.

Create an Input for the Data in Dropbox

  1. From the Hero_Flow dashboard, click Inputs.

  2. Click Create New Input.

  3. When creating a new Input:

    1. Enter a name for the Input. (Example: Address Change Data)

    2. Select the Dropbox Connection.

    3. Enter the file path to the data. (Example: /address-change-dataset-mid.csv)

    4. Click the refresh icon next to the Fields mapping table.

      The Fields mapping table displays all the data column names and column types from your source data.

      With this feature, you can review, add, and remove columns to read and analyze in Hero_Flow.

  4. Click Yes to load the table fields.

  5. All the fields are found from the demo data file.

    1. Change the data type form the Label field from LONG to DOUBLE.

    2. Click OK to finish saving the Input.

Build an Intent Detection AI Model in AI Studio

The first step is setting up your model.

  1. From the Hero_Flow dashboard, click on AI Models.

  2. At the top of the AI Models dashboard, click Create a New AI Model.

    1. Enter a name for the AI model.
    2. Select the data set name for the Input you just created. (Example: Address Change Data)
  3. Configure the fields.
    1. Select the Input radio button for the "sentence" field.
    2. Select the Output radio button for the "label" field.
  4. Click Create.
    1. You are now in the AI Studio where the training model can be configured.
  5. Directly after the input box (titled "sentence"), click the plus icon (+) to add a preprocessor.
    1. Select Text Embedder and click OK.
  6. Next, between the two Dense layers, click the plus icon (+) to add a new layer.
    1. Select Dense and click OK.
    2. Under Layer Configuration, change the Unit value to 20.
    3. Click OK to save the layer.

Configure an AI Model

  1. From the toolbar at the top of AI Studio, click Configure.
  2. Click the Basic tab.
    1. The training Data Set should list the Address Change Data.
    2. Set the Split Data value so Trainings Data is at 80%.
  3. Click the Advanced tab.
    1. Set the Epochs value to 10.
    2. Select ADAM for the Optimizer. 
    3. Select Mean Squared Error from the Loss drop-down box.
    4. Select ACCURACY for the Metrics.
  4. Click OK to save the configuration settings.

Train an AI Model

Now that the AI Model has been built, it can be trained on the example data.

  1. From the toolbar at the top of AI Studio, click Save.
    1. Click Save to current revision.
  2. From the toolbar, click Train.
    1. Click OK to begin training the AI model. 

The length of the training process varies depending on the power of the compute node you are using.

View the Results

After the training has completed, the results can be found by clicking Training Dashboards from the toolbar.

The result of this tutorial shows the trained model is over 90% accurate with a low amount of loss. This means that when using this AI model within a Flow, the model has relatively high accuracy in  detecting emails requesting a change of address.