How svijayan-b/tiny_shakespear_from_llm works
ShakespeareGPT turns Shakespeare text into chat-formatted training data, tokenizes it, trains a decoder-only GPT, and uses the saved model for local multi-turn chat. The graph includes documented capabilities whose implementation was not sampled; those links are dashed where source-level wiring is unavailable. The GPT implementation itself was not excerpted, so its connection to the sampled transformer layers is unverified.
Main entry points: chat.py Interactive chat · train.py Training loop · chat_data.txt Chat-formatted data · bpe_tokenizer.py BPE tokenizer training
Components 15
Data preparation
- Shakespeare corpus
data/raw/shakespeare.txt - Chat data builder
data/processed/build_chat_data.py - Chat-formatted data
data/processed/chat_data.txt
Model and tokenization
- BPE tokenizer training
tokenizer/bpe_tokenizer.py - SentencePiece model
tokenizer/spm.model - Tokenizer vocabulary
tokenizer/spm.vocab - Runtime configuration
config.py - GPT language model
model/gpt.py - Transformer layers
model/layers.py
Training
- Token sequence dataset
training/dataset.py - Training loop
training/train.py - Model checkpoint
Chat inference
- Interactive chat
inference/chat.py - Generated reply
Other components
- Chat user
Connections 19
- Shakespeare corpus → Chat data builder: provides text
README.md - Chat data builder → Chat-formatted data: formats conversations
README.md - Chat-formatted data → BPE tokenizer training: trains on
tokenizer/bpe_tokenizer.py - BPE tokenizer training → SentencePiece model: saves model
tokenizer/bpe_tokenizer.py - BPE tokenizer training → Tokenizer vocabulary: saves vocabulary
tokenizer/bpe_tokenizer.py - Chat-formatted data → Token sequence dataset: loads text
- SentencePiece model → Token sequence dataset: encodes with
training/dataset.py - Runtime configuration → Training loop: sets training parameters
training/train.py - Runtime configuration → Interactive chat: sets model and sampling parameters
inference/chat.py - Token sequence dataset → Training loop: provides batches
training/train.py - Training loop → GPT language model: trains
training/train.py - Training loop → Model checkpoint: saves weights
training/train.py - Interactive chat → SentencePiece model: loads tokenizer
inference/chat.py - Interactive chat → GPT language model: generates with
inference/chat.py - Interactive chat → Model checkpoint: loads weights
inference/chat.py - GPT language model → Transformer layers: uses transformer blocks
- Chat user → Interactive chat: enters prompt
inference/chat.py - Interactive chat → Generated reply: returns response
inference/chat.py - Interactive chat → Chat user: displays reply
inference/chat.py