chhatramani commited on
Commit
7d52a65
·
verified ·
1 Parent(s): a41c699

Upload trained model and tokenizer

Browse files
configuration_minimalllm.py CHANGED
@@ -1,4 +1,6 @@
1
 
 
 
2
  class MinimalLLMConfig(PretrainedConfig):
3
  model_type = "minimal_llm"
4
 
 
1
 
2
+ from transformers import PretrainedConfig
3
+
4
  class MinimalLLMConfig(PretrainedConfig):
5
  model_type = "minimal_llm"
6
 
modeling_minimalllm.py CHANGED
@@ -44,7 +44,7 @@ class Rotary(nn.Module):
44
 
45
  def forward(self, x_BTHD: torch.Tensor):
46
  assert self.cos.size(0) >= x_BTHD.size(-3)
47
- cos, sin = self.cos[None, :x_BTHD.size(-3), None, :], self.sin[None, :x_BTHD.size(-3), None, :]
48
  x1, x2 = x_BTHD.to(dtype=torch.float32).chunk(2, dim=-1)
49
  y1 = x1 * cos + x2 * sin
50
  y2 = x1 * (-sin) + x2 * cos
@@ -146,6 +146,11 @@ class TransformerBlock(nn.Module):
146
  return x
147
 
148
 
 
 
 
 
 
149
  class MinimalLLMForCausalLM(PreTrainedModel, GenerationMixin):
150
  config_class = MinimalLLMConfig
151
  base_model_prefix = "model"
 
44
 
45
  def forward(self, x_BTHD: torch.Tensor):
46
  assert self.cos.size(0) >= x_BTHD.size(-3)
47
+ cos, sin = self.cos[None, :x_BTHD.size(-3), None, :], self.sin[None, :x_BTHD.size(-3), None, :]
48
  x1, x2 = x_BTHD.to(dtype=torch.float32).chunk(2, dim=-1)
49
  y1 = x1 * cos + x2 * sin
50
  y2 = x1 * (-sin) + x2 * cos
 
146
  return x
147
 
148
 
149
+ from transformers import PreTrainedModel, GenerationMixin
150
+ from transformers.modeling_outputs import CausalLMOutput
151
+ import torch.nn as nn
152
+ import torch.nn.functional as F
153
+
154
  class MinimalLLMForCausalLM(PreTrainedModel, GenerationMixin):
155
  config_class = MinimalLLMConfig
156
  base_model_prefix = "model"