Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b8f29f4

Browse filesBrowse files
authored
Add baichuan-2 chat format (abetlen#936)
Signed-off-by: caiyesd <caiyesd@gmail.com>
1 parent 9515467 commit b8f29f4
Copy full SHA for b8f29f4

File tree

Expand file treeCollapse file tree

1 file changed

+15
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-0
lines changed

‎llama_cpp/llama_chat_format.py

Copy file name to clipboardExpand all lines: llama_cpp/llama_chat_format.py
+15Lines changed: 15 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.