Fill-Mask
Transformers
PyTorch
Norwegian
Norwegian Bokmål
Norwegian Nynorsk
BERT
NorBERT
Norwegian
encoder
custom_code
Instructions to use ltg/norbert3-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ltg/norbert3-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="ltg/norbert3-base", trust_remote_code=True)# Load model directly from transformers import AutoModelForMaskedLM model = AutoModelForMaskedLM.from_pretrained("ltg/norbert3-base", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
Fix compatibility with transformers v5
Browse files- modeling_norbert.py +5 -5
modeling_norbert.py
CHANGED
|
@@ -312,7 +312,7 @@ class NorbertModel(NorbertPreTrainedModel):
|
|
| 312 |
|
| 313 |
|
| 314 |
class NorbertForMaskedLM(NorbertModel):
|
| 315 |
-
_keys_to_ignore_on_load_unexpected = ["head"]
|
| 316 |
_tied_weights_keys = {"classifier.nonlinearity.5.weight": "embedding.word_embedding.weight"}
|
| 317 |
|
| 318 |
def __init__(self, config, **kwargs):
|
|
@@ -385,7 +385,7 @@ class Classifier(nn.Module):
|
|
| 385 |
|
| 386 |
|
| 387 |
class NorbertForSequenceClassification(NorbertModel):
|
| 388 |
-
_keys_to_ignore_on_load_unexpected = ["classifier"]
|
| 389 |
|
| 390 |
def __init__(self, config, **kwargs):
|
| 391 |
super().__init__(config, add_mlm_layer=False, **kwargs)
|
|
@@ -451,7 +451,7 @@ class NorbertForSequenceClassification(NorbertModel):
|
|
| 451 |
|
| 452 |
|
| 453 |
class NorbertForTokenClassification(NorbertModel):
|
| 454 |
-
_keys_to_ignore_on_load_unexpected = ["classifier"]
|
| 455 |
|
| 456 |
def __init__(self, config, **kwargs):
|
| 457 |
super().__init__(config, add_mlm_layer=False, **kwargs)
|
|
@@ -499,7 +499,7 @@ class NorbertForTokenClassification(NorbertModel):
|
|
| 499 |
|
| 500 |
|
| 501 |
class NorbertForQuestionAnswering(NorbertModel):
|
| 502 |
-
_keys_to_ignore_on_load_unexpected = ["classifier"]
|
| 503 |
|
| 504 |
def __init__(self, config, **kwargs):
|
| 505 |
super().__init__(config, add_mlm_layer=False, **kwargs)
|
|
@@ -567,7 +567,7 @@ class NorbertForQuestionAnswering(NorbertModel):
|
|
| 567 |
|
| 568 |
|
| 569 |
class NorbertForMultipleChoice(NorbertModel):
|
| 570 |
-
_keys_to_ignore_on_load_unexpected = ["classifier"]
|
| 571 |
|
| 572 |
def __init__(self, config, **kwargs):
|
| 573 |
super().__init__(config, add_mlm_layer=False, **kwargs)
|
|
|
|
| 312 |
|
| 313 |
|
| 314 |
class NorbertForMaskedLM(NorbertModel):
|
| 315 |
+
_keys_to_ignore_on_load_unexpected = ["head", r".*position_indices.*"]
|
| 316 |
_tied_weights_keys = {"classifier.nonlinearity.5.weight": "embedding.word_embedding.weight"}
|
| 317 |
|
| 318 |
def __init__(self, config, **kwargs):
|
|
|
|
| 385 |
|
| 386 |
|
| 387 |
class NorbertForSequenceClassification(NorbertModel):
|
| 388 |
+
_keys_to_ignore_on_load_unexpected = ["classifier", r".*position_indices.*"]
|
| 389 |
|
| 390 |
def __init__(self, config, **kwargs):
|
| 391 |
super().__init__(config, add_mlm_layer=False, **kwargs)
|
|
|
|
| 451 |
|
| 452 |
|
| 453 |
class NorbertForTokenClassification(NorbertModel):
|
| 454 |
+
_keys_to_ignore_on_load_unexpected = ["classifier", r".*position_indices.*"]
|
| 455 |
|
| 456 |
def __init__(self, config, **kwargs):
|
| 457 |
super().__init__(config, add_mlm_layer=False, **kwargs)
|
|
|
|
| 499 |
|
| 500 |
|
| 501 |
class NorbertForQuestionAnswering(NorbertModel):
|
| 502 |
+
_keys_to_ignore_on_load_unexpected = ["classifier", r".*position_indices.*"]
|
| 503 |
|
| 504 |
def __init__(self, config, **kwargs):
|
| 505 |
super().__init__(config, add_mlm_layer=False, **kwargs)
|
|
|
|
| 567 |
|
| 568 |
|
| 569 |
class NorbertForMultipleChoice(NorbertModel):
|
| 570 |
+
_keys_to_ignore_on_load_unexpected = ["classifier", r".*position_indices.*"]
|
| 571 |
|
| 572 |
def __init__(self, config, **kwargs):
|
| 573 |
super().__init__(config, add_mlm_layer=False, **kwargs)
|