Baidu UNIT Intents and Entities

UNIT is Baidu's Natural Language Processing offering, supporting Simplified Chinese. Full documentation is available on the UNIT site.

Before attempting to work with UNIT's entities, make sure you have a solid understanding of how Slots and Intent and Entity Mapping work.

Before linking up your intents and entities, be sure to first connect your Baidu UNIT agent's Cloud Configuration to your bot.

The first step is to fetch your agent's intent name. To do this, launch UNIT, select the agent whose intents you are using and click Intents in the side navigation.

UNIT Intents list

*A UNIT agent with 7 intents.*

Here you can see all the intents associated with this agent. These are the intent names you will need to use in the Stackchat Bot Builder.

To trigger navigation to a Stackchat flow when this intent is detected, open the Configure AI dialogue for the Flow you want to navigate to.

UNIT AI Configuration Location

*The Configure AI button in the List View.*

In the overlay, add the intent name from UNIT that you want to map to the Flow. Be sure to copy it exactly, as it is case-sensitive. All UNIT intents are in all caps.

UNIT Copy Intent from UNIT

*An exact match including case is required.*

Paste the intent name into your desired location in Stackchat.

Dialogflow Paste Intent to Stackchat

*An exact match achieved.*

Now, you can enter the entities associated with that intent. You can see all the entities associated with an intent by clicking on it in UNIT.

Whereas intents represent the user's overall intention in their utterance, entities represent key words in the utterance that we want to extract. There are three types of entities in UNIT, custom entities (those created by you), system entities (pre-built entities provided by UNIT in order to facilitate handling the most popular common concepts), and hybrid entities, which are a combination of system and custom entities.

Custom and hybrid entities are no more difficult than dealing with the intent, in that it is a one-to-one mapping between Dialogflow and Stackchat. For example, in the Weather intent used above, there is one custom entity, @user_forecast_type.

A UNIT Custom Entity

*You can assign whatever name you wish to custom entities.*

Copy the text found in the 词槽名称 column of UNIT for the entity you are mapping.

And paste that value into Stackchat and select the Stackchat slot you wish to map it to. In this example, the Stackchat slot has the same name as the Dialogflow entity to prevent confusion.

UNIT Entity Connection to Slot

*UNIT 词槽名称 pasted into Stackchat.*

UNIT system entities follow the same naming convention as custom or hybrid entities, i.e. all names start with user_ and the remaining at the user's discretion. The user selects which system entity library or libaries they wish to use when creating the entity.

For many system entities, UNIT returns both original and normalized values. The original value is exactly what the user entered, while the normalized value converts that data into a standardized format. For example, if the agent extracts the entity "Tuesday", the original value will be "Tuesday", while the normalized value will be "YEAR-MONTH-DAY".

For some sytem entities such as location, Stackchat returns the original value, but there are some specific cases like the date example above, for which the original value is not useful. In these cases, Stackchat returns the normalized value.

In order for Stackchat to recognize that you wish to use the normalized value, there is a fixed naming convention that must be followed, as seen in the table below. Failure to follow this convention will result in UNIT returning the original value.

The general convention is user_<SYS_ENTITY_NAME>:<MEANINGFUL_NAME> where MEANINGFUL_NAME can be named at your discretion or omitted entirely (although we highly recommend using it if you have multiple entities employing the same). UNIT entity names can only be 16 characters long, excluding user_, so space for the meaningful name is limited.

System Entity Name for Use in Stackchat
time user_sys_time:MEANINGFUL_NAME
time_unit user_sys_time_unit:MEANINGFUL_NAME
time_interval user_sys_interval:MEANINGFUL_NAME
unit user_sys_unit:MEANINGFUL_NAME
money_unit user_sys_money_unit:MEANINGFUL_NAME

The system time entity covers both times and dates.

All other system entities return their original value.

Once you have the naming convention in place, simply copy and paste the intent name into the Configure AI dialogue as you would with a custom or hybrid entity.

UNIT System Entities

*Two system entities properly formatted without `MEANINGFUL_NAME`.*

UNIT System Entities in Stackchat

*Two system entities inserted into Stackchat.*