MCPcopy Create free account
hub / github.com/Tele-AI/Telechat / TelechatMLP

Class TelechatMLP

models/7B_4bit/modeling_telechat.py:493–505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

491
492
493class TelechatMLP(nn.Module):
494 def __init__(self, config: TelechatConfig):
495 super().__init__()
496 hidden_size = config.hidden_size
497 self.gate_proj = nn.Linear(hidden_size, config.ffn_hidden_size, bias=False)
498 self.up_proj = nn.Linear(hidden_size, config.ffn_hidden_size, bias=False)
499 self.down_proj = nn.Linear(config.ffn_hidden_size, hidden_size, bias=True)
500 self.hidden_dropout = config.hidden_dropout
501
502 def forward(self, hidden_states: torch.Tensor, residual: torch.Tensor) -> torch.Tensor:
503 intermediate_output = self.down_proj(F.silu(self.gate_proj(hidden_states)) * self.up_proj(hidden_states))
504 output = dropout_add(intermediate_output, residual, self.hidden_dropout, self.training)
505 return output
506
507
508class TelechatBlock(nn.Module):

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected