Show HN: MacMind – A transformer neural network in HyperCard on a 1989 Macintosh
Posted by hammer32 1 day ago
I trained a transformer in HyperCard. 1,216 parameters. 1989 Macintosh. And yes, it took a while.
MacMind is a complete transformer neural network, embeddings, positional encoding, self-attention, backpropagation, and gradient descent, implemented entirely in HyperTalk, the scripting language Apple shipped with HyperCard in 1987. Every line of code is readable inside HyperCard's script editor. Option-click any button and read the actual math.
The task: learn the bit-reversal permutation, the opening step of the Fast Fourier Transform. The model has no formula to follow. It discovers the positional pattern purely through attention and repeated trial and error. By training step 193, it was oscillating between 50%, 75%, and 100% accuracy on successive steps, settling into convergence like a ball rolling into a bowl.
The whole "intelligence" is 1,216 numbers stored in hidden fields in a HyperCard stack. Save the file, quit, reopen: the trained model is still there, still correct. It runs on anything from System 7 through Mac OS 9.
As a former physics student, and the FFT is an old friend, it sits at the heart of signal processing, quantum mechanics, and wave analysis. I built this because we're at a moment where AI affects all of us but most of us don't understand what it actually does. Backpropagation and attention are math, not magic. And math doesn't care whether it's running on a TPU cluster or a 68030 from 1989.
The repo has a pre-trained stack (step 1,000), a blank stack you can train yourself, and a Python/NumPy reference implementation that validates the math.
Comments
Comment by edwin 21 hours ago
Comment by wdbm 20 hours ago
But first you have to find that position.
Comment by zoky 15 hours ago
If you mean that when you feed the numbers starting with some offset of pi into a specific algorithm you will get a rendering of the Mona Lisa, then yes, but so what? Allow me to introduce you to the PiMona algorithm. I won’t bother you with the implementation details, but it takes exactly one integer parameter. If it’s 3, it produces a beautiful rendering of the Mona Lisa. Anything else and it generates random garbage. Turns out, it’s really easy to find where the Mona Lisa is encoded in pi! It’s right there at the start.
But let’s say you meant that the digits of pi at some offset, when encoded properly and fed into any algorithm that is theoretically capable of generating the Mona Lisa will cause that algorithm to do so, then sure. But that’s also true of random noise, and says more about the algorithm and the nature of random numbers than about the Mona Lisa somehow being encoded into the fabric of the universe (which I’m sure isn’t what you meant, but I’m just saying there’s nothing really special about pi in that regard, except that as far as we know, it continues infinitely).
Comment by hammer32 19 hours ago
Comment by Unbeliever69 19 hours ago
Comment by hyperhello 23 hours ago
Comment by hammer32 22 hours ago
Comment by hyperhello 22 hours ago
Comment by hammer32 21 hours ago
Comment by hyperhello 21 hours ago
Comment by hammer32 20 hours ago
Comment by jasomill 13 hours ago
Does HyperCard implement its on text handling for the HyperTalk editor that doesn't rely on the TextEdit toolbox service (which IIRC is the source of SimpleText's 32 kB limit)?
Comment by hyperhello 12 hours ago
Comment by jasomill 12 hours ago
The HyperTalk editor is indeed limited to 32 kB.
It's certainly possible that this limit only applies to editing scripts, as it's unlikely TextEdit was used in the process of interpreting them, but I don't have time tonight to investigate.
Later versions of HyperCard supported OSA scripts as well, now I'm also curious what the size limit is for (presumably) compiled AppleScripts stored in HyperCard stacks.
Comment by watersb 16 hours ago
I first studied back-propagation in 1988, at the same time I fell in love with HyperCard programming. This project helps me recall this elegant weapon for a more civilized age.
Comment by hammer32 3 hours ago
Comment by nxobject 14 hours ago
Comment by hammer32 3 hours ago
Comment by gcanyon 23 hours ago
Comment by hammer32 23 hours ago
Comment by jeffbee 19 hours ago
Comment by anthk 22 hours ago
On the Greeks, Archimede almost did 'Calculus 0.9'.
Comment by kdhaskjdhadjk 22 hours ago
Comment by ashleyn 22 hours ago
Comment by anthk 7 hours ago
For the rest, yes, it's really astounding until you push these polygons while moving around in a game loop...
Comment by qingcharles 18 hours ago
Comment by andai 19 hours ago
Comment by tomcam 21 hours ago
Comment by andai 19 hours ago
Comment by anthk 7 hours ago
Comment by tty456 19 hours ago
Comment by hammer32 18 hours ago
Comment by tty456 18 hours ago
Comment by hammer32 18 hours ago
Comment by rcarmo 17 hours ago
(still debugging it, but getting closer to full coverage)
Comment by hammer32 3 hours ago
Comment by immanuwell 20 hours ago
Comment by hammer32 19 hours ago
Comment by DetroitThrow 23 hours ago
Comment by hammer32 22 hours ago