Downloads · 30 days
17
7% of all-time downloads
George-Ogden/gptr2-nano-without-momentum-without-weight-decay
gptr2-nano-without-momentum-without-weight-decay is a machine learning model from George-Ogden. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as mit.
This model is significantly undertrained and designed for research purposes only. For use in transformers:
Downloads · 30 days
17
7% of all-time downloads
All-time downloads
248
Public
Repo size
71.5 MB
Likes
1
Public
Click a slice to open those files.
.bin71.5 MB · 96%
From the Hugging Face model README
This model is significantly undertrained and designed for research purposes only.
For use in transformers:
from transformers import AutoTokenizer, GPT2Model
import torch.nn as nn
import torch
class RMSLayerNorm(nn.Module):
def __init__(self, normalized_shape, eps=1e-8, affine=True):
super(RMSLayerNorm, self).__init__()
self.normalized_shape = normalized_shape
self.eps = eps
self.affine = affine
if self.affine:
self.weight = nn.Parameter(torch.ones(()))
else:
self.register_parameter('weight', None)
self.register_parameter('bias', None)
def forward(self, x):
rms = torch.sqrt(torch.mean(x**2, dim=-1, keepdim=True) + self.eps)
x_normalized = x / rms
if self.affine:
x_normalized = x_normalized * self.weight
return x_normalized
def replace(model):
for name, child in model.named_children():
if isinstance(child, nn.modules.normalization.LayerNorm):
setattr(model, name, RMSLayerNorm(child.normalized_shape, eps=child.eps, affine=True))
else:
replace(child)
return model
class GPTR2Model(GPT2Model):
def __init__(self, config):
super().__init__(config)
replace(self)
model = GPTR2Model.from_pretrained("George-Ogden/gptr2-nano-without-momentum-without-weight-decay")
tokenizer = AutoTokenizer.from_pretrained("gpt2")
For more details and example usage, see https://github.com/George-Ogden/residual-streams