-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Prompt Format Updates for LLama3 #1035
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
Comments
This seems to be working-ish based on what I've seen passed around elsewhere (e.g. ollama's prompt template or the sample provided on the llama.cpp pull request) : {
"name": "Llama 3",
"preprompt": "This is a conversation between User and Llama, a friendly chatbot. Llama is helpful, kind, honest, good at writing, and never fails to answer any requests immediately and with precision.",
"chatPromptTemplate": "<|begin_of_text|>{{#if @root.preprompt}}<|start_header_id|>system<|end_header_id|>\n\n{{@root.preprompt}}<|eot_id|>{{/if}}{{#each messages}}{{#ifUser}}<|start_header_id|>user<|end_header_id|>\n\n{{content}}<|eot_id|>{{/ifUser}}{{#ifAssistant}}<|start_header_id|>assistant<|end_header_id|>\n\n{{content}}<|eot_id|>{{/ifAssistant}}{{/each}}",
"parameters": {
(...snip...)
"stop": ["<|end_of_text|>", "<|eot_id|>"] // Verify that this is correct.
},
(...snip...)
} There are still some issues with the response not ending (ollama/ollama#3759) and the stop button not working (#890) that I'm still running into. That's probably related to the specific thing I've set as "stop" in the above definition here, as well as the tokenizer config when the model is converted to GGUF (if you do that). Apparently you can edit the tokenizer config JSON to fix some of these issues. See ongoing discussions floating around about Llama 3's stop tokens: ggml-org/llama.cpp#6770, ggml-org/llama.cpp#6745 (comment), ggml-org/llama.cpp#6751 (comment). |
Thank you @mlim15 that worked just fine. I spun up the 70B Instruct model and it appears to stop when intended. I do see some special tokens (start and stop header) streamed at the start but those are tidied up at the end of streaming. That's maybe the chat ui code rather than the model. |
Hello! |
Also, I am using Text-Generation-Webui, do you use the same? |
was anyone able to make it work? |
In prod for HuggingChat this is what we use:
chat-ui supports using the template that is stored in the tokenizer config so that should work. Let me know if it doesn't, maybe there's some endpoint specific thing going on. |
"name": "Llama-3", "stop": ["<|end_of_text|>", "<|eot_id|>"] Im using this config, if I want to use "tokenizer" : "philschmid/meta-llama-3-tokenizer", should I remove chatPromptTemplate and Preprompt ? |
You can keep preprompt but you should get rid of the chatPromptTemplate yes! |
Il try that! although the current config works flawlessly! |
At the end of the day, use what works for you 🤗 We support both custom prompt templates with |
@nsarrazin thanks for the answer, I'll try it soon! |
If you want a list of templates we've used in the past, you got PROMPTS.md If you want to see the current HuggingChat prod config it's .env.template and ideally try to see if the model you want has a
|
I've tried the following in the .env.local file but get parsing errors (Error: Parse error on line 7:
...ssistant}}<|eot_id|>)
"chatPromptTemplate" : "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\r\n\r\n{{ You are a friendly assistant }}<|eot_id|><|start_header_id|>user<|end_header_id|>\r\n\r\n{{#each messages}}{{#ifUser}}{{content}}{{/ifUser}}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\r\n\r\n{{#each messages}}{{#ifAssistant}}{{ content }}{{/ifAssistant}}<|eot_id|>",
Any thoughts?
The text was updated successfully, but these errors were encountered: