llama : add llama-3 chat template (#6751)
* Added llama-3 chat template * Update llama.cpp Co-authored-by: Samuel Tallet <[email protected]> * Update llama.cpp Co-authored-by: Samuel Tallet <[email protected]> * Update tests/test-chat-template.cpp Co-authored-by: Samuel Tallet <[email protected]> * Added EOS stop sequence according to https://github.com/ggerganov/llama.cpp/pull/6751#issuecomment-2065602862 * Removed adding of BOS token before first message * Removed bos token from expected output from llama-3 * Update tests/test-chat-template.cpp Co-authored-by: Rene Leonhardt <[email protected]> * Update tests/test-chat-template.cpp Co-authored-by: Rene Leonhardt <[email protected]> * Added <|end_of_text|> as another stop token * Reverted last change of adding the end_of_text stop word for llama 3 --------- Co-authored-by: Wouter Tichelaar <[email protected]> Co-authored-by: Samuel Tallet <[email protected]> Co-authored-by: Rene Leonhardt <[email protected]> Co-authored-by: Georgi Gerganov <[email protected]>
This commit is contained in:
co-authored by
Wouter Tichelaar
Samuel Tallet
Rene Leonhardt
Georgi Gerganov
parent
c1386c936e
commit
7dbdba5690
@@ -17247,6 +17247,15 @@ static int32_t llama_chat_apply_template_internal(
|
||||
if (add_ass) {
|
||||
ss << "<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>";
|
||||
}
|
||||
} else if (tmpl == "llama3" || (tmpl.find("<|start_header_id|>") != std::string::npos && tmpl.find("<|end_header_id|>") != std::string::npos)) {
|
||||
// Llama 3
|
||||
for (auto message : chat) {
|
||||
std::string role(message->role);
|
||||
ss << "<|start_header_id|>" << role << "<|end_header_id|>\n\n" << trim(message->content) << "<|eot_id|>";
|
||||
}
|
||||
if (add_ass) {
|
||||
ss << "<|start_header_id|>assistant<|end_header_id|>\n\n";
|
||||
}
|
||||
} else {
|
||||
// template not supported
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user