How hadjsaidsamy2209-glitch/mini-gpt works
Mini-GPT is a single-script character-level language-model trainer and sampler. The workflow reads a local text corpus, builds character IDs and train/validation splits, samples next-character batches, trains a causal Transformer while periodically measuring loss, then samples and decodes generated text and saves weights. The graph separates data preparation, model internals, and training/inference orchestration. All runtime code is in the one excerpted script; the README documents the workflow and capabilities, but there are no separate modules or sampled persistence/loading path.
Main entry points: biagram.py Training loop · input.txt Shakespeare text
Components 13
Corpus preparation
- Shakespeare text
input.txt - Character encoding and splits
biagram.py - Batch sampling
biagram.py
Transformer model
- Causal multi-head attention
biagram.py - Feed-forward layer
biagram.py - Transformer blocks
biagram.py - Character language model
biagram.py
Training and generation
- Loss evaluation
biagram.py - AdamW optimizer
biagram.py - Training loop
biagram.py - Text generation and decoding
biagram.py - Saved model weights
biagram.py
Other components
- Project runner
Connections 18
- Project runner → Training loop: runs
README.md - Shakespeare text → Character encoding and splits: provides text
biagram.py - Character encoding and splits → Batch sampling: supplies splits
biagram.py - Training loop → Batch sampling: requests batches
biagram.py - Batch sampling → Character language model: provides inputs
biagram.py - Character language model → Causal multi-head attention: uses
biagram.py - Character language model → Transformer blocks: applies blocks
biagram.py - Transformer blocks → Causal multi-head attention: invokes
biagram.py - Transformer blocks → Feed-forward layer: invokes
biagram.py - Training loop → Character language model: computes loss
biagram.py - Training loop → AdamW optimizer: updates parameters
biagram.py - Loss evaluation → Batch sampling: requests batches
biagram.py - Loss evaluation → Character language model: measures loss
biagram.py - Training loop → Loss evaluation: evaluates periodically
biagram.py - Text generation and decoding → Character language model: samples from
biagram.py - Text generation and decoding → Saved model weights: saves state
biagram.py - Training loop → Text generation and decoding: starts sampling
biagram.py - Project runner → Shakespeare text: provides corpus
README.md