A 44.91M-parameter GPT-2 Causal Language Model (BF16 + SDPA), designed, tokenized, and trained entirely from scratch on C4.
A 44.91M-parameter autoregressive causal language model built and trained 100% from scratch (zero pretrained weights) over 5 Epochs (6,220 steps — 203.74M dataset tokens) on 1× NVIDIA A100-SXM4 (40GB) using Native
BF16 + TF32+ PyTorchSDPA, achieving Validation Perplexity 93.52 (Loss 4.5382) and Held-Out Test Perplexity 96.97 (Loss 4.5744).
44,909,056 parameters and the 50,257-token Byte-Level BPE tokenizer (fit strictly on Train split) are learned from scratch.54,773.00 Test PPL), with a small Val-to-Test generalization gap of +0.0362 nats (93.52 Val / 96.97 Test PPL).242.44 blocks/sec) at 14.07 GB Peak VRAM, completing all 5 epochs in 27.37 minutes of training (30.37 minutes full end-to-end pipeline).bfloat16 (model.safetensors: 89,825,728 bytes), well-suited for edge inference or Draft Model experiments in Speculative Decoding.seed=42) with explicit </s> (eos_token_id=2) document delimiters and linear-time packing (99.94% token retention, 0% <pad>).Generate text using PyTorch and 🤗 Transformers (stored natively in bfloat16):
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
repo = "GiangSon-5/c4-gpt-mini-causallm"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo)
device = "cuda" if torch.cuda.is_available() else "cpu"
model.to(device).eval()
prompt = "Artificial intelligence is transforming"
inputs = tokenizer(prompt, add_special_tokens=False, return_tensors="pt").to(device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=80,
do_sample=True,
temperature=0.8,
top_k=50,
top_p=0.92,
repetition_penalty=1.15,
pad_token_id=tokenizer.pad_token_id,
eos_token_id=tokenizer.eos_token_id,
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Or run via the high-level Hugging Face Pipeline:
from transformers import pipeline
generator = pipeline("text-generation", model="GiangSon-5/c4-gpt-mini-causallm")
result = generator("The future of software engineering lies in", max_new_tokens=60, do_sample=True, temperature=0.8, top_k=50, top_p=0.92)
print(result[0]["generated_text"])
Verbatim continuations generated after reloading the standalone bfloat16 checkpoint from disk (max_new_tokens=80, temperature=0.8, top_k=50, top_p=0.92, repetition_penalty=1.15):
| Prompt | Generated Full Text (5 Epochs, Step 6,220) |
|---|---|
Artificial intelligence is transforming |
Artificial intelligence is transforming the human mind. With the help of the film, the story will become a very powerful feature of the film which is used by artists. The show will be available from the original production team in 0000 and will be on sale for the film. |
Deep neural networks learn representations by |
Deep neural networks learn representations by the need of communication, including the user interface that is being performed on a daily basis. |
The future of software engineering lies in |
The future of software engineering lies in the evolution of its own. The new technology is a great way to communicate the concepts, concepts and experiences that we are faced by problems of human nature, whether or not they relate to humans's ideas. This has been a long way through which we have to see how to control human consciousness through our thinking process. A team of engineers can provide their solutions to customers in the development of AI systems and |
Large language models trained on web corpora |
Large language models trained on web corpora-based applications. We have worked with the team, to develop a new level of expertise and make sure that it will enable you to develop your skills through the development process. This is the most important part of any application for all types of applications. This program is designed to help improve your application performance while providing you with your knowledge. When you do not have the ability to be able to be able |
In scientific computing, parallel matrix multiplication |
In scientific computing, parallel matrix multiplication, we found that the new approaches can be used to make a more efficient solution for all of our technologies. We can also find solutions where and when we need to find ways to create an environment within this context. This method uses an interactive framework to support the different aspects of human interaction with others (or as they are not able to achieve) by understanding their experiences and experiences in order to develop the |
Qualitative Critique: The model produces fluent English syntax and demonstrates clean autonomous EOS termination (
</s>stop observed naturally in Prompt 2). Consistent with a compact 44.91M-parameter model trained on C4 web crawls, longer completions exhibit topical drift (Prompt 1 shifting into film promotional text with C4 anonymized0000year placeholders) and occasional local phrase repetition (to be able to be able,concepts, concepts).
| Specification | Value | Architecture Details |
|---|---|---|
| Model Type | GPT-2 Decoder (sdpa) |
Autoregressive Causal LM with PyTorch SDPA FlashAttention |
| Total Parameters | 44,909,056 (~44.91M) | 100% randomly initialized (bfloat16 serialized weights: 85.66 MB) |
Decoder Layers (n_layer) |
6 Blocks | Pre-Layer Normalization + Residual Connections |
Attention Heads (n_head) |
8 Heads | Scaled Dot-Product Self-Attention (64 dim / head) |
Hidden Dimension (n_embd) |
512 | Intermediate hidden representation size |
Context Window (n_positions) |
512 Tokens | Absolute learned positional embeddings |
| Vocabulary & Special IDs | 50,257 (NFKC + Byte-Level BPE) |
Train-only fit (73.99s); BOS=0, PAD=1, EOS=2; clean prompt encoding without forced </s> |
| Activation & Dropout | GELU (gelu_new) • Dropout 0.1 |
Exact match to serialized config.json (resid_pdrop, embd_pdrop, attn_pdrop) |
| Weight Tying | Enabled (tie_word_embeddings: true) |
Input wte weights shared with output lm_head |
datablations/c4-filter-small (100,000 quality-filtered English web documents from the Colossal Clean Crawled Corpus — C4).seed=42):90,000 documents → 79,585 packed 512-token blocks (40,747,520 tokens/epoch; 99.94% retention from 40,773,413 raw tokenized+EOS tokens).5,000 documents → 4,623 packed 512-token blocks (2,366,976 tokens).5,000 documents → 4,535 packed 512-token blocks (2,321,920 tokens).79,585 × 512 × 5; 203,816,960 batch step-slot tokens across 6,220 steps × 64 blocks × 512 tokens).</s> (eos_token_id=2) before linear concatenation (itertools.chain) into uniform 512-token chunks, completely eliminating <pad> tokens.| Hyperparameter | Value | Technical Notes |
|---|---|---|
| Optimizer | adamw_torch_fused |
β₁ = 0.9, β₂ = 0.95, ε = 1e-8, Weight Decay = 0.1, Max Grad Norm = 1.0 |
| Peak Learning Rate | 6e-4 |
Cosine Annealing schedule with 5% linear warmup |
| Effective Batch Size | 64 (32 × 2 grad accum) |
32,768 tokens per optimizer update |
| Epochs / Total Steps | 5.0 Epochs / 6,220 Steps | Uninterrupted full 5-epoch convergence (EarlyStopping patience=4 active) |
| Compute Precision | BF16 + TF32 (bfloat16) |
Native Ampere bf16=True, allow_tf32=True; serialized model.safetensors: 85.66 MB (89,825,728 bytes) |
| Hardware & Peak VRAM | 1× NVIDIA A100-SXM4 (40GB) | Peak allocation 14.07 GB / 39.49 GB |
| Throughput | 124,127 tokens/sec | 242.44 context blocks/sec (2.13× faster than FP32+TF32 baseline) |
| Training Duration | 1,642.00 seconds (~27.37 min) | Pure training runtime on 1× A100; total end-to-end pipeline: 30.37 min (1,822.29s) |
| Frameworks | PyTorch 2.14.1+cu130, 🤗 Transformers 5.22.1 |
SDPA FlashAttention + Fused AdamW stack |
| Milestone | Step | Epoch | Train Loss (Nearest Step) | Eval / Test Loss | Perplexity (PPL) | Learning Rate | Technical Notes |
|---|---|---|---|---|---|---|---|
| Random-Init Test Baseline | 0 | 0.00 | — | 10.9110 (Test) | 54,773.00 | — | Uninitialized baseline on 4,535 unseen Test blocks |
| Warmup & Early Decay | 500 | 0.40 | 6.2369 | 6.1483 | 467.93 | 5.91e-04 | >100× initial Perplexity drop in ~0.4 epoch |
| Early Epoch 2 | 1,500 | 1.21 | 5.4197 | 5.3513 | 210.87 | 5.18e-04 | Grammar and basic phrase structure emergence |
| Midpoint (Epoch 2) | 2,500 | 2.01 | 5.0284 | 4.9271 | 137.98 | 3.91e-04 | Steady monotonic decrease without overfitting |
| Late Epoch 3 | 3,500 | 2.81 | 4.8044 | 4.7013 | 110.09 | 2.41e-04 | Surpasses prior 3-epoch baseline trajectory |
| Sub-100 PPL Crossing | 4,500 | 3.62 | 4.6400 | 4.5903 | 98.52 | 1.06e-04 | Crosses sub-100 Validation PPL before Epoch 4 |
| Final Annealing Phase | 5,500 | 4.42 | 4.5658 | 4.5435 | 94.02 | 1.97e-05 | Cosine LR decay refines flat optimum |
| ★ Best Checkpoint (Validation) | 6,220 | 5.00 | 4.5455 (step 6200) | 4.5382 (Val) | 93.52 (Val) | 1.69e-08 (step 6200) | 5-epoch avg Train Loss = 5.0975; best Validation checkpoint |
| ★ Held-Out Test Evaluation | 6,220 | 5.00 | — | 4.5744 (Test) | 96.97 (Test) | — | Val-to-Test Generalization Gap Δ = +0.0362 nats (+3.45 PPL) |
0000 replacing years or phone digits) and inherits societal biases from public web pages.en) causal language model for research, educational benchmarking, and lightweight speculative decoding drafts; not aligned (no SFT/RLHF) and unsuitable for medical, legal, or financial advice.