Skip to content

Commit acd76ba

Browse files
authored
feat(model): Support glm-4-9b-chat (#1602)
1 parent 43b5821 commit acd76ba

File tree

5 files changed

+28
-2
lines changed

5 files changed

+28
-2
lines changed

README.ja.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ DB-GPTのアーキテクチャは以下の図に示されています:
154154
私たちは、LLaMA/LLaMA2、Baichuan、ChatGLM、Wenxin、Tongyi、Zhipuなど、オープンソースおよびAPIエージェントからの数十の大規模言語モデル(LLM)を含む幅広いモデルをサポートしています。
155155

156156
- ニュース
157+
- 🔥🔥🔥 [glm-4-9b-chat](https://huggingface.co/THUDM/glm-4-9b-chat)
157158
- 🔥🔥🔥 [Phi-3](https://huggingface.co/collections/microsoft/phi-3-6626e15e9585a200d2d761e3)
158159
- 🔥🔥🔥 [Yi-1.5-34B-Chat](https://huggingface.co/01-ai/Yi-1.5-34B-Chat)
159160
- 🔥🔥🔥 [Yi-1.5-9B-Chat](https://huggingface.co/01-ai/Yi-1.5-9B-Chat)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ At present, we have introduced several key features to showcase our current capa
158158
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.
159159

160160
- News
161+
- 🔥🔥🔥 [glm-4-9b-chat](https://huggingface.co/THUDM/glm-4-9b-chat)
161162
- 🔥🔥🔥 [Phi-3](https://huggingface.co/collections/microsoft/phi-3-6626e15e9585a200d2d761e3)
162163
- 🔥🔥🔥 [Yi-1.5-34B-Chat](https://huggingface.co/01-ai/Yi-1.5-34B-Chat)
163164
- 🔥🔥🔥 [Yi-1.5-9B-Chat](https://huggingface.co/01-ai/Yi-1.5-9B-Chat)

README.zh.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
海量模型支持,包括开源、API代理等几十种大语言模型。如LLaMA/LLaMA2、Baichuan、ChatGLM、文心、通义、智谱等。当前已支持如下模型:
153153

154154
- 新增支持模型
155+
- 🔥🔥🔥 [glm-4-9b-chat](https://huggingface.co/THUDM/glm-4-9b-chat)
155156
- 🔥🔥🔥 [Phi-3](https://huggingface.co/collections/microsoft/phi-3-6626e15e9585a200d2d761e3)
156157
- 🔥🔥🔥 [Yi-1.5-34B-Chat](https://huggingface.co/01-ai/Yi-1.5-34B-Chat)
157158
- 🔥🔥🔥 [Yi-1.5-9B-Chat](https://huggingface.co/01-ai/Yi-1.5-9B-Chat)

dbgpt/configs/model_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def get_device() -> str:
5252
"chatglm2-6b-int4": os.path.join(MODEL_PATH, "chatglm2-6b-int4"),
5353
# https://huggingface.co/THUDM/chatglm3-6b
5454
"chatglm3-6b": os.path.join(MODEL_PATH, "chatglm3-6b"),
55+
# https://huggingface.co/THUDM/glm-4-9b-chat
56+
"glm-4-9b-chat": os.path.join(MODEL_PATH, "glm-4-9b-chat"),
5557
"guanaco-33b-merged": os.path.join(MODEL_PATH, "guanaco-33b-merged"),
5658
"falcon-40b": os.path.join(MODEL_PATH, "falcon-40b"),
5759
"gorilla-7b": os.path.join(MODEL_PATH, "gorilla-7b"),

dbgpt/model/adapter/hf_adapter.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class NewHFChatModelAdapter(LLMModelAdapter, ABC):
1818
prompt template for this model
1919
"""
2020

21+
trust_remote_code: bool = True
22+
2123
def new_adapter(self, **kwargs) -> "NewHFChatModelAdapter":
2224
return self.__class__()
2325

@@ -77,13 +79,18 @@ def load(self, model_path: str, from_pretrained_kwargs: dict):
7779
model_path,
7880
use_fast=self.use_fast_tokenizer(),
7981
revision=revision,
80-
trust_remote_code=True,
82+
trust_remote_code=self.trust_remote_code,
8183
)
8284
except TypeError:
8385
tokenizer = AutoTokenizer.from_pretrained(
84-
model_path, use_fast=False, revision=revision, trust_remote_code=True
86+
model_path,
87+
use_fast=False,
88+
revision=revision,
89+
trust_remote_code=self.trust_remote_code,
8590
)
8691
try:
92+
if "trust_remote_code" not in from_pretrained_kwargs:
93+
from_pretrained_kwargs["trust_remote_code"] = self.trust_remote_code
8794
model = AutoModelForCausalLM.from_pretrained(
8895
model_path, low_cpu_mem_usage=True, **from_pretrained_kwargs
8996
)
@@ -480,6 +487,19 @@ def do_match(self, lower_model_name_or_path: Optional[str] = None):
480487
)
481488

482489

490+
class GLM4Aapter(NewHFChatModelAdapter):
491+
"""
492+
https://huggingface.co/defog/glm-4-8b
493+
"""
494+
495+
def do_match(self, lower_model_name_or_path: Optional[str] = None):
496+
return (
497+
lower_model_name_or_path
498+
and "glm-4" in lower_model_name_or_path
499+
and "chat" in lower_model_name_or_path
500+
)
501+
502+
483503
# The following code is used to register the model adapter
484504
# The last registered model adapter is matched first
485505
register_model_adapter(YiAdapter)
@@ -496,3 +516,4 @@ def do_match(self, lower_model_name_or_path: Optional[str] = None):
496516
register_model_adapter(PhiAdapter)
497517
register_model_adapter(SQLCoderAdapter)
498518
register_model_adapter(OpenChatAdapter)
519+
register_model_adapter(GLM4Aapter)

0 commit comments

Comments
 (0)