Growing the codebook
“Vigorous writing is concise. A sentence should contain no unnecessary words, a paragraph no unnecessary sentences … that every word tell.”
Strunk & White, The Elements of Style
How do you decide what words to say? When you actually want to get what you’re feeling into someone else’s head, how do you choose?
I think this one came from my junior-year AP Lang teacher, though honestly the memory might be half mine by now: writing as planting a seed. You have a feeling, you come up with prose, and the reader follows the instructions inside your words. They nurture the seed, grow the tree, and bite into the fruit. If you wrote it well, they feel the very thing you felt when you wrote it.
Then my senior-year world lit teacher, walking us through Donne’s A Valediction: Forbidding Mourning, got me to actually appreciate poetry. He defined it as the art of choosing which words to leave out, and letting the reader reason about what could have gone there and why the poet picked what they picked. It’s the same thing that makes a certain rap verse hit when the melody switches, simple words that say a lot because of the words the artist chose not to say. Mr. Brightside runs on this. The lyric is she’s touching his chest, but the line is written to make you expect a word that rhymes with the sick from two lines before. I didn’t clock it until years after I knew the song, because I learned the lyrics before I was old enough for my mind to go there. I expect that’s the case for a lot of people.
Years later I noticed I now stare at that exact question all day. Why did the writer choose this word, knowing very well they could have chosen a different one? That’s , the log-probability of the word that was chosen given everything that came before it, the quantity language models are trained on.
There’s a wrinkle here I like. We don’t speak in the most likely next word. If we did, we’d be saying almost nothing, because the goal of speaking is to transmit information, and the low-probability words are the ones carrying it. Information theory calls this typicality. A writer who only ever picked the safest word would never write the chest line.
And leaving words out only works if the reader can fill them back in. The poet is betting on my codebook.
The codebook
When I first came across Huffman coding, it made no sense to me. I was like, how can you convey a message with a 0 or a 1? I knew characters have binary representations under the hood, that part was fine. What I couldn’t see was how the lengths of those representations could be choices. What unlocked it was separating two things I had been collapsing. There’s the knowledge itself, and there’s the medium used to transmit that knowledge. Once those came apart, compression stopped being mysterious. If the same pattern shows up many times, you give it a short name and pay for it once.
English kind of already does this. The most frequent word in the language is the, and it costs one syllable. So does almost everything at the top of the frequency chart, of, and, to, a. The four-syllable words live out in the long tail. Huffman coding is this, made optimal:
In words: in an optimal code, the length of a symbol’s codeword is about the negative log of its probability. Frequent things get short codes, rare things get long ones, and the average message comes out as short as possible.
Now let the symbols be ideas instead of characters. Take someone who has been through a data structures class, who can reason about hash maps and time and space complexity. You can teach that person a bloom filter in a couple of minutes. It’s a small data structure that answers have I seen this before? fast and occasionally lies, and every word of that sentence already lives in their codebook. Someone without that class needs much longer. And it’s not because either person is smarter or dumber. It’s just: what does your codebook capture?
That’s the theory of learning I can’t stop thinking about. The hard work of learning comes down to mapping between what I already know and what I want to know, and bridging that gap. Said with entropy:
In words: is conditional entropy, the average surprise left in a new idea given what you already hold. Learning well means growing the codebook so that number keeps shrinking, so that more and more can be left unsaid to you.
skippable. For a random variable (the next idea) and side information (what you already know), conditional entropy is
the number of bits (0s and 1s) you still need, on average, once is given. Shannon’s source coding theorem says you can’t compress below entropy on average, and Huffman codes get within one bit of it. Conditioning never increases entropy, : more side information, less surprise.
Huffman the curriculum
I never took multivariable calculus. In college this bit me at the same spot every term. In the last third of my upper-div math and CS courses, the focus would swing to applications, cool ones that connect concepts outside the silo of the course’s remit, and the connection would get glossed over as a prereq. In linear algebra it was minimize subject to some constraints. I could solve it, and I could see the linear algebra intuition. But there’s a second picture, the multivariable calculus one, and that one didn’t stick until I met the same problem again in an optimization class years later.
To be fair, I could usually reach mechanical competence anyway. I got through ODEs in my signals class that way. And the proof that it can go differently came from the same class. Babak’s gift was simplifying to the key points. He taught me the Fourier transforms and the FFT in a way I intuitively understood without being versed in complex analysis, and the codewords I was missing became an afterthought instead of a wall. My best experiences with teachers have all looked like that, and not just at a surface level, truly at a deep level. They let me navigate the critical points without fumbling on the codewords.
So in those last-third weeks I did have codewords. Enough to compute, not enough to see. The lecture was transmitting on an axis I couldn’t decode yet, and everything on that axis read as noise. You can still grind through it. But it’s like a process hitting an out-of-memory error, and it’s demotivating.
The fix runs in the other direction. In a probability curriculum the word distribution shows up constantly. A distribution is values and the probabilities assigned to them. If those words don’t mean anything to you yet, you’re not learning when you read. You’re just pronouncing English, or whatever language you’re reading, math included, code included. And it’s not even about knowing the definition. I knew what a gradient was. But in a dense proof, one object plays several parts. A vector can be a point, a direction, a similarity, and that’s not even the full list. If I lose my handle on which part it’s playing, the proof unravels. The object has to live in memory in my brain, not out on disk. Every trip to go remind myself costs me the thread. And that memory has a limited capacity, so the move is two steps. First I bring the thing into memory, then I compress it, so I can hold more things in memory at once. Once a gradient became automatic for me, I stopped spending brainpower on what it is and could focus on its properties, like the linearity that a key step of a Lagrangian proof turns on.
So Huffman the curriculum. Find the concepts that show up most often. Teach them first. Drill them until they’re nearly free. Shortest codewords to the most frequent symbols.
The opposite move is the quick trick. A GSI once taught me matrix derivatives as, add a delta, distribute, delete the delta-delta terms. For :
Drop the last term because it’s second-order small, read off the parts linear in , and out comes the gradient, . It works. It answers the exam. But it’s a codeword with no decoder behind it, and without the decoder you can’t think about the harder things that come next. The harder things, in this case, being the entire geometric story below, where a gradient is a direction a function is sensitive to. That reading just isn’t available if a gradient is only a delta ritual.
Minting a codeword
The first time I read the words constraint gradient, in that same Lagrangian material, I was like, wtf is that. Three words, each pointing somewhere else. Then I unpacked it once. The constraint is , which just forces the distribution’s expected value to be . The gradient of that constraint is a vector telling me how sensitive is to each coordinate , the probability of each outcome. That’s it, a vector in with a job.
After that, constraint gradient stopped being a three-word puzzle and became an object I can picture, with its own personality and properties. I could suddenly reason about what it would mean to move along it, and why an optimizer must not. Name a recurring pattern once, pay one codeword forever after.
My note-taking has this literally built in. In vim, mk drops me into math mode between dollar signs. Typing sum i and hitting tab scaffolds a sigma with placeholders for the start, the end, and the body, and I tab through each one. In my real analysis class that stares at convergence of series all day, meaning partial sums, meaning sigmas everywhere, the whole gesture costs a couple of keystrokes. And the payoff has nothing to do with typing speed. I get to transcribe at the speed of the lecture and spend my attention on the concept being discussed instead of on the notation.
Wrong on purpose
There’s a real finding here: guessing the answer before you’re taught it improves learning, even when the guess is wrong. Richland, Kornell and Kao showed this in 2009, across five experiments; they call it the pretesting effect. I also remember a Huberman episode throwing around a stat in the same direction, something like frequent self-quizzing being 50% more effective than rereading. I’m probably butchering the number, but the direction is real and measured. The canonical study is Roediger and Karpicke’s test-enhanced learning. A week after studying, the students who had quizzed themselves retained substantially more than the students who had spent the same time rereading. And the rereaders were more confident while remembering less.
Here’s what a wrong guess does for me. Working through the geometric picture of the Lagrangian, I half-remembered that the projection of a feasible point had to land on along the first constraint gradient axis . Fine. If that’s true I should be able to show it. So what are these two objects? The constraint gradient is a vector, a direction. is a distribution, but it lives in the same space, so I’ll think of it as a point. To project, I recall, you take an inner product and normalize. Then I tried to write the statement that had to be true for to equal “the point along ,” and realized mid-sentence it made no sense. What does it mean to be a point along a vector? is a direction. So I’m not looking for a point. I’m asking how much of the direction. Some constant of it, probably normalized. So I committed to
and started checking what else had to be true for that to hold.
The guess ended up being wrong. It was also the most useful part of the session. Committing to a thought and auditing it, knowing full well my understanding would crumble somewhere, charted out the frontier of exactly where the gaps were. The forcing function of why it has to be a certain way carries way more learning signal than memorizing properties and axioms. Every moment of wait, what is this mathematical object, how does it relate to the others on the page, was a connection getting built. (I remember how excruciating this same process was for the Jordan-Hölder theorem. I stayed stuck until a hint about the diamond isomorphism theorem connected the dots.) Reading the correct derivation first would have skipped all of it.
That’s why generate-then-compare beats rereading. In compression terms, retrieval measures distortion and reading doesn’t. You produce your reconstruction, hold it against the reference, and the difference lands precisely on the codewords you’re missing.
// this above is precisely debugging
The edge
By definition, I stop reading when I get stuck, when something doesn’t align with my current understanding. I’ve started treating that as a signal. A passage I can read straight through without stopping is close to a tautology to my codebook, facts I already hold. I know that’s not strictly true. Plenty of things have taught me something without a single stall. But empirically, the stuff that gets me really stuck is where the most learning happens. The friction, the push and the pull, is the learning.
I notice the same meter in what I can and can’t consume. I’ve struggled to stay with shows where I already know what’s going to happen, where the story fits a pattern I’ve seen too many times. And it isn’t clean in the other direction either. I can follow Crime and Punishment on audiobook just fine, and part of that is the narrator doing codebook work for me. He changes pitch and register for each character, so I’m not fumbling over the Russian names or losing track of who’s talking, and hearing the vocabulary performed a certain way lets me infer from context what some words mean. Side information, arriving through a different channel. Where classics genuinely slow me down is the middle of a long dialogue in The Count of Monte Cristo where I’m fkin confused about who’s talking. And past that there’s the reading-between-the-lines layer. Why did the author choose to put this here? That part of critical reading fascinates me. It’s the same axiomatic analysis you’d run on a math proof, applied to writing. I don’t know that confusion always means more learning. But boredom and being gripped do work as a rough surprisal meter, and boredom is the needle reading zero.
Painting with a broad brush, there are three states, and only one of them teaches. Material with zero surprise teaches nothing. Material with too much surprise, my last-third state, also teaches nothing, because nothing decodes. Learning lives in the band between. There’s even a measured version, the Eighty Five Percent Rule. For gradient-descent-style learners on two-choice tasks, learning is fastest around 85% accuracy, and the result lines up with animal-learning data. Whether the exact number carries over to you and me, who knows. The shape is the thing.
The RL version of this is something I hit with my own code. In GRPO, a post-training algorithm, you sample a group of responses to a prompt, score them, and standardize the scores into advantages. When every response in the group earns the same reward, an easy prompt everyone solves or a hard one nobody does, the advantages are all zero and the batch moves nothing. No spread, no signal, no gradient. I wrote in the last post that practice material you always get right, or always get wrong, carries no gradient for you either, and that the idea deserved its own post.
Run it until it breaks
I’d love to tell you I run spaced repetition like clockwork. It doesn’t work that way for me, and the reason turned out to be the thesis again. You have to know what you’re climbing toward. My Anki habit dies exactly when the deck fills with cards that don’t connect to anything I’m building, and the struggle to remember them is the tell. Rote recall is real, it frees you from holding a fact in working memory. But that’s different from being able to pull the fact in the right sequence at the right time for the right reasons.
The best version of that I know of is secondhand, someone shared it with me: Jeff Dean keeping the base performance numbers of his systems in his head, so a design proposal can be tested with arithmetic right there in the meeting, one estimate replacing a prototype and a follow-up meeting. And when you’re working with people, being able to align live, in the room, is the whole game. It reminds me of where LLMs fit now. I catch myself reaching to ask Claude stuff all the time, and you can get an answer to any well-defined question. But some fraction of the answers are wrong, and if you’re doing this live in a meeting, waiting on responses, sifting the exponential rabbit holes each answer opens, you’re getting nowhere. Knowing where to poke and how to poke is the differentiator. Dean’s numbers live in memory. The LLM is out on disk.
What actually works for me is what I do when preparing for public speaking. Start from the top. Go until I get stuck and forget what comes next. Read the line I lost. Start again from the top. Repeat until I can run fifteen minutes straight. Nobody scheduled those reviews. You find where memory breaks by running the sequence until it breaks, and each restart hands the early material its spacing for free. There’s probably a progressive overload angle here too, the lifting principle. You work the thing to fatigue, and the fatigue point moves further out each time.
Different axes through the same point
When a concept matters, I try to hold it in two or three independent formulations. When I was rebuilding attention from scratch, I wanted the rows interpretation, the columns interpretation, and the outer-product interpretation, inside out. A second formulation gives you a different angle. It sheds light on an axis you may not have considered. And when you reach the same conclusion starting from a different point, that does something a second rereading never does. It confirms the conclusion is real and not an artifact of one path.
It pays off directly. The rows view is what showed me that an attention output is a weighted average of value rows, a center of mass, and that picture is something I can actually reason with instead of recite. One formulation stores the idea. The second and third are what let me use it. In CS terms this is error correction rather than repetition. Independent encodings fail independently. When one path breaks, I still have another that reaches the answer.
Intelligence is compression
One of the most insightful conversations I’ve ever had was with Misha Laskin. We were talking about why coding agents got good, and his point was that part of the problem is already solved once you can build an environment with a constant feedback loop running. AlphaGo and the DOTA agents were the early proof. Give the loop a constrained environment with real signal and it wins. The hard part is solving the environment. The basic loop is old. Define the action space, read the reward off the environment, learn the value of the states each action can take you to, take the action with the best discounted future. Go and DOTA were that loop in small constrained worlds. Coding is the same principle in a bigger one, and it’s the domain where agents got good first for exactly this reason: the environment answers back. Code runs or it doesn’t. Tests pass or they don’t. The feedback loop is sitting right there. What stuck with me as much as the point was how fast he got to it. That’s the superpower of the people we call brilliant. They compress. They also seem to know where the limit of their compression sits, and they navigate along that barrier instead of pretending it isn’t there.
There’s even a standing bet that this is what intelligence is. The Hutter Prize pays cash for compressing a snapshot of Wikipedia, on the argument that compressing knowledge and understanding it are the same act.
// something about normalizing flows bijective functions between two distributinos, a full max likelihood estimate and not lossy
And there’s a tension here I’m leaving open on purpose. If learning is compression, why do compressors like us chase high-entropy input? One reading of the Odyssey I keep coming back to: what the sirens were offering was knowledge, and sailors steered into rocks for it. Constant curiosity as the human condition, dopamine doing the steering. Whatever that is, it’s its own post.
Like breathing
How do I know the codebook actually grew? I wanted the answer to be a metric, explain the idea in fewer words each week or you haven’t compressed it. I still like that as a goal. Honestly though, that’s not how I experience it. For me it’s an image, being able to describe a picture in my head and hold all the pieces and details of it at once. It usually starts when I go to bed thinking about something. I fall asleep, wake up, and recalling certain pieces is easier. Over a few days or a few weeks it becomes very intuitive, like breathing. I don’t have to think about the steps between the steps. (Does that make me a visual learner? I don’t think the label matters. A picture is just a very big chunk.)
The hard part is trusting the process, because at the beginning it’s genuinely difficult, there’s a lot of tension holding the pieces. Then at some point I reread my old notes and what I’m actually seeing is a photo of the page in my head, usually organized around one figure or geometric shape that the whole thing makes sense against. That collapse, many pieces under tension into one picture, is the compression. Measured in chunks, not words.
// call back to my volume of a sphere as integration along the function of a bunch of circles
What you choose to encode
People build whole systems dancing around this idea, zettelkasten, second brains, and I’ve been obsessed with those too. But at the end of the day it is your brain, and what you choose to prioritize, what you choose to encode, and what you keep formulating off those encodings.
George Box’s line is that all models are wrong, but some are useful. This model of learning is wrong too. It’s still been useful to me. It’s strung me along to mathematical insights I’m genuinely proud of, in school and outside it, and to ways of applying them that actually mattered.
And if the frame is more than vocabulary, it should make a prediction that can fail. Here’s one I can check against my own study logs: sessions where I never got stuck should show worse recall a week later than sessions where I got stuck two or three times, even though the smooth sessions felt better. I keep the logs. That test is a future post.
And a core belief of mine sits under all of it. Set aside the asymmetric edge cases and nearly every single person is surprisingly capable and intelligent. The brain is our greatest equalizer, and I’m a big believer in the nurture side of things. The gap between you and any idea is just codewords you haven’t minted yet. I love skill trees in games, and this is the same obsession pointed at real life, growing the character’s abilities, except the character is me and the outcomes are physical. I’m obsessed with growing the codebook.