LightningIRClassFactory
- class lightning_ir.base.class_factory.LightningIRClassFactory(MixinConfig: Type[LightningIRConfig])[source]
Bases:
ABC
Base class for creating derived Lightning IR classes from HuggingFace classes.
- __init__(MixinConfig: Type[LightningIRConfig]) None [source]
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 Lightning IR class from a backbone HuggingFace class.
from_pretrained
(model_name_or_path, *args, ...)Loads a derived Lightning IR class 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.
- abstractmethod from_backbone_class(BackboneClass: Type) Type [source]
Creates a derived Lightning IR class from a backbone HuggingFace class. Must be implemented by subclasses.
- Parameters:
BackboneClass (Type) – Backbone class
- Returns:
Derived Lightning IR class
- Return type:
Type
- abstractmethod from_pretrained(model_name_or_path: str | Path, *args, **kwargs) Any [source]
Loads a derived Lightning IR class from a pretrained HuggingFace model. Must be implemented by subclasses.
- Parameters:
model_name_or_path (str | Path) – Path to the model or its name
- Returns:
Derived Lightning IR class
- Return type:
Any
- static get_backbone_config(model_name_or_path: str | Path) Type[PretrainedConfig] [source]
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 [source]
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 [source]
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 [source]
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