Run this model with HF Jobs
Run TreeLoys/microRL-20M-TinyStories on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/TreeLoys/microRL-20M-TinyStories. Ask me which dataset to train on, then push the LoRA adapter to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs and Transformers to run batch inference with https://huggingface.co/TreeLoys/microRL-20M-TinyStories on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the predictions back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs and Lighteval to evaluate https://huggingface.co/TreeLoys/microRL-20M-TinyStories. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/TreeLoys/microRL-20M-TinyStories with Transformers and bitsandbytes. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use TreeLoys/microRL-20M-TinyStories with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TreeLoys/microRL-20M-TinyStories with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="TreeLoys/microRL-20M-TinyStories")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("TreeLoys/microRL-20M-TinyStories") model = AutoModelForCausalLM.from_pretrained("TreeLoys/microRL-20M-TinyStories", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use TreeLoys/microRL-20M-TinyStories with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TreeLoys/microRL-20M-TinyStories" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TreeLoys/microRL-20M-TinyStories", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/TreeLoys/microRL-20M-TinyStories
- SGLang
How to use TreeLoys/microRL-20M-TinyStories with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "TreeLoys/microRL-20M-TinyStories" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TreeLoys/microRL-20M-TinyStories", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "TreeLoys/microRL-20M-TinyStories" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TreeLoys/microRL-20M-TinyStories", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use TreeLoys/microRL-20M-TinyStories with Docker Model Runner:
docker model run hf.co/TreeLoys/microRL-20M-TinyStories
microRL-20M-TinyStories
A 20M-parameter decoder-only language model trained from scratch on TinyStories (V2, GPT-4 curated) as a small, fast testbed for reinforcement-learning experiments on language models.
Trained in about 1.5 hours (93 minutes) of wall-clock time on a single consumer GPU: the NVIDIA P106-100 (2017), the mining variant of the GeForce GTX 1060 (2016), Pascal architecture, 6 GB. No cloud, no multi-GPU, no framework — a plain PyTorch loop. Full setup is in the Training section.
It is the same size class as the official TinyStories-8M from the TinyStories paper, but uses a Llama-style architecture and a custom 20k BPE tokenizer, so the whole model is 19.6M parameters and runs on a single 6 GB GPU with plenty of room to spare.
Status: first checkpoint (3000 optimizer steps). The loss was still falling when training stopped, so it is undertrained on purpose — it is a starting point for RL fine-tuning, not a finished model.
Quick start
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("TreeLoys/microRL-20M-TinyStories")
tok = AutoTokenizer.from_pretrained("TreeLoys/microRL-20M-TinyStories")
ids = tok("Once upon a time, there was a little girl named Lily.", return_tensors="pt")
out = model.generate(**ids, max_new_tokens=80, do_sample=True, temperature=0.8, top_k=40)
print(tok.decode(out[0], skip_special_tokens=True))
No trust_remote_code needed: the weights are stored as a native LlamaForCausalLM.
Architecture
| Type | decoder-only Transformer, Llama-style |
| Attention | causal, RoPE (theta 10 000), 8 heads × 32 dims |
| FFN | SwiGLU, 704 intermediate |
| Norm | RMSNorm (eps 1e-5), pre-norm |
| Layers | 18 |
| Hidden size | 256 |
| Context length | 512 |
| Vocabulary | 20 000 byte-level BPE, trained from scratch |
| Embeddings | input and output tied |
| Parameters | 19.58M total, 14.46M without embeddings |
| Biases | none |
Special tokens: [BOS] [EOS] [UNK] [PAD] <|user|> <|bot|>. The last two are reserved for later instruction tuning and were never seen in training.
The tokenizer was trained on a mixed sample: TinyStories (150 MB), WikiText-103 (120 MB), arXiv abstracts (80 MB) and OpenAssistant/oasst1 (60 MB). The model itself was pretrained on TinyStories only, so about 11k of the 20k vocabulary entries (mostly non-English and technical pieces) have never been activated by this checkpoint.
Training
| Hardware | 1 × NVIDIA P106-100, 6 GB (Pascal, sm_61; the mining variant of a GTX 1060) |
| Software | PyTorch 2.7.1 + CUDA 11.8, NVIDIA driver 472.12, plain torch loop, no frameworks |
| Precision | mixed fp16 (autocast + GradScaler), attention and softmax in fp32 (Pascal has no bf16) |
| Batch | 32 sequences × 512 tokens = 16 384 tokens per step (8 per pass × 4 gradient accumulation) |
| Optimizer | AdamW, lr 3e-3, betas (0.9, 0.95), weight decay 0.1, 100 warm-up steps, cosine decay to 0 |
| Grad clipping | global norm 1.0 |
| Steps | 3000 |
| Tokens seen | 49.15M (≈0.09 epoch of the 531M-token corpus) |
| Speed | ~9 400 tokens/s, 1.73 s per step |
| Training time | ~93 minutes (about 1.5 hours) wall-clock for the 3000 steps, ~1.86 s per step including periodic sampling and logging |
| Peak GPU memory | 2.7 GB |
Corpus: TinyStoriesV2-GPT4-train.txt, each story framed as [BOS] … [EOS], random 512-token windows.
Training loss, raw (light) and 5-point moving average, linear and log scale.
Evaluation
Held-out text, every model scored with its own tokenizer, so the numbers are reported in bits per byte (lower is better). 150 stories per validation set, same text for all models. The official models were trained on V1, this model on V2.
| Model | Total params | bits/byte, V1 valid | bits/byte, V2 valid |
|---|---|---|---|
| TinyStories-1M | 3.7M | 0.581 | 0.648 |
| TinyStories-3M | 8.3M | 0.439 | 0.512 |
| microRL-20M (this) | 19.6M | 0.491 | 0.500 |
| TinyStories-8M | 19.7M | 0.355 | 0.422 |
| TinyStories-28M | 52.0M | 0.304 | 0.362 |
| TinyStories-33M | 68.5M | 0.305 | 0.363 |
The official names count parameters without embeddings; with their 50 257-token untied vocabulary the real totals are 2–2.5× larger, which is why "8M" is the same size as this model.
Community models (top-liked on the Hub with the TinyStories dataset tag, up to 50M parameters)
Same 150 stories per set, same bits-per-byte metric. Only models that load with the stock AutoModelForCausalLM are listed; of the top-liked tagged repos most were dropped before scoring (ONNX/GGUF-only, custom code, no standard tokenizer, non-Transformer architectures, or over 50M parameters).
| Model | Total params | bits/byte, V1 valid | bits/byte, V2 valid |
|---|---|---|---|
| xxparthparekhxx/tinystories-33m (ONNX, scored without the KV cache) | 33.1M | 0.333 | 0.404 |
| SupraLabs/StorySupra-10M | 12.6M | 0.387 | 0.482 |
| microRL-20M (this) | 19.6M | 0.491 | 0.500 |
| nkthebass/tinybrainbot-10m-v2-base | 9.9M | 0.529 | 0.554 |
| PicoKittens/PicoStories-853K | 0.9M | 0.583 | 0.685 |
| nkthebass/tinybrainbot-3m-v2-base | 2.9M | 0.619 | 0.646 |
| calum/tinystories-gpt2-3M | 3.7M | 0.667 | 0.701 |
Additional numbers for this checkpoint on the V2 validation set: loss 1.62 nats/token (perplexity 5.0), top-1 accuracy 59 %, only 8 875 distinct tokens used.
Loss on out-of-domain text is close to uniform guessing (≈9 nats/token on Wikipedia, arXiv, oasst1 and books, ≈11.7 on Russian): the model knows the TinyStories genre and essentially nothing else.
Training loss: 9.69 → 1.69 over 3000 steps, still declining slowly at the end.
Six views of this checkpoint: held-out loss by domain, loss versus position in the context, predictive entropy versus the error on the actual next token, the entropy distribution, loss versus training frequency of the token, and embedding norm versus token frequency.
Generations
Greedy decoding, 80 new tokens:
Once upon a time, there was a little girl named Lily. She had a big, red ball that she loved to play with. One day, she saw a small, helpless bird on the ground. The bird was sad because it could not fly. Lily wanted to help the bird. She thought of a plan to make the bird happy. She took her ball and threw it to the bird. The bird was happy and flew away. Lily was happy that she
One day, Tom found a magic box in the forest. He did not know what was inside. Tom was very curious about the box. He wanted to know what was inside. Tom opened the box and found a big, shiny ball. He was so happy! He played with the ball all day. But then, something unexpected happened. The ball started to talk! It said, "Thank you for playing with me. I am a magic ball. I
Lily's mom said, "Lily, you need to be careful. You need to be careful." Lily did not listen. She wanted to play with her toys. She said, "No, mom, I want to play with my toys." Her mom said, "Lily, you have to listen to me. You have to listen to me. You have to listen to me. You have to listen to me. You
Sampling, temperature 0.8, top-k 40, 90 new tokens:
Once upon a time , there was a little girl named Lily. She loved to dance. Lily was an intelligent girl who always helped her mom and dad. She would dance every day, but she was very careful not to dance. One day, Lily's mom told her a story about a big, tasty cake. This story was about a big, round cake. The cake could talk! Lily was very happy and ate the cake. She clapped her hands and danced with
The little bird was scared. The bird wanted to help. It flew to the house and said, "Boo!" The bird was surprised! The bird said, "Don't be sad, big dog. I will help you." The big dog gave the bird a pretty dress. The bird was happy and gave the dress to the big dog. They both became good friends.
Intended use and limitations
- Intended: a cheap base model for RL experiments (preference tuning, verifiable rewards), teaching, and architecture tests on consumer hardware.
- Not intended: any factual or general-purpose use. It has no world knowledge, cannot count, and loses the thread after a few sentences.
- English only, child-like stories only. Greedy decoding repeats sentences; use sampling.
- Non-English text is tokenized (the vocabulary has room for it) but the model has never been trained on it.
Negative result: fine-tuning on one domain only
This checkpoint was fine-tuned on a private book collection (83M tokens of Russian and English non-fiction and fiction, 3 000 steps, lr 3e-4, no replay of the original data). Result: loss on those books went from 11.7 to 2.8 nats/token, but the model forgot most of what it had learned — loss on the TinyStories validation set rose from 1.65 to 4.40 and English prose became incoherent. Classic catastrophic forgetting.
The follow-up model microRL-20M-ru-en fixes this by mixing TinyStories back into the training data; its card lists the other things that did not work.
Source data and citation
Trained on roneneldan/TinyStories, which is distributed under the CDLA-Sharing-1.0 license. The dataset and the baseline models come from:
@article{eldan2023tinystories,
title = {TinyStories: How Small Can Language Models Be and Still Speak Coherent English?},
author = {Eldan, Ronen and Li, Yuanzhi},
journal = {arXiv preprint arXiv:2305.07759},
year = {2023}
}
- Downloads last month
- 303

