-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mistral template is wrong #2520
Comments
Could you send a fix? |
Sure: #2529 |
Hi, according to this page: https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.1 from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.1", use_default_system_prompt=False)
messages = [
{"role": "user", "content": "A"},
{"role": "assistant", "content": "B"},
{"role": "user", "content": "C"},
{"role": "assistant", "content": "D"},
{"role": "user", "content": "E"},
{"role": "assistant", "content": "F"},
{"role": "user", "content": "G"},
]
encodeds = tokenizer.apply_chat_template(messages, tokenize=False)
print(encodeds)
# <s>[INST] A [/INST] B </s><s>[INST] C [/INST] D </s><s>[INST] E [/INST] F </s><s>[INST] G [/INST] It seems the sep2 should be |
The output there seems to be in llama2 format, but you can see in this
section the separator should be </s> with no space: https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.1#instruction-format
…On Mon, Oct 9, 2023 at 1:28 AM Chen Xin ***@***.***> wrote:
@normster <https://github.com/normster>
Hi, according to this page:
https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.1
from transformers import AutoModelForCausalLM, AutoTokenizertokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.1", use_default_system_prompt=False)messages = [
{"role": "user", "content": "A"},
{"role": "assistant", "content": "B"},
{"role": "user", "content": "C"},
{"role": "assistant", "content": "D"},
{"role": "user", "content": "E"},
{"role": "assistant", "content": "F"},
{"role": "user", "content": "G"},
]encodeds = tokenizer.apply_chat_template(messages, tokenize=False)print(encodeds)
# <s>[INST] A [/INST] B </s><s>[INST] C [/INST] D </s><s>[INST] E [/INST] F </s><s>[INST] G [/INST]
It seems the sep2 should be ' </s><s>' and the ret seems lacking the
leading <s>
—
Reply to this email directly, view it on GitHub
<#2520 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABTAZJSK3XL5BMZBLJL6WODX6OYUDAVCNFSM6AAAAAA5VPLT7GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJSGU2TGNBSGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
They delete the chat template when I run the code. But I found they added it back. With current chat template,
the output is While with FastChat and #2529, the output is Should sep2 be set as Is this difference important, or can we ignore it? I'm not familiar with language model. |
I don't think the mistral conversation template is implemented correctly:
But according to the official docs the prompt format should be:
i.e. your implementation adds an extra space before the first [/INST], and before
</s>
, and after the second [INST].The text was updated successfully, but these errors were encountered: