File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
Original file line number Diff line number Diff line change 29
29
MISTRAL_INSTRUCT_BOS_TOKEN = "<s>"
30
30
MISTRAL_INSTRUCT_EOS_TOKEN = "</s>"
31
31
32
+ # Source: https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1/blob/main/tokenizer_config.json
33
+ MIXTRAL_INSTRUCT_CHAT_TEMPLATE = "{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token}}{% else %}{{ raise_exception('Only user and assistant roles are supported!') }}{% endif %}{% endfor %}"
32
34
33
35
### Chat Completion Handler ###
34
36
@@ -470,7 +472,8 @@ def guess_chat_format_from_gguf_metadata(metadata: Dict[str, str]) -> Optional[s
470
472
if metadata ["tokenizer.chat_template" ] == CHATML_CHAT_TEMPLATE :
471
473
return "chatml"
472
474
473
- if metadata ["tokenizer.chat_template" ] == MISTRAL_INSTRUCT_CHAT_TEMPLATE :
475
+ if (metadata ["tokenizer.chat_template" ] == MISTRAL_INSTRUCT_CHAT_TEMPLATE or
476
+ metadata ["tokenizer.chat_template" ] == MIXTRAL_INSTRUCT_CHAT_TEMPLATE ):
474
477
return "mistral-instruct"
475
478
476
479
return None
You can’t perform that action at this time.
0 commit comments