wop commited on
Commit
e45937f
·
verified ·
1 Parent(s): 5b382ea

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +189 -0
README.md ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ datasets:
21
+ - wop/XXXXXL-chain-of-thought
22
+ model-index:
23
+ - name: Cosmos T2-Accelerate-beta
24
+ results:
25
+ - task:
26
+ type: text-generation
27
+ name: Causal Language Modeling
28
+ dataset:
29
+ name: wop/XXXXXL-chain-of-thought
30
+ type: wop/XXXXXL-chain-of-thought
31
+ split: train
32
+ metrics:
33
+ - type: loss
34
+ name: Final training loss (cross-entropy)
35
+ value: 2.1199
36
+ - type: perplexity
37
+ name: Final training perplexity
38
+ value: 8.33
39
+ - type: loss
40
+ name: Final validation loss (cross-entropy)
41
+ value: 1.9287
42
+ - type: perplexity
43
+ name: Final validation perplexity
44
+ value: 6.88
45
+ ---
46
+
47
+ <img src="https://calm-heart-d697.mmmmmm505090.workers.dev?text=Cosmos T2-Accelerate-beta" width="900" alt="Cosmos T2-Accelerate-beta" />
48
+
49
+ # Cosmos T2-Accelerate-beta
50
+
51
+ Universal Kaggle-ready training notebook for the Cosmos T2-Accelerate-beta series.
52
+
53
+ > Notebook-generated card. Final metrics are filled after the Kaggle training run.
54
+ > This notebook is designed to stay Kaggle-friendly on 2x T4 GPUs. The goal is a reusable training recipe, not a production assistant.
55
+
56
+ ## Model Details
57
+
58
+ | | |
59
+ |---|---|
60
+ | **Model class** | `CosmosT2_Accelerate_LLM` |
61
+ | **Architecture** | Decoder-only Transformer with RoPE, RMSNorm, SwiGLU, GQA, and a configurable Engram memory path |
62
+ | **Parameters** | `~9.96 M` |
63
+ | **Layers** | `4` |
64
+ | **Attention heads** | `4` |
65
+ | **KV heads** | `1` |
66
+ | **d_model** | `64` |
67
+ | **FFN hidden** | `256` |
68
+ | **Positional encoding** | RoPE (`rope_base=10000`) |
69
+ | **Normalization** | RMSNorm |
70
+ | **MLP** | SwiGLU |
71
+ | **Memory** | Engram (`use_engram=True`, every `2` blocks) |
72
+ | **Context length** | `1028` |
73
+ | **Training block size** | `1028` |
74
+ | **Tokenizer** | [`Qwen/Qwen2.5-0.5B`](https://huggingface.co/Qwen/Qwen2.5-0.5B) |
75
+ | **Dataset** | [`wop/XXXXXL-chain-of-thought`](https://huggingface.co/datasets/wop/XXXXXL-chain-of-thought) |
76
+ | **License** | Apache-2.0 |
77
+
78
+ ### Why these choices
79
+
80
+ - **RoPE** keeps positional handling compact and avoids learned absolute embeddings.
81
+ - **RMSNorm** is cheaper and more stable than LayerNorm for this small decoder-only model.
82
+ - **SwiGLU** usually gives a better quality/compute tradeoff than a plain GELU MLP.
83
+ - **GQA** reduces KV cost while keeping multi-head query capacity.
84
+ - **Engram** gives the stack a lightweight explicit memory path for repeated reasoning patterns.
85
+ - **Dynamic isolated batching** keeps conversations separate while padding and masking each batch on CPU.
86
+ - **KV-cache generation** avoids recomputing the full prompt for every generated token in the app.
87
+
88
+ ## Training Summary
89
+
90
+ | Metric | Value |
91
+ |---|---|
92
+ | Rows used | `10,000` |
93
+ | Loss tokens seen | `10,591,118` |
94
+ | Epochs | `50` |
95
+ | Batch size | `6` |
96
+ | Peak LR | `3.00e-04` |
97
+ | Weight decay | `0.1` |
98
+ | Gradient clipping | `1.0` |
99
+ | Wall-clock time | `26m 40s` |
100
+ | Final training loss | `2.1199` |
101
+ | Final training perplexity | `8.33` |
102
+ | Final validation loss | `1.9287` |
103
+ | Final validation perplexity | `6.88` |
104
+ | Best validation loss | `1.8973` |
105
+ | Best epoch | `10` |
106
+
107
+ ### Loss and perplexity
108
+
109
+ The notebook shows live loss and perplexity plots every `20` epochs and does not save the graph to disk.
110
+
111
+ ## How to Use
112
+
113
+ ### Quick start
114
+
115
+ ~~~python
116
+ import torch
117
+ from transformers import AutoTokenizer
118
+
119
+ from app import CosmosT2_Accelerate_LLM
120
+
121
+ tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B")
122
+ if tokenizer.pad_token is None:
123
+ tokenizer.pad_token = tokenizer.eos_token
124
+
125
+ ckpt = torch.load("$CHECKPOINT_NAME", map_location="cpu")
126
+ model = CosmosT2_Accelerate_LLM(**ckpt["config"])
127
+ model.load_state_dict(ckpt["model_state"])
128
+ model.eval()
129
+
130
+ prompt = tokenizer.apply_chat_template(
131
+ [
132
+ {"role": "system", "content": "Enable thinking features: INTUITION"},
133
+ {"role": "user", "content": "What is 12 * 7?"},
134
+ ],
135
+ tokenize=False,
136
+ add_generation_prompt=True,
137
+ )
138
+ ids = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).input_ids
139
+ out = model.generate(ids, max_new_tokens=120, temperature=0.8, top_k=50)
140
+ print(tokenizer.decode(out[0], skip_special_tokens=False))
141
+ ~~~
142
+
143
+ ### Prompt format
144
+
145
+ Use the Qwen2.5 chat template. The default system prompt is:
146
+
147
+ ~~~text
148
+ Enable thinking features: INTUITION
149
+ ~~~
150
+
151
+ The model will then emit a `<think>` block followed by an answer when it has enough signal.
152
+
153
+ The model is trained to end its turn with the `<|im_end|>` token (ChatML), so generation stops there. During data prep, any example longer than the `1028`-token context has its `<think>` reasoning replaced by a short placeholder (or is dropped) so every training sequence ends cleanly - the model is never trained on a mid-thought truncation.
154
+
155
+ ## Limitations
156
+
157
+ - The model is intentionally small and is still a research/demo artifact.
158
+ - Training on chain-of-thought data can overfit quickly if the corpus is tiny.
159
+ - Long-context behavior is limited by the configured block size.
160
+ - The model is not safety-aligned and should not be exposed as a public assistant without additional work.
161
+
162
+ ## Intended Use
163
+
164
+ - Research into small-scale pretraining and reasoning-style formatting
165
+ - Educational demos for decoder-only Transformer training
166
+ - Hugging Face Spaces or local inference demos
167
+ - Not for production use
168
+
169
+ ## Cosmos T2-Accelerate-beta Series
170
+
171
+ This notebook is designed to train future Cosmos T2-Accelerate-beta variants by changing only the config block at the top.
172
+
173
+ ## Citation
174
+
175
+ ~~~bibtex
176
+ @misc{cosmos-t2,
177
+ author = {wop},
178
+ title = {Cosmos-T2: A small from-scratch chain-of-thought Transformer},
179
+ year = {2026},
180
+ publisher = {Hugging Face},
181
+ url = {https://huggingface.co/wop/Cosmos-T2-Accelerate-beta}
182
+ }
183
+ ~~~
184
+
185
+ ## Acknowledgements
186
+
187
+ - Tokenizer from Qwen2.5 by Alibaba Cloud
188
+ - Training data from wop/XXXXXL-chain-of-thought
189
+ - Trained on Kaggle T4 GPUs