File size: 1,009 Bytes
460fdd7 801d9ed 460fdd7 |
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 26 27 28 29 30 31 32 33 34 35 |
from __future__ import annotations
import json
from pathlib import Path
import copy
from transformers.configuration_utils import PretrainedConfig
class GptBertConfig(PretrainedConfig):
def __init__(
self,
config_file: Path | str | None = None,
**kwargs
):
super().__init__(**kwargs)
self.model = "norbert4"
if config_file is not None:
if type(config_file) is str:
config_file = Path(config_file)
assert type(config_file) is not Path, "The config_file should either be a Path or str"
with config_file.open("r") as file:
config = json.load(file)
for attr, value in config.items():
if isinstance(value, str):
value = value.lower()
setattr(self, attr, value)
for attr, value in kwargs.items():
if isinstance(value, str):
value = value.lower()
setattr(self, attr, value)
|