Warning: This document is for an old version of Rasa. The latest version is 1.10.8.

Validate Data

Test Domain and Data Files for Mistakes

To verify if there are any mistakes in your domain file, NLU data, or story data, run the validate script. You can run it with the following command:

rasa data validate

The script above runs all the validations on your files. Here is the list of options to the script:

usage: rasa data validate [-h] [-v] [-vv] [--quiet]
                          [--max-history MAX_HISTORY] [--fail-on-warnings]
                          [-d DOMAIN] [--data DATA]
                          {stories} ...

positional arguments:
  {stories}
    stories             Checks for inconsistencies in the story files.

optional arguments:
  -h, --help            show this help message and exit
  --max-history MAX_HISTORY
                        Number of turns taken into account for story structure
                        validation. (default: None)
  --fail-on-warnings    Fail validation on warnings and errors. If omitted
                        only errors will result in a non zero exit code.
                        (default: False)
  -d DOMAIN, --domain DOMAIN
                        Domain specification. This can be a single YAML file,
                        or a directory that contains several files with domain
                        specifications in it. The content of these files will
                        be read and merged together. (default: domain.yml)
  --data DATA           Path to the file or directory containing Rasa data.
                        (default: data)

Python Logging Options:
  -v, --verbose         Be verbose. Sets logging level to INFO. (default:
                        None)
  -vv, --debug          Print lots of debugging statements. Sets logging level
                        to DEBUG. (default: None)
  --quiet               Be quiet! Sets logging level to WARNING. (default:
                        None)

You can also run these validations through the Python API by importing the Validator class, which has the following methods:

from_files(): Creates the instance from string paths to the necessary files.

verify_intents(): Checks if intents listed in domain file are consistent with the NLU data.

verify_intents_in_stories(): Verification for intents in the stories, to check if they are valid.

verify_utterances(): Checks domain file for consistency between utterance templates and utterances listed under actions.

verify_utterances_in_stories(): Verification for utterances in stories, to check if they are valid.

verify_all(): Runs all verifications above.

To use these functions it is necessary to create a Validator object and initialize the logger. See the following code:

import logging
from rasa import utils
from rasa.core.validator import Validator

logger = logging.getLogger(__name__)

utils.configure_colored_logging('DEBUG')

validator = Validator.from_files(domain_file='domain.yml',
                                 nlu_data='data/nlu_data.md',
                                 stories='data/stories.md')

validator.verify_all()