yujiepan commited on
Commit
5d63f52
1 Parent(s): f09e07c

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ pipeline_tag: text-generation
4
+ inference: true
5
+ widget:
6
+ - text: Hello!
7
+ example_title: Hello world
8
+ group: Python
9
+ ---
10
+
11
+ This model is for debugging. It is randomly initialized using the config from [tiiuae/falcon-mamba-7b](https://huggingface.co/tiiuae/falcon-mamba-7b) but with smaller size.
12
+
13
+ Codes:
14
+ ```python
15
+ import os
16
+
17
+ import torch
18
+
19
+ from huggingface_hub import create_repo, upload_folder
20
+ from transformers import (
21
+ AutoModelForCausalLM,
22
+ AutoTokenizer,
23
+ GenerationConfig,
24
+ AutoConfig,
25
+ pipeline,
26
+ set_seed,
27
+ )
28
+
29
+ model_id = "tiiuae/falcon-mamba-7b"
30
+ repo_id = "yujiepan/falcon-mamba-tiny-random"
31
+ save_path = f"/tmp/{repo_id}"
32
+ os.system(f'rm -rf {save_path}')
33
+
34
+ config = AutoConfig.from_pretrained(model_id)
35
+ config.use_cache = True
36
+ config.num_hidden_layers = 2
37
+ config.hidden_size = 8
38
+ config.intermediate_size = 16
39
+ config.state_size = 8
40
+
41
+ tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
42
+ tokenizer.save_pretrained(save_path)
43
+
44
+ model = AutoModelForCausalLM.from_config(
45
+ config, torch_dtype=torch.bfloat16,
46
+ trust_remote_code=True,
47
+ )
48
+ model.generation_config = GenerationConfig.from_pretrained(
49
+ model_id,
50
+ trust_remote_code=True,
51
+ )
52
+
53
+ set_seed(42)
54
+ num_params = 0
55
+ with torch.no_grad():
56
+ for name, p in sorted(model.named_parameters()):
57
+ print(name, p.shape)
58
+ torch.nn.init.uniform_(p, -0.5, 0.5)
59
+ num_params += p.numel()
60
+ print("Total number of parameters:", num_params)
61
+ model.save_pretrained(save_path)
62
+
63
+ pipe = pipeline(
64
+ "text-generation",
65
+ model=save_path,
66
+ device="cpu",
67
+ trust_remote_code=True,
68
+ max_new_tokens=20,
69
+ )
70
+ print(pipe("Hello World!"))
71
+
72
+ # create_repo(repo_id, exist_ok=True)
73
+ # upload_folder(repo_id=repo_id, folder_path=save_path, repo_type='model')
74
+ ```
config.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "tiiuae/falcon-mamba-7b",
3
+ "architectures": [
4
+ "FalconMambaForCausalLM"
5
+ ],
6
+ "bos_token_id": 0,
7
+ "conv_kernel": 4,
8
+ "eos_token_id": 11,
9
+ "expand": 16,
10
+ "hidden_act": "silu",
11
+ "hidden_size": 8,
12
+ "initializer_range": 0.1,
13
+ "intermediate_size": 16,
14
+ "layer_norm_epsilon": 1e-05,
15
+ "mixer_rms_eps": 1e-06,
16
+ "model_type": "falcon_mamba",
17
+ "num_hidden_layers": 2,
18
+ "pad_token_id": 11,
19
+ "rescale_prenorm_residual": false,
20
+ "residual_in_fp32": true,
21
+ "state_size": 8,
22
+ "tie_word_embeddings": false,
23
+ "time_step_floor": 0.0001,
24
+ "time_step_init_scheme": "random",
25
+ "time_step_max": 0.1,
26
+ "time_step_min": 0.001,
27
+ "time_step_rank": 256,
28
+ "time_step_scale": 1.0,
29
+ "torch_dtype": "bfloat16",
30
+ "transformers_version": "4.45.0",
31
+ "use_bias": false,
32
+ "use_cache": true,
33
+ "use_conv_bias": true,
34
+ "use_mambapy": false,
35
+ "vocab_size": 65024
36
+ }
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": 11,
5
+ "pad_token_id": 11,
6
+ "transformers_version": "4.45.0"
7
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c906d1cda0ef7996efab32cf97b7394d6241c4a575bfc3eedd926cbcc2454a30
3
+ size 2119944
special_tokens_map.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ ">>TITLE<<",
4
+ ">>ABSTRACT<<",
5
+ ">>INTRODUCTION<<",
6
+ ">>SUMMARY<<",
7
+ ">>COMMENT<<",
8
+ ">>ANSWER<<",
9
+ ">>QUESTION<<",
10
+ ">>DOMAIN<<",
11
+ ">>PREFIX<<",
12
+ ">>SUFFIX<<",
13
+ ">>MIDDLE<<"
14
+ ],
15
+ "eos_token": {
16
+ "content": "<|endoftext|>",
17
+ "lstrip": false,
18
+ "normalized": false,
19
+ "rstrip": false,
20
+ "single_word": false
21
+ }
22
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": ">>TITLE<<",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": ">>ABSTRACT<<",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": ">>INTRODUCTION<<",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": ">>SUMMARY<<",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "4": {
37
+ "content": ">>COMMENT<<",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ },
44
+ "5": {
45
+ "content": ">>ANSWER<<",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "6": {
53
+ "content": ">>QUESTION<<",
54
+ "lstrip": false,
55
+ "normalized": false,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": true
59
+ },
60
+ "7": {
61
+ "content": ">>DOMAIN<<",
62
+ "lstrip": false,
63
+ "normalized": false,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": true
67
+ },
68
+ "8": {
69
+ "content": ">>PREFIX<<",
70
+ "lstrip": false,
71
+ "normalized": false,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": true
75
+ },
76
+ "9": {
77
+ "content": ">>SUFFIX<<",
78
+ "lstrip": false,
79
+ "normalized": false,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": true
83
+ },
84
+ "10": {
85
+ "content": ">>MIDDLE<<",
86
+ "lstrip": false,
87
+ "normalized": false,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": true
91
+ },
92
+ "11": {
93
+ "content": "<|endoftext|>",
94
+ "lstrip": false,
95
+ "normalized": false,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": true
99
+ }
100
+ },
101
+ "additional_special_tokens": [
102
+ ">>TITLE<<",
103
+ ">>ABSTRACT<<",
104
+ ">>INTRODUCTION<<",
105
+ ">>SUMMARY<<",
106
+ ">>COMMENT<<",
107
+ ">>ANSWER<<",
108
+ ">>QUESTION<<",
109
+ ">>DOMAIN<<",
110
+ ">>PREFIX<<",
111
+ ">>SUFFIX<<",
112
+ ">>MIDDLE<<"
113
+ ],
114
+ "clean_up_tokenization_spaces": true,
115
+ "eos_token": "<|endoftext|>",
116
+ "model_input_names": [
117
+ "input_ids",
118
+ "attention_mask"
119
+ ],
120
+ "model_max_length": 1000000000000000019884624838656,
121
+ "padding_side": "left",
122
+ "tokenizer_class": "PreTrainedTokenizerFast"
123
+ }