From e11087aa7e9ffc780a86ad844a94721d8ebca1bb Mon Sep 17 00:00:00 2001 From: Fangyin Cheng Date: Fri, 7 Jun 2024 00:56:20 +0800 Subject: [PATCH] feat(model): Support Qwen2 models (#1612) --- README.ja.md | 5 +++++ README.md | 5 +++++ README.zh.md | 5 +++++ dbgpt/configs/model_config.py | 37 +++++++++++++++++++++++++++++++ dbgpt/model/adapter/hf_adapter.py | 15 +++++++++++++ 5 files changed, 67 insertions(+) diff --git a/README.ja.md b/README.ja.md index c11a6647e..d43d988b0 100644 --- a/README.ja.md +++ b/README.ja.md @@ -154,6 +154,11 @@ DB-GPTのアーキテクチャは以下の図に示されています: 私たちは、LLaMA/LLaMA2、Baichuan、ChatGLM、Wenxin、Tongyi、Zhipuなど、オープンソースおよびAPIエージェントからの数十の大規模言語モデル(LLM)を含む幅広いモデルをサポートしています。 - ニュース + - 🔥🔥🔥 [Qwen2-57B-A14B-Instruct](https://huggingface.co/Qwen/Qwen2-57B-A14B-Instruct) + - 🔥🔥🔥 [Qwen2-72B-Instruct](https://huggingface.co/Qwen/Qwen2-72B-Instruct) + - 🔥🔥🔥 [Qwen2-7B-Instruct](https://huggingface.co/Qwen/Qwen2-7B-Instruct) + - 🔥🔥🔥 [Qwen2-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2-1.5B-Instruct) + - 🔥🔥🔥 [Qwen2-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2-0.5B-Instruct) - 🔥🔥🔥 [glm-4-9b-chat](https://huggingface.co/THUDM/glm-4-9b-chat) - 🔥🔥🔥 [Phi-3](https://huggingface.co/collections/microsoft/phi-3-6626e15e9585a200d2d761e3) - 🔥🔥🔥 [Yi-1.5-34B-Chat](https://huggingface.co/01-ai/Yi-1.5-34B-Chat) diff --git a/README.md b/README.md index 561df833d..9ee8375f8 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,11 @@ At present, we have introduced several key features to showcase our current capa We offer extensive model support, including dozens of large language models (LLMs) from both open-source and API agents, such as LLaMA/LLaMA2, Baichuan, ChatGLM, Wenxin, Tongyi, Zhipu, and many more. - News + - 🔥🔥🔥 [Qwen2-57B-A14B-Instruct](https://huggingface.co/Qwen/Qwen2-57B-A14B-Instruct) + - 🔥🔥🔥 [Qwen2-72B-Instruct](https://huggingface.co/Qwen/Qwen2-72B-Instruct) + - 🔥🔥🔥 [Qwen2-7B-Instruct](https://huggingface.co/Qwen/Qwen2-7B-Instruct) + - 🔥🔥🔥 [Qwen2-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2-1.5B-Instruct) + - 🔥🔥🔥 [Qwen2-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2-0.5B-Instruct) - 🔥🔥🔥 [glm-4-9b-chat](https://huggingface.co/THUDM/glm-4-9b-chat) - 🔥🔥🔥 [Phi-3](https://huggingface.co/collections/microsoft/phi-3-6626e15e9585a200d2d761e3) - 🔥🔥🔥 [Yi-1.5-34B-Chat](https://huggingface.co/01-ai/Yi-1.5-34B-Chat) diff --git a/README.zh.md b/README.zh.md index 5b78f9097..1035c3526 100644 --- a/README.zh.md +++ b/README.zh.md @@ -152,6 +152,11 @@ 海量模型支持,包括开源、API代理等几十种大语言模型。如LLaMA/LLaMA2、Baichuan、ChatGLM、文心、通义、智谱等。当前已支持如下模型: - 新增支持模型 + - 🔥🔥🔥 [Qwen2-57B-A14B-Instruct](https://huggingface.co/Qwen/Qwen2-57B-A14B-Instruct) + - 🔥🔥🔥 [Qwen2-72B-Instruct](https://huggingface.co/Qwen/Qwen2-72B-Instruct) + - 🔥🔥🔥 [Qwen2-7B-Instruct](https://huggingface.co/Qwen/Qwen2-7B-Instruct) + - 🔥🔥🔥 [Qwen2-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2-1.5B-Instruct) + - 🔥🔥🔥 [Qwen2-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2-0.5B-Instruct) - 🔥🔥🔥 [glm-4-9b-chat](https://huggingface.co/THUDM/glm-4-9b-chat) - 🔥🔥🔥 [Phi-3](https://huggingface.co/collections/microsoft/phi-3-6626e15e9585a200d2d761e3) - 🔥🔥🔥 [Yi-1.5-34B-Chat](https://huggingface.co/01-ai/Yi-1.5-34B-Chat) diff --git a/dbgpt/configs/model_config.py b/dbgpt/configs/model_config.py index 7a0e20102..fefd4c953 100644 --- a/dbgpt/configs/model_config.py +++ b/dbgpt/configs/model_config.py @@ -54,6 +54,7 @@ LLM_MODEL_CONFIG = { "chatglm3-6b": os.path.join(MODEL_PATH, "chatglm3-6b"), # https://huggingface.co/THUDM/glm-4-9b-chat "glm-4-9b-chat": os.path.join(MODEL_PATH, "glm-4-9b-chat"), + "glm-4-9b-chat-1m": os.path.join(MODEL_PATH, "glm-4-9b-chat-1m"), "guanaco-33b-merged": os.path.join(MODEL_PATH, "guanaco-33b-merged"), "falcon-40b": os.path.join(MODEL_PATH, "falcon-40b"), "gorilla-7b": os.path.join(MODEL_PATH, "gorilla-7b"), @@ -124,6 +125,42 @@ LLM_MODEL_CONFIG = { "codeqwen1.5-7b-chat": os.path.join(MODEL_PATH, "CodeQwen1.5-7B-Chat"), # https://huggingface.co/Qwen/Qwen1.5-MoE-A2.7B-Chat "qwen1.5-moe-a2.7b-chat": os.path.join(MODEL_PATH, "Qwen1.5-MoE-A2.7B-Chat"), + "qwen2-57b-a14b-instruct": os.path.join(MODEL_PATH, "Qwen2-57B-A14B-Instruct"), + "qwen2-57b-a14b-instruct-gptq-int4": os.path.join( + MODEL_PATH, "Qwen2-57B-A14B-Instruct-GPTQ-Int4" + ), + "qwen2-72b-instruct": os.path.join(MODEL_PATH, "Qwen2-72B-Instruct"), + "qwen2-72b-instruct-awq": os.path.join(MODEL_PATH, "Qwen2-72B-Instruct-AWQ"), + "qwen2-72b-instruct-gptq-int8": os.path.join( + MODEL_PATH, "Qwen2-72B-Instruct-GPTQ-Int8" + ), + "qwen2-72b-instruct-gptq-int4": os.path.join( + MODEL_PATH, "Qwen2-72B-Instruct-GPTQ-Int4" + ), + "qwen2-7b-instruct": os.path.join(MODEL_PATH, "Qwen2-7B-Instruct"), + "qwen2-7b-instruct-awq": os.path.join(MODEL_PATH, "Qwen2-7B-Instruct-AWQ"), + "qwen2-7b-instruct-gptq-int8": os.path.join( + MODEL_PATH, "Qwen2-7B-Instruct-GPTQ-Int8" + ), + "qwen2-7b-instruct-gptq-int4": os.path.join( + MODEL_PATH, "Qwen2-7B-Instruct-GPTQ-Int4" + ), + "qwen2-1.5b-instruct": os.path.join(MODEL_PATH, "Qwen2-1.5B-Instruct"), + "qwen2-1.5b-instruct-awq": os.path.join(MODEL_PATH, "Qwen2-1.5B-Instruct-AWQ"), + "qwen2-1.5b-instruct-gptq-int8": os.path.join( + MODEL_PATH, "Qwen2-1.5B-Instruct-GPTQ-Int8" + ), + "qwen2-1.5b-instruct-gptq-int4": os.path.join( + MODEL_PATH, "Qwen2-1.5B-Instruct-GPTQ-Int4" + ), + "qwen2-0.5b-instruct": os.path.join(MODEL_PATH, "Qwen2-0.5B-Instruct"), + "qwen2-0.5b-instruct-awq": os.path.join(MODEL_PATH, "Qwen2-0.5B-Instruct-AWQ"), + "qwen2-0.5b-instruct-gptq-int8": os.path.join( + MODEL_PATH, "Qwen2-0.5B-Instruct-GPTQ-Int8" + ), + "qwen2-0.5b-instruct-gptq-int4": os.path.join( + MODEL_PATH, "Qwen2-0.5B-Instruct-GPTQ-Int4" + ), # (Llama2 based) We only support WizardLM-13B-V1.2 for now, which is trained from Llama-2 13b, see https://huggingface.co/WizardLM/WizardLM-13B-V1.2 "wizardlm-13b": os.path.join(MODEL_PATH, "WizardLM-13B-V1.2"), # wget https://huggingface.co/TheBloke/vicuna-13B-v1.5-GGUF/resolve/main/vicuna-13b-v1.5.Q4_K_M.gguf -O models/ggml-model-q4_0.gguf diff --git a/dbgpt/model/adapter/hf_adapter.py b/dbgpt/model/adapter/hf_adapter.py index a24031136..d71453e54 100644 --- a/dbgpt/model/adapter/hf_adapter.py +++ b/dbgpt/model/adapter/hf_adapter.py @@ -310,6 +310,20 @@ class QwenAdapter(NewHFChatModelAdapter): and "qwen" in lower_model_name_or_path and "1.5" in lower_model_name_or_path and "moe" not in lower_model_name_or_path + and "qwen2" not in lower_model_name_or_path + ) + + +class Qwen2Adapter(QwenAdapter): + + support_4bit: bool = True + support_8bit: bool = True + + def do_match(self, lower_model_name_or_path: Optional[str] = None): + return ( + lower_model_name_or_path + and "qwen2" in lower_model_name_or_path + and "instruct" in lower_model_name_or_path ) @@ -517,3 +531,4 @@ register_model_adapter(PhiAdapter) register_model_adapter(SQLCoderAdapter) register_model_adapter(OpenChatAdapter) register_model_adapter(GLM4Aapter) +register_model_adapter(Qwen2Adapter)