luxfer / runtime /embeddings /token.py
mdxss's picture
Publish Luxfer early beta with runnable weights and language metadata
7b6f2cc verified
Raw History Blame Contribute Delete
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