Compose¶
Hybrid model building from extracted components.
PyTorchModelBuilder¶
PyTorchModelBuilder
¶
Bases: BaseModelBuilder
Builder for PyTorch hybrid models.
Combines extracted components from different models into new architectures with dimension adapters.
Source code in src/model_garage/compose/builder.py
add_component
¶
Add a component to the model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name for this component in the architecture |
required |
component
|
Any
|
The component (PyTorch module or ExtractedComponent) |
required |
metadata
|
Dict[str, Any]
|
Component metadata with input/output dimensions |
required |
Source code in src/model_garage/compose/builder.py
add_adapter
¶
Add a dimension adapter between components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Name of source component |
required |
target
|
str
|
Name of target component |
required |
adapter
|
Any
|
Linear adapter module |
required |
Source code in src/model_garage/compose/builder.py
define_forward_pass
¶
Define the execution order for the forward pass.
Source code in src/model_garage/compose/builder.py
build
¶
Build the model from components.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict containing the assembled model specification. |
Source code in src/model_garage/compose/builder.py
BaseModelBuilder¶
BaseModelBuilder
¶
Bases: ABC
Base class for model builders.
Defines the interface for combining extracted components into new hybrid architectures.
Source code in src/model_garage/compose/base.py
add_component
abstractmethod
¶
add_adapter
abstractmethod
¶
define_forward_pass
abstractmethod
¶
build
abstractmethod
¶
validate_architecture
¶
Validate the model architecture.
Source code in src/model_garage/compose/base.py
save_architecture
¶
Save the model architecture specification.