Partager via


Language understanding in Composer

APPLIES TO: Composer v1.x and v2.x

Note

Language Understanding (LUIS) will be retired on 1 October 2025. Beginning 1 April 2023, you won't be able to create new LUIS resources. A newer version of language understanding is now available as part of Azure AI Language.

Conversational language understanding (CLU), a feature of Azure AI Language, is the updated version of LUIS. For more information about question-and-answer support in Composer, see Natural language processing.

A bot can use language understanding to interpret a user's input and contextually determine what to do next in a conversation. Associate a recognizer with a dialog and add training data to let your bot extract intents and entities. Use triggers to define how the bot responds to specific intents.

  • Training data is authored in the inline editor or on the User input page using the .lu file format.
  • Training data can be used with any recognizer that can consume .lu files, such as the Language Understanding (LUIS) and Orchestrator recognizers.

Utterances

Utterances are inputs from users and may have many variations. Since utterances aren't always well-formed, we need to provide example utterances for specific intents to train bots to recognize intents from different utterances. By doing so, your bots will have some "intelligence" to understand human languages.

In Composer, utterances are always captured in a Markdown list following the intent they refer to. For example, the Greeting intent with some example utterances are shown in the Intents section above.

Note

While the LU and LG formats look similar, the two formats are different. LU is for bots to understand user's inputs (primarily capture intent and optionally entities) and it's associated with recognizers, while LG is for bots to respond to users as output, and it's associated with a language generator.

Intents

Intents are categories or classifications of user intentions. An intent represents an action the user wants to perform. It's a purpose or goal expressed in the user's input, such as booking a flight, paying a bill, or finding a news article. You define and name intents that correspond to these actions. A travel app may define an intent named "BookFlight."

Here's a sample .lu file that demonstrates a simple Greeting intent with a list of example user utterances that capture different ways they might express this intent. You can use - or + or * to denote lists. Numbered lists aren't supported.

# Greeting
- Hi
- Hello
- How are you?

#<intent-name> defines a new intent. Each line after the intent definition contains an example utterance that describe that intent. You can stitch together multiple intent definitions in a language understanding editor in Composer. Each section is identified by #<intent-name> notation. Blank lines are skipped when parsing the file.

Entities

Entities are a collection of objects, each consisting of data extracted from an utterance such as places, times, and people. Entities and intents are both important data extracted from utterances. An utterance may include zero or more entities, while an utterance usually represents one intent. In Composer, all entities are defined and managed inline. Entities in the .lu file format are denoted using {\<entityName\>=\<labelled value\>} notation. For example:

# BookFlight
- book a flight to {toCity=seattle}
- book a flight from {fromCity=new york} to {toCity=seattle}

The example above shows the definition of a BookFlight intent with two example utterances and two entity definitions: toCity and fromCity. When triggered, if LUIS is able to identify a destination city, the city name will be made available as @toCity within the triggered actions or a departure city with @fromCity as available entity values. The entity values can be used directly in expressions and LG templates, or stored into a property in memory for later use. For more information on entities, including adding list entities, see advanced intents and entities.

Example

The table below shows an example of an intent with its corresponding utterances and entities. All three utterances share the same intent BookFlight each with a different entity. There are different types of entities, you can find more information in .lu file format.

Intent Utterances Entities
BookFlight "Book me a flight to London" "London"
"Fly me to London on the 31st" "London", "31st"
"I need a plane ticket next Sunday to London" "next Sunday", "London"

Below is a similar definition of a BookFlight intent, with entity specification {city=name} and a set of example utterances. This example shows one way to represent this intent in Composer. Extracted entities are passed along to any triggered actions or child dialogs using the syntax @city.

# BookFlight
- book a flight to {city=austin}
- travel to {city=new york}
- I want to go to {city=los angeles}

After publishing the model to LUIS, it will be able to identify a city as an entity and the city name will be made available as @city within the triggered actions. The entity value can be used directly in expressions and LG templates, or stored into a property in memory for later use. See the Define intents with entities article for examples of how these are implemented in Composer.

To add language understanding to a dialog

You author .lu files as training data for recognizers in Composer. Before creating your own .lu files, it's helpful to be familiar with:

To create .lu files in Composer, follow these steps:

Set up a Recognizer/Dispatch Type

Select a dialog in the bot explorer. Navigate to Recognizer/Dispatch type on the right in the properties pane. Select Change, and then select Default from the Choose a recognizer type pop-up window. Then select Done on the bottom right.

Select recognizer

Create an Intent recognized trigger

In the same dialog you selected the Default recognizer recognizer, select the three-dot icon then select Add a trigger from the drop-down menu.

Select Intent recognized from the trigger type menu. Fill in the What is the name of this trigger field with an intent name and add example utterances in the Trigger phrases field.

An Intent recognized trigger with an intent named weather and a few examples utterances can look like the following:

- How is the weather?
- Tell me about the weather?
- Is it raining tomorrow?

Select Submit. Composer creates an Intent recognized trigger named weather in the Navigation pane and shows the trigger in the authoring canvas. You can edit the .lu file on the right side of the Composer screen in the properties pane as shown below:

Select User input from the navigation pane to view all the training data created. Select a dialog from the Navigation pane then select Show code to edit the .lu file.

Add actions to the Intent recognized trigger

Select + under the Intent recognized trigger and add any actions you want your bot to execute when the weather trigger is fired.

Publish LU to LUIS

The last step is to publish your .lu files to LUIS.

Select Configure from the navigation pane, then select Development resources:

Publish LU

Add values for the Language Understanding region and Language Understanding authoring key if you already have them. If you don't, select Set up Language Understanding and pick the option that works for you:

  • Use existing resources: you already have LUIS resources published that you want to use.
  • Create and configure new Azure resource: use Azure to provision new LUIS resources.
  • Generate instructions for Azure administrator: generates Azure administrator instructions for users without Azure access.

For more information, see the section on updating LUIS values.

Anytime you start or restart your bot project, Composer will evaluate if your LU content has changed. If so, Composer will automatically make the required updates to your LUIS applications and then train and publish them. If you go to your LUIS app website, you'll find the newly published language model.

Additional information

Next step