Skip to content

Commit

Permalink
Add support for Phind-CodeLlama models (#2415) (#2416)
Browse files Browse the repository at this point in the history
Co-authored-by: Lianmin Zheng <lianminzheng@gmail.com>
  • Loading branch information
tobiabir and merrymercy committed Sep 18, 2023
1 parent 658736f commit d26d9e7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions fastchat/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,19 @@ def get_conv_template(name: str) -> Conversation:
)
)

# Phind template
register_conv_template(
Conversation(
name="phind",
system_message="### System Prompt\nYou are an intelligent programming assistant.",
roles=("### User Message", "### Assistant"),
messages=(),
offset=0,
sep_style=SeparatorStyle.ADD_COLON_SINGLE,
sep="\n\n",
)
)


if __name__ == "__main__":
print("Vicuna template:")
Expand Down
11 changes: 11 additions & 0 deletions fastchat/model/model_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,16 @@ def get_default_conv_template(self, model_path: str) -> Conversation:
return get_conv_template("llama-2")


class PhindCodeLlamaAdapter(CodeLlamaAdapter):
"""The model adapter for Phind Code Llama"""

def match(self, model_path: str):
return "phind-codellama-" in model_path.lower()

def get_default_conv_template(self, model_path: str) -> Conversation:
return get_conv_template("phind")


# Note: the registration order matters.
# The one registered earlier has a higher matching priority.
register_model_adapter(PeftModelAdapter)
Expand Down Expand Up @@ -1658,6 +1668,7 @@ def get_default_conv_template(self, model_path: str) -> Conversation:
register_model_adapter(VigogneChatAdapter)
register_model_adapter(OpenLLaMaOpenInstructAdapter)
register_model_adapter(ReaLMAdapter)
register_model_adapter(PhindCodeLlamaAdapter)
register_model_adapter(CodeLlamaAdapter)

# After all adapters, try the default base adapter.
Expand Down

0 comments on commit d26d9e7

Please sign in to comment.