aka7774 commited on
Commit
bc16f24
1 Parent(s): 74aef90

Upload fn.py

Browse files
Files changed (1) hide show
  1. fn.py +5 -2
fn.py CHANGED
@@ -109,7 +109,11 @@ def apply_template(messages):
109
  if type(messages) is str:
110
  if cfg['inst_template']:
111
  return cfg['inst_template'].format(instruction=cfg['instruction'], input=messages)
112
- return cfg['instruction'].format(input=messages)
 
 
 
 
113
  if type(messages) is list:
114
  return tokenizer.apply_chat_template(conversation=messages, add_generation_prompt=True, tokenize=False)
115
 
@@ -180,5 +184,4 @@ def numel(message, history = [], instruction = None, args = {}):
180
 
181
  return torch.numel(model_inputs['input_ids'])
182
 
183
-
184
  load_model(cfg['model_name'], '4bit')
 
109
  if type(messages) is str:
110
  if cfg['inst_template']:
111
  return cfg['inst_template'].format(instruction=cfg['instruction'], input=messages)
112
+ messages = [
113
+ {'role': 'user', 'content': cfg['instruction']},
114
+ {'role': 'assistant', 'content': 'I understand.'},
115
+ {'role': 'user', 'content': messages},
116
+ ]
117
  if type(messages) is list:
118
  return tokenizer.apply_chat_template(conversation=messages, add_generation_prompt=True, tokenize=False)
119
 
 
184
 
185
  return torch.numel(model_inputs['input_ids'])
186
 
 
187
  load_model(cfg['model_name'], '4bit')