An introduction to LGF utterance configuration.
Utterance templates
This document describes how to configure utterance templates for intents.
LGF configuration approach
(1) Collect utterances: Simulate user utterances in real-world scenarios or extract them from a raw corpus.
(2) Select key words: Use keywords that confirm a hit for the target intent.
(3) Expand key words: Add synonyms to enrich the corpus and increase coverage.
(4) Reorder key words: Rearrange key words into different combinations that still match the intent.
Basic elements
An utterance template, or LGF, uses template matching to represent user utterances. Utterance templates support the following elements.
Element
Description
Example
${}
References an entity parameter.
Template content: ${City}
Template meaning: References the "City" entity parameter.
NoteThe system has built-in common entities and also supports custom entities.
For more information about entities, see Entity Management.
[]
Optional character
Template content: [Please|Kindly] get me some water
Matching utterances: "Get me some water", "Please get me some water", and "Kindly get me some water" all match the utterance template.
()
Required character
Template content: Nearby (restaurant|eatery)
Matching utterances: "Nearby restaurant" and "Nearby eatery" match the utterance template. However, "Nearby hotel" or "Nearby" do not match.
|
Or
Template content: Xiaoming's (phone|contact information)
Matching utterances: "Xiaoming's phone" and "Xiaoming's contact information" both match the utterance template.
.{min,max}
A specified number of characters
Template content: .{0,3}${Date}${City} weather
Template meaning: .{0,3} represents any 0 to 3 characters.
Matching utterances (including but not limited to): "Check tomorrow's weather in Beijing", "I want to ask about the day after tomorrow's weather in Hangzhou", and "Next Monday's weather in Shanghai" all match the utterance template.
Important1. All symbols used in the elements must be standard English characters.
2. When you use a logical NOT before a wildcard rule, use `!` instead of `.`. The LGF configuration will fail if you use a `.` before the wildcard. For example, in the expression `(!decoration|rent){0,10}(need|want|recommend|introduce)`, the NOT logic part `(!...){0,10}` does not have a period before the curly braces.
3. An entire LGF utterance cannot consist only of optional parts, such as `.{min,max}` and `[]`.
4. LGFs for different intents must not overlap. This can cause incorrect intent hits and prevent a match with the correct intent.
Common usage
Use common wildcard characters to extract keywords and improve semantic generalization.
Is a credit card required?
(!decoration|rent){0,10}(need|want|recommend|introduce)(!decoration|rent){0,10}(house|property|floor plan|furnished)(!decoration|rent){0,10}
Use common NOT logic.
This sentence pattern asks whether it is necessary to buy a house.
(!decoration|rent){0,10}(need|want|recommend|introduce)(!decoration|rent){0,10}(house|property|floor plan|furnished)(!decoration|rent){0,10}
Common LGF patterns for intents
Intent name
LGF configuration
Convenient
(!|not|no){0,8}(yes|okay|sure|fine|convenient|go ahead|speak|ask|have time|free).{0,10}
Inconvenient
.{0,18}(injection|vaccine|hurry|not.{0,2}convenient|cooking|kid|inconvenient|meeting|busy|driving|takeoff|catching a flight|catching a train|catching a high-speed train|subway|highway|sleeping|no time|emergency|hospital|sick|car accident|check-up|prenatal check-up|eating|drinking|attending a wedding|rehearsal|dress rehearsal|class|traveling|live stream|showering|at work|discussion|work|training|handing out flyers|working|night shift|day shift|taking medicine|doing laundry|cleaning|sanitation|going upstairs|parking|ticket check|flight|train|high-speed train|wedding banquet|going to market|attending a fair|temple fair|playing|picking up kids|dropping off kids|attending a lecture|giving a lecture|symposium|Summit|translation|communication|seminar|postgraduate exam|research|trade show|exhibition|visiting|library|hiking|swimming|bathhouse scrub|game|museum|exploration|surveying).{0,18}
.{0,20}(don't have|no|not|not have).{0,6}(time|leisure).{0,10}
Satisfied
(!|not|no|non|un){0,10}(satisfied|good|great|awesome|nice|ok|fine|perfect).{0,10}
Unsatisfied
.{0,10}(unsatisfied|not good|poor|terrible|bad|awful).{0,10}
Affirmative
(!not|no){0,8}(yes|right|correct|indeed|that's it)(!robot|what|who|which|?){0,8}
Negative
.{0,15}(no|not|fail|error|wrong|false).{0,10}
Don't know the person
.{0,10}(don't know|wrong number|not sure|never heard of).{0,8}