Transformers, but Make It Make Sense (from your confused-but-determined homie)

MorpheusMorpheus
3 min read

Alright, so you’ve probably heard of transformers — no, not the robot kind — but the AI kind that powers stuff like ChatGPT. I was trying to wrap my head around how they work, and here’s the most no-BS breakdown I could come up with. If you're also tired of reading textbook-level jargon, you’re in the right place.

1. Tokenization: Turning Words Into Numbers

So first off, there's this thing called a tokenizer (like tiktokenizer) that just takes your input and chops it up into tiny pieces — called tokens. It then turns those into numbers because, surprise: computers don’t vibe with words, they only deal with numbers.

2. Vector Embedding: Giving Tokens Some Meaning

Once the words are turned into tokens, each one gets a vector embedding, which is basically its vibe check. Like, what does this token actually mean in context?

But wait — position matters too. That’s where positional encoding jumps in.

For example:

  • "The cat sat on the mat"

  • "The mat sat on the cat"

Same words, totally different energy. So even if the words are the same, the model needs to know where they are in the sentence. That’s why we add positional info to the embeddings — so it doesn’t mix up the cat and the mat.

3. Self-Attention: Tokens Start Gossiping

Here’s the cool part: self-attention lets tokens talk to each other. Like,

“Yo ‘sat’, what’s around you? Oh, a ‘cat’? Cool, I’ll update myself.”

This is how tokens update their meaning based on what’s around them. It’s like socializing but for words. Super useful.

4. Multi-Head Attention: Multiple Gossip Groups

Instead of one convo, the model creates multiple attention heads. Think of it as multiple groups at a party all talking about different stuff. Each group (or head) catches different relationships and perspectives. Then they all sync up and share notes.

Now the model has a 360-degree view of the sentence. Powerful stuff.

5. Feed Forward Networks : A Bit of Brain Work

After attention, each token goes through a tiny neural network (a.k.a. feed-forward layer) that adds more brain power to the process. Just refining things more.

6. Training vs Inference : Learning vs Showing Off

Two main modes here:

  • Training: This is when the model is still learning. It updates its weights through things like add & norm. Think of this as the gym phase — lifting, sweating, improving.

  • Inference: Now the model’s all trained up and just doing its thing — like showing off what it learned. This is when you actually use the model.

“Model ko use karna is inferencing.” (yes, bilingual flex )

7. Output Layer: Picking the Best Guess

At the end of the model pipeline:

  • Linear layer throws out some raw scores.

  • Softmax converts those into probabilities.

And then the model just picks the one with the highest probability. Like,

“Hmm... 92% sure the next word is ‘cat’. Let’s go with that.”

Alright, so transformers ain’t magic — they just look fancy with all their layers and attention and whatnot. But at the end of the day, it’s just a bunch of numbers talking to each other, figuring out context, and trying their best to guess what comes next. Kinda like us trying to finish each other’s sentences but with hella math. If you made it this far, props — you just mentally ran through a neural network without losing your mind. And remember, behind every AI model is just a glorified group chat of tokens trying not to mess up. Peace out.

0
Subscribe to my newsletter

Read articles from Morpheus directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Morpheus
Morpheus

i write about stuff i build