Views
No views yet
First Citizen: We’ll have that end.
Status: Preview Epochs trained100| Checkpoint size ≈ 30 MB | License MIT
| Resource | Link |
|---|---|
| Training script | fine_tune_gpt2_from_scratch_mps.py |
| Tokenizer files | see Files & versions tab |
| Responsible AI Toolkit | Hugging Face safe-completion docs |
| Component | Value |
|---|---|
| Base | GPT-2 (from‐scratch) |
| Layers / Heads | 8 / 8 |
| Hidden size | 256 |
| Context length | 256 tokens |
| Vocab size | 5 000 |
| Parameters | ≈ 7.63 M |
| Dropout | 0.1 (attn/embd/resid) |
| Modality | Shape | Description |
|---|---|---|
| Text input | up to 256 tokens | Archaic/modern English prompt |
| Text output | 1 – 256 tokens | Autoregressive continuation in Shakespearean style |
| Setting | Value |
|---|---|
| Dataset | Public-domain Shakespeare text (Project Gutenberg) stored in one CSV column text |
| Total tokens | ~0.9 M |
| Tokeniser | Byte-Level BPE (5000 vocab, min freq 3) |
| Window | 256 tokens, 50 % overlap |
| Train / Val split | 95 % / 5 % |
| Epochs | 100 |
| Optimiser | AdamW |
| LR schedule | Linear, peak 8 e-5, warm-up 5 % |
| Gradient accum | 4 |
| Hardware | Apple M-series GPU (MPS backend) |
| Framework | PyTorch / Transformers 4.x |
| Final losses | train_loss ≈ 1.92, eval_loss ≈ 1.90 |
| Metric | Value |
|---|---|
| Perplexity (eval) | ~6.7 |
| Generation sample | “First Citizen: Before we proceed any further, if we have power to the people, we come not suffer us. First Citizen: We'll have that end. CORIOLANUS: You are, noble Marcius, You have that come in arms. BRUTUS: What! let's to the gods do? SICINIUS: That would you do? First Citizen: I would he were well. CORIOLANUS: I know you have heard me speak: I am a word, and I have not to do it as a man |
1from transformers import GPT2LMHeadModel, GPT2TokenizerFast
2
3model_id = "Esmaelmoat/SHAKESPEAR_GTP2"
4tok = GPT2TokenizerFast.from_pretrained(model_id)
5gpt2 = GPT2LMHeadModel.from_pretrained(model_id)
6
7prompt = "To be, or not to be"
8out = gpt2.generate(
9 **tok(prompt, return_tensors="pt"),
10 max_length=100,
11 do_sample=True,
12 temperature=0.8,
13 top_k=40,
14 top_p=0.95,
15)
16print(tok.decode(out[0], skip_special_tokens=True))| Use-case | Examples |
|---|---|
| Creative exploration | poetry, stage dialogue, themed emails |
| Teaching / research | tokenisation demos, low-resource fine-tuning |
| Lightweight chat | NPC dialogue in indie games |
1@misc{shakespear_gpt2_2025,
2 author = {Esmael M. Aly Shaban},
3 title = {SHAKESPEAR\_GTP2: A Tiny GPT-2 Trained on Shakespeare},
4 year = {2025},
5 howpublished = {\url{https://huggingface.co/Esmaelmoat/SHAKESPEAR_GTP2}},
6 note = {MIT License}
7}