-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update configuration of chatglm and add support in coati
- Loading branch information
1 parent
ff83679
commit 2f492fa
Showing
7 changed files
with
2,070 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .chatglm_actor import ChatGLMActor | ||
|
||
__all__ = ['ChatGLMActor'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from typing import Optional | ||
|
||
import torch | ||
from .configuration_chatglm import ChatGLMConfig | ||
from .modeling_chatglm import ChatGLMForConditionalGeneration | ||
|
||
from ..base import Actor | ||
|
||
|
||
class ChatGLMActor(Actor): | ||
""" | ||
ChatGLM Actor model. | ||
Args: | ||
pretrained (str): Pretrained model name or path. | ||
config (ChatGLMConfig): Model config. | ||
checkpoint (bool): Enable gradient checkpointing. | ||
do not support lora for now. | ||
""" | ||
|
||
def __init__(self, | ||
pretrained: str = None, | ||
config: Optional[ChatGLMConfig] = None, | ||
checkpoint: bool = False) -> None: | ||
if pretrained is not None: | ||
model = ChatGLMForConditionalGeneration.from_pretrained(pretrained) | ||
elif config is not None: | ||
model = ChatGLMForConditionalGeneration(config) | ||
else: | ||
model = ChatGLMForConditionalGeneration(ChatGLMConfig()) | ||
if checkpoint: | ||
model.gradient_checkpointing_enable() | ||
super().__init__(model, lora_rank=0, lora_train_bias='none') |
Oops, something went wrong.