What I Built and Why It Surprised Me
I coded a spiking neural network to explore working memory. The number 7 emerged without being programmed — and forced me to rethink…
What I Built and Why It Surprised Me
I coded a spiking neural network to explore working memory. The number 7 emerged without being programmed — and forced me to rethink chunking as an architectural inevitability.

I didn’t set out to prove Miller’s Law. I just wanted to watch a few hundred silicon neurons fight over time.
The plan was simple: build a spiking neural network (SNN) with a small recurrent loop, feed it a stream of input items, and see how many it could hold simultaneously in an active, self-sustaining state. No predefined memory slots. No hard-coded buffer size. Just leaky integrate-and-fire neurons, lateral inhibition, and synapses that decayed if they weren’t refreshed. I expected messy, unbounded recall, maybe a capacity that scaled with the network size if I tuned it right. What I got was a stubborn, beautiful ceiling: the network rarely held more than 7 ± 2 items before older representations flickered out.
I stared at the spike raster's for a long time that evening, half-convinced I’d introduced a bug that accidentally hard-coded the limit. I hadn’t. The magic number had emerged from the architecture’s fundamental properties.
The haunting of George Miller
Every psychology student knows the phrase “the magical number seven, plus or minus two.” In 1956, cognitive psychologist George Miller observed that human working memory — the mind’s mental scratchpad — seems constrained to about seven discrete items, be they digits, words, or tones. Later research refined this to around four when chunking is strictly prevented, but the 7±2 figure stuck in the popular imagination. For decades, it felt like a quirk of cognition, a cognitive speed limit with no obvious physical reason.
But what if the number isn’t a psychological fact as much as a biophysical one? What if the 7±2 limit isn’t a rule the brain follows, but a phenomenon that falls out of the wet, competitive physics of neurons?
That question sent me to my keyboard. I’d been reading about attractor networks, temporal competition, and the harsh energy budgets of real brains. I wanted to see if a minimal circuit — no psychological assumptions, just biophysics-inspired dynamics — would produce something similar. So I built one, and I put the code on GitHub not expecting much. The spiking model: competition, not counters
The architecture was embarrassingly modest. A population of excitatory neurons received sequential inputs, each input briefly driving a subset of cells. Recurrent excitatory connections allowed the network to sustain activity after the input vanished — the neural equivalent of holding a thought. A second population of inhibitory interneurons provided global lateral inhibition: the more strongly some neurons fired, the more they suppressed others.
Crucially, the synaptic connections were dynamic. Their weights decayed over time with a biologically plausible time constant, unless a spike arrived to refresh them. Working memory wasn’t a fixed buffer; it was a tournament of fading whispers. To stay “in mind,” an item had to keep winning the competition for firing-rate real estate.
I fed the network simple patterns — a sequence of distinct “items” encoded as sparse spike trains — and then measured how many of them could maintain elevated firing rates simultaneously after the input stopped. For small loads, the network hummed along, happily juggling three or four items with clean temporal separation. When I pushed to five or six, the patterns started overlapping in time, blurring slightly but still distinguishable. At seven items, something qualitatively shifted. New inputs began pushing old representations below a viability threshold, and by eight or nine, the earliest items were irrevocably gone — not just weakened, but fully extinguished.
I ran hundreds of trials with different initializations. The histogram of maximum simultaneous items formed a neat bell curve centered at seven.
I hadn’t coded the number seven anywhere.
Why capacity emerges from competition
The explanation, once I traced the dynamics, was both elegant and humbling. Each active memory trace needed a minimum firing rate to be detectable above the noise and to resist passive decay. Excitatory recurrence amplified these traces, but global inhibition imposed a soft ceiling on total activity. The network couldn’t be in two states at once: if total excitation climbed too high, inhibition clamped down; if total excitation fell too low, all traces died. Between these bounds, only a finite number of items could coexist, their number limited by the sharpness of lateral inhibition and the decay time of the synapses.
In effect, the network’s working memory capacity was an emergent consequence of a resource competition — temporal real estate in the spiking domain, analogous to the spectral bandwidth of an oscillatory system. You could hold as many items as could be maintained above threshold within the inhibitory window, and no more. For my parameter set, that window worked out to about seven. Had I dialed up the synaptic decay rate, the capacity dropped to four or five. Had I weakened inhibition, the system became epileptic and patterns bled into one another. The number 7 wasn’t magic; it was the Goldilocks point of a dynamic system.
This was the first surprise: Miller’s limit might be less about cognitive architecture and more about neural tissue physics, a natural ceiling before the brain’s electrical machinery saturates.
The deeper surprise: chunking as survival strategy
The second surprise came when I tried to push past the limit not by tweaking parameters, but by changing the input.
Instead of feeding the network independent items, I presented inputs that were structurally related — pairs of items that co-occurred regularly, forming a kind of statistical chunk. After repeated exposure, the network learned (via a separate, slower plasticity rule) to treat the pair as a single, compressed representation. Suddenly, the same network that could hold only seven individual items could now hold seven chunks, each containing multiple sub-items. The raw information throughput had increased dramatically, without changing the underlying biological constraints.
This made me sit back. Chunking — the mental trick of grouping digits into a phone number, or chess pieces into a tactical pattern — is often taught as a clever cognitive strategy, a hack that intelligent minds deploy to overcome limited memory. My SNN suggested a different story: chunking isn’t a strategy; it’s a necessity forced by architecture. When temporal competition and synaptic decay limit the number of simultaneously active representations, the only way to increase functional capacity is to compress those representations. The network doesn’t choose to chunk; it is driven to it by the relentless pressure of limited bandwidth.
I realized that this is precisely what brains do. The hippocampus compresses episodes into sparse codes. The cortex builds hierarchical schemas. Language gives us words for entire constellations of experience. These are not optional cognitive luxuries — they are the emergent solutions of a system operating near its physical memory limits. Chunking, abstraction, compression: these are the shadow cast by a brain that can only hold so many live traces at once.
Why this matters for AI and for us
Building this tiny SNN rewired how I think about intelligence — both biological and artificial.
In machine learning, we casually increase context windows to 100k tokens and call it a day. But that brute-force expansion misses the architectural lessons of the brain. Real neurons don’t get infinitely long memory buffers; they get a few hundred milliseconds of temporal integration and a fiercely competitive recurrent circuit. And from that constraint, they wring generalization, abstraction, and hierarchical understanding. The limit is not a bug to be engineered away; it is the forge where smarter representations are made.
When I look at my own mind now, I see those 7±2 slots not as a weakness but as the reason I have a mind at all. Without the pressure to compress, to chunk, to abstract, I’d never have learned to see patterns, to form concepts, to think in metaphors. The constraint creates the cognition.
The code is still on GitHub, a few hundred lines of Python and Brian2, with spike raster's that dance within a magic circle they were never told about. The number seven was never in the code. It was in the physics, waiting. And it surprised me more than any clever algorithm ever has.
메타데이터
- post_id
- 2dc0a1f2235c
- slug
- what-i-built-and-why-it-surprised-me-2dc0a1f2235c
- url
- https://medium.com/@virajkadwe01/what-i-built-and-why-it-surprised-me-2dc0a1f2235c
- canonical_url
- https://medium.com/@virajkadwe01/what-i-built-and-why-it-surprised-me-2dc0a1f2235c
- author_url
- https://medium.com/@virajkadwe01
- status
- ok
- fetched_at
- 2026-07-08 05:22:04