Run this model with HF Jobs
Run olanokhin/micro-qwen3 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 to fine-tune https://huggingface.co/olanokhin/micro-qwen3. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/olanokhin/micro-qwen3 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/olanokhin/micro-qwen3. 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/olanokhin/micro-qwen3. 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 olanokhin/micro-qwen3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use olanokhin/micro-qwen3 with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # if on a CUDA device, also pip install mlx[cuda] # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("olanokhin/micro-qwen3") prompt = "Once upon a time in" text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use olanokhin/micro-qwen3 with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Generate some text mlx_lm.generate --model "olanokhin/micro-qwen3" --prompt "Once upon a time"
- Atomic Chat
micro-qwen3
A language model with 1,056,656 parameters that follows the Qwen3 architecture block by block, trained from scratch. It writes short children's stories in English and can be asked for a story with up to three given words. It is small enough to run on an ESP32-S3 microcontroller at about 60 tokens per second, and to be watched step by step in a browser.
- Watch it work: TensorLupa, a studio that runs this model in your browser and shows every logit, attention head and layer.
- Run it on a microcontroller, or train it yourself: github.com/olanokhin/micro-qwen3-esp32 (firmware, the C inference core, training code and logs).
- How every size and setting was chosen, with the branches that lost: How micro-qwen3 was made.
It contains no Qwen weights and is not affiliated with Qwen or Alibaba Cloud.
Files
| Path | What it is |
|---|---|
instruct/ |
The demo model: instruction-tuned, full-precision weights (model.safetensors, MLX), config.json, tokenizer.json |
base/ |
The base model before instruction tuning: plain story continuation |
quantized/micro-qwen3-w8.bin |
The demo model with 8-bit weights for the C core (1.14 MB), as precise as the original |
quantized/micro-qwen3-w4r.bin |
The demo model with 4-bit weights (0.68 MB), the version that runs on the ESP32-S3 |
The .bin files hold the weights and the tokenizer in one file and are read by the dependency-free C core
(microqwen.c) from the GitHub repository.
The model
| Qwen3-0.6B | micro-qwen3 | |
|---|---|---|
| Block | RMSNorm (pre-norm), grouped-query attention, QK-norm, RoPE, SwiGLU, tied embeddings | the same |
| Layers × hidden size | 28 × 1024 | 3 × 112 |
| Attention | 16 heads × 128, 8 key-value heads | 4 heads × 64, 2 key-value heads |
| Vocabulary | 151,936 | 4,096, byte-level BPE with Qwen3's splitting rule |
| Context | 32K | 256 tokens |
| Parameters | about 596M | 1.057M |
How it was trained
Two runs on a MacBook with MLX:
- Pretraining from scratch on TinyStories V2, next-token prediction, 124M tokens. Held-out quality: 0.669 bits per byte.
- Instruction tuning on 900,000 dialogues from TinyStoriesInstruct in the Qwen chat format, 150M tokens, with the loss on the answer only and quantization-aware training for the 4-bit format from the first step. Held-out quality on the answers: 0.747 bits per byte in full precision and with 8-bit weights, 0.762 with 4-bit weights.
Reproduce it in Colab
The whole recipe also runs in PyTorch on a free T4 GPU: open the notebook in Colab, set the runtime to T4 GPU and run all cells. It downloads both datasets, trains the tokenizer and both stages, exports the 4-bit file and writes a story with the C engine. Training takes about 17 minutes, the data preparation about as long.
A run of the notebook, 35 minutes from start to finish, reached 0.667 bits per byte after pretraining (0.669 here) After instruction tuning, on the held-out windows that the training log uses (a different set from the one above), it reached 0.706 in full precision and 0.721 with 4-bit weights, the same as the original run in that log. The tokenizer comes out identical to the one in this repository. The weights do not: the random numbers differ, so you get your own model of the same quality. Every setting is in plain view in the notebook: keep it to repeat this model, or change the data, the shape or the learning rates and compare.
Use
The weights load with the training code from the GitHub repository (training/micro_qwen3):
import mlx.core as mx
from tokenizers import Tokenizer
from micro_qwen3.config import ModelConfig
from micro_qwen3.model import Qwen3ForCausalLM
from micro_qwen3.sampling import generate
d = "instruct" # or "base"
model = Qwen3ForCausalLM(ModelConfig.load(f"{d}/config.json"))
model.load_weights(f"{d}/model.safetensors")
model.eval()
tok = Tokenizer.from_file(f"{d}/tokenizer.json")
prompt = ("<|im_start|>user\nWrite a short story. Use the words: dragon, cookie, school.<|im_end|>\n"
"<|im_start|>assistant\n")
ids = list(generate(model, tok.encode(prompt).ids, max_tokens=200, temperature=0.6, top_k=40, stop_ids={0, 1, 2}))
print(tok.decode(ids))
For the base model, pass the start of a story as the prompt, for example "Once upon a time".
What to expect
- Short children's stories in English, sometimes clumsy. The model knows grammar, punctuation and the shape of a story. It does not know facts about the world, which do not fit into a million parameters.
- With plain sampling, as in the example above, about 64% of the requested words make it into the story. The studio and the firmware add a small decoding rule that gives the unused words a growing push and a spelling automaton that finishes a started word. With them all three words appeared in every one of the 200 test orders the rule was tuned on, and in 298 of 300 stories from orders the model had never seen, with today's settings of both the studio and the board.
- The context is 256 tokens, enough for one short story.
License
Apache 2.0 for the weights and the code. The model was trained on TinyStories, released under CDLA-Sharing-1.0, and on TinyStoriesInstruct by the same authors, Ronen Eldan and Yuanzhi Li (2023); the TinyStoriesInstruct page states no license.
Made by Alex Anokhin.
Quantized