diff options
author | Tristan Druyen <tristan@vault81.mozmail.com> | 2024-04-24 10:52:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-24 11:52:37 +0300 |
commit | abd3314064cd3c513f9eef34c3ba6c23a107442c (patch) | |
tree | 980fa51072bf88ac313982c393cac7900f5cdbbb /llama.cpp | |
parent | 3fec68be4e9577fc53158366d3b3af039c17bb1f (diff) |
llama : add phi 3 chat template (#6857)
* Add phi 3 chat template & tests
* test : fix chat template result
---------
Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
Diffstat (limited to 'llama.cpp')
-rw-r--r-- | llama.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -17447,6 +17447,15 @@ static int32_t llama_chat_apply_template_internal( if (add_ass) { ss << "<|start_header_id|>assistant<|end_header_id|>\n\n"; } + } else if (tmpl == "phi3" || (tmpl.find("<|assistant|>") != std::string::npos && tmpl.find("<|end|>") != std::string::npos )) { + // Phi 3 + for (auto message : chat) { + std::string role(message->role); + ss << "<|" << role << "|>\n" << trim(message->content) << "<|end|>\n"; + } + if (add_ass) { + ss << "<|assistant|>\n"; + } } else { // template not supported return -1; |