Download custom_embedding.py from luisfrentzen/pathpiecel_initbpe_firstspace_1_49152: direct link, hf CLI and curl.
- Browser
- Download file 315 Bytes
-
https://huggingface.co/luisfrentzen/pathpiecel_initbpe_firstspace_1_49152/resolve/main/custom_embedding.py
- Command line
-
hf download hf://luisfrentzen/pathpiecel_initbpe_firstspace_1_49152/custom_embedding.py
-
curl -L -o custom_embedding.py https://huggingface.co/luisfrentzen/pathpiecel_initbpe_firstspace_1_49152/resolve/main/custom_embedding.py
315 Bytes
| import torch | |
| import torch.nn as nn | |
| import torch.nn.functional as F | |
| from torch import Tensor | |
| class SharedEmbedding(nn.Embedding): | |
| def forward(self, input: Tensor, unembed: bool=False) -> Tensor: | |
| if unembed: | |
| return F.linear(input, self.weight) | |
| return super().forward(input) |