Intent Detection I - Build and Train an AI 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.
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.
The steps to complete for this guide are as follows:
- Set Up the Data.
- Set Up Dropbox.
- Create a Connection to Dropbox.
- Create an Input.
- Build an Intent Detection AI model.
- Configure AI Model.
- Train AI Model.
- View the Results of the Trained AI Model.
Set Up the Data
This section links to the steps explained in a previous tutorial.
- Log in or create a Dropbox account.
- Create a Connection and upload the CSV file to Dropbox
- 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.
- Go to Dropbox.com and login or create a Dropbox account.
- After signing in, go to https://www.dropbox.com/developers/apps and click the button Create app.
- On the Create a New App page:
- Select the option Dropbox API.
- Select the option App folder.
- Enter a name for the app. In this example, the name "Hero_Flow" is entered.
- Click Create app.
- In the Dropbox Hero Flow settings:
- Open Hero_Flow to the Home screen on your computer.
- Copy the URL in your address bar except for the text "home".
- 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.
- Make a note of your App key and App secret.
- Enter your Hero_Flow redirect URI for the OAuth 2 setting.
How to find the redirect URI for the OAuth2 setting:
- 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
- Log into your Hero_Flow environment.
- Click Connections.
- Click CREATE NEW CONNECTION.
- When creating a new Connection:
- Enter a name for the Connection. (Example: Dropbox Connection)
- Select File System for the Connection type.
- Select DropBox File System for the Input file system.
- Enter your Dropbox App Key and App Secret.
- Click the button SIGN IN WITH DROPBOX. (When successful, your User Name is automatically filled in.)
- Click Continue to to confirm that you trust the app (Hero_Flow)
- Click Allow to create a new folder for your app in Dropbox.
- Go to Dropbox.com:
- Click the folder titled Apps.
- Click the name of the folder you created for Hero_Flow.
- Click the option New Folder.
- Enter a name for the new folder. In this example, it is called DemoData.
- In the DemoData folder, upload the Dropbox_Demo_Data.csv file.
- Go back to Hero_Flow.
- The file path must start with a slash character "/"
- The file path is case sensitive.
- In the File path field, enter the folder name you created in the app. (Example: /DemoData)
- Click TEST CONNECTION.
- 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
From the Hero_Flow dashboard, click Inputs.
Click Create New Input.
When creating a new Input:
Enter a name for the Input. (Example: Address Change Data)
Select the Dropbox Connection.
Enter the file path to the data. (Example: /address-change-dataset-mid.csv)
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.
Click Yes to load the table fields.
All the fields are found from the demo data file.
Change the data type form the Label field from LONG to DOUBLE.
Click OK to finish saving the Input.
Build an Intent Detection AI Model in AI Studio
The first step is setting up your model.
From the Hero_Flow dashboard, click on AI Models.
At the top of the AI Models dashboard, click Create a New AI Model.
- Enter a name for the AI model.
- Select the data set name for the Input you just created. (Example: Address Change Data)
- Configure the fields.
- Select the Input radio button for the "sentence" field.
- Select the Output radio button for the "label" field.
- Click Create.
- You are now in the AI Studio where the training model can be configured.
- Directly after the input box (titled "sentence"), click the plus icon (+) to add a preprocessor.
- Select Text Embedder and click OK.
- Next, between the two Dense layers, click the plus icon (+) to add a new layer.
- Select Dense and click OK.
- Under Layer Configuration, change the Unit value to 20.
- Click OK to save the layer.
Configure an AI Model
- From the toolbar at the top of AI Studio, click Configure.
- Click the Basic tab.
- The training Data Set should list the Address Change Data.
- Set the Split Data value so Trainings Data is at 80%.
- Click the Advanced tab.
- Set the Epochs value to 10.
- Select ADAM for the Optimizer.
- Select Mean Squared Error from the Loss drop-down box.
- Select ACCURACY for the Metrics.
- 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.
- From the toolbar at the top of AI Studio, click Save.
- Click Save to current revision.
- From the toolbar, click Train.
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.