Spaces:
Sleeping
Sleeping
Download models/transformer/module/generator.py from Songyou/LLM-fastAPI: direct link, hf CLI and curl.
- Browser
- Download file 347 Bytes
-
https://huggingface.co/spaces/Songyou/LLM-fastAPI/resolve/main/models/transformer/module/generator.py
- Command line
-
hf download hf://spaces/Songyou/LLM-fastAPI/models/transformer/module/generator.py
-
curl -L -o generator.py https://huggingface.co/spaces/Songyou/LLM-fastAPI/resolve/main/models/transformer/module/generator.py
347 Bytes
| import torch.nn as nn | |
| import torch.nn.functional as F | |
| class Generator(nn.Module): | |
| "Define standard linear + softmax generation step." | |
| def __init__(self, d_model, vocab): | |
| super(Generator, self).__init__() | |
| self.proj = nn.Linear(d_model, vocab) | |
| def forward(self, x): | |
| return F.log_softmax(self.proj(x), dim=-1) | |