def _fallback_model(self): meta = Metadata( { "pipeline": [{ "name": "intent_classifier_keyword", "class": utils.module_path_from_object(KeywordIntentClassifier()) }] }, "") return Interpreter.create(meta, self._component_builder)
def persist(self, path, persistor=None, project_name=None, fixed_model_name=None): # type: (Text, Optional[Persistor], Text) -> Text """Persist all components of the pipeline to the passed path. Returns the directory of the persisted model.""" timestamp = datetime.datetime.now().strftime('%Y%m%d-%H%M%S') metadata = { "language": self.config["language"], "pipeline": [ utils.module_path_from_object(component) for component in self.pipeline ], "model_fasttext": self.config["model_fasttext"], } if project_name is None: project_name = "default" if fixed_model_name: model_name = fixed_model_name else: model_name = "model_" + timestamp dir_name = os.path.join(path, project_name, model_name) create_dir(dir_name) if self.training_data: metadata.update(self.training_data.persist(dir_name)) for component in self.pipeline: update = component.persist(dir_name) if update: metadata.update(update) Metadata(metadata, dir_name).persist(dir_name) if persistor is not None: persistor.persist(dir_name, model_name, project_name) logger.info("Successfully saved model into " "'{}'".format(os.path.abspath(dir_name))) return dir_name
def persist(self, path: Text, persistor: Optional[Persistor] = None, project_name: Text = None, fixed_model_name: Text = None) -> Text: """Persist all components of the pipeline to the passed path. Returns the directory of the persisted model.""" timestamp = datetime.datetime.now().strftime('%Y%m%d-%H%M%S') metadata = { "language": self.config["language"], "pipeline": [], } if project_name is None: project_name = "default" if fixed_model_name: model_name = fixed_model_name else: model_name = "model_" + timestamp path = make_path_absolute(path) dir_name = os.path.join(path, project_name, model_name) create_dir(dir_name) if self.training_data: metadata.update(self.training_data.persist(dir_name)) for i, component in enumerate(self.pipeline): file_name = self._file_name(i, component.name) update = component.persist(file_name, dir_name) component_meta = component.component_config if update: component_meta.update(update) component_meta["class"] = utils.module_path_from_object(component) metadata["pipeline"].append(component_meta) Metadata(metadata, dir_name).persist(dir_name) if persistor is not None: persistor.persist(dir_name, model_name, project_name) logger.info("Successfully saved model into " "'{}'".format(os.path.abspath(dir_name))) return dir_name
def persist(self, path, persistor=None, project_name=None, fixed_model_name=None): # type: (Text, Optional[Persistor], Text) -> Text """Persist all components of the pipeline to the passed path. Returns the directory of the persisted model.""" timestamp = datetime.datetime.now().strftime('%Y%m%d-%H%M%S') metadata = { "language": self.config["language"], "pipeline": [], } if project_name is None: project_name = "default" if fixed_model_name: model_name = fixed_model_name else: model_name = "model_" + timestamp path = config.make_path_absolute(path) dir_name = os.path.join(path, project_name, model_name) create_dir(dir_name) if self.training_data: metadata.update(self.training_data.persist(dir_name)) for component in self.pipeline: update = component.persist(dir_name) component_meta = component.component_config if update: component_meta.update(update) component_meta["class"] = utils.module_path_from_object(component) metadata["pipeline"].append(component_meta) Metadata(metadata, dir_name).persist(dir_name) if persistor is not None: persistor.persist(dir_name, model_name, project_name) logger.info("Successfully saved model into " "'{}'".format(os.path.abspath(dir_name))) return dir_name
def _fallback_model(self): meta = Metadata({"pipeline": [{ "name": "KeywordIntentClassifier", "class": utils.module_path_from_object(KeywordIntentClassifier()) }]}, "") return Interpreter.create(meta, self._component_builder)