Align tokenizer with mistral-common (#51)
Browse files- Align tokenizer with mistral-common (6a36bb0533187c3bce8634125df867deccda043d)
- Defend the honour of the Hugging Face tokenizer (d9fd2986d74edf78a53c48d6a3cfa579de642309)
- Update chat template to handle system message (38c100ec7f397942c341c9f1e768137131729628)
Co-authored-by: Matthew Carrigan <[email protected]>
- README.md +0 -6
- tokenizer_config.json +1 -1
README.md
CHANGED
@@ -6,12 +6,6 @@ license: apache-2.0
|
|
6 |
|
7 |
###
|
8 |
|
9 |
-
> [!IMPORTANT]
|
10 |
-
> ❗
|
11 |
-
> We recommend using `mistral_common` for tokenization as the transformers tokenizer has not been tested by the Mistral team and might give incorrect results.
|
12 |
-
|
13 |
-
---
|
14 |
-
|
15 |
The Mistral-7B-Instruct-v0.3 Large Language Model (LLM) is an instruct fine-tuned version of the Mistral-7B-v0.3.
|
16 |
|
17 |
Mistral-7B-v0.3 has the following changes compared to [Mistral-7B-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2/edit/main/README.md)
|
|
|
6 |
|
7 |
###
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
The Mistral-7B-Instruct-v0.3 Large Language Model (LLM) is an instruct fine-tuned version of the Mistral-7B-v0.3.
|
10 |
|
11 |
Mistral-7B-v0.3 has the following changes compared to [Mistral-7B-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2/edit/main/README.md)
|
tokenizer_config.json
CHANGED
@@ -6173,7 +6173,7 @@
|
|
6173 |
}
|
6174 |
},
|
6175 |
"bos_token": "<s>",
|
6176 |
-
"chat_template": "{{
|
6177 |
"clean_up_tokenization_spaces": false,
|
6178 |
"eos_token": "</s>",
|
6179 |
"legacy": false,
|
|
|
6173 |
}
|
6174 |
},
|
6175 |
"bos_token": "<s>",
|
6176 |
+
"chat_template": "{%- if messages[0]['role'] == 'system' %}\n {%- set system_message = messages[0]['content'] %}\n {%- set loop_messages = messages[1:] %}\n{%- else %}\n {%- set loop_messages = messages %}\n{%- endif %}\n\n{{- bos_token }}\n{%- for message in loop_messages %}\n {%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}\n {{- raise_exception('After the optional system message, conversation roles must alternate user/assistant/user/assistant/...') }}\n {%- endif %}\n {%- if message['role'] == 'user' %}\n {%- if loop.last and system_message is defined %}\n {{- '[INST] ' + system_message + '\\n\\n' + message['content'] + '[/INST]' }}\n {%- else %}\n {{- '[INST] ' + message['content'] + '[/INST]' }}\n {%- endif %}\n {%- elif message['role'] == 'assistant' %}\n {{- ' ' + message['content'] + eos_token}}\n {%- else %}\n {{- raise_exception('Only user and assistant roles are supported, with the exception of an initial optional system message!') }}\n {%- endif %}\n{%- endfor %}\n",
|
6177 |
"clean_up_tokenization_spaces": false,
|
6178 |
"eos_token": "</s>",
|
6179 |
"legacy": false,
|