create_model_with_gradiend
Create a ModelWithGradiend instance.
This is a generic factory function that can create any type of ModelWithGradiend. The model_class parameter must be specified explicitly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Any
|
Base model name/path or ModelWithGradiend instance |
required |
param_map
|
Optional[List[str]]
|
List of param names to use (None = all core model params (e.g., excluding prediction layers) |
None
|
activation_encoder
|
str
|
Activation function for encoder |
'tanh'
|
activation_decoder
|
str
|
Activation function for decoder |
'id'
|
bias_decoder
|
bool
|
Whether decoder has bias |
True
|
torch_dtype
|
dtype
|
Data type for model |
float32
|
latent_dim
|
int
|
Latent dimension (number of features) |
1
|
model_class
|
Type[ModelWithGradiend]
|
ModelWithGradiend subclass to use (required). For text models, use TextModelWithGradiend. |
required |
**kwargs
|
Any
|
Additional arguments passed to model_class.from_pretrained |
{}
|
Returns:
| Type | Description |
|---|---|
ModelWithGradiend
|
ModelWithGradiend instance (of the specified type) |
Examples:
Create a text model
from gradiend.model import TextModelWithGradiend model = create_model_with_gradiend("model-base-cased", model_class=TextModelWithGradiend)