wop commited on
Commit
7a10347
·
verified ·
1 Parent(s): bf5e2cd

Initial preview release: model checkpoints, history, config, README

Browse files
Cosmos-T2-Accelerate-Preview.best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b589fecdc2725c74cc9d038a46ac6e50d6768bc0c589d56071f4a6c685381e96
3
+ size 41362459
Cosmos-T2-Accelerate-Preview.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f0af6d26bef0e642b95a43696ce51646c0c674a08cd4c9253a87b26e616f38f
3
+ size 41466105
README.md ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ library_name: transformers
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - chain-of-thought
9
+ - reasoning
10
+ - instruct
11
+ - pretrained-from-scratch
12
+ - decoder-only
13
+ - transformer
14
+ - qwen-tokenizer
15
+ - rope
16
+ - rmsnorm
17
+ - swiglu
18
+ - gqa
19
+ - engram
20
+ - preview
21
+ datasets:
22
+ - wop/XXXXXL-chain-of-thought
23
+ model-index:
24
+ - name: Cosmos-T2-Accelerate-Preview
25
+ results:
26
+ - task:
27
+ type: text-generation
28
+ name: Causal Language Modeling
29
+ dataset:
30
+ name: wop/XXXXXL-chain-of-thought
31
+ type: wop/XXXXXL-chain-of-thought
32
+ split: train
33
+ metrics:
34
+ - type: loss
35
+ name: Final training loss (cross-entropy)
36
+ value: 2.2055
37
+ - type: perplexity
38
+ name: Final training perplexity
39
+ value: 9.08
40
+ - type: loss
41
+ name: Final validation loss (cross-entropy)
42
+ value: 2.3608
43
+ - type: perplexity
44
+ name: Final validation perplexity
45
+ value: 10.60
46
+ ---
47
+
48
+ <img src="https://calm-heart-d697.mmmmmm505090.workers.dev?text=Cosmos-T2-Accelerate-Preview" width="900" alt="Cosmos-T2-Accelerate-Preview" />
49
+
50
+ # Cosmos-T2-Accelerate-Preview
51
+
52
+ A **preview** release of the Cosmos-T2-Accelerate series — a tiny decoder-only Transformer trained from scratch on chain-of-thought data, produced by the universal Cosmos-T2-Accelerate Kaggle training notebook.
53
+
54
+ > ⚠️ **Preview / research checkpoint.** Tiny (≈10M params, `d_model=64`, 4 layers). It will hallucinate freely and locks into the `<think>…</think> Answer: N` GSM8K-style template. Use it to study the architecture and the training recipe, not for production.
55
+
56
+ ## Try it
57
+
58
+ 🚀 **Live demo:** [`wop/Cosmos-T2-Accelerate-Preview-DEMO`](https://huggingface.co/spaces/wop/Cosmos-T2-Accelerate-Preview-DEMO)
59
+
60
+ ## Model Details
61
+
62
+ | | |
63
+ |---|---|
64
+ | **Model class** | `CosmosT2_Accelerate_LLM` |
65
+ | **Architecture** | Decoder-only Transformer with RoPE, RMSNorm, SwiGLU, GQA, and a configurable Engram memory path |
66
+ | **Parameters** | `~9.96 M` |
67
+ | **Layers** | `4` |
68
+ | **Attention heads** | `4` |
69
+ | **KV heads** | `1` (GQA) |
70
+ | **d_model** | `64` |
71
+ | **FFN hidden** | `256` |
72
+ | **Positional encoding** | RoPE (`rope_base=10000`, NeoX-style interleaved) |
73
+ | **Normalization** | RMSNorm |
74
+ | **MLP** | SwiGLU |
75
+ | **Memory** | Engram (`use_engram=True`, every `2` blocks, `128` buckets, `dim=16`, `order=3`) |
76
+ | **Context length** | `1028` |
77
+ | **Training block size** | `1028` |
78
+ | **Tokenizer** | [`Qwen/Qwen2.5-0.5B`](https://huggingface.co/Qwen/Qwen2.5-0.5B) |
79
+ | **Vocab size** | `151665` |
80
+ | **Dataset** | [`wop/XXXXXL-chain-of-thought`](https://huggingface.co/datasets/wop/XXXXXL-chain-of-thought) |
81
+ | **License** | Apache-2.0 |
82
+
83
+ ### Why these choices
84
+
85
+ - **RoPE** keeps positional handling compact and avoids learned absolute embeddings.
86
+ - **RMSNorm** is cheaper and more stable than LayerNorm for this small decoder-only model.
87
+ - **SwiGLU** usually gives a better quality/compute tradeoff than a plain GELU MLP.
88
+ - **GQA** reduces KV cost while keeping multi-head query capacity.
89
+ - **Engram** gives the stack a lightweight explicit memory path for repeated reasoning patterns.
90
+
91
+ ## Training Summary
92
+
93
+ | Metric | Value |
94
+ |---|---|
95
+ | Rows used | `10,000` |
96
+ | Approx. packed tokens (after padding) | `461,150,000+` (50 epochs × 75 000 steps × 1 028 tokens/step ≈ `462.1M` total trained tokens) |
97
+ | Epochs | `50` |
98
+ | Batch size | `6` |
99
+ | Peak LR | `3e-4` |
100
+ | Weight decay | `0.1` |
101
+ | Warmup steps | `50` |
102
+ | Gradient clipping | `1.0` |
103
+ | Wall-clock time | `4h 58m 00s` on 2× T4 (Kaggle) |
104
+ | **Final training loss** | `2.2055` |
105
+ | **Final training perplexity** | `9.08` |
106
+ | **Final validation loss** | `2.3608` |
107
+ | **Final validation perplexity** | `10.60` |
108
+ | **Best validation loss** | `2.3585` |
109
+ | **Best epoch** | `47` |
110
+
111
+ `history.json` contains the full step-level and epoch-level training/validation curves.
112
+
113
+ ## Files in this repo
114
+
115
+ | File | Description |
116
+ |---|---|
117
+ | `Cosmos-T2-Accelerate-Preview.pt` | Final-epoch checkpoint (epoch 50). |
118
+ | `Cosmos-T2-Accelerate-Preview.best.pt` | Best-validation checkpoint (epoch 47). Recommended. |
119
+ | `model_config.json` | Full architecture + training config. |
120
+ | `history.json` | Step-level + epoch-level loss/ppl curves and final metrics. |
121
+ | `README.md` | This file. |
122
+
123
+ Both `.pt` files are PyTorch dicts with the following layout:
124
+
125
+ ```python
126
+ {
127
+ "model_state": state_dict, # nn.Module state dict
128
+ "config": {...}, # architecture config (see model_config.json)
129
+ "tokenizer_name": "Qwen/Qwen2.5-0.5B",
130
+ "history": {...}, # training curves
131
+ "best_epoch": 47,
132
+ "best_val_loss": 2.3584773325920105,
133
+ }
134
+ ```
135
+
136
+ ## How to Use
137
+
138
+ ### Quick start
139
+
140
+ ```python
141
+ import torch
142
+ from huggingface_hub import hf_hub_download
143
+ from transformers import AutoTokenizer
144
+
145
+ # The model class is defined in the demo app.py; copy it into your project
146
+ # (it's ~150 lines of standard PyTorch).
147
+ from app import CosmosT2_Accelerate_LLM # see the Space `wop/Cosmos-T2-Accelerate-Preview-DEMO`
148
+
149
+ REPO = "wop/Cosmos-T2-Accelerate-Preview"
150
+ CKPT = "Cosmos-T2-Accelerate-Preview.best.pt"
151
+ DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
152
+
153
+ tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B")
154
+ if tokenizer.pad_token is None:
155
+ tokenizer.pad_token = tokenizer.eos_token
156
+
157
+ ckpt = torch.load(hf_hub_download(REPO, CKPT), map_location=DEVICE, weights_only=False)
158
+ cfg = ckpt["config"]
159
+ model = CosmosT2_Accelerate_LLM(
160
+ vocab_size=cfg["vocab_size"], d_model=cfg["d_model"], n_layers=cfg["n_layers"],
161
+ n_heads=cfg["n_heads"], n_kv_heads=cfg["n_kv_heads"], d_ff=cfg["d_ff"],
162
+ max_len=cfg["max_len"], rope_base=cfg["rope_base"], use_engram=cfg["use_engram"],
163
+ engram_every=cfg["engram_every"], engram_bucket_count=cfg["engram_bucket_count"],
164
+ engram_dim=cfg["engram_dim"], engram_order=cfg["engram_order"],
165
+ pad_id=cfg["pad_id"], dropout=0.0,
166
+ )
167
+ model.load_state_dict(ckpt["model_state"], strict=False)
168
+ model.to(DEVICE).eval()
169
+
170
+ prompt = tokenizer.apply_chat_template(
171
+ [
172
+ {"role": "system", "content": "Enable thinking features: INTUITION"},
173
+ {"role": "user", "content": "What is 2 + 2?"},
174
+ ],
175
+ tokenize=False, add_generation_prompt=True,
176
+ )
177
+ ids = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).input_ids.to(DEVICE)
178
+ out = model.generate(ids, max_new_tokens=120, temperature=0.1, top_k=40)
179
+ print(tokenizer.decode(out[0], skip_special_tokens=False))
180
+ ```
181
+
182
+ ### System prompt
183
+
184
+ The notebook uses a single fixed system prompt during training:
185
+
186
+ ```
187
+ Enable thinking features: INTUITION
188
+ ```
189
+
190
+ Using a different system prompt at inference time tends to degrade quality.
191
+
192
+ ## Known limitations
193
+
194
+ - **Size.** ~10M trainable params is too small to memorise arithmetic or world facts. Expect format-correct nonsense.
195
+ - **Template lock-in.** The model produces `<think>...</think> Answer: N` for nearly every prompt, regardless of whether the task is math.
196
+ - **No KV cache.** The bundled `generate()` recomputes the full context each step — fine for a tiny model and short contexts, slow for long ones.
197
+ - **RoPE flavour.** This checkpoint was trained with **NeoX-style interleaved RoPE** (cos/sin built with `repeat_interleave(2, dim=-1)`), not Llama-style concatenated RoPE. The reference `app.py` in the demo space uses the matching layout — if you port the code elsewhere, make sure `build_rope` and `rotate_half` are paired correctly.
198
+
199
+ ## Citation / Acknowledgements
200
+
201
+ - Tokenizer: [Qwen/Qwen2.5-0.5B](https://huggingface.co/Qwen/Qwen2.5-0.5B)
202
+ - Dataset: [wop/XXXXXL-chain-of-thought](https://huggingface.co/datasets/wop/XXXXXL-chain-of-thought)
203
+ - Sibling release: [wop/Cosmos-T2-80M-Test](https://huggingface.co/wop/Cosmos-T2-80M-Test)
history.json ADDED
The diff for this file is too large to render. See raw diff
 
model_config.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_family": "Cosmos-T2-Accelerate-Preview",
3
+ "model_name": "Cosmos-T2-Accelerate-Preview",
4
+ "model_class_name": "CosmosT2_Accelerate_LLM",
5
+ "hf_repo_id": "wop/Cosmos-T2-Accelerate-Preview",
6
+ "tokenizer_name": "Qwen/Qwen2.5-0.5B",
7
+ "dataset_name": "wop/XXXXXL-chain-of-thought",
8
+ "dataset_split": "train",
9
+ "dataset_row_limit": 10000,
10
+ "train_val_fraction": 0.1,
11
+ "seed": 42,
12
+ "block_size": 1028,
13
+ "max_len": 1028,
14
+ "d_model": 64,
15
+ "n_layers": 4,
16
+ "n_heads": 4,
17
+ "n_kv_heads": 1,
18
+ "d_ff": 256,
19
+ "rope_base": 10000,
20
+ "dropout": 0.05,
21
+ "use_engram": true,
22
+ "engram_every": 2,
23
+ "engram_buckets": 128,
24
+ "engram_dim": 16,
25
+ "engram_order": 3,
26
+ "epochs": 50,
27
+ "batch_size": 6,
28
+ "lr": 0.0003,
29
+ "weight_decay": 0.1,
30
+ "warmup_steps": 50,
31
+ "grad_clip": 1.0,
32
+ "log_every_steps": 10,
33
+ "eval_every_steps": 500,
34
+ "plot_every_epochs": 20,
35
+ "val_max_batches": 50
36
+ }