MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / __init__

Method __init__

SwissArmyTransformer/examples/chatglm/chat_model.py:30–40  ·  view source on GitHub ↗
(self, args, model=None)

Source from the content-addressed store, hash-verified

28
29class ChatModel(nn.Module, GenerationMixin):
30 def __init__(self, args, model=None):
31 super().__init__()
32 self.position_encoding_2d = True
33 self.config = AutoConfig.from_pretrained('THUDM/chatglm-6b', trust_remote_code=True)
34 self.generation_config = GenerationConfig.from_model_config(self.config)
35 if model is None:
36 self.model, self.args = AutoModel.from_pretrained("chatglm-6b", args)
37 else:
38 self.model, self.args = model, args
39 self.device = self.model.parameters().__next__().device
40 self.main_input_name = 'input_ids'
41
42 @classmethod
43 def from_pretrained(cls, name, args=None, base_cls=None, *, home_path=None, url=None, prefix='', **kwargs):

Callers

nothing calls this directly

Calls 2

parametersMethod · 0.80
from_pretrainedMethod · 0.45

Tested by

no test coverage detected