async def _train_nlu_async( config: Text, nlu_data: Text, output: Text, train_path: Optional[Text] = None, fixed_model_name: Optional[Text] = None, persist_nlu_training_data: bool = False, ): # training NLU only hence the training files still have to be selected file_importer = TrainingDataImporter.load_nlu_importer_from_config( config, training_data_paths=[nlu_data]) training_datas = await file_importer.get_nlu_data() if training_datas.is_empty(): print_error( "No NLU data given. Please provide NLU data in order to train " "a Rasa NLU model using the '--nlu' argument.") return return await _train_nlu_with_validated_data( file_importer, output=output, train_path=train_path, fixed_model_name=fixed_model_name, persist_nlu_training_data=persist_nlu_training_data, )
async def _train_nlu_async( config: Text, nlu_data: Text, output: Text, train_path: Optional[Text] = None, fixed_model_name: Optional[Text] = None, persist_nlu_training_data: bool = False, additional_arguments: Optional[Dict] = None, ): if not nlu_data: print_error( "No NLU data given. Please provide NLU data in order to train " "a Rasa NLU model using the '--nlu' argument.") return # training NLU only hence the training files still have to be selected file_importer = TrainingDataImporter.load_nlu_importer_from_config( config, training_data_paths=[nlu_data]) training_datas = await file_importer.get_nlu_data() if training_datas.is_empty(): print_error(f"Path '{nlu_data}' doesn't contain valid NLU data in it. " "Please verify the data format. " "The NLU model training will be skipped now.") return return await _train_nlu_with_validated_data( file_importer, output=output, train_path=train_path, fixed_model_name=fixed_model_name, persist_nlu_training_data=persist_nlu_training_data, additional_arguments=additional_arguments, )
async def test_eval_data(component_builder, tmpdir, project): _config = RasaNLUModelConfig({ "pipeline": [ { "name": "WhitespaceTokenizer" }, { "name": "CountVectorsFeaturizer" }, { "name": "DIETClassifier", "epochs": 2 }, { "name": "ResponseSelector", "epochs": 2 }, ], "language": "en", }) config_path = os.path.join(project, "config.yml") data_importer = TrainingDataImporter.load_nlu_importer_from_config( config_path, training_data_paths=[ "data/examples/rasa/demo-rasa.md", "data/examples/rasa/demo-rasa-responses.md", ], ) (_, _, persisted_path) = await train( _config, path=tmpdir.strpath, data=data_importer, component_builder=component_builder, persist_nlu_training_data=True, ) interpreter = Interpreter.load(persisted_path, component_builder) data = await data_importer.get_nlu_data() intent_results, response_selection_results, entity_results, = get_eval_data( interpreter, data) assert len(intent_results) == 46 assert len(response_selection_results) == 46 assert len(entity_results) == 46
async def test_nlu_only(project: Text): config_path = os.path.join(project, DEFAULT_CONFIG_PATH) default_data_path = os.path.join(project, DEFAULT_DATA_PATH) actual = TrainingDataImporter.load_nlu_importer_from_config( config_path, training_data_paths=[default_data_path]) assert isinstance(actual, NluDataImporter) stories = await actual.get_stories() assert stories.is_empty() domain = await actual.get_domain() assert domain.is_empty() config = await actual.get_config() assert config nlu_data = await actual.get_nlu_data() assert not nlu_data.is_empty()