Download runtime/embeddings/token.py from hscr/luxfer: direct link, hf CLI and curl.
- Browser
- Download file 723 Bytes
-
https://huggingface.co/hscr/luxfer/resolve/main/runtime/embeddings/token.py
- Command line
-
hf download hf://hscr/luxfer/runtime/embeddings/token.py
-
curl -L -o token.py https://huggingface.co/hscr/luxfer/resolve/main/runtime/embeddings/token.py
723 Bytes
| # Derived from PFN PLaMo; see docs/LICENSING.md. | |
| import enum | |
| import math | |
| import warnings | |
| from typing import Any, Dict, List, Literal, NamedTuple, Optional, Tuple, Union | |
| import torch | |
| from torch import nn | |
| from torch.nn import functional as F | |
| from transformers import GenerationMixin, PretrainedConfig, PreTrainedModel | |
| from transformers.cache_utils import DynamicCache | |
| from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast | |
| class LuxferEmbedding(nn.Embedding): | |
| def forward(self, x: torch.Tensor) -> torch.Tensor: | |
| y = super().forward(x) | |
| return y * (self.embedding_dim**0.5) | |
| # Legacy source aliases; canonical public names use Luxfer. | |
| Plamo3Embedding = LuxferEmbedding | |