# Twilight-135M

Horizon Labs' first model: a 135M-parameter base model, pretrained from scratch on 9.81B tokens in 4h 21m on a single B200.

- Writeup: https://horiznlabs.dev/research/twilight
- Model page: https://horiznlabs.dev/models/twilight

## Use

```bash
pip install torch safetensors tokenizers
python twilight.py "The heart is a muscle that"
```

```python
from twilight import load, generate

model, tokenizer = load()  # this folder
print(generate(model, tokenizer, "The heart is a muscle that"))
```

This is a base model: it continues text. It is not instruction- or chat-tuned.

## Model

| | |
|---|---|
| Parameters | 134.5M |
| Layers | 30 |
| Width | 576 |
| Attention | 9 query / 3 key-value heads, head dim 64 |
| Feed-forward | SwiGLU, 1,536 |
| Positions | Rotary, theta 100,000 |
| Norm | RMSNorm, pre-norm |
| Embeddings | Tied input/output |
| Vocabulary | 49,152 (SmolLM2 tokenizer) |
| Context | 512 tokens |
| Weights | float32 |

## Training

- **Data:** 9.81B tokens of Zyda-2 (FineWeb-Edu, DCLM, Dolma CC, Zyda), packed into 512-token sequences.
- **TST (token superposition):** for the first 36,621 steps, each position averages the embeddings of 6 consecutive tokens and predicts the next 6 as a bag. Then plain next-token prediction to step 116,396.
- **Optimizer:** Muon for hidden matrices, AdamW for embeddings and norms. 200-step warmup, cosine to 10% of peak.
- **Batch:** 64 × 512 positions per step.
- **Held-out loss:** 3.17.

## Evaluation

Zero-shot accuracy (%), full evaluation sets, same scoring code for both models. HellaSwag and ARC-Challenge are length-normalized.

| | Twilight-135M | GPT-2 (124M) |
|---|---|---|
| HellaSwag | 32.1 | 31.2 |
| ARC-Easy | 51.4 | 43.8 |
| ARC-Challenge | 25.2 | 22.4 |
| PIQA | 62.9 | 62.9 |

## Limitations

A 135M base model trained on under 10B tokens. It writes fluent English but often states facts incorrectly, has very little code in its training data, and is not safety-tuned. Don't rely on its outputs.

## License

Apache License 2.0. See `LICENSE`. The tokenizer is from SmolLM2 (Apache 2.0); the training data, Zyda-2, is released under ODC-BY.
