diff --git a/docs/model_support.md b/docs/model_support.md index a9eb4c895..780e11110 100644 --- a/docs/model_support.md +++ b/docs/model_support.md @@ -45,6 +45,7 @@ - [WizardLM/WizardLM-13B-V1.0](https://huggingface.co/WizardLM/WizardLM-13B-V1.0) - [WizardLM/WizardCoder-15B-V1.0](https://huggingface.co/WizardLM/WizardCoder-15B-V1.0) - [HuggingFaceH4/starchat-beta](https://huggingface.co/HuggingFaceH4/starchat-beta) +- [HuggingFaceH4/zephyr-7b-alpha](https://huggingface.co/HuggingFaceH4/zephyr-7b-alpha) - Any [EleutherAI](https://huggingface.co/EleutherAI) pythia model such as [pythia-6.9b](https://huggingface.co/EleutherAI/pythia-6.9b) - Any [Peft](https://github.com/huggingface/peft) adapter trained on top of a model above. To activate, must have `peft` in the model path. Note: If diff --git a/fastchat/conversation.py b/fastchat/conversation.py index 1371c3ab4..032aea9ea 100644 --- a/fastchat/conversation.py +++ b/fastchat/conversation.py @@ -1010,6 +1010,20 @@ def get_conv_template(name: str) -> Conversation: ) ) +# Zephyr template +# reference: https://huggingface.co/spaces/HuggingFaceH4/zephyr-playground/blob/main/dialogues.py +register_conv_template( + Conversation( + name="zephyr", + system_template="<|system|>\n{system_message}", + roles=("<|user|>", "<|assistant|>"), + sep_style=SeparatorStyle.CHATML, + sep="", + stop_token_ids=[2], + stop_str="", + ) +) + if __name__ == "__main__": from fastchat.conversation import get_conv_template diff --git a/fastchat/model/model_adapter.py b/fastchat/model/model_adapter.py index 0ca86a386..f33d5232d 100644 --- a/fastchat/model/model_adapter.py +++ b/fastchat/model/model_adapter.py @@ -1662,6 +1662,16 @@ def get_default_conv_template(self, model_path: str) -> Conversation: return get_conv_template("polyglot_changgpt") +class ZephyrAdapter(BaseModelAdapter): + """The model adapter for Zephyr (e.g. HuggingFaceH4/zephyr-7b-alpha)""" + + def match(self, model_path: str): + return "zephyr" in model_path.lower() + + def get_default_conv_template(self, model_path: str) -> Conversation: + return get_conv_template("zephyr") + + # Note: the registration order matters. # The one registered earlier has a higher matching priority. register_model_adapter(PeftModelAdapter) @@ -1722,6 +1732,7 @@ def get_default_conv_template(self, model_path: str) -> Conversation: register_model_adapter(PhindCodeLlamaAdapter) register_model_adapter(CodeLlamaAdapter) register_model_adapter(Llama2ChangAdapter) +register_model_adapter(ZephyrAdapter) # After all adapters, try the default base adapter. register_model_adapter(BaseModelAdapter) diff --git a/fastchat/model/model_registry.py b/fastchat/model/model_registry.py index 46c9a8710..9f562b846 100644 --- a/fastchat/model/model_registry.py +++ b/fastchat/model/model_registry.py @@ -318,3 +318,10 @@ def get_model_info(name: str) -> ModelInfo: "", "Deluxe Chat", ) + +register_model_info( + ["zephyr-7b-alpha"], + "Zephyr", + "https://huggingface.co/HuggingFaceH4/zephyr-7b-alpha", + "a chatbot fine-tuned from Mistral by Hugging Face", +)