๐Ÿ“– Privoid TinyStories 30M

A small language model built completely from scratch

Own tokenizer ยท own model code ยท own training loop ยท random weights to storyteller in 140 minutes on one GPU

Parameters From scratch Tokenizer Format Hardware License


โœจ At a glance

๐Ÿ Result
Matches Microsoft TinyStories-33M on Microsoft's own held-out split 0.4768 vs 0.4772 bits per byte, with less than half the parameters (29.9M vs 68.5M)
Beats Microsoft TinyStories-28M and -8M on both validation sets 0.4768 vs 0.4846 and 0.5562 on V1
Lowest score of the four on the GPT-4 validation stories 0.376 vs 0.439 for the best Microsoft model (see the training-data note below)
Runs anywhere Llama runs plain transformers, llama.cpp, Ollama; GGUF files from 32 MB

It writes short, simple English stories, the kind a young child can read.

๐Ÿ“Š Results against Microsoft Research's TinyStories models

Bits per byte

Model Total parameters TinyStories V1 validation
(Microsoft held-out split)
TinyStories V2 validation
(GPT-4 stories)
๐ŸŸฃ Privoid TinyStories 30M (ours) 29.9M 0.4768 0.3759
Microsoft TinyStories-33M 68.5M 0.4772 0.4389
Microsoft TinyStories-28M 52.0M 0.4846 0.4392
Microsoft TinyStories-8M 19.7M 0.5562 0.5113

Lower is better.

  • V1 validation (Microsoft's own held-out split): Privoid TinyStories matches Microsoft TinyStories-33M (0.477 vs 0.477; a gap of 0.0004 is too small to call a win) with less than half the parameters, and beats the 28M and 8M models.
  • V2 validation (GPT-4 stories): Privoid TinyStories scores lowest of the four models.
  • What is bits per byte? The model's average prediction loss, in bits, for each byte of story text. Lower means the model predicts real stories better. Unlike perplexity, it is fair across models with different tokenizers.
  • How it was measured: 5,000 held-out stories from each set, the same stories for every model, each scored on its own from its start.
  • Parameter counts are totals including embeddings, counted from the released weights. The Microsoft model names refer to a different count.
  • โš ๏ธ Training-data note: Microsoft's models were trained on TinyStories V1, which mixes GPT-3.5 and GPT-4 stories. This model was trained on the newer GPT-4-only V2 file, which gives it a home advantage on V2 validation. Training stories that appear in either validation set were removed. V1 validation is the stricter, fairer test for this model.

๐Ÿ“ Sample stories

Same prompts and same sampling settings (temperature 0.7, top-k 40) for both models. Not cherry-picked.

Prompt: Once upon a time, there was a little girl named Lily who

๐ŸŸฃ Privoid TinyStories 30M: Once upon a time, there was a little girl named Lily who loved to play with her toys. One day, she found a big, red ball in her yard. She thought it was the most useful thing she had ever seen. She couldn't wait to play with it and see what it could do. Lily took the ball outside and started to bounce it. As she played, she noticed that the ball had a handle on it. She was curious and decided to use the handle to attach a string to the ball. She thought it would be fun to see what would happen if she played with it. Lily played with the ball all day,

Microsoft TinyStories-33M: Once upon a time, there was a little girl named Lily who loved to explore. One day, she went to her garden and saw a tiny plant. She picked it up and showed it to her mom. "What's this?" Lily asked. "That's a tomato plant," her mom replied. "We need to raise it so it could grow big and strong." Lily was excited to help her mom raise the tomato plant. She watered it every day and watched it grow. One day, her mom told her they were going on a trip to the beach. Lily was thrilled and couldn't wait to see

Prompt: Tom and his dog went to the park. Suddenly,

๐ŸŸฃ Privoid TinyStories 30M: Tom and his dog went to the park. Suddenly, Tom saw a big, ugly tree. He wanted to climb it, so he asked his dog to help him. The dog said yes, so Tom began to climb. Tom climbed higher and higher. When he reached the top, he could see the whole park. He could see the other kids playing, but he was a bit scared. Suddenly, Tom heard a loud roar. It was a big, ugly monster! The monster was growling and it wanted to come out of the tree. Tom was so scared that he started to cry. The monster came closer and closer until it

Microsoft TinyStories-33M: Tom and his dog went to the park. Suddenly, they saw a giant. The giant was very big and had a big smile. Tom was scared but his dog said, "Don't worry, Tom. I will protect you." The giant said, "I am the giant and I have a big heart. If you help me, I will give you a big surprise." Tom was very excited and said, "Yes, yes, yes!" Tom and his dog helped the giant pick some apples from the tree. They picked many apples and put them in a basket. The giant was very happy and gave Tom a big surprise.

Prompt: The little bird was sad because

๐ŸŸฃ Privoid TinyStories 30M: The little bird was sad because it was very hot outside. The sun was shining, and the wind was blowing. The little bird wanted to be warm for a whole week. The little bird went to find some shade to rest in. It found a big tree with lots of leaves. The little bird felt better in the shade. It was not hot anymore. The little bird was very happy. After a short time, the little bird started to feel better. It was not hot anymore. The little bird looked around and saw the sun shining again. It was not hot anymore. The little bird flew out of the

Microsoft TinyStories-33M: The little bird was sad because he loved the sunflower so much. But then, the bird had an idea. He took the sunflower and flew away. The sunflower was happy again and thanked the bird for helping. From that day on, the sunflower knew that even though he was small, he could still do big things.

Prompt: One day, a big red ball rolled into the garden. Mia

๐ŸŸฃ Privoid TinyStories 30M: One day, a big red ball rolled into the garden. Mia, a little girl, saw the ball and wanted to play with it. She ran to the ball and gave it a big kick. But something unexpected happened. The ball did not go far. Instead, it went up into a tree. Mia was sad. A nice bird saw Mia and asked, "Why are you sad?" Mia said, "My ball went into the tree." The bird had an idea. It flew up to the tree and pushed the ball out with its beak. The ball fell down, and Mia caught it. She was happy and said, "Thank you, bird

Microsoft TinyStories-33M: One day, a big red ball rolled into the garden. Mia and Ben saw it and wanted to play with it. Mia said, "Let's roll the ball down the hill and see what happens!" Ben said, "OK!" They took turns rolling the ball and watching it bounce and spin. The ball rolled down the hill very fast. It went so high that it went over the fence. Mia and Ben gasped. They ran after the ball. The ball rolled into the street. A big car came and hit the ball. The ball popped and made a loud noise. The car stopped and the driver got out. He was sorry and scared.

๐Ÿš€ How to use

๐Ÿค— Transformers

from transformers import AutoModelForCausalLM, AutoTokenizer

tok = AutoTokenizer.from_pretrained("Privoid-ai/Privoid-TinyStories-30M")
model = AutoModelForCausalLM.from_pretrained("Privoid-ai/Privoid-TinyStories-30M")

inputs = tok("Once upon a time, there was a little girl named Lily who", return_tensors="pt")
out = model.generate(**inputs, max_new_tokens=200, do_sample=True, temperature=0.7, top_k=40)
print(tok.decode(out[0], skip_special_tokens=True))

๐Ÿฆ™ llama.cpp (GGUF)

llama-cli -hf Privoid-ai/Privoid-TinyStories-30M-GGUF:Q8_0 -p "Once upon a time" -n 200 --temp 0.7

๐Ÿง  Architecture

Type Decoder-only transformer, Llama-style
Parameters 29.9M (25.7M without embeddings)
Layers / width / heads 8 / 512 / 8
Feed-forward SwiGLU, 1,408 hidden
Position encoding RoPE (theta 10,000)
Normalization RMSNorm (pre-norm)
Context length 512 tokens
Vocabulary 8,192 tokens, SentencePiece BPE with byte fallback, trained by Privoid
Embeddings Input and output embeddings tied

๐Ÿ‹๏ธ Training

Training loss

Data TinyStoriesV2-GPT4 training file: 542M tokens
Tokens seen 1.02B (1.9 passes over the data)
Optimizer AdamW (beta 0.9/0.95), weight decay 0.1, peak learning rate 0.001, warm-up 300 steps, cosine decay
Batch 131,072 tokens per step, 7,787 steps
Precision bf16 mixed precision, torch.compile
Hardware and time One NVIDIA L4, 140.1 minutes
Final validation loss 1.1024 nats per token (GPT-4 validation stories)

The exported Llama weights were checked against the original PyTorch model before upload (largest logit difference 6.75e-4), and the tokenizer was checked to give identical token ids.

โš ๏ธ Limitations

  • It is a story model, not an assistant. It writes simple English children's stories and does not follow instructions or answer questions.
  • Its vocabulary and world knowledge are limited to what appears in TinyStories.
  • It can repeat itself or lose the thread in longer stories (see the bird sample above). Context is limited to 512 tokens.

๐Ÿ“š Credits and licence

  • Training data: TinyStories by Ronen Eldan and Yuanzhi Li (Microsoft Research), TinyStories: How Small Can Language Models Be and Still Speak Coherent English? (2023). CDLA-Sharing-1.0.
  • Compared models: roneneldan/TinyStories-8M, -28M and -33M, MIT.
  • This model (weights, tokenizer and code): Apache-2.0, built by Privoid.

Built from zero by Privoid ๐Ÿ’œ

Keywords: language model from scratch, small language model, tiny LLM, TinyStories, Llama architecture, SentencePiece tokenizer, pretraining, story generation, GGUF, llama.cpp.

Downloads last month
-
Safetensors
Model size
29.9M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for Privoid-ai/Privoid-TinyStories-30M

Quantizations
1 model

Dataset used to train Privoid-ai/Privoid-TinyStories-30M

Evaluation results

  • bits_per_byte on TinyStories V1 validation
    self-reported
    0.477
  • bits_per_byte on TinyStories V2 validation (GPT-4)
    self-reported
    0.376