Spaces:
Runtime error
Runtime error
Upload fn.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
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')
|