wop/Cosmos-T2A-low
<img src="https://calm-heart-d697.mmmmmm505090.workers.dev?text=Cosmos T2A-low" width="900" alt="Cosmos T2A-low" />
Cosmos T2A-low
Universal Kaggle-ready training notebook for the Cosmos T2A-low series.
Notebook-generated card. Final metrics are filled after the Kaggle training run. This notebook is designed to stay Kaggle-friendly on 2x T4 GPUs. The goal is a reusable training recipe, not a production assistant.
Model Details
Why these choices
- RoPE keeps positional handling compact and avoids learned absolute embeddings.
- RMSNorm is cheaper and more stable than LayerNorm for this small decoder-only model.
- SwiGLU usually gives a better quality/compute tradeoff than a plain GELU MLP.
- GQA reduces KV cost while keeping multi-head query capacity.
- Engram gives the stack a lightweight explicit memory path for repeated reasoning patterns.
- Dynamic isolated batching keeps conversations separate while padding and masking each batch on CPU.
- KV-cache generation avoids recomputing the full prompt for every generated token in the app.
Training Summary
Loss and perplexity
The notebook shows live loss and perplexity plots every 5000 epochs and does not save the graph to disk.
How to Use
Quick start
~~~python import torch from transformers import AutoTokenizer
from app import CosmosT2AccelerateLLM
tokenizer = AutoTokenizer.frompretrained("Qwen/Qwen2.5-0.5B") if tokenizer.padtoken is None: tokenizer.padtoken = tokenizer.eostoken
ckpt = torch.load("$CHECKPOINTNAME", maplocation="cpu") model = CosmosT2AccelerateLLM(**ckpt["config"]) model.loadstatedict(ckpt["model_state"]) model.eval()
prompt = tokenizer.applychattemplate( [ {"role": "system", "content": "Enable thinking features: INTUITION"}, {"role": "user", "content": "What is 12 * 7?"}, ], tokenize=False, addgenerationprompt=True, ) ids = tokenizer(prompt, returntensors="pt", addspecialtokens=False).inputids out = model.generate(ids, maxnewtokens=120, temperature=0.8, topk=50) print(tokenizer.decode(out[0], skipspecial_tokens=False)) ~~~
Prompt format
Use the Qwen2.5 chat template. The default system prompt is:
~~~text Enable thinking features: INTUITION ~~~
The model will then emit a <think> block followed by an answer when it has enough signal.
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.
Limitations
- The model is intentionally small and is still a research/demo artifact.
- Training on chain-of-thought data can overfit quickly if the corpus is tiny.
- Long-context behavior is limited by the configured block size.
- The model is not safety-aligned and should not be exposed as a public assistant without additional work.
Intended Use
- Research into small-scale pretraining and reasoning-style formatting
- Educational demos for decoder-only Transformer training
- Hugging Face Spaces or local inference demos
- Not for production use
Cosmos T2A-low Series
This notebook is designed to train future Cosmos T2A-low variants by changing only the config block at the top.
Citation
~~~bibtex @misc{cosmos-t2, author = {wop}, title = {Cosmos-T2: A small from-scratch chain-of-thought Transformer}, year = {2026}, publisher = {Hugging Face}, url = {https://huggingface.co/wop/Cosmos-T2A-low} } ~~~
Acknowledgements
- Tokenizer from Qwen2.5 by Alibaba Cloud
- Training data from wop/minitron-dataset
- Trained on Kaggle T4 GPUs
