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

Method __init__

SwissArmyTransformer/examples/chatglm2/chat_model.py:30–39  ·  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.config = AutoConfig.from_pretrained('THUDM/chatglm2-6b', trust_remote_code=True)
33 self.generation_config = GenerationConfig.from_model_config(self.config)
34 if model is None:
35 self.model, self.args = AutoModel.from_pretrained("chatglm2-6b", args)
36 else:
37 self.model, self.args = model, args
38 self.device = self.model.parameters().__next__().device
39 self.main_input_name = 'input_ids'
40
41 @classmethod
42 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