widebluesky commited on
Commit
feb757e
·
verified ·
1 Parent(s): 01ad414

Publish trained tiny LLM base demo-v1 (full fp32, epoch 2)

Browse files
README.md ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ pipeline_tag: text-generation
4
+ tags:
5
+ - advai-notebooks
6
+ - llm-base
7
+ - demo
8
+ - synthetic-data
9
+ - random-initialization
10
+ - full
11
+ - llama
12
+ language:
13
+ - en
14
+ ---
15
+
16
+ # widebluesky/wbs-llm-base-demo
17
+
18
+ ## Demo release v1
19
+
20
+ This is a **trained tiny demo model** for testing training, export, publication,
21
+ download and inference. A tiny Llama architecture was initialized randomly
22
+ and trained for **two epochs** on synthetic fixtures from `advai-notebooks`.
23
+ It is not derived from Meta Llama weights or another pretrained checkpoint.
24
+ It is a workflow placeholder for future domain-trained releases.
25
+ The model has no demonstrated general language or instruction-following capability.
26
+ Generation may be repetitive or incorrect. Synthetic metrics do not establish domain quality.
27
+
28
+ ## Model and training
29
+
30
+ | Setting | Value |
31
+ | --- | --- |
32
+ | Architecture | LlamaForCausalLM; random initialization |
33
+ | Parameters | 13,248 |
34
+ | Layers / hidden size / FFN size | 1 / 32 / 64 |
35
+ | Attention heads / key-value heads | 4 / 2 |
36
+ | Vocabulary / context length | 123 tokens / 128 tokens |
37
+ | Training objective | next-token causal language modeling over document text (continued pre-training) |
38
+ | Method | Full-parameter training; not a LoRA adapter |
39
+ | Epochs completed / selected | 2 / 2 |
40
+ | Selection | Lowest validation token-weighted NLL, including epoch zero; test is report-only |
41
+ | Dataset | 8 training, 2 validation and 2 test synthetic examples |
42
+ | Optimizer / learning rate / weight decay | AdamW / 0.003 / 0.01 |
43
+ | Batch size / gradient accumulation | 2 / 2 |
44
+ | Scheduler / gradient clipping | Constant / 1.0 |
45
+ | Seed / device / precision | 42 / CPU / fp32 |
46
+ | Export | Standalone full safetensors model |
47
+ | SDK versions | Transformers 5.18.0; PyTorch 2.14.1 |
48
+
49
+ Training supervises the next token in each document, including its EOS marker.
50
+ Padding tokens are masked from the loss. A chat template is included as tokenizer
51
+ metadata for compatibility; the Base training objective does not teach chat behavior.
52
+
53
+ ## Synthetic held-out test metrics
54
+
55
+ | Metric | Before training | Selected trained export |
56
+ | --- | ---: | ---: |
57
+ | nll | 4.792373 | 4.695202 |
58
+ | perplexity | 120.587147 | 109.420896 |
59
+
60
+ NLL and perplexity are computed over each task's supervised tokens.
61
+ Base and Instruct perplexity values are not directly comparable because their
62
+ supervision ranges differ. These results use only two synthetic test examples.
63
+
64
+ ## Inference
65
+
66
+ In a checkout of `advai-notebooks`:
67
+
68
+ ```bash
69
+ python -m pip install -e '.[llm-base]'
70
+ ```
71
+
72
+ ```python
73
+ from advai_notebooks.llm.base.model import BaseModel
74
+
75
+ model = BaseModel.load("widebluesky/wbs-llm-base-demo", revision="demo-v1", device="cpu")
76
+ outputs = model.generate(["the sky is"], max_new_tokens=8)
77
+ print(outputs)
78
+ ```
79
+
80
+ The full model also supports native Hugging Face loading:
81
+
82
+ ```python
83
+ from transformers import AutoModelForCausalLM, AutoTokenizer
84
+
85
+ repo_id = "widebluesky/wbs-llm-base-demo"
86
+ model = AutoModelForCausalLM.from_pretrained(repo_id, revision="demo-v1")
87
+ tokenizer = AutoTokenizer.from_pretrained(repo_id, revision="demo-v1")
88
+ ```
89
+
90
+ For Instruct inference, render the exported chat template with an assistant generation
91
+ For Base inference, tokenize the document prompt and generate a continuation.
92
+ Pin the publication commit SHA in `revision` for reproducible deployment.
93
+
94
+ ## Verification and package contents
95
+
96
+ - All 11 stored weight tensors changed from the random baseline.
97
+ - Exported weights exactly match the validation-selected trained checkpoint.
98
+ - Fresh-process reload reproduced test metrics exactly.
99
+ - Native Hugging Face loading and project facade loading produced identical logits.
100
+ - CLI generation/chat and facade API outputs matched.
101
+ - File sizes and SHA256 hashes are recorded in `publish_manifest.json`.
102
+
103
+ The package contains inference weights, architecture and generation configuration,
104
+ tokenizer, chat template, task facade metadata, this English model card and a manifest.
105
+ Raw data, optimizer state, resumable training checkpoints, logs and credentials are excluded.
106
+
107
+ Source implementation commit: `f43a44e2431bae9d0451b445cc3bde5f1e2b8493`.
advai_metadata.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": 1,
3
+ "kind": "llm/base",
4
+ "format": "full",
5
+ "model": {
6
+ "id": "tiny",
7
+ "revision": null,
8
+ "max_len": 128,
9
+ "chat_template": null
10
+ },
11
+ "source": {
12
+ "id": "tiny",
13
+ "revision": null
14
+ },
15
+ "base_model": null,
16
+ "generation": {
17
+ "max_new_tokens": 8,
18
+ "do_sample": false,
19
+ "temperature": 1.0,
20
+ "top_p": 1.0
21
+ }
22
+ }
chat_template.jinja ADDED
@@ -0,0 +1 @@
 
 
1
+ {% for message in messages %}{{ '<|' + message['role'] + '|>\n' }}{% if message['role'] == 'assistant' %}{% generation %}{{ message['content'] + '<|end|>\n' }}{% endgeneration %}{% else %}{{ message['content'] + '<|end|>\n' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '<|assistant|>\n' }}{% endif %}
config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "LlamaForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 2,
8
+ "dtype": "float32",
9
+ "eos_token_id": 3,
10
+ "head_dim": 8,
11
+ "hidden_act": "silu",
12
+ "hidden_size": 32,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 64,
15
+ "max_position_embeddings": 128,
16
+ "mlp_bias": false,
17
+ "model_type": "llama",
18
+ "num_attention_heads": 4,
19
+ "num_hidden_layers": 1,
20
+ "num_key_value_heads": 2,
21
+ "pad_token_id": 0,
22
+ "pretraining_tp": 1,
23
+ "rms_norm_eps": 1e-06,
24
+ "rope_parameters": {
25
+ "rope_theta": 10000.0,
26
+ "rope_type": "default"
27
+ },
28
+ "tie_word_embeddings": true,
29
+ "transformers_version": "5.18.0",
30
+ "use_cache": false,
31
+ "vocab_size": 123
32
+ }
generation_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 2,
4
+ "eos_token_id": [
5
+ 3,
6
+ 7
7
+ ],
8
+ "output_attentions": false,
9
+ "output_hidden_states": false,
10
+ "pad_token_id": 0,
11
+ "transformers_version": "5.18.0",
12
+ "use_cache": true
13
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:35bfeab0f6962e04ef35bb8c9cda4a01f5e9ae9228ae194dd023c682e2a504b6
3
+ size 54104
publish_manifest.json ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": 1,
3
+ "task": "llm/base",
4
+ "files": [
5
+ {
6
+ "path": "README.md",
7
+ "bytes": 4108,
8
+ "sha256": "3dc3ae8c9a46740a4b3bf1f0dcfafd3135e6bff8e997771df22949ca1f3feadc"
9
+ },
10
+ {
11
+ "path": "advai_metadata.json",
12
+ "bytes": 365,
13
+ "sha256": "0e8f8360f8f90b0496fdaf20aa79feef37e89efa4b81ab9ebdb23b53ce8ec837"
14
+ },
15
+ {
16
+ "path": "chat_template.jinja",
17
+ "bytes": 313,
18
+ "sha256": "3fd481918ea6c2894de967ff3f15b13092db403ba035422e44228166e17665af"
19
+ },
20
+ {
21
+ "path": "config.json",
22
+ "bytes": 712,
23
+ "sha256": "a5dbd336ebe6691eb28df7fcd31211f20121104adcc9d36c1cc78f2d90cac3f9"
24
+ },
25
+ {
26
+ "path": "generation_config.json",
27
+ "bytes": 233,
28
+ "sha256": "a6274a69494f96eff68d35f00ea56a6ee6ba54b05244f5091593e2a8612328ef"
29
+ },
30
+ {
31
+ "path": "model.safetensors",
32
+ "bytes": 54104,
33
+ "sha256": "35bfeab0f6962e04ef35bb8c9cda4a01f5e9ae9228ae194dd023c682e2a504b6"
34
+ },
35
+ {
36
+ "path": "tokenizer.json",
37
+ "bytes": 4412,
38
+ "sha256": "445ba332356fb579e90ef463fbceb90a9bdc151a88b8e5c187901db84cbf2048"
39
+ },
40
+ {
41
+ "path": "tokenizer_config.json",
42
+ "bytes": 346,
43
+ "sha256": "e36c2dcb7a856d0c7a55e56f780ac356a1da4b07ed4a16875db39b24f4595e1f"
44
+ }
45
+ ]
46
+ }
tokenizer.json ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "1.0",
3
+ "truncation": null,
4
+ "padding": null,
5
+ "added_tokens": [
6
+ {
7
+ "id": 0,
8
+ "content": "<pad>",
9
+ "single_word": false,
10
+ "lstrip": false,
11
+ "rstrip": false,
12
+ "normalized": false,
13
+ "special": true
14
+ },
15
+ {
16
+ "id": 1,
17
+ "content": "<unk>",
18
+ "single_word": false,
19
+ "lstrip": false,
20
+ "rstrip": false,
21
+ "normalized": false,
22
+ "special": true
23
+ },
24
+ {
25
+ "id": 2,
26
+ "content": "<bos>",
27
+ "single_word": false,
28
+ "lstrip": false,
29
+ "rstrip": false,
30
+ "normalized": false,
31
+ "special": true
32
+ },
33
+ {
34
+ "id": 3,
35
+ "content": "<eos>",
36
+ "single_word": false,
37
+ "lstrip": false,
38
+ "rstrip": false,
39
+ "normalized": false,
40
+ "special": true
41
+ },
42
+ {
43
+ "id": 4,
44
+ "content": "<|system|>",
45
+ "single_word": false,
46
+ "lstrip": false,
47
+ "rstrip": false,
48
+ "normalized": false,
49
+ "special": true
50
+ },
51
+ {
52
+ "id": 5,
53
+ "content": "<|user|>",
54
+ "single_word": false,
55
+ "lstrip": false,
56
+ "rstrip": false,
57
+ "normalized": false,
58
+ "special": true
59
+ },
60
+ {
61
+ "id": 6,
62
+ "content": "<|assistant|>",
63
+ "single_word": false,
64
+ "lstrip": false,
65
+ "rstrip": false,
66
+ "normalized": false,
67
+ "special": true
68
+ },
69
+ {
70
+ "id": 7,
71
+ "content": "<|end|>",
72
+ "single_word": false,
73
+ "lstrip": false,
74
+ "rstrip": false,
75
+ "normalized": false,
76
+ "special": true
77
+ }
78
+ ],
79
+ "normalizer": null,
80
+ "pre_tokenizer": {
81
+ "type": "WhitespaceSplit"
82
+ },
83
+ "post_processor": {
84
+ "type": "TemplateProcessing",
85
+ "single": [
86
+ {
87
+ "Sequence": {
88
+ "id": "A",
89
+ "type_id": 0
90
+ }
91
+ }
92
+ ],
93
+ "pair": [
94
+ {
95
+ "Sequence": {
96
+ "id": "A",
97
+ "type_id": 0
98
+ }
99
+ },
100
+ {
101
+ "Sequence": {
102
+ "id": "B",
103
+ "type_id": 1
104
+ }
105
+ }
106
+ ],
107
+ "special_tokens": {}
108
+ },
109
+ "decoder": null,
110
+ "model": {
111
+ "type": "WordLevel",
112
+ "vocab": {
113
+ "<pad>": 0,
114
+ "<unk>": 1,
115
+ "<bos>": 2,
116
+ "<eos>": 3,
117
+ "<|system|>": 4,
118
+ "<|user|>": 5,
119
+ "<|assistant|>": 6,
120
+ "<|end|>": 7,
121
+ "the": 8,
122
+ "a": 9,
123
+ "is": 10,
124
+ "are": 11,
125
+ "of": 12,
126
+ "to": 13,
127
+ "and": 14,
128
+ "in": 15,
129
+ "for": 16,
130
+ "with": 17,
131
+ "you": 18,
132
+ "your": 19,
133
+ "I": 20,
134
+ "can": 21,
135
+ "please": 22,
136
+ "answer": 23,
137
+ "only": 24,
138
+ "help": 25,
139
+ "account": 26,
140
+ "password": 27,
141
+ "reset": 28,
142
+ "login": 29,
143
+ "email": 30,
144
+ "click": 31,
145
+ "settings": 32,
146
+ "support": 33,
147
+ "change": 34,
148
+ "cancel": 35,
149
+ "subscription": 36,
150
+ "profile": 37,
151
+ "name": 38,
152
+ "update": 39,
153
+ "billing": 40,
154
+ "payment": 41,
155
+ "card": 42,
156
+ "refund": 43,
157
+ "yes": 44,
158
+ "no": 45,
159
+ "true": 46,
160
+ "false": 47,
161
+ "one": 48,
162
+ "two": 49,
163
+ "three": 50,
164
+ "four": 51,
165
+ "1": 52,
166
+ "2": 53,
167
+ "3": 54,
168
+ "4": 55,
169
+ "hello": 56,
170
+ "world": 57,
171
+ "blue": 58,
172
+ "red": 59,
173
+ "green": 60,
174
+ "sky": 61,
175
+ "water": 62,
176
+ "grass": 63,
177
+ "color": 64,
178
+ "what": 65,
179
+ "how": 66,
180
+ "where": 67,
181
+ "why": 68,
182
+ "when": 69,
183
+ "return": 70,
184
+ "JSON": 71,
185
+ "book": 72,
186
+ "read": 73,
187
+ "model": 74,
188
+ "text": 75,
189
+ "train": 76,
190
+ "data": 77,
191
+ "test": 78,
192
+ "validation": 79,
193
+ "document": 80,
194
+ "code": 81,
195
+ "language": 82,
196
+ "learn": 83,
197
+ "cat": 84,
198
+ "dog": 85,
199
+ "animal": 86,
200
+ "bird": 87,
201
+ "fish": 88,
202
+ "flies": 89,
203
+ "swims": 90,
204
+ "runs": 91,
205
+ "capital": 92,
206
+ "France": 93,
207
+ "Paris": 94,
208
+ "Italy": 95,
209
+ "Rome": 96,
210
+ "Germany": 97,
211
+ "Berlin": 98,
212
+ "sun": 99,
213
+ "hot": 100,
214
+ "ice": 101,
215
+ "cold": 102,
216
+ "instruction": 103,
217
+ "question": 104,
218
+ "response": 105,
219
+ "user": 106,
220
+ "assistant": 107,
221
+ "system": 108,
222
+ "explain": 109,
223
+ "compute": 110,
224
+ "add": 111,
225
+ "result": 112,
226
+ "5": 113,
227
+ "6": 114,
228
+ "7": 115,
229
+ "8": 116,
230
+ "9": 117,
231
+ "10": 118,
232
+ ".": 119,
233
+ ",": 120,
234
+ ":": 121,
235
+ "?": 122
236
+ },
237
+ "unk_token": "<unk>"
238
+ }
239
+ }
tokenizer_config.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": "<bos>",
4
+ "eos_token": "<eos>",
5
+ "extra_special_tokens": [
6
+ "<|system|>",
7
+ "<|user|>",
8
+ "<|assistant|>",
9
+ "<|end|>"
10
+ ],
11
+ "is_local": true,
12
+ "local_files_only": false,
13
+ "model_max_length": 128,
14
+ "pad_token": "<pad>",
15
+ "tokenizer_class": "TokenizersBackend",
16
+ "unk_token": "<unk>"
17
+ }