Model Details
Model Description
This model is a compact 4-layer transformer decoder built for CS4681 - Assignment 02: Self Supervised Learning. It learns statistical regularities, financial terminology, and syntactic wire-journalism structure directly from raw unlabelled text without human annotations.
- Developed by: Sithum
- Model type: Causal Language Model (Autoregressive Decoder Transformer)
- Language(s) (NLP): English (
en)
- License: MIT
- Finetuned from model: None (Trained from scratch from Gaussian random initial weights)
- Tokenizer:
ingeniumacademy/gpt2-reuters-tokenizer (BPE with 52,000 vocabulary size)
Model Sources
Uses
Direct Use
- Demonstrating causal language modeling and autoregressive text generation from scratch.
- Analyzing self-supervised learning dynamics, token probability distributions, and minimal pair attention redirection.
- Generating domain-specific 1980s financial wire news continuations.
Downstream Use
- Educational reference for pretraining small transformer decoders on domain-specific corpora.
- Baseline for comparing small custom models against pretrained foundation models.
Out-of-Scope Use
- Any real-world financial, stock trading, or investment advice.
- Open-domain factual question answering (the model is strictly trained on 1987 financial wire news).
Bias, Risks, and Limitations
- Domain & Temporal Bias: Trained exclusively on ~13 MB of 1987 Reuters financial articles. It has zero knowledge of post-1987 events, modern technology, science, or general conversational English. Out-of-domain prompts are forced into corporate finance terminology.
- Capacity Limitations: With only 4 layers, 4 attention heads, and a hidden dimension of 256 (~16.5M parameters), the model has a limited attention horizon and can exhibit repetitive loops or hallucination when generating sequences longer than 50–80 tokens.
Recommendations
Users should treat generated texts as academic demonstrations of causal language modeling rather than factually accurate historical or financial reporting.
How to Get Started with the Model
Use the code below to generate text with this model:
import torchfrom transformers import AutoTokenizer, GPT2LMHeadModel # 1. Load model and tokenizerrepo_id = "the-sithum/gpt2-reuters-cs4681"tokenizer = AutoTokenizer.from_pretrained(repo_id)model = GPT2LMHeadModel.from_pretrained(repo_id)model.eval() # 2. Provide a news promptprompt = "PENTAGON STOPS NEW BUSINESS WITH TOSHIBA"inputs = tokenizer(prompt, return_tensors="pt") # 3. Autoregressively generate continuationwith torch.no_grad(): output_ids = model.generate( **inputs, max_new_tokens=50, do_sample=True, top_k=50, top_p=0.9, temperature=0.8, repetition_penalty=1.2, pad_token_id=tokenizer.eos_token_id ) print(tokenizer.decode(output_ids[0], skip_special_tokens=True))
Training Details
Training Data
- Dataset:
ingeniumacademy/reuters_articles
- Data Splits: 17,262 training articles, 2,158 validation articles, 2,158 test articles (~13 MB total).
- Format: Each article's
title and body fields were concatenated with double newlines (title + "\n\n" + body) to construct the full training text.
Training Procedure
Preprocessing
- Tokenized using
ingeniumacademy/gpt2-reuters-tokenizer truncated to a maximum context window of 256 tokens.
- Dynamic padding handled via
DataCollatorForLanguageModeling with mlm=False and pad_token = eos_token.
Training Hyperparameters
- Training regime: FP16 mixed precision
- Optimizer: AdamW
- Learning rate: 5e-4 (linear warmup over 100 steps)
- Batch size: 32 per device (train and eval)
- Weight decay: 0.01
- Epochs: 5 epochs (2,700 total optimization steps)
Speeds, Sizes, Times
- Hardware: Google Colab NVIDIA Tesla T4 GPU (15.64 GB VRAM)
- Training Time: 527.0 seconds (~8.78 minutes) for 5 epochs
- Model Checkpoint Size: ~66 MB (
model.safetensors)
Evaluation
Testing Data, Factors & Metrics
Testing Data
Evaluated on the official unseen test split (2,158 articles) of ingeniumacademy/reuters_articles.
Metrics
- Cross-Entropy Loss: Evaluated across next-token positions.
- Perplexity (PPL): Exponentiated cross-entropy (eL).
Results
Table with columns: Configuration, Epochs, Training Time, Validation Loss, Validation PPL, Test Loss, Test PPL| Configuration | Epochs | Training Time | Validation Loss | Validation PPL | Test Loss | Test PPL |
|---|
| Run 1 (Baseline) | 2 | 226.8 s (3.78 min) | 4.7566 | 116.35 | 4.4077 | 82.08 |
| Run 2 (Final Model) | 5 | 527.0 s (8.78 min) | 4.2145 | 67.66 | 3.9115 | 49.97 |
Prompt Generation Perplexity:
- Prompt 1 (
PENTAGON STOPS NEW BUSINESS WITH TOSHIBA): Perplexity reduced from 31.34 (2 epochs) down to 18.34 (5 epochs).
- Prompt 2 (
VENEZUELA WANTS 2.4 BILLION DLRS EXPORT FINANCE): Perplexity reduced from 15.81 (2 epochs) down to 11.28 (5 epochs).
Environmental Impact
- Hardware Type: 1 x NVIDIA Tesla T4 GPU
- Hours used: ~0.25 hours (~15 minutes total compute across runs)
- Cloud Provider: Google Colab
- Compute Region: US (Google Cloud Platform)
- Carbon Emitted: < 0.02 kg CO2eq (negligible educational run)
Technical Specifications
Model Architecture and Objective
- Objective: Causal Language Modeling (Next-Token Prediction)
- Architecture: GPT-2 Decoder Transformer
- Vocabulary Size: 52,000
- Embedding Dimension (
n_embd): 256
- Transformer Layers (
n_layer): 4
- Attention Heads (
n_head): 4 (64 dim per head)
- Max Sequence Length (
n_positions): 256
- Total Parameters: 16,537,088 (100% trainable)
Compute Infrastructure
- Hardware: NVIDIA Tesla T4 GPU (16 GB GDDR6)
- Software: Python 3.10+, PyTorch, Hugging Face Transformers, Datasets, Accelerate
Citation
@misc{cs4681_assignment2_gpt2_reuters, author = {Sithum}, title = {Small GPT-2 Autoregressive Model Trained from Scratch on Reuters Articles}, year = {2026}, publisher = {Hugging Face}, howpublished = {\url{https://huggingface.co/the-sithum/gpt2-reuters-cs4681}}}
Model Card Authors
- Author: Sithum (CS4681 Student)
- Course: CS4681 Deep Learning / Advanced NLP