phi3 chat format

Open Beginner friendly
#1,736 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
python

Research direction

The issue points to llama_chat_format.py as the file to modify. Start by examining existing chat format registrations in that file to understand the pattern. The provided code snippet shows the expected function signature and structure. Test by adding the new format and verifying it produces the correct prompt for Phi-3 models as described in the Hugging Face link.

Written by the indexing model from the issue text.

Description

Hello,

Could you add the chat format for the phi3 models ?

It is described here :

<|user|>\nQuestion<|end|>\n<|assistant|>\nAnswer<|end|>\n

Maybe something like this in llama_chat_format.py ?

@register_chat_format("phi3")
def format_phi3(
    messages: List[llama_types.ChatCompletionRequestMessage],
    **kwargs: Any,
) -> ChatFormatterResponse:
    _roles = dict(
        user="<|user|>\n",
        assistant="<|assistant|>\n",
    )
    _sep = "<|end|>\n"
    _messages = _map_roles(messages, _roles)
    _messages.append((_roles["assistant"], None))
    _prompt = _format_no_colon_single("", _messages, _sep)
    return ChatFormatterResponse(prompt=_prompt, stop=_sep)
Dominant language
Python
Stars
10.6k
Forks
1.5k
Avg merge
23m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from abetlen/llama-cpp-python

All issues in abetlen/llama-cpp-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.