Skip to content

Commit

Permalink
Add Pygmalion chat format (abetlen#986)
Browse files Browse the repository at this point in the history
  • Loading branch information
chiensen authored Dec 12, 2023
1 parent 6bbeea0 commit b938ccc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions llama_cpp/llama_chat_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,23 @@ def format_zephyr(
_prompt = _format_chatml(system_message, _messages, _sep)
return ChatFormatterResponse(prompt=_prompt, stop=_sep)


@register_chat_format("pygmalion")
def format_pygmalion(
messages: List[llama_types.ChatCompletionRequestMessage],
**kwargs: Any,
) -> ChatFormatterResponse:
system_template = """<|system|>{system_message}"""
system_message = _get_system_message(messages)
system_message = system_template.format(system_message=system_message)
_roles = dict(user="<|user|>", assistant="<|model|>")
_sep = "\n"
_messages = _map_roles(messages, _roles)
_messages.append((_roles["assistant"], None))
_prompt = _format_chatml(system_message, _messages, _sep)
return ChatFormatterResponse(prompt=_prompt, stop=_sep)


@register_chat_format("chatml")
def format_chatml(
messages: List[llama_types.ChatCompletionRequestMessage],
Expand Down

0 comments on commit b938ccc

Please sign in to comment.