Spaces:
Sleeping
Sleeping
Download models/transformer/module/subsequent_mask.py from Songyou/LLM-fastAPI: direct link, hf CLI and curl.
- Browser
- Download file 254 Bytes
-
https://huggingface.co/spaces/Songyou/LLM-fastAPI/resolve/main/models/transformer/module/subsequent_mask.py
- Command line
-
hf download hf://spaces/Songyou/LLM-fastAPI/models/transformer/module/subsequent_mask.py
-
curl -L -o subsequent_mask.py https://huggingface.co/spaces/Songyou/LLM-fastAPI/resolve/main/models/transformer/module/subsequent_mask.py
254 Bytes
| import numpy as np | |
| import torch | |
| def subsequent_mask(size): | |
| "Mask out subsequent positions." | |
| attn_shape = (1, size, size) | |
| subsequent_mask = np.triu(np.ones(attn_shape), k=1).astype('uint8') | |
| return torch.from_numpy(subsequent_mask) == 0 | |