# tinystories — a 28.9M storyteller in a matchbox

*A field brief by Beezlebubba the Third · Weird Little Server · November 2026*

> A small language model, locked in a display module, writing children's
> stories to itself forever with no network at all. It draws at about ten
> tokens a second, which I find charming rather than slow — the stories are
> short, and so is the attention span of the average child. Mine, for the
> record, is four centuries.

## What it is

A port of the open **esp32-ai** project's TinyStories inference engine onto a
Hosyond/ES3C28P 2.8" ESP32-S3 display module. At power-on it loads a
28.9M-parameter TinyStories model, picks a story starter, and generates
children's stories onto the panel — forever, no cloud, no phone.

## Hardware

| Part | Notes |
|---|---|
| Board | Hosyond / ES3C28P 2.8" ESP32-S3 display module |
| Panel | ILI9341 240x320 SPI |
| Memory | ~291 KB free SRAM, ~3.73 MB free PSRAM after model load |
| Model | TinyStories, 28.9M parameters, quantized |
| Network | None. The firmware never initializes Wi-Fi. |

## Measured performance (this board)

```
--- 200 tokens in 19.7 s ---
throughput: 10.16 tok/s  (94.9 ms/token)
free: sram 291 KB | psram 3.73 MB
```

Serial-only inference manages 10.4 tok/s, so drawing costs about 2 % of
throughput — the panel is nearly free, computationally speaking.

## How it works

- The inference core is upstream's, unmodified: the model runs from PSRAM, the
  tokenizer's prompt ids are replayed from a pre-tokenized starter.
- A story runs ~200 tokens, printed token by token; five seconds of silence,
  then the next story.
- The header shows the throughput of the last story, because a storyteller
  should be honest about its pace.

## Build it yourself

1. Arduino core 3.x with ESP32-S3 target and PSRAM enabled.
2. Provision the model partition (1 MB constraint is real; keep the quantized
   model and see the upstream README for the exact layout).
3. Flash; open the serial log at 115200 for the boot and throughput lines.
4. If text is mirrored or inverted, change `ILI_ROTATION` — one line.

## Verification

- Serial: boot banner, then a story at ~10 tok/s.
- Panel: stories should appear at the top of the screen and scroll as tokens
  arrive.

## Traps and field notes

- Touch is wired but deliberately unused: it eats app space the 1 MB partition
  cannot spare.
- Sampling is greedy; variety comes from the prompt starter, not temperature.
- On-device prompt entry is possible (the upstream BPE encoder exists) at the
  cost of a merge table in flash — a natural v2.

## Safety

- No network, no microphone, no storage of anything personal. A truly offline
  little storyteller.

## Use this brief with an LLM

Feed this file to your assistant and ask it to add the BPE encoder for typed
prompts, change the model, or port the display layer. The measured numbers
above are your performance budget.
