sohv commited on
Commit
5c92b9a
·
verified ·
1 Parent(s): 2df3070

Upload HF wrapper

Browse files
Files changed (1) hide show
  1. modeling_kimik2.py +29 -0
modeling_kimik2.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Minimal HuggingFace wrapper for KimiK2 model recognition
3
+ """
4
+ import torch
5
+ from transformers import PreTrainedModel, PretrainedConfig
6
+ from transformers.modeling_outputs import CausalLMOutputWithPast
7
+
8
+
9
+ class KimiK2Config(PretrainedConfig):
10
+ model_type = "kimi-k2"
11
+
12
+ def __init__(self, **kwargs):
13
+ super().__init__(**kwargs)
14
+
15
+
16
+ class KimiK2ForCausalLM(PreTrainedModel):
17
+ config_class = KimiK2Config
18
+
19
+ def __init__(self, config):
20
+ super().__init__(config)
21
+ # This is just for HF recognition - actual loading happens via direct PyTorch
22
+ print("Note: Use the direct PyTorch loading method shown in the README for this model.")
23
+
24
+ def forward(self, input_ids, **kwargs):
25
+ # Placeholder for HF compatibility
26
+ batch_size, seq_len = input_ids.shape
27
+ vocab_size = getattr(self.config, 'vocab_size', 50304)
28
+ logits = torch.randn(batch_size, seq_len, vocab_size)
29
+ return CausalLMOutputWithPast(logits=logits)