LLM Training: How Does a Model Learn?
Loading like and share buttons...
#llmtraining#weights#lossfunction#next-tokenprediction

LLM Training: How Does a Model Learn?

Ever wondered what "7B parameters" means? It's 7 billion little knobs, and LLM training is the guessing game that sets them: guess the next letter, get a score, nudge the knobs, repeat. We trained a tiny model to watch it learn, and to see why no model knows your code.

Vibki AI
Vibki AI
Nov 28•6 min read

Get new posts in your inbox. No spam, unsubscribe any time.

Have you ever wondered what "7B parameters" means? It's 7 billion little knobs, and LLM training is how every one of them gets set. The whole trick is a guessing game: guess the next letter, get a score, turn the knobs a tiny bit, repeat. By the end you'll know why no model knows your code.

Can you use an LLM well without knowing how it was trained?

Mostly, yes. You don't need to know how an engine works to drive a car.

But when the car makes a weird noise, it helps. Same here. When a model gets something wrong, was your prompt weak, or did the model simply never learn this? If you can't tell, you guess: you rerun, you switch to a bigger model, you paste more context. Every guess costs money.

So let's open the hood. It's much simpler than it sounds.

What is a model, really?

A giant table of numbers. That's it. No rules, no dictionary, no saved copy of the internet.

Think of a huge mixing desk covered in knobs. Each number is one knob. "7B" means seven billion knobs. These numbers are called weights (or parameters, same thing).

On day one every knob sits in a random position, so the model writes garbage. Training is the job of turning the knobs, one tiny move at a time, until what comes out sounds right.

Is training really just guess, score, nudge and repeat?

Yes. It's the kids' game of "hot and cold", played a ridiculous number of times:

  1. Guess. Show the model some text, hide the next letter, and ask it to guess.
  2. Score. Give it one number that says how wrong it was. This number is called the loss. Like golf, lower is better.
  3. Nudge. Turn every knob a hair, in the direction that would have made the guess less wrong.
  4. Repeat. Again and again, on a mountain of text.

Nobody ever explains to the model what a word is or how grammar works. It only hears "colder" or "warmer".

What does learning actually look like?

We tried it. We built a baby model with 121,344 knobs, about 58,000 times smaller than a "7B" model, and let it read Shakespeare for a few minutes on a laptop.

At the start it wrote pure noise. Then, every so often, we gave it the word "First" and let it keep writing:

📄Text
1
2
3
4
After 200 nudges:    First Cine mho ran., perd se
After 1,000 nudges:  First Cies alu lither aly one cot!
After 5,000 nudges:  First Cirghoute petieft cance.
                     RURIUKE: Noul to this far

Still nonsense, but look closer. First it worked out that letters come in word-sized chunks with spaces between them. Then came punctuation. By the end it invented a character called RURIUKE and gave him a line, because that is what a play looks like. Nobody taught it any of this. It all fell out of the guessing game.

The score tells the same story. Random guessing gets a loss of 5.55. After 5,000 nudges our baby model was down to 2.08.

One guess up close: in Shakespeare, after ood morr comes o ("good morrow"). Before training, the model gave o a 0.25% chance. After training, 13%. Its favourite guess was e, at 36%. Wrong, but a sensible kind of wrong.

Real models play the exact same game, only bigger. Andrej Karpathy's nanoGPT config for GPT-2, with 124 million knobs, sets 600,000 nudges and says to wait about 5 days on 8 A100 graphics cards.

So why will no model ever know my private code?

Because a knob only moves for text the model actually read.

We trained three baby models: one on Shakespeare, one on Python code and one on our own frontend's TypeScript. Then we gave all three the same exam: a private file from our repo, useCategories.ts, that none of them had ever seen. Testing on unseen text is the honest way to score a model. In Perplexity and Intelligence, Jakub Pachocki says OpenAI scores its models that way too.

The results (remember, lower is better):

  • Guessing at random: 5.55
  • The Shakespeare model: 6.61
  • The Python model: 2.68
  • The model that read our frontend: 1.48

The Shakespeare model did worse than random guessing. It isn't just clueless, it is confidently wrong, like someone waiting for "thou" in the middle of a TypeScript file. The Python model did okay, because code looks a bit like other code. The model that had read our own codebase won easily.

Big models work the same way. Your private repo was not in their pile of text. The library released last week was not either. And once training ends, the knobs freeze.

So what do you do? Hand the model what it never saw, right in the prompt, as the Understanding Context Window post explains:

📄Text
1
Here is useCategories.ts, pasted in full. Add a hook for tags in the same style.

Conclusion

So can you use an LLM well without knowing how LLM training works? Yes, but now you know what is under the hood. A model is a giant desk of knobs. Training is a game of hot and cold: guess, score, nudge, repeat. The knobs only move for text the model read, so your code is in a model only if it was in that text.

Next time a model gets your code wrong, ask yourself first: could it have seen this? If not, paste it in. Next, we'll see how a model becomes a chat assistant.

Sources

Enjoyed this post?

Get the next one in your inbox. No spam, unsubscribe any time.

Comments

0 comments

Enter your comment. Maximum 2000 characters.

No comments yet. Be the first to share your thoughts!
Vibki logo wave icon
Vibki Surfing Bot
Vibki

Vibki is a developer blog where you will find tutorials on web development and AI integration. Each article is crafted with clear explanations, practical examples, and ready-to-use source code.

Talk to me
Copy email
LinkedIn
GitHub
Dev.to
Privacy Policy