Skip to content

Commit

Permalink
feat(model): Support codegeex4-all-9b (#1720)
Browse files Browse the repository at this point in the history
  • Loading branch information
fangyinc authored Jul 14, 2024
1 parent 125db53 commit e4abd56
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions dbgpt/configs/model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def get_device() -> str:
# 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"),
# https://huggingface.co/THUDM/codegeex4-all-9b
"codegeex4-all-9b": os.path.join(MODEL_PATH, "codegeex4-all-9b"),
"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
23 changes: 20 additions & 3 deletions dbgpt/model/adapter/hf_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ def do_match(self, lower_model_name_or_path: Optional[str] = None):
)


class GLM4Aapter(NewHFChatModelAdapter):
class GLM4Adapter(NewHFChatModelAdapter):
"""
https://huggingface.co/defog/glm-4-8b
https://huggingface.co/THUDM/glm-4-9b-chat
"""

def do_match(self, lower_model_name_or_path: Optional[str] = None):
Expand All @@ -565,6 +565,22 @@ def do_match(self, lower_model_name_or_path: Optional[str] = None):
)


class Codegeex4Adapter(GLM4Adapter):
"""
https://huggingface.co/THUDM/codegeex4-all-9b
"""

def do_match(self, lower_model_name_or_path: Optional[str] = None):
return lower_model_name_or_path and "codegeex4" in lower_model_name_or_path

def load(self, model_path: str, from_pretrained_kwargs: dict):
if not from_pretrained_kwargs:
from_pretrained_kwargs = {}
if "trust_remote_code" not in from_pretrained_kwargs:
from_pretrained_kwargs["trust_remote_code"] = True
return super().load(model_path, from_pretrained_kwargs)


# The following code is used to register the model adapter
# The last registered model adapter is matched first
register_model_adapter(YiAdapter)
Expand All @@ -583,5 +599,6 @@ def do_match(self, lower_model_name_or_path: Optional[str] = None):
register_model_adapter(PhiAdapter)
register_model_adapter(SQLCoderAdapter)
register_model_adapter(OpenChatAdapter)
register_model_adapter(GLM4Aapter)
register_model_adapter(GLM4Adapter)
register_model_adapter(Codegeex4Adapter)
register_model_adapter(Qwen2Adapter)

0 comments on commit e4abd56

Please sign in to comment.