An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained models.
| 693 | |
| 694 | |
| 695 | class ChatGLMPreTrainedModel(PreTrainedModel): |
| 696 | """ |
| 697 | An abstract class to handle weights initialization and |
| 698 | a simple interface for downloading and loading pretrained models. |
| 699 | """ |
| 700 | |
| 701 | is_parallelizable = True |
| 702 | supports_gradient_checkpointing = True |
| 703 | config_class = ChatGLMConfig |
| 704 | base_model_prefix = "transformer" |
| 705 | _no_split_modules = ["GLM6BBlock"] |
| 706 | |
| 707 | def __init__(self, *inputs, **kwargs): |
| 708 | super().__init__(*inputs, **kwargs) |
| 709 | |
| 710 | def _init_weights(self, module): |
| 711 | return |
| 712 | |
| 713 | def _set_gradient_checkpointing(self, module, value=False): |
| 714 | if isinstance(module, (GLMBlock)): |
| 715 | module.gradient_checkpointing = value |
| 716 | |
| 717 | |
| 718 | CHATGLM_6B_START_DOCSTRING = r""" |
nothing calls this directly
no outgoing calls
no test coverage detected