Back to browse
GitHub Repository

GPT in a QR Code ; The actual most atomic way to train and inference a GPT in pure, dependency-free JS/Python.

130 starsHTML

PicoGPT v2 – GPT in <40 lines of vanilla JS running from a QR code

by kuberwastaken·Feb 16, 2026·2 points·1 comment

AI Analysis

MidWizardryRabbit Hole
The Take

It crams a full micro-GPT training loop — autograd, multi-head attention, GeLU² approximation, AdamW and a seeded PRNG — into 39 lines of JS and then gzips+base64s the page so it fits inside a version-40 QR. Using the browser's DecompressionStream to decompress and execute the payload on mobile is a clever, very practical trick; this is clearly a demonstration/teaching stunt rather than a practical model deployment, but it's an excellent exercise in minimalism and browser capabilities.

Category
Target Audience

ML enthusiasts, web developers, demo / code-golf hobbyists, people interested in on-device/browser ML experiments

Post Description

A few days ago I posted about PicoGPT - my take on MicroGPT by Andrej Karpathy, minified to 64 lines to run from a QR code

This is now v2 with minified JS! This version features a minimal GPT implementation with native browser execution through data URI with <40 lines of minified JS and no external dependencies

It makes use of the DecompressionStream Web API and a similiar logic to my past project of running a DOOM-like game from a QR code

you can quite literally "train" and run inference of a GPT model from your mobile device

Would love to hear what you think about it !

Related Links:

Show HN: PicoGPT – GPT in a QR Code https://news.ycombinator.com/item?id=46993035

MicroGPT by Andrej Karpathy - https://gist.github.com/karpathy/8627fe009c40f57531cb1836010... https://karpathy.github.io/2026/02/12/microgpt/

Show HN: I made a Doom-like game fit inside a QR code - https://news.ycombinator.com/item?id=43729683 https://github.com/kuberwastaken/backdooms

(PS: You'd need something like https://qrscanner.org/ that can scan larger QR codes)

Similar Projects

AI/MLMid

PicoGPT – GPT in a QR Code

The author minified Karpathy’s MicroGPT, ported it to 39 lines of JS (including a tiny autograd, MHA, AdamW and training loop) and shoehorned the whole gzipped HTML into a version-40 QR code that the browser decompresses and runs. It's clearly a stunt — the model is toy-scale (≈4k params, 8-token context) — but the compression trick, browser-native DecompressionStream use, and runnable-in-QR delivery are a delightful technical flex.

WizardryCrowd Pleaser
kuberwastaken
103mo ago
AI/ML●●●Banger

MicroGPT-C – C99 GPT for Edge Training and Tiny Model Pipelines

Karpathy's microgpt in C99, proves tiny coordinated models beat single large models on logic.

WizardryBig Brain
Ajay__soni
103mo ago
Education●●Solid

How-to-train-your-GPT. Every line commented

Explains attention mechanisms to five-year-olds while building LLaMA 3 from scratch.

CozyNiche Gem
mateenah
4019d ago