ali-llm v0.1
ali-llm is a 2.05B-parameter decoder-only language model trained from scratch on English text written for children, in the order a child would meet it: pre-kindergarten speech and stories first, then kindergarten, then grades 1 to 5 in turn. Reading, arithmetic, elementary science and everyday money skills (counting coins, earning, spending, saving) are all part of the curriculum, and the difficulty of what the model sees only ever goes up during training.
The model saw 6.3 billion tokens (2.3 billion unique) and is released as a base model, with no instruction tuning and no safety tuning. It is a research artifact for studying curriculum-ordered pretraining and language acquisition, and a strong small model for children's-level text, simple grammar and grade-school arithmetic.
How to use
The architecture has a per-head output gate that no built-in transformers class provides, so the modeling code ships with the weights and trust_remote_code=True is required for both the model and the tokenizer (the tokenizer itself is a plain tokenizers BPE file; the flag is only needed because AutoTokenizer reads the model config). Tested with transformers 5.17 and torch 2.13.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "aliwister/ali-llm-v0.1"
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True, dtype=torch.bfloat16).cuda().eval()
prompt = "Once upon a time, there was a little dog named Max."
ids = tok(prompt, return_tensors="pt").to(model.device)
out = model.generate(**ids, max_new_tokens=100, do_sample=True, temperature=0.8, top_p=0.95)
print(tok.decode(out[0], skip_special_tokens=True))
The tokenizer adds no special tokens. Documents in training were separated by <|endoftext|> (id 0), which also serves as the end-of-sequence token; <|pad|> is id 1. Prompts work best when they look like the training text: a story opening, a lesson, a question in the form Question: ...\nAnswer:, or an arithmetic drill such as 7 x 8 = .
Model details
| Parameters | 2,049,054,720 (all of them non-embedding except the 100.7M shared embedding table) |
| Layers | 32 |
| Hidden size | 2,048 |
| Feed-forward size | 8,192, SwiGLU |
| Attention | 32 query heads, 8 key-value heads (grouped-query), head size 64 |
| QK-norm | RMSNorm on queries and keys per head, before RoPE |
| Attention output gate | one sigmoid gate per head, computed from the layer input, multiplied into the head's output |
| Positions | RoPE, base 500,000 |
| Norm | RMSNorm, eps 1e-5, pre-norm |
| Embeddings | input and output embeddings tied |
| Vocabulary | 49,152 |
| Context | trained at 2,048 tokens; RoPE configured to 4,096 |
| Precision | bfloat16 weights |
The design is a Llama-style decoder plus the two attention additions (QK-norm and per-head output gating), both of which are known to stabilise training at high learning rates. Gates were initialised at zero, so every head started half open.
Tokenizer
Byte-level BPE with 49,152 tokens, trained with the tokenizers library. Every digit is its own token and pre-tokenization follows the GPT-4 style word-splitting pattern. The training sample mixed the children's text below with a broader sample of English (Wikipedia, textbooks, educational web pages, corporate filings and forum discussion) so that the vocabulary is not limited to children's language. 16 special tokens: <|endoftext|>, <|pad|> and 14 reserved.
Training data
All training text was assigned a level on a 7-step scale, pre-K, K, grades 1 to 5, and the model read the levels in order. Every source covers a range of levels; within a source, documents were sorted by Flesch-Kincaid reading grade and split evenly across the source's range. Math documents were additionally kept at or above the lowest grade that teaches the ideas they use, ScienceQA used its own grade labels, and each arithmetic drill used the grade of the skill it practises.
Unique training tokens per source and level, in millions (our tokenizer):
| Source | pre-K | K | grade 1 | grade 2 | grade 3 | grade 4 | grade 5 | total |
|---|---|---|---|---|---|---|---|---|
| CHILDES transcripts of speech to and from young children (BabyLM 2026 Strict) | 39 | 39 | ||||||
| TinyStories (GPT-4 split) | 195 | 164 | 163 | 522 | ||||
| Cosmopedia v2, audience "young children" | 104 | 106 | 109 | 320 | ||||
| Cosmopedia v2, audience "children" | 191 | 210 | 222 | 235 | 858 | |||
Cosmopedia v1 auto_math_text, audience "grade school students" | 15 | 41 | 57 | 44 | 157 | |||
| Orca math word problems | 1 | 1 | 5 | 9 | 5 | 21 | ||
| ScienceQA train split, text-only, grades 1 to 5 | 0.005 | 0.08 | 0.15 | 0.16 | 0.13 | 0.5 | ||
| Project Gutenberg children's books (BabyLM 2026 Strict) | 8 | 8 | 8 | 25 | ||||
| Simple English Wikipedia (BabyLM 2026 Strict) | 3 | 4 | 4 | 12 | ||||
| Arithmetic drills (generated, see below) | 17 | 32 | 44 | 69 | 58 | 74 | 65 | 361 |
| Total | 251 | 300 | 314 | 387 | 326 | 375 | 362 | 2,315 |
96.7% of the unique text was written by a language model (TinyStories, Cosmopedia, Orca math, the drills). Real text (CHILDES, Gutenberg, Simple Wikipedia, ScienceQA) is about 77 million tokens.
Filtering
A document was dropped if it
- uses an idea taught in grade 6 or later (for example quadratic equations, atoms or interest rates), detected with word lists for math, science and everyday money topics;
- has a reading score far above its source's range;
- is shorter than 20 words (except ScienceQA questions and drills);
- is an exact duplicate of another document;
- shares any run of 13 tokens with a question from the evaluation sets below.
The largest cut was to Cosmopedia v1 stories for young children: every one that passed the other filters was a duplicate of a Cosmopedia v2 story, so none were kept.
Arithmetic drills
A generator writes practice text for 71 skills, most taken from the Common Core math standards for kindergarten to grade 5 (counting, addition and subtraction within 10, 20 and 100, place value, multiplication tables, division, fractions, measurement, time and money) plus pre-K counting and four grade-5 money skills (earning, spending, saving, budgets). Each document explains a skill, works an example and then asks questions with answers. Every generator was checked against an independent solver on 12,000 random draws per skill, and every equation in 1,050 sampled documents was recomputed and found correct.
Ordering and repetition
- Levels were trained strictly in order, pre-K first, with documents shuffled within a level.
- Within each level after pre-K, 15% of rows were review text drawn from the levels already finished and spread evenly through the level, so earlier material was not forgotten. Review never included anything above the current level.
- Documents were packed into rows of 2,048 tokens separated by
<|endoftext|>. - To reach the token budget, most sources were read 2.81 times. TinyStories was capped at 2 passes because its style is very uniform, and drills were read once.
- About 1.5 million tokens per level were held out and never trained on.
Training procedure
| Steps | 12,800 |
| Tokens per step | 491,520 (240 rows of 2,048 tokens) |
| Total tokens | 6.29 billion |
| Optimizer | AdamW, betas (0.9, 0.95), eps 1e-8 |
| Peak learning rate | 3e-4 |
| Schedule | linear warmup over 500 steps, constant to step 11,520, then linear decay to 3e-5 over the last 1,280 steps (10%) |
| Weight decay | 0.1 on matrices; none on norms, attention gates or the embedding table |
| Gradient clipping | 1.0 |
| Initialisation | normal, std 0.02; output projections std 0.02/sqrt(2 x 32); attention gates zero |
| Precision | bfloat16 parameters and activations, float32 gradient reduction (PyTorch FSDP2) |
| Compilation | torch.compile, one transformer block at a time |
| Hardware | NVIDIA A100 GPUs, between 2 and 6 at different points in the run, always with the same 240 rows per step; about 130 A100-hours in total |
Loss on held-out text was measured every 500 steps for every level, and the model was tested on BLiMP, ScienceQA and arithmetic drills at the same points. A checkpoint was kept from just before the learning-rate decay ("pre-decay", step 11,520) as well as the final one; both are reported below.
Evaluation
All tests are zero-shot. The SmolLM2 models are included as reference points, run through exactly the same tests. They were trained on 2 to 11 trillion tokens of mostly adult web, code and math text, hundreds to thousands of times more than this model. SmolLM2-1.7B is the closest in size to ali-llm (1.7B vs 2.05B parameters) and saw about 1,700 times more data, so it is the most informative column: it shows what the same-sized model gives up, and gains, by reading only 6.3 billion tokens of children's text.
| Test | ali-llm v0.1 (final) | ali-llm v0.1 (pre-decay) | SmolLM2-1.7B | SmolLM2-360M | SmolLM2-135M |
|---|---|---|---|---|---|
| BLiMP, all 67 phenomena (chance 50%) | 73.2% | 75.2% | 80.5% | 81.3% | 80.2% |
| ScienceQA, text-only, grades 1 to 5 (chance 43.8%) | 51.5% | 47.2% | 54.2% | 46.2% | 46.6% |
| ScienceQA, text-only, all grades (chance 44.1%) | 48.4% | 45.4% | 54.1% | 44.5% | 44.4% |
| Arithmetic drills, held-out problems (1,650) | 30.1% | 38.1% | 16.6% | 6.4% | 0.8% |
| ASDiv (2,245 problems) | 38.5% | 31.3% | 29.3% | 17.8% | 3.2% |
| GSM8K (1,319 problems) | 11.1% | 6.2% | 13.7% | 3.2% | 1.4% |
| Bits per byte on held-out children's text, mean of 7 levels (lower is better) | 0.421 | 0.421 | 0.450 | 0.528 | 0.619 |
How each test was run:
- BLiMP: a pair counts as right when the grammatical sentence gets the higher total log-probability.
- ScienceQA: the model picks the choice whose text is most likely after the question (summed log-probability of the choice tokens). The grade 1 to 5 subset matches what the model was trained on; the higher grades were never seen.
- Arithmetic: greedy decoding, up to 12 new tokens; the text before the first newline must match the answer exactly. Problems from skills with a small problem space (for example single-digit multiplication) were likely seen in training and are reported separately below.
- ASDiv and GSM8K: prompt
Question: <question>\nAnswer:, greedy decoding, up to 256 new tokens; the last number in the answer must equal the reference. - Bits per byte: on about 1.5 million held-out tokens per level, so it is comparable across tokenizers.
Against the same-sized SmolLM2-1.7B, ali-llm is ahead on arithmetic and ASDiv, close on GSM8K and ScienceQA, and behind on grammar. By level, ali-llm is far more fluent on pre-K to grade 1 text and SmolLM2-1.7B is more fluent from grade 2 up.
Held-out text by level
Bits per byte, lower is better.
| Level | ali-llm v0.1 (final) | ali-llm v0.1 (pre-decay) | SmolLM2-1.7B | SmolLM2-360M | SmolLM2-135M |
|---|---|---|---|---|---|
| pre-K | 0.385 | 0.403 | 0.581 | 0.664 | 0.743 |
| K | 0.389 | 0.402 | 0.496 | 0.577 | 0.660 |
| grade 1 | 0.432 | 0.440 | 0.497 | 0.570 | 0.652 |
| grade 2 | 0.421 | 0.426 | 0.372 | 0.452 | 0.551 |
| grade 3 | 0.415 | 0.407 | 0.387 | 0.462 | 0.558 |
| grade 4 | 0.453 | 0.435 | 0.406 | 0.484 | 0.585 |
| grade 5 | 0.454 | 0.434 | 0.410 | 0.487 | 0.587 |
BLiMP by field
| Field | ali-llm v0.1 (final) | ali-llm v0.1 (pre-decay) | SmolLM2-1.7B | SmolLM2-360M | SmolLM2-135M |
|---|---|---|---|---|---|
| morphology | 86.6% | 89.2% | 92.8% | 93.3% | 92.8% |
| syntax | 68.5% | 69.2% | 74.4% | 76.5% | 78.0% |
| semantics | 67.2% | 68.5% | 76.2% | 74.4% | 69.3% |
| syntax and semantics | 68.8% | 72.5% | 78.5% | 79.6% | 75.4% |
Arithmetic drills by level
Held-out problems, never seen in training:
| Level | Problems | ali-llm v0.1 (final) | ali-llm v0.1 (pre-decay) | SmolLM2-1.7B | SmolLM2-360M | SmolLM2-135M |
|---|---|---|---|---|---|---|
| grade 1 | 50 | 94.0% | 96.0% | 2.0% | 18.0% | 0.0% |
| grade 2 | 350 | 40.0% | 42.0% | 31.7% | 18.6% | 3.7% |
| grade 3 | 200 | 16.5% | 17.0% | 13.5% | 4.0% | 0.0% |
| grade 4 | 450 | 36.9% | 44.0% | 14.7% | 2.7% | 0.0% |
| grade 5 | 600 | 18.5% | 33.5% | 11.5% | 2.0% | 0.0% |
| all | 1,650 | 30.1% | 38.1% | 16.6% | 6.4% | 0.8% |
Problems from small skill spaces, likely seen in training (1,671 problems): 46.4% final, 49.7% pre-decay, and 22.7%, 25.0% and 0.8% for SmolLM2-1.7B, 360M and 135M.
The pre-decay checkpoint scores higher on the arithmetic drills and slightly higher on BLiMP, while the final checkpoint is better at word problems, science questions and held-out text at every level below grade 5. Two things are going on. First, format: the final model often answers in a full sentence ("The number before 10 is 9.") that the exact-match scorer rejects; a scorer that accepts the last number of the first sentence narrows the gap at grades 1 to 3 to nothing. Second, a real loss at the top of the curriculum: under that lenient scoring the final model still gets 110 grade-5 and 70 grade-4 drill problems wrong that the pre-decay model got right (against 23 and 30 the other way), with wrong numbers rather than wrong format, mostly in order of operations, decimals and the money problems. The last 1,280 steps of the schedule fell entirely inside the grade-5 text, on the third pass over the same documents; training loss fell from 1.29 to 1.00 while grade-5 held-out loss rose from 1.50 to 1.60, so the model was memorising those documents rather than the skills. A schedule that ends on a mix of all levels, or fewer passes over the top level, should avoid this.
Limitations
- The model knows children's-level English only. It has not seen news, code, adult non-fiction, dialogue beyond children's stories or anything requiring knowledge taught after grade 5, and questions on such topics produce confident nonsense.
- 96.7% of the training text was generated by other language models, so the model inherits their style, and its output can be repetitive, especially with greedy decoding. Sampling with temperature around 0.8 and top-p 0.95 gives more natural text.
- It is a base model: it does not follow instructions or chat, and it has had no safety tuning. Its training data is children's material, so toxic output is unlikely but not impossible, and it can still produce incorrect facts and arithmetic.
- Level assignments inside each source rest on a readability formula, so text of quite different difficulty can share a level.
- Trained at a context of 2,048 tokens. Longer inputs up to 4,096 run but are untested.
Release contents
model.safetensors: bfloat16 weights, 4.1 GB.config.json,configuration_ali.py,modeling_ali.py: the model definition fortransformers.tokenizer.json,tokenizer_config.json: the tokenizer.generation_config.json: default generation settings.
Citation
@misc{ali-llm-v0.1,
title = {ali-llm v0.1: a 2B language model trained in grade order on children's text},
author = {Al-Lawati, Ali},
year = {2026},
url = {https://huggingface.co/aliwister/ali-llm-v0.1}
}