Natural language understanding best practices

This page contains some Natural Language Understanding (NLU) best practices and recommendations for building high quality Actions.

General

  • Conversations and verbal interaction can take many forms, and getting early user data can help your Action be more useful, effective, and fun.
  • Pay attention to errors and warnings. Even if your Action is working fine, it may cause problems in the future and you'll spend more time investigating the issues.
  • After your Actions are released, review your Action's conversation logs and update the Action in accordance with real user behavior.

Intents

  • Reuse intents between scenes as much as possible. If you have multiple intents that can be matched, it's hard for users to match the one they want, and even harder for Google Assistant to pick the correct intent based on user input.
  • Build your intent training phrases starting with the most common requests or interaction flows for your Actions.
  • Think about some extreme cases for your training phrases, like shortest and longest acceptable queries.
  • The number of training phrases you add to your intents depends on the complexity and breadth of what the intent is expected to handle. This means as few as 5 phrases can be okay for simple understanding ("yes" or "no"), but hundreds of training phrases can be added for more complicated language models.
  • For complex intents, where user input can vary, provide as many training phrases as needed to cover all potential user responses.
  • If you need to collect specific data from your users, use the slot filling functionality.
  • Do not create intents that contain only free-text intent parameters. If you need to match everything in the user input, use slot filling or the NO_MATCH system intent.

Types

  • If your type synonyms consist of multiple words, such as song names or food items, consider enabling fuzzy matching. This approach allows the user to omit unimportant words or change the expected order of their input.
  • Avoid using the Accept unknown values option whenever possible by providing additional synonyms.
  • If you do use the Accept unknown values option for your type, provide varying training phrases to ensure Assistant can identify the correct information. For example, if you have a type message set as Accept unknown values, your training phrases might look like this:

    • Send $message
    • Send $message to Tim
    • Send mom $message
  • If you need to match IDs or other structured input, consider using regular expressions.

  • Use the Free form text option sparingly. This option matches any non-empty input and makes it difficult for the language processor to train and match data effectively. You should use it as a last resort, when you simply can't predict what a user might say.