Skip to content

Commit

Permalink
Merge pull request #687 from Xydane/main
Browse files Browse the repository at this point in the history
Add Support for DeepSeek-R1 models
  • Loading branch information
cjpais authored Jan 30, 2025
2 parents 72a5f8d + 7af1115 commit 29b5f27
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion llama.cpp/llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5187,7 +5187,7 @@ static void llm_load_vocab(
vocab.type_pre = LLAMA_VOCAB_PRE_TYPE_COMMAND_R;
vocab.tokenizer_clean_spaces = false;
} else if (
tokenizer_pre == "qwen2") {
tokenizer_pre == "qwen2" || tokenizer_pre == "deepseek-r1-qwen") {
vocab.type_pre = LLAMA_VOCAB_PRE_TYPE_QWEN2;
vocab.tokenizer_clean_spaces = false;
} else if (
Expand Down Expand Up @@ -19160,6 +19160,21 @@ static int32_t llama_chat_apply_template_internal(
if (add_ass) {
ss << "Assistant:";
}
} else if (tmpl == "deepseek3" || tmpl_contains(LU8("<|Assistant|>")) && tmpl_contains(LU8("<|User|>")) && tmpl_contains(LU8("<|end▁of▁sentence|>"))) {
// DeepSeek-V3
for (auto message : chat) {
std::string role(message->role);
if (role == "system") {
ss << message->content << "\n\n";
} else if (role == "user") {
ss << LU8("<|User|>") << message->content;
} else if (role == "assistant") {
ss << LU8("<|Assistant|>") << message->content << LU8("<|end▁of▁sentence|>");
}
}
if (add_ass) {
ss << LU8("<|Assistant|>");
}
} else if (tmpl == "exaone3" || (tmpl_contains("[|system|]") && tmpl_contains("[|assistant|]") && tmpl_contains("[|endofturn|]"))) {
// ref: https://huggingface.co/LGAI-EXAONE/EXAONE-3.0-7.8B-Instruct/discussions/8#66bae61b1893d14ee8ed85bb
// EXAONE-3.0-7.8B-Instruct
Expand Down

0 comments on commit 29b5f27

Please sign in to comment.