TinyStories-GPT2-10k is a lightweight, decoder-only transformer model trained from scratch on a tokenized version of the
TinyStories dataset. It uses a custom Byte Pair Encoding (BPE) tokenizer with a vocabulary size of 10,000 tokens, making it well-suited for experiments in efficient language modeling, scaling laws, and low-resource fine-tuning.
This model follows the core GPT-2 architectural principles with a few simplifications to reduce parameter count and training cost.
Weights were initialized with a normal distribution (𝒩(0, 0.02)), with additional scaling in residual paths by ( \frac{1}{\sqrt{2N}} ), where ( N = 8 ) (number of decoder layers), as inspired by GPT-2's residual accumulation strategy.
The model was trained using a custom BPE tokenizer built from the TinyStories dataset using the Hugging Face tokenizers library. The tokenizer was capped at 10,000 tokens and saved as bpe-tokenizer_tinystories.json.
1from transformers import GPT2TokenizerFast, GPT2LMHeadModel
2
3tokenizer = GPT2TokenizerFast.from_pretrained("KabirBakhshaei/TinyStories-GPT2-10k", tokenizer_file="bpe-tokenizer_tinystories.json")
4model = GPT2LMHeadModel.from_pretrained("KabirBakhshaei/TinyStories-GPT2-10k")
5
6prompt = "Once upon a time"
7inputs = tokenizer(prompt, return_tensors="pt")
8outputs = model.generate(**inputs, max_new_tokens=100, temperature=0.9, top_k=10)
9
10print(tokenizer.decode(outputs[0], skip_special_tokens=True))