LightningIRConfigClassFactory
- class lightning_ir.base.class_factory.LightningIRConfigClassFactory(MixinConfig: Type[LightningIRConfig])[source]
Bases:
LightningIRClassFactory
Class factory for creating derived LightningIRConfig classes from HuggingFace configuration classes.
- __init__(MixinConfig: Type[LightningIRConfig]) None
Creates a new LightningIRClassFactory.
- Parameters:
MixinConfig (Type[LightningIRConfig]) – LightningIRConfig mixin class
Methods
__init__
(MixinConfig)Creates a new LightningIRClassFactory.
from_backbone_class
(BackboneClass)Creates a derived LightningIRConfig from a transformers.PretrainedConfig backbone configuration class.
from_pretrained
(model_name_or_path, *args, ...)Loads a derived LightningIRConfig from a pretrained HuggingFace model.
get_backbone_config
(model_name_or_path)Grabs the configuration class from a checkpoint of a pretrained HuggingFace model.
get_backbone_model_type
(model_name_or_path, ...)Grabs the model type from a checkpoint of a pretrained HuggingFace model.
get_lightning_ir_config
(model_name_or_path)Grabs the Lightning IR configuration class from a checkpoint of a pretrained Lightning IR model.
get_lightning_ir_model_type
(model_name_or_path)Grabs the Lightning IR model type from a checkpoint of a pretrained HuggingFace model.
Attributes
Camel case model type of the Lightning IR model.
- from_backbone_class(BackboneClass: Type[PretrainedConfig]) Type[LightningIRConfig] [source]
Creates a derived LightningIRConfig from a transformers.PretrainedConfig backbone configuration class. If the backbone configuration class is already a dervied LightningIRConfig, it is returned as is.
- Parameters:
BackboneClass (Type[PretrainedConfig]) – Backbone configuration class
- Returns:
Derived LightningIRConfig
- Return type:
Type[LightningIRConfig]
- from_pretrained(model_name_or_path: str | Path, *args, **kwargs) Type[LightningIRConfig] [source]
Loads a derived LightningIRConfig from a pretrained HuggingFace model.
- Parameters:
model_name_or_path (str | Path) – Path to the model or its name
- Returns:
Derived LightningIRConfig
- Return type:
Type[LightningIRConfig]
- static get_backbone_config(model_name_or_path: str | Path) Type[PretrainedConfig]
Grabs the configuration class from a checkpoint of a pretrained HuggingFace model.
- Parameters:
model_name_or_path (str | Path) – Path to the model or its name
- Returns:
Configuration class of the backbone model
- Return type:
PretrainedConfig
- static get_backbone_model_type(model_name_or_path: str | Path, *args, **kwargs) str
Grabs the model type from a checkpoint of a pretrained HuggingFace model.
- Parameters:
model_name_or_path (str | Path) – Path to the model or its name
- Returns:
Model type of the backbone model
- Return type:
str
- static get_lightning_ir_config(model_name_or_path: str | Path) Type[LightningIRConfig] | None
Grabs the Lightning IR configuration class from a checkpoint of a pretrained Lightning IR model.
- Parameters:
model_name_or_path (str | Path) – Path to the model or its name
- Returns:
Configuration class of the Lightning IR model
- Return type:
Type[LightningIRConfig]
- static get_lightning_ir_model_type(model_name_or_path: str | Path) str | None
Grabs the Lightning IR model type from a checkpoint of a pretrained HuggingFace model.
- Parameters:
model_name_or_path (str | Path) – Path to the model or its name
- Returns:
Model type of the Lightning IR model
- Return type:
str | None