From 602f481afebe866b39b8b97961d32fa86575ff5d Mon Sep 17 00:00:00 2001 From: wangpengfei1013 <155146149+wangpengfei1013@users.noreply.github.com> Date: Sun, 14 Jan 2024 12:11:58 +0800 Subject: [PATCH 1/5] Update conversation.py add yuan 2.0 conv_temp --- fastchat/conversation.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fastchat/conversation.py b/fastchat/conversation.py index 5fb1f0b70..0692b84cd 100644 --- a/fastchat/conversation.py +++ b/fastchat/conversation.py @@ -1408,6 +1408,22 @@ def get_conv_template(name: str) -> Conversation: ) ) + +#yuan 2.0 template +#reference:https://github.com/IEIT-Yuan/Yuan-2.0 +#reference:https://huggingface.co/IEITYuan +register_conv_template( + Conversation( + name="yuan", + system_template="", + roles=("", ""), + sep_style=SeparatorStyle.NO_COLON_SINGLE, + sep="", + stop_str="", + + ) +) + if __name__ == "__main__": from fastchat.conversation import get_conv_template From 3a4db79d0c8d9c60749040dec4ad4b1a562fcd42 Mon Sep 17 00:00:00 2001 From: wangpengfei1013 <155146149+wangpengfei1013@users.noreply.github.com> Date: Sun, 14 Jan 2024 12:13:03 +0800 Subject: [PATCH 2/5] Update model_registry.py yuan 2.0 model registed --- fastchat/model/model_registry.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fastchat/model/model_registry.py b/fastchat/model/model_registry.py index 60fd55df2..43a44adc3 100644 --- a/fastchat/model/model_registry.py +++ b/fastchat/model/model_registry.py @@ -536,3 +536,9 @@ 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( + ["Yuan2-2B-hf","Yuan2-51B-hf","Yuan2-102B-hf"], + "IEIYuan", + "https://huggingface.co/IEITYuan", + "Yuan2 is a Basemodel developed by IEI.", +) From 0a729e2cc1f785040cb63ecdf1b20cba44d4ebd9 Mon Sep 17 00:00:00 2001 From: wangpengfei1013 <155146149+wangpengfei1013@users.noreply.github.com> Date: Sun, 14 Jan 2024 12:14:27 +0800 Subject: [PATCH 3/5] Update model_adapter.py add yuan2Adapter --- fastchat/model/model_adapter.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fastchat/model/model_adapter.py b/fastchat/model/model_adapter.py index bb268e093..d6611efd3 100644 --- a/fastchat/model/model_adapter.py +++ b/fastchat/model/model_adapter.py @@ -2102,7 +2102,22 @@ def match(self, model_path: str): def get_default_conv_template(self, model_path: str) -> Conversation: return get_conv_template("solar") +class Yuan2Adapter(BaseModelAdapter): + """The model adapter for Yuan """ + def match(self, model_path: str): + return "yuan" in model_path.lower() + + def load_model(self, model_path: str, from_pretrained_kwargs: dict): + model, tokenizer = super().load_model(model_path, from_pretrained_kwargs) + tokenizer.add_tokens( + ['', '', '', '', '', '', '', '', + '', '', '', '', '', + '', ''], special_tokens=True) + return model, tokenizer + + def get_default_conv_template(self, model_path: str) -> Conversation: + return get_conv_template("yuan") # Note: the registration order matters. # The one registered earlier has a higher matching priority. register_model_adapter(PeftModelAdapter) @@ -2186,6 +2201,7 @@ def get_default_conv_template(self, model_path: str) -> Conversation: register_model_adapter(MetaMathAdapter) register_model_adapter(BagelAdapter) register_model_adapter(SolarAdapter) +register_model_adapter(Yuan2Adapter) # After all adapters, try the default base adapter. register_model_adapter(BaseModelAdapter) From 323f8ea7bf70a25ff5f5d7a726fbda82ef3851ba Mon Sep 17 00:00:00 2001 From: wangpengfei1013 <155146149+wangpengfei1013@users.noreply.github.com> Date: Sun, 14 Jan 2024 12:18:34 +0800 Subject: [PATCH 4/5] Update model_support.md add yuan2.0 support --- docs/model_support.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/model_support.md b/docs/model_support.md index 86e08fed0..4a76036b8 100644 --- a/docs/model_support.md +++ b/docs/model_support.md @@ -60,6 +60,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) - [Xwin-LM/Xwin-LM-7B-V0.1](https://huggingface.co/Xwin-LM/Xwin-LM-70B-V0.1) +- [IEITYuan/Yuan2-2B/51B/102B-hf](https://huggingface.co/IEITYuan) - 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 From f8578394ccf067b28eaf64fbb38dfd464baae1e5 Mon Sep 17 00:00:00 2001 From: Lianmin Zheng Date: Tue, 16 Jan 2024 22:57:10 -0800 Subject: [PATCH 5/5] Apply suggestions from code review --- fastchat/model/model_adapter.py | 1 + fastchat/model/model_registry.py | 1 + 2 files changed, 2 insertions(+) diff --git a/fastchat/model/model_adapter.py b/fastchat/model/model_adapter.py index d6611efd3..7f95a2f1c 100644 --- a/fastchat/model/model_adapter.py +++ b/fastchat/model/model_adapter.py @@ -2118,6 +2118,7 @@ def load_model(self, model_path: str, from_pretrained_kwargs: dict): def get_default_conv_template(self, model_path: str) -> Conversation: return get_conv_template("yuan") + # Note: the registration order matters. # The one registered earlier has a higher matching priority. register_model_adapter(PeftModelAdapter) diff --git a/fastchat/model/model_registry.py b/fastchat/model/model_registry.py index 43a44adc3..ada6fbd32 100644 --- a/fastchat/model/model_registry.py +++ b/fastchat/model/model_registry.py @@ -536,6 +536,7 @@ 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( ["Yuan2-2B-hf","Yuan2-51B-hf","Yuan2-102B-hf"], "IEIYuan",