-
Notifications
You must be signed in to change notification settings - Fork 94
/
portuguese_bert.py
25 lines (20 loc) · 1.09 KB
/
portuguese_bert.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""Custom Bert model pretrained on Portuguese."""
from h2oaicore.models import TextBERTModel, CustomModel
class PortugueseBertModel(TextBERTModel, CustomModel):
"""
Custom model class for using a model from https://huggingface.co/models.
Ensure that the model can be loaded using AutoModelForSequenceClassification.from_pretrained(_model_name)
The class inherits :
- CustomModel that really is just a tag. It's there to make sure DAI knows it's a custom model.
- TextBERTModel so that the custom model inherits all the properties and methods.
How to use:
- Disable genetic algorithm in the expert settings.
- Enable PortugueseBertModel in the expert settings and disable all other models.
- One model is fitted on the whole training dataset. To be able to see model scores, specify a validation or
a test dataset.
"""
_mojo = False
_booster_str = "pytorch_custom"
_model_name = "neuralmind/bert-base-portuguese-cased"
def _set_model_name(self, *args, **kwargs):
self.model_path = self.model_name = self._model_name