gpt2-reuters-scratch-2ep
A small GPT-2 style autoregressive language model trained from randomly initialised weights (no pretrained GPT-2 weights) on the Reuters articles dataset (title + body as full text) for the Self-Supervised Learning assignment. Next-token prediction (causal LM) objective.
Model configuration
| Setting | Value |
|---|---|
| Layers / heads | 6 / 8 |
| Hidden size (d_model) | 256 |
| FFN size | 1024 |
| Context length | 256 |
| Vocabulary | 52000 (ingeniumacademy/gpt2-reuters-t) |
| Parameters | 18,116,608 |
Training
- Epochs: 2, batch size 32, lr 0.0005 (cosine, 5% warmup), AdamW, weight decay 0.01, fp16
- Data: Reuters train split (17,262 articles), packed into 256-token blocks
- Training time: 159.0 s
Results
| Split | Loss | Perplexity |
|---|---|---|
| Validation | 5.0261 | 152.34 |
| Test | 4.7997 | 121.47 |
Usage
from transformers import AutoTokenizer, AutoModelForCausalLM
tok = AutoTokenizer.from_pretrained("Induwara02/gpt2-reuters-scratch-2ep")
model = AutoModelForCausalLM.from_pretrained("Induwara02/gpt2-reuters-scratch-2ep")
ids = tok("AMEX SAYS SHORT INTEREST", return_tensors="pt")
print(tok.decode(model.generate(**ids, max_new_tokens=50, do_sample=True, top_p=0.9)[0]))
Limitations
Small corpus (~3M tokens) and small model: output is topical but often incoherent, and the model can repeat or invent facts. Not for real use. Educational project only.