Intended Use
- Generating short bedtime-style stories for children (with adult review)
- Learning and demo projects on small-model fine-tuning
Not intended for: unsupervised use by children, factual writing, or any use that needs guaranteed safe output.
How to Use
The model expects this prompt format:
Write a {length} children's story about {theme}.
length: short, medium, or long
theme: for example animals, friendship, adventure, kindness, family, everyday life
import torchfrom transformers import AutoTokenizer, AutoModelForCausalLM model_id = "sumiya-riaz/smollm-children-stories"tok = AutoTokenizer.from_pretrained(model_id)model = AutoModelForCausalLM.from_pretrained(model_id) prompt = "Write a short children's story about kindness."messages = [{"role": "user", "content": prompt}]text = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)inputs = tok(text, return_tensors="pt") with torch.no_grad(): out = model.generate(**inputs, max_new_tokens=300, do_sample=True, temperature=0.7, top_p=0.9, repetition_penalty=1.1) print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Training Data
A random 50,000-story subset of TinyStories (1,000 validation stories). The dataset has no theme or length labels, so these were assigned automatically:
- Theme: keyword matching on the story text
- Length: word count (short < 120 words, medium < 220, long otherwise)
Because themes come from keywords, they are approximate and sometimes wrong.
Training Procedure
Table with columns: Setting, Value| Setting | Value |
|---|
| Method | Full fine-tuning with TRL SFTTrainer |
| Epochs | 1 (1,563 steps) |
| Batch size | 16, gradient accumulation 2 (effective 32) |
| Learning rate | 5e-5, cosine schedule, 50 warmup steps |
| Max sequence length | 512 |
| Precision | fp32 weights, fp16 mixed precision |
| Hardware | Google Colab T4 GPU, about 56 minutes |
| Final average training loss | 1.29 |
Results
Compared with the base model, the fine-tuned model:
- finishes its stories instead of stopping mid-sentence
- uses shorter, simpler sentences suited to young children
- has a clearer beginning, problem, and ending, often with a simple moral
No formal benchmark was run. Evaluation was done by comparing generated stories before and after fine-tuning.
Limitations and Bias
- Small model (135M parameters): stories may contain logic errors or inconsistent settings and characters.
- English only, and style is limited to simple TinyStories-like writing.
- Theme control is approximate because of keyword-based labels.
- The model can still produce unsuitable content. The demo app adds a rule-based word filter on top, but this filter is basic and does not replace adult supervision.
- Outputs may reflect biases present in the training data.
Author
Sumiya Riaz (sumiya-riaz)