MCPcopy Create free account
hub / github.com/FreedomIntelligence/CMB / __init__

Method __init__

workers/chatglm3_modeling.py:68–82  ·  view source on GitHub ↗
(self, config: ChatGLMConfig)

Source from the content-addressed store, hash-verified

66 """
67
68 def __init__(self, config: ChatGLMConfig):
69 super().__init__()
70 self.prefix_projection = config.prefix_projection
71 if self.prefix_projection:
72 # Use a two-layer MLP to encode the prefix
73 kv_size = config.num_layers * config.kv_channels * config.multi_query_group_num * 2
74 self.embedding = torch.nn.Embedding(config.pre_seq_len, kv_size)
75 self.trans = torch.nn.Sequential(
76 torch.nn.Linear(kv_size, config.hidden_size),
77 torch.nn.Tanh(),
78 torch.nn.Linear(config.hidden_size, kv_size)
79 )
80 else:
81 self.embedding = torch.nn.Embedding(config.pre_seq_len,
82 config.num_layers * config.kv_channels * config.multi_query_group_num * 2)
83
84 def forward(self, prefix: torch.Tensor):
85 if self.prefix_projection:

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected