PretrainedModelProtocol
HasConfigClassProtocolPretrainedModelProtocol(config: Any)Composite structural contract for a family's model class —
either the backbone (ResNet, BERTModel) or a task wrapper
(ResNetForImageClassification, BERTForMaskedLM).
The protocol requires (i) the config_class pointer (from
HasConfigClass) and (ii) the two methods every
framework-consumed model exposes: __init__(self, config) and
forward(...). Concrete framework subclasses additionally
inherit lucid.nn.Module — so parameters() /
state_dict() / train() / eval() come for free — but
those are intentionally not part of the structural contract:
the protocol is meant to be checkable against the class object
alone, before instantiation, so the static validator can use
it.
Attributes
config_classClassVar[type]HasConfigClass.Notes
Refinements: BackboneProtocol for direct-model classes
(no For<Task> in name); TaskWrapperProtocol for
*For<Task> heads. Use the refined protocol in signatures
that need to distinguish — e.g. a feature extractor utility
should take a BackboneProtocol, while a fine-tuning
helper might take a TaskWrapperProtocol.
Examples
>>> from lucid.models.vision.resnet import (
... ResNet, ResNetForImageClassification,
... )
>>> from lucid.models._protocols import PretrainedModelProtocol
>>> isinstance(ResNet, PretrainedModelProtocol)
True
>>> isinstance(ResNetForImageClassification, PretrainedModelProtocol)
True