| 9 | |
| 10 | |
| 11 | class TokenRouter(nn.Module): |
| 12 | def __init__(self, hidden_dim: int, bottleneck_dim: int = 128): |
| 13 | super().__init__() |
| 14 | self.down = nn.Linear(hidden_dim, bottleneck_dim, bias=False) |
| 15 | self.up = nn.Linear(bottleneck_dim, 1, bias=False) |
| 16 | self.act = nn.SiLU() |
| 17 | |
| 18 | def forward(self, hidden_state: torch.Tensor) -> torch.Tensor: |
| 19 | return torch.sigmoid(self.up(self.act(self.down(hidden_state)))).squeeze(-1) |
| 20 | |
| 21 | |
| 22 | @dataclass |
no outgoing calls