refactor: 修改分词器部分结构, 更新特殊token等

This commit is contained in:
2026-04-03 14:52:35 +08:00
parent 94c6a015c8
commit c5560740b6
3 changed files with 158 additions and 78 deletions
+5 -5
View File
@@ -28,16 +28,16 @@ def build_prompt(
result = ""
if system_prompt:
result += f"<|im_start|>system\n{system_prompt}<|im_end|>\n"
result += f"<imstart>system\n{system_prompt}<imend>\n"
# (convert tuple format to ChatML)
if history:
for user_msg, assistant_msg in history:
result += f"<|im_start|>user\n{user_msg}<|im_end|>\n"
result += f"<|im_start|>assistant\n{assistant_msg}<|im_end|>\n"
result += f"<imstart>user\n{user_msg}<imend>\n"
result += f"<imstart>assistant\n{assistant_msg}<imend>\n"
result += f"<|im_start|>user\n{query}<|im_end|>\n"
result += "<|im_start|>assistant\n"
result += f"<imstart>user\n{query}<imend>\n"
result += "<imstart>assistant\n"
return result