Fix strict and Lint
Browse files- scripts/finetune.py +5 -5
- src/axolotl/utils/models.py +2 -7
scripts/finetune.py
CHANGED
@@ -158,7 +158,7 @@ def train(
|
|
158 |
cfg_keys = cfg.keys()
|
159 |
for k, _ in kwargs.items():
|
160 |
# if not strict, allow writing to cfg even if it's not in the yml already
|
161 |
-
if k in cfg_keys or cfg.strict
|
162 |
# handle booleans
|
163 |
if isinstance(cfg[k], bool):
|
164 |
cfg[k] = bool(kwargs[k])
|
@@ -198,9 +198,9 @@ def train(
|
|
198 |
logging.info(f"loading tokenizer... {tokenizer_config}")
|
199 |
tokenizer = load_tokenizer(tokenizer_config, cfg.tokenizer_type, cfg)
|
200 |
|
201 |
-
if
|
202 |
-
["shard", "merge_lora"], kwargs
|
203 |
-
)
|
204 |
train_dataset, eval_dataset = load_prepare_datasets(
|
205 |
tokenizer, cfg, DEFAULT_DATASET_PREPARED_PATH
|
206 |
)
|
@@ -226,7 +226,7 @@ def train(
|
|
226 |
cfg.model_type,
|
227 |
tokenizer,
|
228 |
cfg,
|
229 |
-
adapter=cfg.adapter
|
230 |
)
|
231 |
|
232 |
if "merge_lora" in kwargs and cfg.adapter is not None:
|
|
|
158 |
cfg_keys = cfg.keys()
|
159 |
for k, _ in kwargs.items():
|
160 |
# if not strict, allow writing to cfg even if it's not in the yml already
|
161 |
+
if k in cfg_keys or not cfg.strict:
|
162 |
# handle booleans
|
163 |
if isinstance(cfg[k], bool):
|
164 |
cfg[k] = bool(kwargs[k])
|
|
|
198 |
logging.info(f"loading tokenizer... {tokenizer_config}")
|
199 |
tokenizer = load_tokenizer(tokenizer_config, cfg.tokenizer_type, cfg)
|
200 |
|
201 |
+
if (
|
202 |
+
check_not_in(["shard", "merge_lora"], kwargs) and not cfg.inference
|
203 |
+
): # don't need to load dataset for these
|
204 |
train_dataset, eval_dataset = load_prepare_datasets(
|
205 |
tokenizer, cfg, DEFAULT_DATASET_PREPARED_PATH
|
206 |
)
|
|
|
226 |
cfg.model_type,
|
227 |
tokenizer,
|
228 |
cfg,
|
229 |
+
adapter=cfg.adapter,
|
230 |
)
|
231 |
|
232 |
if "merge_lora" in kwargs and cfg.adapter is not None:
|
src/axolotl/utils/models.py
CHANGED
@@ -77,14 +77,9 @@ def load_tokenizer(
|
|
77 |
|
78 |
|
79 |
def load_model(
|
80 |
-
base_model,
|
81 |
-
base_model_config,
|
82 |
-
model_type,
|
83 |
-
tokenizer,
|
84 |
-
cfg,
|
85 |
-
adapter="lora"
|
86 |
):
|
87 |
-
# type: (str, str, str, AutoTokenizer, DictDefault, Optional[str]
|
88 |
"""
|
89 |
Load a model from a base model and a model type.
|
90 |
"""
|
|
|
77 |
|
78 |
|
79 |
def load_model(
|
80 |
+
base_model, base_model_config, model_type, tokenizer, cfg, adapter="lora"
|
|
|
|
|
|
|
|
|
|
|
81 |
):
|
82 |
+
# type: (str, str, str, AutoTokenizer, DictDefault, Optional[str]) -> Tuple[PreTrainedModel, Optional[PeftConfig]]
|
83 |
"""
|
84 |
Load a model from a base model and a model type.
|
85 |
"""
|