Spaces:
Sleeping
Sleeping
Fix DesklibAIDetectionModel for transformers >= 4.50
Browse filestransformers 4.50 introduced mark_tied_weights_as_initialized() which
iterates self.all_tied_weights_keys during from_pretrained. Custom
PreTrainedModel subclasses must declare _tied_weights_keys and
all_tied_weights_keys even when empty, otherwise AttributeError fires
right after the weights load.
Error seen on HF Spaces:
AttributeError: 'DesklibAIDetectionModel' object has no attribute
'all_tied_weights_keys'
- utils/desklib_model.py +4 -0
utils/desklib_model.py
CHANGED
|
@@ -16,6 +16,10 @@ from transformers import AutoConfig, AutoModel, PreTrainedModel
|
|
| 16 |
|
| 17 |
class DesklibAIDetectionModel(PreTrainedModel):
|
| 18 |
config_class = AutoConfig
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
def __init__(self, config):
|
| 21 |
super().__init__(config)
|
|
|
|
| 16 |
|
| 17 |
class DesklibAIDetectionModel(PreTrainedModel):
|
| 18 |
config_class = AutoConfig
|
| 19 |
+
# transformers >= 4.50 expects every PreTrainedModel subclass to declare
|
| 20 |
+
# its tied-weight keys. We have no tied weights, so this stays empty.
|
| 21 |
+
_tied_weights_keys: list[str] = []
|
| 22 |
+
all_tied_weights_keys: dict = {}
|
| 23 |
|
| 24 |
def __init__(self, config):
|
| 25 |
super().__init__(config)
|