Skip to content

Commit b8f29f4

Browse files
authored
Add baichuan-2 chat format (ggml-org#936)
Signed-off-by: caiyesd <[email protected]>
1 parent 9515467 commit b8f29f4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

llama_cpp/llama_chat_format.py

+15
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,21 @@ def format_oasst_llama(
456456
return ChatFormatterResponse(prompt=_prompt)
457457

458458

459+
@register_chat_format("baichuan-2")
460+
def format_baichuan2(
461+
messages: List[llama_types.ChatCompletionRequestMessage],
462+
**kwargs: Any,
463+
) -> ChatFormatterResponse:
464+
_system_template = "{system_message}"
465+
_roles = dict(user="<reserved_106>", assistant="<reserved_107>")
466+
_sep = ""
467+
system_message = _get_system_message(messages)
468+
system_message = _system_template.format(system_message=system_message)
469+
_messages = _map_roles(messages, _roles)
470+
_messages.append((_roles["assistant"], None))
471+
_prompt = _format_no_colon_single(system_message, _messages, _sep)
472+
return ChatFormatterResponse(prompt=_prompt)
473+
459474
@register_chat_format("openbuddy")
460475
def format_openbuddy(
461476
messages: List[llama_types.ChatCompletionRequestMessage],

0 commit comments

Comments
 (0)