From ff9c91bbc8dc7d9ded05a4d47b8af0c95c92d536 Mon Sep 17 00:00:00 2001 From: BabyChouSr Date: Sun, 17 Dec 2023 19:44:33 +0000 Subject: [PATCH] Add solar model --- fastchat/conversation.py | 13 +++++++++++++ fastchat/model/model_adapter.py | 11 +++++++++++ fastchat/model/model_registry.py | 7 +++++++ 3 files changed, 31 insertions(+) diff --git a/fastchat/conversation.py b/fastchat/conversation.py index 6a277fa31..784dbe9ed 100644 --- a/fastchat/conversation.py +++ b/fastchat/conversation.py @@ -1341,6 +1341,19 @@ def get_conv_template(name: str) -> Conversation: ) ) +# Solar-10.7B Chat Template +# Reference: https://huggingface.co/upstage/SOLAR-10.7B-Instruct-v1.0/blob/main/tokenizer_config.json +register_conv_template( + Conversation( + name="solar", + system_message="", + roles=("### User", "### Assistant"), + sep_style=SeparatorStyle.ADD_NEW_LINE_SINGLE, + sep="\n\n", + 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 78e6c2c8c..477ebf224 100644 --- a/fastchat/model/model_adapter.py +++ b/fastchat/model/model_adapter.py @@ -1989,6 +1989,16 @@ def get_default_conv_template(self, model_path: str) -> Conversation: return get_conv_template("metamath") +class SolarAdapter(BaseModelAdapter): + """The model adapter for upstage/SOLAR-10.7B-Instruct-v1.0""" + + def match(self, model_path: str): + return "solar-" in model_path.lower() and "instruct" in model_path.lower() + + def get_default_conv_template(self, model_path: str) -> Conversation: + return get_conv_template("solar") + + # Note: the registration order matters. # The one registered earlier has a higher matching priority. register_model_adapter(PeftModelAdapter) @@ -2065,6 +2075,7 @@ def get_default_conv_template(self, model_path: str) -> Conversation: register_model_adapter(DeepseekCoderAdapter) register_model_adapter(DeepseekChatAdapter) register_model_adapter(MetaMathAdapter) +register_model_adapter(SolarAdapter) # 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 7f392c596..8bd99b255 100644 --- a/fastchat/model/model_registry.py +++ b/fastchat/model/model_registry.py @@ -441,3 +441,10 @@ def get_model_info(name: str) -> ModelInfo: "https://huggingface.co/meta-math", "MetaMath is a finetune of Llama2 on [MetaMathQA](https://huggingface.co/datasets/meta-math/MetaMathQA) that specializes in mathematical reasoning.", ) + +register_model_info( + ["upstage/SOLAR-10.7B-Instruct-v1.0"], + "SOLAR-10.7B-Instruct", + "https://huggingface.co/upstage/SOLAR-10.7B-Instruct-v1.0", + "A Llama2 fine-tune developed by upstage.ai that incorporates depth up-scaling.", +)