Rorical commited on
Commit
69c2267
·
verified ·
1 Parent(s): fc1674c

Fix inference code: configuration_logos.py

Browse files
Files changed (1) hide show
  1. configuration_logos.py +7 -15
configuration_logos.py CHANGED
@@ -2,17 +2,11 @@
2
 
3
  from __future__ import annotations
4
 
5
- import sys
6
- import importlib
7
- from pathlib import Path
8
  from typing import Any, Dict
9
 
10
  from transformers import PretrainedConfig
11
 
12
- _MODULE_DIR = Path(__file__).resolve().parent
13
- if str(_MODULE_DIR) not in sys.path:
14
- sys.path.insert(0, str(_MODULE_DIR))
15
-
16
 
17
  _NATIVE_DEFAULTS: Dict[str, Any] = {
18
  "vocab_size": 32000,
@@ -100,15 +94,13 @@ class LogosConfig(PretrainedConfig):
100
  }
101
 
102
  def to_native_config(self):
103
- model_dir = getattr(self, "_name_or_path", None) or getattr(self, "name_or_path", None)
104
- if model_dir:
105
- model_path = Path(str(model_dir)).resolve()
106
- if model_path.exists() and str(model_path) not in sys.path:
107
- sys.path.insert(0, str(model_path))
108
- NativeLogosConfig = importlib.import_module("models.logos").LogosConfig
109
-
110
  data = {name: getattr(self, name) for name in _NATIVE_DEFAULTS}
111
- return NativeLogosConfig(**data)
 
 
 
 
 
112
 
113
 
114
  __all__ = ["LogosConfig"]
 
2
 
3
  from __future__ import annotations
4
 
5
+ from types import SimpleNamespace
 
 
6
  from typing import Any, Dict
7
 
8
  from transformers import PretrainedConfig
9
 
 
 
 
 
10
 
11
  _NATIVE_DEFAULTS: Dict[str, Any] = {
12
  "vocab_size": 32000,
 
94
  }
95
 
96
  def to_native_config(self):
 
 
 
 
 
 
 
97
  data = {name: getattr(self, name) for name in _NATIVE_DEFAULTS}
98
+ data["num_layers"] = (
99
+ int(data["num_entry_layers"])
100
+ + int(data["num_body_layers"])
101
+ + int(data["num_exit_layers"])
102
+ )
103
+ return SimpleNamespace(**data)
104
 
105
 
106
  __all__ = ["LogosConfig"]