|
Download README.md from AlmostNobody/Tinygpt-python-teacher: direct link, hf CLI and curl.
- Browser
- Download file 1.95 kB
-
https://huggingface.co/AlmostNobody/Tinygpt-python-teacher/resolve/main/README.md
- Command line
-
hf download hf://AlmostNobody/Tinygpt-python-teacher/README.md
-
curl -L -o README.md https://huggingface.co/AlmostNobody/Tinygpt-python-teacher/resolve/main/README.md
1.95 kB
metadata
license: mit
library_name: pytorch
tags:
- text-generation
- from-scratch
- character-level
- tiny-model
- educational
TinyGPT: a 1M parameter model trained from scratch
A tiny character-level transformer (about 1.04 million parameters), written in PyTorch and trained from scratch (not fine-tuned from any other model) on a small "friendly Python teacher" dataset. It is a learning project and is not meant to be useful for real questions.
Model details
| Parameters | ~1.04M |
| Layers / heads / embedding size | 5 / 4 / 128 |
| Context length | 128 characters |
| Tokenizer | character-level (108 characters, see vocab.json) |
| Training data | 3,000 question/answer examples (~1.5M characters) |
| Final loss | train ~0.16, validation ~0.89 |
What it can and can't do
- It picks up the style of the training data: friendly tone, emojis, code blocks.
- It mostly memorizes its training answers. The training set has only about 150 distinct questions, so it does not understand new questions, and for unseen wording it tends to produce confident-looking but wrong or nonsensical text.
- Questions worded like the training data work best, for example "How does a while loop work?" or "What is recursion?".
Usage
Put tinygpt.pt (the weights) in the same folder as the other files, then:
pip install torch
python generate.py "How does a while loop work?"
The model expects this prompt format (generate.py adds it for you):
### Question:
<your question>
### Answer:
Files
tinygpt.pt: trained weights (PyTorch state dict)model.py: the model code (needed to load the weights)config.json: model settingsvocab.json: the character vocabulary, in ordergenerate.py: example script
Training
Trained for 3,000 steps with AdamW (lr 2e-3), batch size 64, on 1,529,604 characters, with 15 held-out questions used for validation.