denizyuret-shallowai commited on
Commit
c4c6d7d
1 Parent(s): ded60ae

Upload model

Browse files
Files changed (4) hide show
  1. config.json +32 -0
  2. generation_config.json +6 -0
  3. modeling_custom.py +25 -0
  4. pytorch_model.bin +3 -0
config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "EleutherAI/pythia-70m",
3
+ "architectures": [
4
+ "CustomModel"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoModelForCausalLM": "modeling_custom.CustomModel"
9
+ },
10
+ "bos_token_id": 0,
11
+ "classifier_dropout": 0.1,
12
+ "eos_token_id": 0,
13
+ "hidden_act": "gelu",
14
+ "hidden_dropout": 0.0,
15
+ "hidden_size": 512,
16
+ "initializer_range": 0.02,
17
+ "intermediate_size": 2048,
18
+ "layer_norm_eps": 1e-05,
19
+ "max_position_embeddings": 2048,
20
+ "model_type": "gpt_neox",
21
+ "num_attention_heads": 8,
22
+ "num_hidden_layers": 6,
23
+ "rope_scaling": null,
24
+ "rotary_emb_base": 10000,
25
+ "rotary_pct": 0.25,
26
+ "tie_word_embeddings": false,
27
+ "torch_dtype": "float32",
28
+ "transformers_version": "4.31.0",
29
+ "use_cache": true,
30
+ "use_parallel_residual": true,
31
+ "vocab_size": 50304
32
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": 0,
5
+ "transformers_version": "4.31.0"
6
+ }
modeling_custom.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # https://huggingface.co/docs/transformers/custom_models
2
+
3
+ from transformers import PreTrainedModel, GPTNeoXForCausalLM, AutoModelForCausalLM
4
+ from torch.nn.functional import log_softmax
5
+
6
+ # In the example there is also config class but we'll just use the one from GPTNeoX
7
+ # The norm is to import from PreTrainedModel but we'll take a shortcut
8
+ class CustomModel(GPTNeoXForCausalLM):
9
+ def __init__(self, config):
10
+ super().__init__(config)
11
+
12
+ def forward(self, *args, **kwargs):
13
+ # See https://huggingface.co/docs/transformers/main_classes/output
14
+ out = super().forward(*args, **kwargs)
15
+ out.logits = log_softmax(out.logits, dim=-1)
16
+ return out
17
+
18
+ @classmethod
19
+ def copy_from_neox(cls, *args, **kwargs):
20
+ m0 = GPTNeoXForCausalLM.from_pretrained(*args, **kwargs)
21
+ m1 = cls(m0.config)
22
+ m1.load_state_dict(m0.state_dict())
23
+ return m1
24
+
25
+ CustomModel.register_for_auto_class('AutoModelForCausalLM')
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3e4128420302e58c85fc79e4553c320c270cab3169bc72310bdf2b5b75032a6d
3
+ size 281732711