Make sure custom configs work with Transformers (#15569)
* Make sure custom configs work with Transformers * Apply code review suggestions
This commit is contained in:
@@ -2,7 +2,7 @@ import torch
|
||||
|
||||
from transformers import PreTrainedModel
|
||||
|
||||
from .custom_configuration import CustomConfig
|
||||
from .custom_configuration import CustomConfig, NoSuperInitConfig
|
||||
|
||||
|
||||
class CustomModel(PreTrainedModel):
|
||||
@@ -18,3 +18,18 @@ class CustomModel(PreTrainedModel):
|
||||
|
||||
def _init_weights(self, module):
|
||||
pass
|
||||
|
||||
|
||||
class NoSuperInitModel(PreTrainedModel):
|
||||
config_class = NoSuperInitConfig
|
||||
base_model_prefix = "custom"
|
||||
|
||||
def __init__(self, config):
|
||||
super().__init__(config)
|
||||
self.linear = torch.nn.Linear(config.attribute, config.attribute)
|
||||
|
||||
def forward(self, x):
|
||||
return self.linear(x)
|
||||
|
||||
def _init_weights(self, module):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user