LightningIRModelClassFactory
- class lightning_ir.base.class_factory.LightningIRModelClassFactory(MixinConfig: Type[LightningIRConfig])[source]
Bases:
LightningIRClassFactoryClass factory for creating derived LightningIRModel classes from HuggingFace model classes.
Methods
from_backbone_class(BackboneClass)Creates a derived LightningIRModel from a transformers.PreTrainedModel backbone model. If the backbone model
from_pretrained(model_name_or_path, *args, ...)Loads a derived LightningIRModel from a pretrained HuggingFace model.
- from_backbone_class(BackboneClass: Type[PreTrainedModel]) Type[LightningIRModel][source]
- Creates a derived LightningIRModel from a transformers.PreTrainedModel backbone model. If the backbone model
is already a LightningIRModel, it is returned as is.
- Parameters:
BackboneClass (Type[PreTrainedModel]) – Backbone model class.
- Returns:
Derived LightningIRModel.
- Return type:
Type[LightningIRModel]
- Raises:
ValueError – If the backbone model is not a valid backbone model.
ValueError – If the backbone model is not a LightningIRModel and no LightningIRConfig is passed.
ValueError – If the LightningIRModel mixin is not registered with the Hugging Face model mapping.
- from_pretrained(model_name_or_path: str | Path, *args, **kwargs) Type[LightningIRModel][source]
Loads a derived LightningIRModel from a pretrained HuggingFace model.
- Parameters:
model_name_or_path (str | Path) – Path to the model or its name.
- Returns:
Derived LightningIRModel.
- Return type:
Type[LightningIRModel]