Ahmet Yildirim commited on
Commit
63ee95e
·
1 Parent(s): c10f440

- Fix comments in files, - Tidy up main modeling file

Browse files
configuration_norbert.py CHANGED
@@ -1,4 +1,7 @@
1
- # Taken from https://huggingface.co/ltg/norbert3-large/blob/main/configuration_norbert.py
 
 
 
2
  from transformers.configuration_utils import PretrainedConfig
3
 
4
  class NorbertConfig(PretrainedConfig):
 
1
+ # The whole code is taken from
2
+ # https://huggingface.co/ltg/norbert3-large/blob/main/configuration_norbert.py
3
+ # which is distributed under Apache 2.0 license.
4
+
5
  from transformers.configuration_utils import PretrainedConfig
6
 
7
  class NorbertConfig(PretrainedConfig):
modeling_humit_tagger.py CHANGED
@@ -43,28 +43,13 @@ class HumitTaggerModel(torch.nn.Module):
43
  spec.loader.exec_module(lemma_rules)
44
 
45
  # Download base_model files into cache
46
- # base_config_file = hf_hub_download(repo_id=kwargs["this_model_config"]["base_model"], filename=kwargs["this_model_config"]["base_model_config_file"])
47
  base_config_file = hf_hub_download(repo_id=repo_name, filename=kwargs["this_model_config"]["base_model_config_file"])
48
- # base_model_file = hf_hub_download(repo_id=kwargs["this_model_config"]["base_model"], filename=kwargs["this_model_config"]["base_model_model_file"])
49
  base_model_file = hf_hub_download(repo_id=repo_name, filename=kwargs["this_model_config"]["base_model_model_file"])
50
  base_model_config_json_file = hf_hub_download(repo_id=kwargs["this_model_config"]["base_model"], filename=kwargs["this_model_config"]["base_model_config_json_file"])
51
  fullformlist_file = hf_hub_download(repo_id=repo_name, filename=kwargs["this_model_config"]["fullformlist_file"])
52
 
53
- # Copy base model's configuration python file into our working directory
54
- # config_file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)) , os.path.basename(base_config_file))
55
- # shutil.copyfile(base_config_file, config_file_path)
56
-
57
- # HACK: Modify base model main file since __init.py__ has already been read and the new file must not contain relative imports
58
- # base_model_file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)) , os.path.basename(base_model_file))
59
- # with open(base_model_file, 'r') as file:
60
- # file_content = file.read().replace("from .", "from ")
61
- # with open(base_model_file_path, 'w') as file:
62
- # file.write(file_content)
63
-
64
  # Register the new files:
65
  # First register the base model config file
66
- # sys.path.append(os.path.dirname(config_file_path))
67
- # spec = importlib.util.spec_from_file_location("base_config", config_file_path)
68
  sys.path.append(os.path.dirname(base_config_file))
69
  spec = importlib.util.spec_from_file_location("base_config", base_config_file)
70
 
@@ -72,8 +57,6 @@ class HumitTaggerModel(torch.nn.Module):
72
  sys.modules["base_config"] = base_config
73
  spec.loader.exec_module(base_config)
74
  # Then register the base model file
75
- # sys.path.append(os.path.dirname(base_model_file_path))
76
- # spec = importlib.util.spec_from_file_location("base_model", base_model_file_path)
77
  sys.path.append(os.path.dirname(base_model_file))
78
  spec = importlib.util.spec_from_file_location("base_model", base_model_file)
79
 
 
43
  spec.loader.exec_module(lemma_rules)
44
 
45
  # Download base_model files into cache
 
46
  base_config_file = hf_hub_download(repo_id=repo_name, filename=kwargs["this_model_config"]["base_model_config_file"])
 
47
  base_model_file = hf_hub_download(repo_id=repo_name, filename=kwargs["this_model_config"]["base_model_model_file"])
48
  base_model_config_json_file = hf_hub_download(repo_id=kwargs["this_model_config"]["base_model"], filename=kwargs["this_model_config"]["base_model_config_json_file"])
49
  fullformlist_file = hf_hub_download(repo_id=repo_name, filename=kwargs["this_model_config"]["fullformlist_file"])
50
 
 
 
 
 
 
 
 
 
 
 
 
51
  # Register the new files:
52
  # First register the base model config file
 
 
53
  sys.path.append(os.path.dirname(base_config_file))
54
  spec = importlib.util.spec_from_file_location("base_config", base_config_file)
55
 
 
57
  sys.modules["base_config"] = base_config
58
  spec.loader.exec_module(base_config)
59
  # Then register the base model file
 
 
60
  sys.path.append(os.path.dirname(base_model_file))
61
  spec = importlib.util.spec_from_file_location("base_model", base_model_file)
62
 
modeling_norbert.py CHANGED
@@ -1,4 +1,7 @@
1
- # Taken from https://huggingface.co/ltg/norbert3-large/blob/a8ed9e21c5bc33c306d814b520c4373c7d29a469/modeling_norbert.py
 
 
 
2
  import math
3
  from typing import List, Optional, Tuple, Union
4
 
 
1
+ # The whole code is taken from
2
+ # https://huggingface.co/ltg/norbert3-large/blob/a8ed9e21c5bc33c306d814b520c4373c7d29a469/modeling_norbert.py
3
+ # which is distributed under Apache 2.0 license.
4
+
5
  import math
6
  from typing import List, Optional, Tuple, Union
7