Skip to content
XDR-SAMPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

🎭 Tiny Shakespeare GPT

A tiny character-level GPT trained on Shakespeare's works. Runs entirely on CPU.

Model Specs

  • Parameters: 0.83M
  • Architecture: 4-layer transformer, 4 attention heads, 128-dim embeddings
  • Vocabulary: 93 characters (ASCII/printable)
  • Context length: 128 characters
  • Training: CPU-only, ~5000 steps on 1.5M chars

Quick Start

CLI Mode

# Basic generation
python3 generate.py --prompt "To be, or not" --max-tokens 200

# More creative (higher temperature)
python3 generate.py --prompt "Romeo, Romeo" --temperature 1.0 --max-tokens 300

# More focused (lower temperature)
python3 generate.py --prompt "good" --temperature 0.7 --max-tokens 150

Web Mode

python3 generate.py --web --port 8081
# Open browser to http://localhost:8081

Files

  • train.py — train the model from scratch
  • generate.py — standalone generator with CLI + web UI
  • model.pt — trained weights
  • tokenizer.json — character mappings
  • input.txt — training dataset

Tips

  • Prompting: Start with Shakespeare-style phrases: "To be, or not", "Romeo, Romeo", "The lady doth"
  • Generation style: Better with phrases longer than a few characters
  • Sampling: top_k=80 and temperature=0.8 work well
  • CPU performance: Generation is instant for short sequences; 200+ tokens is still fast on modern CPUs
  • Limitations: This is a toy model; it captures word patterns and rhythm, but not full grammar

How to Retrain

# 1. Ensure dataset exists
python3 train.py  # downloads Shakespeare if missing

# 2. Train (takes ~5-10 minutes on CPU)
python3 train.py

# 3. Generate
python3 generate.py --prompt "good"

Demo Ideas

Try:

  • "What light through yonder window breaks"
  • "To die, to sleep"
  • "Friends, Romans, countrymen"
  • "The course of true love never did run smooth"

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages