tg-techie-agents commited on
Commit
64c5f64
·
verified ·
1 Parent(s): 61cf87a

lines/mini-chat/latest.json: lines/mini-chat/checkpoints/3843511k (step 96,840)

Browse files
lines.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "lines": [
3
+ {
4
+ "id": "mini",
5
+ "kind": "base",
6
+ "label": "Nirca Mini 0",
7
+ "channels": {
8
+ "latest": "latest.json"
9
+ }
10
+ },
11
+ {
12
+ "id": "mini-chat",
13
+ "kind": "chat",
14
+ "label": "Nirca Mini 0.1 (chat)",
15
+ "channels": {
16
+ "latest": "lines/mini-chat/latest.json"
17
+ }
18
+ }
19
+ ]
20
+ }
lines/mini-chat/README.md ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - ternary
7
+ - mixture-of-experts
8
+ - byte-level
9
+ - chatml
10
+ - webgpu
11
+ - from-scratch
12
+ datasets:
13
+ - HuggingFaceTB/smoltalk
14
+ - open-thoughts/OpenThoughts-114k
15
+ ---
16
+
17
+ # Nirca Mini 0.1 (chat)
18
+
19
+ A chat continuation of Nirca Mini 0: the base model, trained on for one pass over chat data, from step 96,484 (the parent's step 96,467 at the fork) to 96,840; its base line is `latest.json` at the repo root.
20
+
21
+ Nirca Mini is a small chat model trained from scratch, with ternary weights:
22
+ its linear layers' weights are -1, 0 or +1, with a scale and a bias for each
23
+ block of 128 weights. It reads and writes bytes, so it needs no tokenizer. It
24
+ is published as it trains: each new checkpoint replaces `lines/mini-chat/latest/`.
25
+
26
+ - **Small:** about 109 million parameters.
27
+ - Trained from scratch in ternary, with quantization-aware training from almost the very start; the ternary weights were learned in training, not quantized after.
28
+
29
+ Nirca was inspired by [mini-AGI](https://github.com/volotat/mini-AGI), and its architecture is
30
+ deliberately derived from it: Nirca began as a port of mini-AGI to MLX.
31
+
32
+ ➡️ **Try it in your browser (WebGPU):** https://tg-techie-agents.github.io/nirca-mini-webgpu/mini/
33
+
34
+ This card is written by program from the checkpoint's own record, at step
35
+ 96,840 (3,843,511,753 tokens seen).
36
+
37
+ ## Model details
38
+
39
+ - **Type:** decoder-only language model, chat-tuned, with latent recurrence and
40
+ a mixture of experts
41
+ - **Parameters:** about 109 million
42
+ - **Weights:** ternary (-1, 0, +1) with a scale and a bias per block of 128
43
+ (MLX's 2-bit affine layout); norms and a few small layers in floating point
44
+ - **Vocabulary:** 265 tokens: the 256 byte values and 9 special
45
+ tokens
46
+ - **Context length:** 2,048 bytes
47
+ - **Width:** 512, with 8 attention heads and rotary position embeddings
48
+ - **Experts:** 32 in one shared pool, 8 active per token
49
+ - **Recurrence:** one block repeated with learned halting, 1 to 24 passes
50
+ (a mean of 8 in training)
51
+ - **Chat format:** ChatML (`<|im_start|>` / `<|im_end|>`)
52
+ - **Language:** English
53
+
54
+ ## Architecture
55
+
56
+ What it keeps from [mini-AGI](https://github.com/volotat/mini-AGI), and what it changes:
57
+
58
+ - **Kept:** bytes, no tokenizer; latent recurrence; one shared pool of experts
59
+ every pass routes into; a halting head; first pretraining text mini-AGI's
60
+ corpus.
61
+ - **Changed:** ternary weights, trained quantization-aware from step 14,655 of its lineage (its format before that is not recorded);
62
+ tuned on chats; chat format: ChatML instead of mini-AGI's own tags;
63
+ a fixed 32-expert pool where mini-AGI grows and prunes its own.
64
+
65
+ ![Nirca Mini's architecture](architecture.svg)
66
+
67
+ The two dense layers run once. The recurrent block then runs again and again,
68
+ each pass routing into the same pool of experts, and a halting head decides
69
+ per byte when another pass would not change the answer (after PonderNet, Banino
70
+ et al. 2021). Each pass's prediction is weighted by the chance of halting there.
71
+
72
+ ## How to use
73
+
74
+ The [demo](https://tg-techie-agents.github.io/nirca-mini-webgpu/mini/) runs the model in the browser on WebGPU. A page or program
75
+ loads a checkpoint folder by URL:
76
+
77
+ - `lines/mini-chat/latest.json`: the newest checkpoint, its step, tokens seen, shape (`cfg`),
78
+ and each file's URL, size and sha256.
79
+ - `lines/mini-chat/latest/`: the newest checkpoint's files.
80
+ - `lines/mini-chat/checkpoints/<tokens>k/`: every published checkpoint, kept, named by tokens
81
+ seen in thousands.
82
+
83
+ Each folder holds `model.safetensors` (the packed ternary weights) and
84
+ `config.json` (the model's shape and format). Prompts use ChatML:
85
+
86
+ ```
87
+ <|im_start|>user
88
+ Hello!<|im_end|>
89
+ <|im_start|>assistant
90
+ ```
91
+
92
+ ## Training data
93
+
94
+ Across its training, this checkpoint and the runs it was continued from saw:
95
+
96
+ - An open pretraining corpus of text, in the earlier runs this one was continued from.
97
+ - Open chat datasets.
98
+ - An open reasoning dataset.
99
+ - Synthetic chats from open-weight models, written to give the model its character.
100
+ - A small set of private chats, with names, places, contact details and other personal details replaced by placeholders before training.
101
+ - Plus 5 datasets not yet public.
102
+
103
+ Its training data includes text under CC BY 4.0 and CC BY-NC-SA 4.0.
104
+
105
+ ## Data and training workflow
106
+
107
+ Each step is listed because the run's records show it was done:
108
+
109
+ 1. **ChatML.** Every conversation is rendered in ChatML (`<|im_start|>role` … `<|im_end|>`).
110
+ 2. **Splits by content.** Before training, conversations are split into training, validation and test by their content, so one question is never in two splits, and the held-out splits are kept apart from the training machine.
111
+ 3. **Length filter.** Chat sets are cut to conversations whose whole text fits 2,048 bytes, the model's context.
112
+ 4. **Anonymisation.** In the private chats, names, places, contact details and other personal details are replaced by typed placeholders, and the result is scanned again before training.
113
+ 5. **Identifier check.** Synthetic chats that name a known person's identifier are dropped.
114
+ 6. **Decontamination.** A training conversation that shares an exact turn or an 8-gram with a validation or test set is left out (after PaLM's 8-gram overlap test).
115
+ 7. **Loss on the assistant's turns only**, from step 61,181: the model learns to answer, not to write the user's turns.
116
+ 8. **Quantization-aware training in ternary**, from step 14,655 (29,497,375 tokens) on; the steps before it record no weight format. The published weights are the trained ones, not quantized after training.
117
+
118
+ ## Training procedure
119
+
120
+ - **Steps:** 96,840
121
+ - **Tokens seen:** 3,843,511,753 (one token is one byte)
122
+ - **Quantization-aware training:** from step 14,655 of 96,840, so for 99% of its 3,843,511,753 tokens
123
+ - **Objective:** next-byte prediction; on chats, loss on the assistant's turns only
124
+ - **Recurrence:** the number of passes is drawn per step during training, and
125
+ the halting head learns when to stop
126
+
127
+ ## Evaluation
128
+
129
+ No benchmark results are published yet. During training, validation loss is
130
+ measured on held-out conversations that never leave the machine that scores
131
+ them.
132
+
133
+ ## Uses
134
+
135
+ - **Intended:** research and experimentation with small, ternary, recurrent
136
+ models; running a chat model in a browser.
137
+ - **Out of scope:** anything where a wrong answer matters. It is not a source of
138
+ facts or advice, and it has not been through any safety tuning.
139
+
140
+ ## Bias, risks, and limitations
141
+
142
+ It is a small research model, and it is often wrong or incoherent. It may
143
+ repeat biases in its training data. It is trained mostly on English, and it has
144
+ no knowledge of events beyond what its data held. Verify anything it says.
145
+
146
+ ## Citation
147
+
148
+ Nirca Mini's architecture is derived from [mini-AGI](https://github.com/volotat/mini-AGI) (see
149
+ Architecture):
150
+
151
+ ```bibtex
152
+ @misc{volotat_miniagi,
153
+ author = {volotat},
154
+ title = {mini-AGI},
155
+ howpublished = {\url{https://github.com/volotat/mini-AGI}},
156
+ note = {GitHub repository}
157
+ }
158
+ ```
lines/mini-chat/architecture.svg ADDED
lines/mini-chat/latest.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "nirca-mini",
3
+ "step": 96840,
4
+ "quant": "ternary",
5
+ "quant_scope": "all",
6
+ "n_experts": 32,
7
+ "chat_format": "chatml",
8
+ "bytes": 32638048,
9
+ "parameters": 108815393,
10
+ "cfg": {
11
+ "vocab_size": 265,
12
+ "d_model": 512,
13
+ "n_head": 8,
14
+ "d_ff": 1408,
15
+ "block": 2048,
16
+ "rope_theta": 10000.0,
17
+ "tie_embeddings": true,
18
+ "n_prelude": 2,
19
+ "n_recur": 1,
20
+ "n_coda": 0,
21
+ "max_steps": 24,
22
+ "pool_experts": 32,
23
+ "pool_d_ff": 2048,
24
+ "pool_top_k": 8,
25
+ "pool_resident": 32,
26
+ "pool_capacity_factor": 2.25,
27
+ "pool_aux": 0.01,
28
+ "pool_balance": 0.001,
29
+ "min_steps": 1,
30
+ "train_steps_mean": 8.0,
31
+ "train_depth": "halt:8/2/1",
32
+ "bptt_window": 24,
33
+ "ponder_beta": 0.01,
34
+ "halt_prior": 0.072,
35
+ "halt_thresh": 0.9,
36
+ "halt_freeze": true,
37
+ "adam_moments": "bf16",
38
+ "adam_beta2": 0.95,
39
+ "use_pool": true,
40
+ "pool_depth": 1,
41
+ "pool_max": 32
42
+ },
43
+ "tokens": 3843511753,
44
+ "checkpoint": "lines/mini-chat/checkpoints/3843511k/",
45
+ "files": {
46
+ "config.json": {
47
+ "url": "https://huggingface.co/nirca/nirca-mini/resolve/main/lines/mini-chat/checkpoints/3843511k/config.json",
48
+ "sha256": "3b82984b139d262d77461369250af3ae7d3970eb64670c99df82da778be73eaa",
49
+ "bytes": 873
50
+ },
51
+ "model.safetensors": {
52
+ "url": "https://huggingface.co/nirca/nirca-mini/resolve/main/lines/mini-chat/checkpoints/3843511k/model.safetensors",
53
+ "sha256": "393aa705db77592852962ff3afbdda61a8242cfb7bd07316ef9261fa40442922",
54
+ "bytes": 32638048
55
+ }
56
+ }
57
+ }
lines/mini-chat/latest/config.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "nirca-mini",
3
+ "step": 96840,
4
+ "tokens": 3843511753,
5
+ "quant": "ternary",
6
+ "quant_scope": "all",
7
+ "n_experts": 32,
8
+ "chat_format": "chatml",
9
+ "bytes": 32638048,
10
+ "parameters": 108815393,
11
+ "cfg": {
12
+ "vocab_size": 265,
13
+ "d_model": 512,
14
+ "n_head": 8,
15
+ "d_ff": 1408,
16
+ "block": 2048,
17
+ "rope_theta": 10000.0,
18
+ "tie_embeddings": true,
19
+ "n_prelude": 2,
20
+ "n_recur": 1,
21
+ "n_coda": 0,
22
+ "max_steps": 24,
23
+ "pool_experts": 32,
24
+ "pool_d_ff": 2048,
25
+ "pool_top_k": 8,
26
+ "pool_resident": 32,
27
+ "pool_capacity_factor": 2.25,
28
+ "pool_aux": 0.01,
29
+ "pool_balance": 0.001,
30
+ "min_steps": 1,
31
+ "train_steps_mean": 8.0,
32
+ "train_depth": "halt:8/2/1",
33
+ "bptt_window": 24,
34
+ "ponder_beta": 0.01,
35
+ "halt_prior": 0.072,
36
+ "halt_thresh": 0.9,
37
+ "halt_freeze": true,
38
+ "adam_moments": "bf16",
39
+ "adam_beta2": 0.95,
40
+ "use_pool": true,
41
+ "pool_depth": 1,
42
+ "pool_max": 32
43
+ }
44
+ }
lines/mini-chat/latest/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:393aa705db77592852962ff3afbdda61a8242cfb7bd07316ef9261fa40442922
3
+ size 32638048