A small GPT-style language model trained from scratch on
TinyStories.
It is an educational model for generating short, simple English stories.
The exported checkpoint was saved at training step 1,000. Its recorded
training loss was 3.11046 and recorded validation loss was 3.07700. These
values are checkpoint metadata, not a broader benchmark.
1import sys
2from pathlib import Path
3
4import torch
5from huggingface_hub import snapshot_download
6from tokenizers import Tokenizer
7
8model_dir = Path(snapshot_download("Haider92/tinystories-gpt-from-scratch"))
9sys.path.insert(0, str(model_dir))
10
11from inference_utils import generate_story, load_exported_model
12
13device = torch.device("cpu")
14model = load_exported_model(
15 model_dir / "config.json",
16 model_dir / "model.pt",
17 device,
18)
19tokenizer = Tokenizer.from_file(
20 str(model_dir / "tinystories_tokenizer.json")
21)
22
23result = generate_story(
24 model,
25 tokenizer,
26 prompt="Once upon a time",
27 target_tokens=120,
28 extra_tokens=80,
29 temperature=0.8,
30 top_k=40,
31 device=device,
32)
33print(result.story)
This model is intended for education, experimentation, and short
TinyStories-style text generation. It is not a general-purpose assistant.
The model is small and trained on a constrained synthetic-story dataset.
Outputs may be repetitive, inconsistent, incomplete, or factually incorrect.
It has no application-specific safety guarantees.
TinyStories is distributed under
CDLA-Sharing-1.0. No dataset files are
included in this repository.
The exported model weights and included source code are available under the
MIT License.