ereniko commited on
Commit
47bb023
·
verified ·
1 Parent(s): 3dc0499

Upload Ivme-Coder-v1 (Otter 1): safetensors + custom modeling code

Browse files
Files changed (2) hide show
  1. model/model.py +13 -0
  2. modeling_ivme_coder.py +13 -0
model/model.py CHANGED
@@ -129,6 +129,13 @@ class Block(nn.Module):
129
 
130
  class IvmeCoderV1ForCausalLM(PreTrainedModel, GenerationMixin):
131
  config_class = IvmeCoderConfig
 
 
 
 
 
 
 
132
 
133
  def __init__(self, config):
134
  super().__init__(config)
@@ -160,6 +167,12 @@ class IvmeCoderV1ForCausalLM(PreTrainedModel, GenerationMixin):
160
  def set_input_embeddings(self, value):
161
  self.tok_emb = value
162
 
 
 
 
 
 
 
163
  def forward(self, input_ids, labels=None, use_cache=False, past_key_values=None,
164
  attention_mask=None, **kwargs):
165
  # attention_mask is accepted for API compatibility with tokenizer output /
 
129
 
130
  class IvmeCoderV1ForCausalLM(PreTrainedModel, GenerationMixin):
131
  config_class = IvmeCoderConfig
132
+ # Required so from_pretrained's tie-recovery logic knows how to reconnect
133
+ # head.weight to tok_emb.weight when head.weight is absent from the checkpoint
134
+ # (it's deliberately excluded from the safetensors file, since it's tied storage,
135
+ # not distinct data). Without this, HF's loader treats the missing key as needing
136
+ # fresh random initialization instead of re-tying it - which silently produces a
137
+ # working-looking model with a completely untrained output head.
138
+ _tied_weights_keys = {"head.weight": "tok_emb.weight"}
139
 
140
  def __init__(self, config):
141
  super().__init__(config)
 
167
  def set_input_embeddings(self, value):
168
  self.tok_emb = value
169
 
170
+ def get_output_embeddings(self):
171
+ return self.head
172
+
173
+ def set_output_embeddings(self, value):
174
+ self.head = value
175
+
176
  def forward(self, input_ids, labels=None, use_cache=False, past_key_values=None,
177
  attention_mask=None, **kwargs):
178
  # attention_mask is accepted for API compatibility with tokenizer output /
modeling_ivme_coder.py CHANGED
@@ -129,6 +129,13 @@ class Block(nn.Module):
129
 
130
  class IvmeCoderV1ForCausalLM(PreTrainedModel, GenerationMixin):
131
  config_class = IvmeCoderConfig
 
 
 
 
 
 
 
132
 
133
  def __init__(self, config):
134
  super().__init__(config)
@@ -160,6 +167,12 @@ class IvmeCoderV1ForCausalLM(PreTrainedModel, GenerationMixin):
160
  def set_input_embeddings(self, value):
161
  self.tok_emb = value
162
 
 
 
 
 
 
 
163
  def forward(self, input_ids, labels=None, use_cache=False, past_key_values=None,
164
  attention_mask=None, **kwargs):
165
  # attention_mask is accepted for API compatibility with tokenizer output /
 
129
 
130
  class IvmeCoderV1ForCausalLM(PreTrainedModel, GenerationMixin):
131
  config_class = IvmeCoderConfig
132
+ # Required so from_pretrained's tie-recovery logic knows how to reconnect
133
+ # head.weight to tok_emb.weight when head.weight is absent from the checkpoint
134
+ # (it's deliberately excluded from the safetensors file, since it's tied storage,
135
+ # not distinct data). Without this, HF's loader treats the missing key as needing
136
+ # fresh random initialization instead of re-tying it - which silently produces a
137
+ # working-looking model with a completely untrained output head.
138
+ _tied_weights_keys = {"head.weight": "tok_emb.weight"}
139
 
140
  def __init__(self, config):
141
  super().__init__(config)
 
167
  def set_input_embeddings(self, value):
168
  self.tok_emb = value
169
 
170
+ def get_output_embeddings(self):
171
+ return self.head
172
+
173
+ def set_output_embeddings(self, value):
174
+ self.head = value
175
+
176
  def forward(self, input_ids, labels=None, use_cache=False, past_key_values=None,
177
  attention_mask=None, **kwargs):
178
  # attention_mask is accepted for API compatibility with tokenizer output /