Skip to content

Commit

Permalink
feat(model): Support Qwen2 models (#1612)
Browse files Browse the repository at this point in the history
  • Loading branch information
fangyinc authored Jun 6, 2024
1 parent 20e7ccc commit e11087a
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
37 changes: 37 additions & 0 deletions dbgpt/configs/model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def get_device() -> str:
"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"),
Expand Down Expand Up @@ -124,6 +125,42 @@ def get_device() -> str:
"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
Expand Down
15 changes: 15 additions & 0 deletions dbgpt/model/adapter/hf_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,20 @@ def do_match(self, lower_model_name_or_path: Optional[str] = None):
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
)


Expand Down Expand Up @@ -517,3 +531,4 @@ def do_match(self, lower_model_name_or_path: Optional[str] = None):
register_model_adapter(SQLCoderAdapter)
register_model_adapter(OpenChatAdapter)
register_model_adapter(GLM4Aapter)
register_model_adapter(Qwen2Adapter)

0 comments on commit e11087a

Please sign in to comment.