mindmeld.models.model_factory module

This module contains the ModelFactory class that can resolve model class names and create/load appropriate models

class mindmeld.models.model_factory.ModelFactory[source]

Bases: object

Auto class that identifies appropriate text/tagger model from text_models.py/tagger_models.py to load one based on the inputted configs or from the loaded configs file.

The .create_model_from_config() methods allows to load the appropriate model when a ModelConfig is passed. The .create_model_from_path() method uses AbstractModel's load method to load a dumped config, which is then used to load appropriate model and return it through a metadata dictionary object.

classmethod create_model_from_config(model_config: Union[dict, mindmeld.models.model.ModelConfig]) → Type[mindmeld.models.model.AbstractModel][source]

Instantiates and returns a valid model from the specified model configs

Parameters:model_config (Union[dict, ModelConfig]) -- Model configs inputted either as dict or an instance of ModelConfig
Returns:A text/tagger model instance
Return type:model (Type[AbstractModel])
Raises:ValueError -- When the configs are invalid
classmethod create_model_from_path(path: str) → Union[None, Type[mindmeld.models.model.AbstractModel]][source]

Loads and returns a model from the specified path

Parameters:path (str) -- A pickle file path from where a model can be loaded
Returns:
Returns None when the specified path is not
found or if the model loaded from the specified path is a NoneType. If found a valid config and a valid model, the model is load by calling .load() method and returned
Return type:model (Union[None, Type[AbstractModel]])
Raises:ValueError -- When the path is invalid
static register_models() → None[source]