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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
tags:
|
| 6 |
+
- text-generation
|
| 7 |
+
- gpt
|
| 8 |
+
- nanogpt
|
| 9 |
+
- pytorch
|
| 10 |
+
- from-scratch
|
| 11 |
+
- small-language-model
|
| 12 |
+
- slm
|
| 13 |
+
- pretraining
|
| 14 |
+
- muon-optimizer
|
| 15 |
+
- single-gpu
|
| 16 |
+
- base-model
|
| 17 |
+
- research
|
| 18 |
+
pipeline_tag: text-generation
|
| 19 |
---
|
| 20 |
+
|
| 21 |
+
# GTM-v2-base
|
| 22 |
+
|
| 23 |
+
A ~120M parameter, decoder-only GPT-style **base** language model, trained
|
| 24 |
+
from scratch on a single RTX Pro 6000, on roughly 4 billion tokens streamed
|
| 25 |
+
from a mix of open web/educational/math corpora.
|
| 26 |
+
|
| 27 |
+
**This is a base (pretrained) model, not an instruction-tuned or chat
|
| 28 |
+
model.** It completes/continues text; it does not reliably follow
|
| 29 |
+
instructions or answer questions directly. It also has **no fine-tuning
|
| 30 |
+
for factual accuracy** β it can and does confidently generate fluent,
|
| 31 |
+
plausible-sounding but factually incorrect content. Treat it as a small,
|
| 32 |
+
from-scratch research/hobby model, not a production system.
|
| 33 |
+
|
| 34 |
+
A separate instruction-tuned variant (SFT on UltraChat) is planned as a
|
| 35 |
+
follow-up release; this repo is the base-only checkpoint.
|
| 36 |
+
|
| 37 |
+
## Model details
|
| 38 |
+
|
| 39 |
+
- **Architecture**: nanoGPT-style decoder-only transformer
|
| 40 |
+
- 14 layers, 8 attention heads, 704 embedding dim
|
| 41 |
+
- ~119.4M parameters (weight-tied embeddings/output head)
|
| 42 |
+
- Context length: 1024 tokens
|
| 43 |
+
- Uses PyTorch's fused `scaled_dot_product_attention` (flash-attention kernel)
|
| 44 |
+
- **Tokenizer**: `tiktoken` GPT-2 BPE encoding (`tiktoken.get_encoding("gpt2")`),
|
| 45 |
+
vocab size 50,257. No custom tokenizer was trained.
|
| 46 |
+
- **Optimizer**: Muon (for 2D weight matrices) + AdamW (for embeddings,
|
| 47 |
+
layernorms, biases) β a hybrid setup, following the approach popularized
|
| 48 |
+
in recent efficient-pretraining recipes.
|
| 49 |
+
- **Precision**: trained with bf16 autocast; released weights are fp32.
|
| 50 |
+
- **Training tokens seen**: ~4.16B tokens (40,690 steps x effective batch
|
| 51 |
+
100 x 1024 context)
|
| 52 |
+
- **Training data**: streamed via HuggingFace `datasets`, mixed and
|
| 53 |
+
tokenized on the fly (no fixed local copy of the source datasets):
|
| 54 |
+
- FineWeb-Edu (`HuggingFaceFW/fineweb-edu`, `sample-10BT`) β 45%
|
| 55 |
+
- Cosmopedia-v2 (`HuggingFaceTB/cosmopedia-v2`) β 30%
|
| 56 |
+
- FineMath (`HuggingFaceTB/finemath`, `finemath-4plus`) β 15%
|
| 57 |
+
- FineWeb (`HuggingFaceFW/fineweb`, `sample-10BT`) β 10%
|
| 58 |
+
|
| 59 |
+
Note: code data (The Stack v2, StarCoderData, the-stack-smol) was
|
| 60 |
+
intentionally left out of this mix β every BigCode-hosted code corpus we
|
| 61 |
+
checked is gated behind a terms-of-use click-through on HuggingFace, so
|
| 62 |
+
none of them are pulled in without the user separately accepting those
|
| 63 |
+
terms and authenticating.
|
| 64 |
+
|
| 65 |
+
This is the second model in this series. An earlier ~100M parameter
|
| 66 |
+
version (GTM-v1-base, trained on ~3B tokens with the same data mix and
|
| 67 |
+
optimizer) informed several of this model's design choices, including the
|
| 68 |
+
Muon/AdamW optimizer split and the corpus weighting above.
|
| 69 |
+
|
| 70 |
+
## Benchmarks
|
| 71 |
+
|
| 72 |
+
Evaluated via likelihood-scoring (comparing the model's per-token loss
|
| 73 |
+
across candidate answers, no generation/sampling involved), 200 examples
|
| 74 |
+
per benchmark, final checkpoint at step 40,690 (~4.16B tokens seen):
|
| 75 |
+
|
| 76 |
+
| Benchmark | GTM-v2-base | GTM-v1-base | GPT-2 (124M) | Random baseline |
|
| 77 |
+
|----------------|:-----------:|:-----------:|:------------:|:----------------:|
|
| 78 |
+
| HellaSwag | 33.0% | 32.0% | ~28-29% | 25% |
|
| 79 |
+
| ARC-Easy | 43.0% | 42.5% | ~39.2% | ~25% |
|
| 80 |
+
| ARC-Challenge | 24.0% | 26.0% | ~22.5% | ~25% |
|
| 81 |
+
|
| 82 |
+
Corpus perplexity (per-source, lower is better) on freshly streamed,
|
| 83 |
+
non-training-shard text:
|
| 84 |
+
|
| 85 |
+
| Source | Perplexity |
|
| 86 |
+
|----------------|:----------:|
|
| 87 |
+
| Cosmopedia-v2 | 11.80 |
|
| 88 |
+
| FineMath | 13.04 |
|
| 89 |
+
| FineWeb-Edu | 27.68 |
|
| 90 |
+
| FineWeb | 47.34 |
|
| 91 |
+
| **Overall** | **21.19** (vs. GTM-v1-base's 22.87) |
|
| 92 |
+
|
| 93 |
+
GTM-v2-base improves on GTM-v1-base (an earlier ~100M param, ~3B token
|
| 94 |
+
version of this same series) on HellaSwag, ARC-Easy, and overall
|
| 95 |
+
perplexity, but is *not* a clean sweep β it's slightly behind v1 on
|
| 96 |
+
ARC-Challenge (24.0% vs. 26.0%), though both remain above GPT-2's ~22.5%
|
| 97 |
+
reference. ARC-Challenge is a small (200-example), noisy evaluation at
|
| 98 |
+
this scale, so a few-point gap in either direction shouldn't be read as a
|
| 99 |
+
strong signal on its own.
|
| 100 |
+
|
| 101 |
+
GPT-2 (124M) reference numbers are from a from-scratch reproduction
|
| 102 |
+
verified to match official GPT-2 evaluation results. GTM-v2-base was
|
| 103 |
+
trained on roughly 1/10th of GPT-2's training tokens (~4B vs. ~40B), on a
|
| 104 |
+
single consumer/workstation GPU rather than a large multi-GPU cluster.
|
| 105 |
+
|
| 106 |
+
**These numbers should be read as "beats a 2019 baseline on a few narrow
|
| 107 |
+
multiple-choice benchmarks," not "as good as or better than GPT-2 in
|
| 108 |
+
general."** GPT-2 was trained and evaluated far more broadly; free-form
|
| 109 |
+
generation quality, factual grounding, and behavior outside these specific
|
| 110 |
+
benchmark formats have not been rigorously compared.
|
| 111 |
+
|
| 112 |
+
## Known limitations
|
| 113 |
+
|
| 114 |
+
- **No reliable factual recall.** E.g. prompted with "The capital of France
|
| 115 |
+
is", the model does not consistently produce "Paris" β it may produce
|
| 116 |
+
fluent but factually invented content instead. This is expected: the
|
| 117 |
+
training corpus is not dense in discrete factual content, and this
|
| 118 |
+
model's parameter/token budget is small for reliably memorizing specific
|
| 119 |
+
facts.
|
| 120 |
+
- **No code capability.** No code-specific training data was included (see
|
| 121 |
+
above). The model can produce code-*shaped* text (recognizing "write
|
| 122 |
+
code" prompts and using plausible syntax) but not functionally correct
|
| 123 |
+
code.
|
| 124 |
+
- **Not instruction-tuned.** Does not follow instructions or answer
|
| 125 |
+
questions in a chat-like way β it continues text. (A separate SFT/chat
|
| 126 |
+
release is planned; this is the base-only checkpoint.)
|
| 127 |
+
- **Repetition tendency.** Base generation (greedy or low-temperature
|
| 128 |
+
sampling) can fall into repetition loops or lock onto structural
|
| 129 |
+
templates (e.g. numbered-list/fill-in-the-blank formatting) when it
|
| 130 |
+
lacks a confident continuation. A repetition penalty (see usage example)
|
| 131 |
+
substantially reduces this.
|
| 132 |
+
|
| 133 |
+
## Usage
|
| 134 |
+
|
| 135 |
+
Requires `model.py` (included in this repo) alongside the checkpoint β
|
| 136 |
+
this is a plain PyTorch model, not a `transformers` `AutoModel`.
|
| 137 |
+
|
| 138 |
+
```bash
|
| 139 |
+
pip install torch safetensors tiktoken
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
```python
|
| 143 |
+
import json
|
| 144 |
+
import torch
|
| 145 |
+
from safetensors.torch import load_file
|
| 146 |
+
from model import GPT, GPTConfig
|
| 147 |
+
|
| 148 |
+
with open("config.json") as f:
|
| 149 |
+
cfg_dict = json.load(f)
|
| 150 |
+
config = GPTConfig(
|
| 151 |
+
vocab_size=cfg_dict["vocab_size"], block_size=cfg_dict["block_size"],
|
| 152 |
+
n_layer=cfg_dict["n_layer"], n_head=cfg_dict["n_head"],
|
| 153 |
+
n_embd=cfg_dict["n_embd"], dropout=cfg_dict["dropout"], bias=cfg_dict["bias"],
|
| 154 |
+
)
|
| 155 |
+
model = GPT(config)
|
| 156 |
+
state_dict = load_file("model.safetensors")
|
| 157 |
+
model.load_state_dict(state_dict)
|
| 158 |
+
model.eval()
|
| 159 |
+
|
| 160 |
+
import tiktoken
|
| 161 |
+
enc = tiktoken.get_encoding("gpt2")
|
| 162 |
+
|
| 163 |
+
prompt = "Once upon a time,"
|
| 164 |
+
ids = enc.encode_ordinary(prompt)
|
| 165 |
+
x = torch.tensor([ids], dtype=torch.long)
|
| 166 |
+
|
| 167 |
+
with torch.no_grad():
|
| 168 |
+
out = model.generate(
|
| 169 |
+
x, max_new_tokens=128, temperature=0.8, top_k=50,
|
| 170 |
+
eot_token=enc.eot_token, repetition_penalty=1.3,
|
| 171 |
+
)
|
| 172 |
+
|
| 173 |
+
print(enc.decode(out[0].tolist()))
|
| 174 |
+
```
|
| 175 |
+
|
| 176 |
+
## License
|
| 177 |
+
|
| 178 |
+
Apache 2.0 for this repo's contents (model weights, `model.py`, and this
|
| 179 |
+
README). The underlying training data retains its own licenses regardless
|
| 180 |
+
of the license on this trained model β FineWeb, FineWeb-Edu, Cosmopedia-v2,
|
| 181 |
+
and FineMath are each ODC-BY-1.0 (see their respective HF dataset cards for
|
| 182 |
+
full terms and attribution requirements). This repo distributes model
|
| 183 |
+
weights, not the training data itself.
|