Training Data Format
Training Data Format
Warning: This document is for an old version of Rasa. The latest version is 1.10.26.
Data Formats
You can provide training data as Markdown or as JSON, as a single file or as a directory containing multiple files. Note that Markdown is usually easier to work with.
Markdown Format
Markdown is the easiest Rasa NLU format for humans to read and write. Examples are listed using the unordered list syntax, e.g. minus -, asterisk *, or plus +. Examples are grouped by intent, and entities are annotated as Markdown links, e.g. [<entity text>](<entity name>), or by using the following syntax [<entity-text>]{"entity": "<entity name>"}. Using the latter syntax, you can also assign synonyms, roles, or groups to an entity, e.g. [<entity-text>]{"entity": "<entity name>", "role": "<role name>", "group": "<group name>", "value": "<entity synonym>"}. The keywords role, group, and value are optional in this notation.
## intent:check_balance
- what is my balance <!-- no entity -->
- how much do I have on my [savings](source_account) <!-- entity "source_account" has value "savings" -->
- how much do I have on my [savings account]{"entity": "source_account", "value": "savings"} <!-- synonyms, method 1-->
- Could I pay in [yen](currency)? <!-- entity matched by lookup table -->
## intent:greet
- hey
- hello
## synonym:savings <!-- synonyms, method 2 -->
- pink pig
## regex:zipcode
- [0-9]{5}
## lookup:additional_currencies <!-- specify lookup tables in an external file -->
path/to/currencies.txt
The training data for Rasa NLU is structured into different parts:
- common examples
- synonyms
- regex features
- lookup tables
While common examples is the only part that is mandatory, including the others will help the NLU model learn the domain with fewer examples and also help it be more confident of its predictions.
JSON Format
The JSON format consists of a top-level object called rasa_nlu_data, with the keys common_examples, entity_synonyms and regex_features. The most important one is common_examples.
{
"rasa_nlu_data": {
"common_examples": [],
"regex_features" : [],
"lookup_tables" : [],
"entity_synonyms": []
}
}
Improving Intent Classification and Entity Recognition
Common Examples
Common examples have three components: text, intent and entities. The first two are strings while the last one is an array.
- The text is the user message [required]
- The intent is the intent that should be associated with the text [optional]
- The entities are specific parts of the text which need to be identified [optional]
Entities are specified with a start and an end value, which together make a range to apply to the string.
## intent:restaurant_search
- show me [chinese](cuisine) restaurants
Regular Expression Features
Regular expressions can be used to support the intent classification and entity extraction. For example, if your entity has a deterministic structure (like a zipcode or an email address), you can use a regular expression to ease detection of that entity.
## regex:zipcode
- [0-9]{5}
Lookup Tables
Lookup tables provide a convenient way to supply a list of entity examples. The supplied lookup table files must be in a newline-delimited format.
## lookup:plates
data/test/lookup_tables/plates.txt
## intent:food_request
- I'd like beef [tacos](plates) and a [burrito](plates)
Normalizing Data
Entity Synonyms
If you define entities as having the same value they will be treated as synonyms. Here is an example of that:
## intent:search
- in the center of [NYC]{"entity": "city", "value": "New York City"}
- in the centre of [New York City](city)
Conclusion
The document provides extensive guidance on how to format training data for Rasa NLU to optimize intent classification and entity recognition.