LightningIRClassFactory

class lightning_ir.base.class_factory.LightningIRClassFactory(MixinConfig: Type[LightningIRConfig])[source]

Bases: ABC

Base class for creating derived LightningIR 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 LightningIR class from a backbone HuggingFace class.

from_pretrained(model_name_or_path, *args, ...)

Loads a derived LightningIR 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 LightningIR 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

cc_lir_model_type

Camel case model type of the LightningIR model.

property cc_lir_model_type: str

Camel case model type of the LightningIR model.

abstract from_backbone_class(BackboneClass: Type) Type[source]

Creates a derived LightningIR class from a backbone HuggingFace class. Must be implemented by subclasses.

Parameters:

BackboneClass (Type) – Backbone class

Returns:

Derived LightningIR class

Return type:

Type

abstract from_pretrained(model_name_or_path: str | Path, *args, **kwargs) Any[source]

Loads a derived LightningIR 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 LightningIR 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 LightningIR 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