An AI chatbot for the ESP32-S3

The model you chat with on this website is the same affan-ai-engine-nano-int4-v4.afn file that is prepared for the ESP32-S3 microcontroller. No conversion step, no server.

What you need

If your flash partition is larger, there is also an int8 file of about 15 MB that is practically lossless.

The file format

The .afn file begins with the magic AFNESP01, then a JSON header (model configuration, metadata and a tensor table), the tokenizer as JSON, and the weights, aligned to 4096 bytes so the data can be memory-mapped straight from flash. A CRC32 trailer protects the file.

What the firmware does

  1. Memory-map the model from the flash partition and read weights row by row, so the 8.4 MB of weights never have to fit in RAM.
  2. Tokenise the prompt with the byte-level BPE tokenizer stored in the file, using the chat format with the system prompt.
  3. Run the transformer one token at a time (int8 activations times int4 weights), keep the key-value cache in PSRAM, and sample the next token.
  4. Run the calculator tool: when the model writes <|calc|> ... <|/calc|>, evaluate the expression and feed back <|result|>value<|/result|>.

Speed on the chip depends on the firmware port. We have not published ESP32 speed figures yet, and we will add them once they are measured on real hardware.

Try the same model now

You can chat with exactly this model in your browser. It is the quickest way to see what the ESP32 file can do. Read how it works for the architecture and the 4-bit quantisation, or the FAQ.

Download the int4 model file (8.4 MB)

Talk to Nano right now

One 8.4 MB download, then it runs on your device. No sign-up, no server.

Wake up Nano