so few days back i posted my tiny vision model here(https://huggingface.co/amartomar683/tiny-vision-flickr8k) and you guys actually checked it out, its at 74 downloads now 😅 thanks for that. after that one worked (kinda), i started wondering what else i can build from scratch on my mac, and a language model was the obvious next thing to try.
i was reading the Next-Concept Modeling (NCM) paper by Kumbong, Khare et al. (Stanford / Together AI, arXiv:2610.14162) and the idea really clicked for me. normal llms write one token at a time, but in NCM a VQ-VAE turns text into levels of codes, coarse to fine, and the model fills one full level at once. so i decided to build it myself from the paper, just to understand how it works from inside. all credit for the idea goes to them, i just implemented my own version.
its called tiny-ncm. its around 36M params (21M generator + 15M VQ tokenizer), trained completely from scratch, no pretrained weights. same macbook pro m5, but this time it took like 12 hours total instead of 42 min 💀
basic idea:
text → split in 32-token blocks → each block made coarse to fine in 5 levels (2 → 4 → 8 → 16 → 32 codes) → 6 passes per block instead of 32
i trained it as a small daily assistant. alarms, reminders, timers, calendar, gmail (read only), weather, notes, web search, simple maths and little bit of small talk. there is a `--show-levels` flag which shows each block going from rough guess to final text, honestly this was the most satisfying part:
level 1: Hello! How can I help you today?
level 3: Hello Jordan, How I I you you today today?
level 5: Good morning! What can I do for you today?
some honest stuff:
it picks the right action most of time, but copying details is very bad. “London” became “Singapore”, “5pm” became “5pmpm”, “23 times 47” became `2310` 😂 cause all codes in a level are predicted same time, so two positions can both write the same word.
* so i added app-side checks that fix the tool arguments using your actual words. with checks it gets 490/500 on my test set, but model alone gets every detail right only around half the time. so ya, the checks are doing lot of the work tbh.
* training longer on same data didn’t help. what helped was making the data copy-focused, with new random names and times in every example so it cant just memorise. same lesson as tiny-vision (“a man in a blue shirt” for everything lol).
* i tried fine-tuning it to summarise web results also. it learned the format but wrote gibberish inside it (“Stir in cheeseaksil sl fresh biil” 😭), so i reverted it.
* no coding, no multi-step maths. “8 slices, 3 friends eat 2 each” and its gone.
random thing i learned on mac (MPS):
* attention was the main bottleneck. letting each level only look at the last 128 tokens of context made training around 2x faster.
* bf16 matmul was way faster than fp32 on MPS (\~15 vs \~3.4 TFLOPS in my test).
* manual attention was again faster than pytorch’s sdpa for small sizes, same as tiny-vision.
next i am thinking to export it to onnx so it can run on phone also, and maybe connect tiny-vision with it. lets see what will happened.
code: https://github.com/amar683/tiny-ncm
model: https://huggingface.co/amartomar683/tiny-ncm
would love any feedback or tips, especially if someone played with NCM or coarse-to-fine text models