How rcurtis14/microgpt works
microgpt is a from-scratch, character-level GPT implemented in NumPy. Its main workflow turns Tiny Shakespeare text into character IDs and shifted training batches, then trains embeddings, causal attention, and a transformer block to predict the next character. The inference path loads saved weights and samples characters autoregressively. The graph preserves the documented data-download capability; edges are limited to relationships shown in excerpts, the SOURCE INDEX, or README. Unsampled implementation details are not inferred.
Main entry points: train.py Training Loop · generate.py Sampling Loop · tokenizer.py Character Tokenizer · get_data.py Corpus Download
Components 16
Text and Batches
- Corpus Download
get_data.py - Training Corpus
data.txt - Character Tokenizer
tokenizer.py - Shifted Batches
get_batch.py
Model Computation
- Tensor Autograd
engine.py - Token Embeddings
model.py - Causal Attention
attention.py - Transformer Block
block.py - Output and Loss
model.py
Training and Weights
- Training Loop
train.py - Saved Weights
model_weights.npz
Text Generation
- Sampling Loop
generate.py - Generated IDs
generate.py - Decoded Text
tokenizer.py
Other components
- User
- Tiny Shakespeare
Connections 21
- User → Corpus Download: requests corpus
README.md - Tiny Shakespeare → Corpus Download: provides text
get_data.py - Corpus Download → Training Corpus: writes corpus
get_data.py - Training Corpus → Character Tokenizer: reads text
tokenizer.py - Character Tokenizer → Shifted Batches: encodes text
get_batch.py - Shifted Batches → Training Loop: provides batches
train.py - User → Training Loop: starts training
README.md - Training Loop → Token Embeddings: embeds IDs
train.py - Training Loop → Transformer Block: runs block
train.py - Transformer Block → Causal Attention: calls attention
block.py - Training Loop → Output and Loss: computes loss
train.py - Training Loop → Tensor Autograd: backpropagates
README.md - Training Loop → Saved Weights: saves weights
train.py - User → Sampling Loop: starts generation
README.md - Sampling Loop → Saved Weights: loads weights
generate.py - Sampling Loop → Token Embeddings: embeds context
generate.py - Sampling Loop → Transformer Block: runs block
generate.py - Sampling Loop → Output and Loss: projects logits
generate.py - Sampling Loop → Generated IDs: samples IDs
generate.py - Generated IDs → Character Tokenizer: decodes IDs
generate.py - Character Tokenizer → Decoded Text: returns characters
tokenizer.py