winglian commited on
Commit
3a50377
1 Parent(s): b029a11

Add qa style data for alpaca instructions, fix one_cycle scheduler

Browse files
src/axolotl/prompt_strategies/alpaca_chat.py CHANGED
@@ -1,4 +1,4 @@
1
- from axolotl.prompt_tokenizers import AlpacaPromptTokenizingStrategy
2
  from axolotl.prompters import AlpacaPrompter, PromptStyle
3
 
4
 
@@ -6,3 +6,18 @@ def load(tokenizer, cfg):
6
  return AlpacaPromptTokenizingStrategy(
7
  AlpacaPrompter(PromptStyle.chat), tokenizer, cfg.train_on_inputs, cfg.sequence_len
8
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from axolotl.prompt_tokenizers import AlpacaPromptTokenizingStrategy, InstructionPromptTokenizingStrategy
2
  from axolotl.prompters import AlpacaPrompter, PromptStyle
3
 
4
 
 
6
  return AlpacaPromptTokenizingStrategy(
7
  AlpacaPrompter(PromptStyle.chat), tokenizer, cfg.train_on_inputs, cfg.sequence_len
8
  )
9
+
10
+
11
+ class AlpacaQAPromptTokenizingStrategy(InstructionPromptTokenizingStrategy):
12
+ def parse_instruction_fields(self, prompt) -> (str, str, str):
13
+ return (
14
+ prompt["question"],
15
+ "",
16
+ prompt["answer"],
17
+ )
18
+
19
+
20
+ def load_qa(tokenizer, cfg):
21
+ return AlpacaQAPromptTokenizingStrategy(
22
+ AlpacaPrompter(PromptStyle.chat), tokenizer, cfg.train_on_inputs, cfg.sequence_len
23
+ )
src/axolotl/utils/trainer.py CHANGED
@@ -23,7 +23,7 @@ class OneCycleLRSchedulerTrainer(Trainer):
23
  num_training_steps=num_training_steps
24
  pct_start = num_warmup_steps / num_training_steps
25
 
26
- lr_scheduler = OneCycleLR(
27
  optimizer,
28
  max_lr=self.args.learning_rate,
29
  total_steps=num_training_steps,
@@ -31,7 +31,7 @@ class OneCycleLRSchedulerTrainer(Trainer):
31
  div_factor=6,
32
  )
33
 
34
- return lr_scheduler
35
 
36
 
37
  def setup_trainer(cfg, train_dataset, eval_dataset, model, tokenizer):
 
23
  num_training_steps=num_training_steps
24
  pct_start = num_warmup_steps / num_training_steps
25
 
26
+ self.lr_scheduler = OneCycleLR(
27
  optimizer,
28
  max_lr=self.args.learning_rate,
29
  total_steps=num_training_steps,
 
31
  div_factor=6,
32
  )
33
 
34
+ return self.lr_scheduler
35
 
36
 
37
  def setup_trainer(cfg, train_dataset, eval_dataset, model, tokenizer):