winglian commited on
Commit
e8aacfb
1 Parent(s): b9d07aa

more qlora support

Browse files
src/axolotl/prompters.py CHANGED
@@ -11,6 +11,7 @@ class PromptStyle(Enum):
11
  instruct = "instruct"
12
  chat = "chat"
13
 
 
14
  class AlpacaPrompter:
15
  system_prompt = "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n"
16
  system_no_input_prompt = "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n"
@@ -50,6 +51,10 @@ class AlpacaPrompter:
50
  return output.split(self.response_split)[1].strip()
51
 
52
 
 
 
 
 
53
  class JeopardyPrompter(AlpacaPrompter):
54
  prompt_input = "Below is a Jeopardy clue paired with input providing the category of the clue. Write a concise response that best answers tbe clue given the category.\n\n### Instruction:\n{instruction}\n\n### Input:\n{input}\n\n### Response:\n"
55
 
 
11
  instruct = "instruct"
12
  chat = "chat"
13
 
14
+
15
  class AlpacaPrompter:
16
  system_prompt = "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n"
17
  system_no_input_prompt = "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n"
 
51
  return output.split(self.response_split)[1].strip()
52
 
53
 
54
+ class UnpromptedPrompter(AlpacaPrompter):
55
+ system_prompt = ""
56
+ system_no_input_prompt = ""
57
+
58
  class JeopardyPrompter(AlpacaPrompter):
59
  prompt_input = "Below is a Jeopardy clue paired with input providing the category of the clue. Write a concise response that best answers tbe clue given the category.\n\n### Instruction:\n{instruction}\n\n### Input:\n{input}\n\n### Response:\n"
60
 
src/axolotl/utils/data.py CHANGED
@@ -98,6 +98,11 @@ def load_tokenized_prepared_datasets(tokenizer, cfg, default_dataset_prepared_pa
98
  ds = load_dataset("json", data_files=fp, streaming=False, split=None)
99
  if not ds:
100
  raise Exception("unhandled dataset load")
 
 
 
 
 
101
  d_type = d.type
102
  d_type_split = d_type.split(":")
103
  d_base_type = d_type_split[0]
 
98
  ds = load_dataset("json", data_files=fp, streaming=False, split=None)
99
  if not ds:
100
  raise Exception("unhandled dataset load")
101
+ # support for using a subset of the data
102
+ if d.shards:
103
+ ds = ds.shuffle(seed=42)["train"].shard(
104
+ num_shards=cfg.shards, index=0
105
+ )
106
  d_type = d.type
107
  d_type_split = d_type.split(":")
108
  d_base_type = d_type_split[0]
src/axolotl/utils/models.py CHANGED
@@ -134,6 +134,7 @@ def load_model(
134
  model = LlamaForCausalLM.from_pretrained(
135
  base_model,
136
  load_in_8bit=cfg.load_in_8bit and cfg.adapter is not None,
 
137
  torch_dtype=torch_dtype,
138
  device_map=cfg.device_map,
139
  **model_kwargs,
@@ -168,6 +169,7 @@ def load_model(
168
  model = getattr(transformers, model_type).from_pretrained(
169
  base_model,
170
  load_in_8bit=cfg.load_in_8bit and cfg.adapter is not None,
 
171
  torch_dtype=torch_dtype,
172
  device_map=cfg.device_map,
173
  trust_remote_code=True if cfg.trust_remote_code is True else False,
@@ -182,6 +184,7 @@ def load_model(
182
  base_model,
183
  config=config,
184
  load_in_8bit=cfg.load_in_8bit and cfg.adapter is not None,
 
185
  torch_dtype=torch_dtype,
186
  device_map=cfg.device_map,
187
  trust_remote_code=True if cfg.trust_remote_code is True else False,
 
134
  model = LlamaForCausalLM.from_pretrained(
135
  base_model,
136
  load_in_8bit=cfg.load_in_8bit and cfg.adapter is not None,
137
+ load_in_4bit=cfg.load_in_4bit and cfg.adapter is not None,
138
  torch_dtype=torch_dtype,
139
  device_map=cfg.device_map,
140
  **model_kwargs,
 
169
  model = getattr(transformers, model_type).from_pretrained(
170
  base_model,
171
  load_in_8bit=cfg.load_in_8bit and cfg.adapter is not None,
172
+ load_in_4bit=cfg.load_in_4bit and cfg.adapter is not None,
173
  torch_dtype=torch_dtype,
174
  device_map=cfg.device_map,
175
  trust_remote_code=True if cfg.trust_remote_code is True else False,
 
184
  base_model,
185
  config=config,
186
  load_in_8bit=cfg.load_in_8bit and cfg.adapter is not None,
187
+ load_in_4bit=cfg.load_in_4bit and cfg.adapter is not None,
188
  torch_dtype=torch_dtype,
189
  device_map=cfg.device_map,
190
  trust_remote_code=True if cfg.trust_remote_code is True else False,