Version: 2.0.x

rasa.shared.importers.importer

TrainingDataImporter Objects

class TrainingDataImporter()

Common interface for different mechanisms to load training data.

get_domain

| async get_domain() -> Domain

Retrieves the domain of the bot.

Returns:

Loaded Domain.

get_stories

| async get_stories(template_variables: Optional[Dict] = None, use_e2e: bool = False, exclusion_percentage: Optional[int] = None) -> StoryGraph

Retrieves the stories that should be used for training.

Arguments:

  • template_variables - Values of templates that should be replaced while reading the story files.
  • use_e2e - Specifies whether to parse end to end learning annotations.
  • exclusion_percentage - Amount of training data that should be excluded.

Returns:

StoryGraph containing all loaded stories.

get_config

| async get_config() -> Dict

Retrieves the configuration that should be used for the training.

Returns:

The configuration as dictionary.

get_nlu_data

| async get_nlu_data(language: Optional[Text] = "en") -> TrainingData

Retrieves the NLU training data that should be used for training.

Arguments:

  • language - Can be used to only load training data for a certain language.

Returns:

Loaded NLU TrainingData.

load_from_config

| @staticmethod
| load_from_config(config_path: Text, domain_path: Optional[Text] = None, training_data_paths: Optional[List[Text]] = None, training_type: Optional[TrainingType] = TrainingType.BOTH) -> "TrainingDataImporter"

Loads a TrainingDataImporter instance from a configuration file.

load_core_importer_from_config

| @staticmethod
| load_core_importer_from_config(config_path: Text, domain_path: Optional[Text] = None, training_data_paths: Optional[List[Text]] = None) -> "TrainingDataImporter"

Loads core TrainingDataImporter instance.

Instance loaded from configuration file will only read Core training data.

load_nlu_importer_from_config

| @staticmethod
| load_nlu_importer_from_config(config_path: Text, domain_path: Optional[Text] = None, training_data_paths: Optional[List[Text]] = None) -> "TrainingDataImporter"

Loads nlu TrainingDataImporter instance.

Instance loaded from configuration file will only read NLU training data.

load_from_dict

| @staticmethod
| load_from_dict(config: Optional[Dict], config_path: Text, domain_path: Optional[Text] = None, training_data_paths: Optional[List[Text]] = None, training_type: Optional[TrainingType] = TrainingType.BOTH) -> "TrainingDataImporter"

Loads a TrainingDataImporter instance from a dictionary.

NluDataImporter Objects

class NluDataImporter(TrainingDataImporter)

Importer that skips any Core-related file reading.

CoreDataImporter Objects

class CoreDataImporter(TrainingDataImporter)

Importer that skips any NLU related file reading.

CombinedDataImporter Objects

class CombinedDataImporter(TrainingDataImporter)

A TrainingDataImporter that combines multiple importers. Uses multiple TrainingDataImporter instances to load the data as if they were a single instance.

RetrievalModelsDataImporter Objects

class RetrievalModelsDataImporter(TrainingDataImporter)

A TrainingDataImporter that sets up the data for training retrieval models.

Synchronizes response templates between Domain and NLU and adds retrieval intent properties from the NLU training data back to the Domain.

get_domain

| @rasa.shared.utils.common.cached_method
| async get_domain() -> Domain

Merge existing domain with properties of retrieval intents in NLU data.

get_nlu_data

| @rasa.shared.utils.common.cached_method
| async get_nlu_data(language: Optional[Text] = "en") -> TrainingData

Update NLU data with response templates for retrieval intents defined in the domain

E2EImporter Objects

class E2EImporter(TrainingDataImporter)

Importer which

  • enhances the NLU training data with actions / user messages from the stories.
  • adds potential end-to-end bot messages from stories as actions to the domain