UFDModelBuilder

class UFDModelBuilder(models_root_path: str = 'https://storage.googleapis.com/sgnlp/models/ufd/', source_domains: List[str] = ['books', 'music', 'dvd'], target_languages: List[str] = ['de', 'jp', 'fr'], target_domains: List[str] = ['books', 'music', 'dvd'], config_filename: str = 'config.json', model_filename: str = 'pytorch_model.bin', device: torch.device = device(type='cpu'))[source]

Class for building the UFD model groups consisting of adaptor domain, adaptor global, combine features map and classifier models in their cross language cross domain configuration from pretrained model weights and config.

The builder expects the models structure as follows:

|models_root_path |—-[sourcedomain_targetlanguage_targetdomain_modeltype] |——–config_filename |——–model_filename

build_model_group()Dict[str, sgnlp.models.ufd.modeling.UFDModel][source]

Method to generate all UFD model grouping.

Returns

return a dict of model names as keys and the created UFDModel instances as the value.

Each UFDModel instances is created based on their respective adaptor_domain, adaptor_global, features_maper and classifier model instances.

Return type

Dict[str, UFDModel]

property model_map

Property to hold all model creation methods in a hashmap.

Returns

return a dict of models name as key and model create method as values.

Return type

Dict[str, Any]