Nanobit commited on
Commit
bdfe7c9
1 Parent(s): 0d4a7f4

Convert attrdict to addict

Browse files
requirements.txt CHANGED
@@ -1,7 +1,7 @@
1
  peft @ git+https://github.com/huggingface/peft.git
2
  transformers @ git+https://github.com/huggingface/transformers.git
3
  bitsandbytes>=0.39.0
4
- attrdict
5
  fire
6
  PyYAML==6.0
7
  black
 
1
  peft @ git+https://github.com/huggingface/peft.git
2
  transformers @ git+https://github.com/huggingface/transformers.git
3
  bitsandbytes>=0.39.0
4
+ addict
5
  fire
6
  PyYAML==6.0
7
  black
scripts/finetune.py CHANGED
@@ -10,7 +10,7 @@ from typing import Optional, List, Dict, Any, Union
10
  import fire
11
  import torch
12
  import yaml
13
- from attrdict import AttrDefault
14
 
15
  # add src to the pythonpath so we don't need to pip install this
16
  from axolotl.utils.tokenization import check_dataset_labels
@@ -131,7 +131,7 @@ def train(
131
 
132
  # load the config from the yaml file
133
  with open(config, "r") as f:
134
- cfg: AttrDefault = AttrDefault(lambda: None, yaml.load(f, Loader=yaml.Loader))
135
  # if there are any options passed in the cli, if it is something that seems valid from the yaml,
136
  # then overwrite the value
137
  cfg_keys = dict(cfg).keys()
 
10
  import fire
11
  import torch
12
  import yaml
13
+ from addict import Dict
14
 
15
  # add src to the pythonpath so we don't need to pip install this
16
  from axolotl.utils.tokenization import check_dataset_labels
 
131
 
132
  # load the config from the yaml file
133
  with open(config, "r") as f:
134
+ cfg: Dict = Dict(lambda: None, yaml.load(f, Loader=yaml.Loader))
135
  # if there are any options passed in the cli, if it is something that seems valid from the yaml,
136
  # then overwrite the value
137
  cfg_keys = dict(cfg).keys()
src/axolotl/utils/models.py CHANGED
@@ -29,7 +29,7 @@ from axolotl.prompt_tokenizers import LLAMA_DEFAULT_PAD_TOKEN
29
 
30
  if TYPE_CHECKING:
31
  from peft import PeftModel, PeftConfig
32
- from attrdict import AttrDefault
33
  from transformers import PreTrainedTokenizer
34
 
35
 
@@ -79,7 +79,7 @@ def load_model(
79
  adapter="lora",
80
  inference=False,
81
  ):
82
- # type: (str, str, str, str, AttrDefault, Optional[str], bool) -> Tuple[PreTrainedModel, Optional[PeftConfig]]
83
 
84
  # TODO refactor as a kwarg
85
  load_in_8bit = cfg.load_in_8bit
@@ -294,7 +294,7 @@ def load_model(
294
 
295
 
296
  def load_adapter(model, cfg, adapter):
297
- # type: (PreTrainedModel, AttrDefault, Optional[str]) -> Tuple[PreTrainedModel, Optional[PeftConfig]]
298
 
299
  if adapter is None:
300
  return model, None
@@ -307,7 +307,7 @@ def load_adapter(model, cfg, adapter):
307
 
308
 
309
  def load_llama_adapter(model, cfg):
310
- # type: (PreTrainedModel, AttrDefault) -> Tuple[PreTrainedModel, Optional[PeftConfig]]
311
  from peft import (
312
  AdaptionPromptConfig,
313
  get_peft_model,
@@ -355,7 +355,7 @@ def find_all_linear_names(bits, model):
355
 
356
 
357
  def load_lora(model, cfg):
358
- # type: (PreTrainedModel, AttrDefault) -> Tuple[PreTrainedModel, Optional[PeftConfig]]
359
 
360
  from peft import (
361
  LoraConfig,
 
29
 
30
  if TYPE_CHECKING:
31
  from peft import PeftModel, PeftConfig
32
+ from addict import Dict
33
  from transformers import PreTrainedTokenizer
34
 
35
 
 
79
  adapter="lora",
80
  inference=False,
81
  ):
82
+ # type: (str, str, str, str, Dict, Optional[str], bool) -> Tuple[PreTrainedModel, PreTrainedTokenizer, Optional[PeftConfig]]
83
 
84
  # TODO refactor as a kwarg
85
  load_in_8bit = cfg.load_in_8bit
 
294
 
295
 
296
  def load_adapter(model, cfg, adapter):
297
+ # type: (PreTrainedModel, Dict, Optional[str]) -> Tuple[PreTrainedModel, Optional[PeftConfig]]
298
 
299
  if adapter is None:
300
  return model, None
 
307
 
308
 
309
  def load_llama_adapter(model, cfg):
310
+ # type: (PreTrainedModel, Dict) -> Tuple[PreTrainedModel, Optional[PeftConfig]]
311
  from peft import (
312
  AdaptionPromptConfig,
313
  get_peft_model,
 
355
 
356
 
357
  def load_lora(model, cfg):
358
+ # type: (PreTrainedModel, Dict) -> Tuple[PreTrainedModel, Optional[PeftConfig]]
359
 
360
  from peft import (
361
  LoraConfig,