CoolFace
Modelpublic

wop/Cosmos-T2A-low

sourceHugging Faceapache-2.0updated 4mo agoView on Hugging Face
0likes
Model Card

<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

Model classCosmosT2_Accelerate_LLM
ArchitectureDecoder-only Transformer with RoPE, RMSNorm, SwiGLU, GQA, and a configurable Engram memory path
Parameters~9.96 M
Layers4
Attention heads4
KV heads1
d_model64
FFN hidden256
Positional encodingRoPE (rope_base=10000)
NormalizationRMSNorm
MLPSwiGLU
MemoryEngram (use_engram=True, every 2 blocks)
Context length1028
Training block size1028
Tokenizer`Qwen/Qwen2.5-0.5B`
Dataset`wop/minitron-dataset`
LicenseApache-2.0

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

MetricValue
Rows used288,350
Loss tokens seen46,651,194
Epochs1
Batch size2
Peak LR3.00e-04
Weight decay0.1
Gradient clipping1.0
Wall-clock time1h 37m 23s
Final training loss5.6389
Final training perplexity281.15
Final validation loss5.4913
Final validation perplexity242.56
Best validation loss4.9614
Best epoch1

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