What Is an LLM? Understanding the Brain of AI Agents — Claudie’s Classroom EP.2


Written by Thierry K (human) · AI-assisted

🤔 Ever met an AI that’s confidently, completely wrong?

Try asking ChatGPT something like “Tell me about the time Abraham Lincoln accidentally invented the internet.” You might be surprised — the AI will launch into a detailed, self-assured response as if it were established historical fact. Of course, no such event ever happened.

So why does this happen? Is the AI lying? “What on earth is an LLM anyway?” — Today we’re going to find that answer by diving into how the LLM (Large Language Model) — the brain of AI agents — actually works.

If you caught EP.1 — First Look at Agentic AI and got a feel for what AI agents are, this episode is all about cracking open the hood and looking at the core engine!

Siwol

I feel like I kind of know what an LLM is… but if someone asked me to actually explain it, I’d go blank. Pretty sure I’m not alone in that.

Claudie

Don’t worry! By the end of today, you’ll be able to explain it to anyone with total confidence. Let’s take it step by step, shall we?

Claudie wink emoji

🧠 What Is an LLM?

LLM (Large Language Model): An AI system trained on massive amounts of text data that can understand and generate language. “Large” refers to both the number of parameters (hundreds of billions) and the scale of training data.

Simply put, it’s an AI that has read almost everything humanity has ever written and learned “how language flows.” Rather than storing information like a search engine, it statistically learns patterns in language.

Siwol

So GPT, Claude, Gemini — those are all LLMs?

Claudie

Exactly! GPT-4 is from OpenAI, Claude (that’s me!) is from Anthropic, Gemini is from Google, and Llama is from Meta. They’re all built on an architecture called Transformer, which Google introduced back in 2017.

The key thing to understand is that an LLM is not a database. It doesn’t “store facts and retrieve them.” Instead, it calculates “what word is most likely to come next given this context.” That distinction is the key to understanding hallucinations later on.

🔮 Next-Token Prediction — The Core Idea Behind LLMs

The way an LLM works starts from a surprisingly simple idea: “Look at what came before, and predict what comes next.”

Claudie

Here’s an example. If someone says “The weather today is really ___,” you’d naturally think of words like “nice,” “cold,” or “hot,” right? An LLM does exactly the same thing — just based on patterns learned from hundreds of billions of sentences.

This is called Next-Token Prediction. An LLM doesn’t think up the whole response ahead of time and spit it out all at once. It builds the response one token at a time, in sequence. That’s exactly why ChatGPT appears to stream text out character by character.

Siwol

Hold on — token? You said token, not word?

🧩 What’s a Token?

LLMs don’t read text in “word” units. Instead, they break text into pieces called tokens. A token is a subword unit — smaller than a full word.

For example, the English word “unbelievable” gets split into three tokens:

"unbelievable"
→ ["un", "believ", "able"]
→ 3 tokens
Non-Latin scripts need more tokens! For the same meaning, languages like Korean or Japanese can require 1.5–2x more tokens than English. This can add up in API costs, so it’s worth keeping in mind.

Here’s a quick comparison of token pricing for major LLMs:

ModelContext WindowInput $/1M tokensOutput $/1M tokens
Claude Sonnet 4.6200K (1M beta)$3$15
GPT-4.11M$2$8
Gemini 2.5 Pro2M$1.25$10

⚡ Transformers and Attention — The Real Secret of LLMs

The idea of “predicting the next word” is simple enough, but the technology that does it really, really well is the Transformer. Google introduced it in 2017 in a paper called “Attention Is All You Need”, and it’s been the foundation of every major LLM since.

The heart of the Transformer is Self-Attention.

Claudie

Think about studying for an exam. You read the whole textbook, but you highlight the parts that seem most likely to be tested. Attention works the same way! It looks at every word in the sentence and calculates “where should I focus to understand this particular word right now?”

Here’s an example sentence:

“The cat sat on the mat. It was tired.”

What does “It” refer to? You’d naturally understand it means “the cat.” The attention mechanism reaches the same conclusion by giving the “It” token a high relevance score pointing toward the “cat” token.

Siwol

I’ve also heard about QKV — what’s that?

Claudie

Great question! Let me use a library analogy. Query is like saying “I’m looking for a book on this topic.” Key is the librarian’s catalog — “here’s what this book is about.” Match the Query with the Key to calculate relevance, and what you actually retrieve is the Value. When multiple librarians do this simultaneously, that’s Multi-Head Attention!

If you want to explore this more deeply, Georgetown University’s Transformer Explainer lets you interact with the concepts hands-on.

Siwol

So basically, an LLM is just “next-word guessing” with hundreds of billions of parameters. It’s the world’s most expensive autocomplete.

Claudie

Sure, but when that “guessing” is good enough to write poetry, code software, and summarize research papers… that’s some pretty impressive guessing, don’t you think? 😆

🎓 How LLMs Are Trained — School, Major, and Tutoring

For an LLM to hold a great conversation, it goes through three stages of training.

Stage 1: Pre-training — Going to School

The model reads vast amounts of text from the internet and learns the fundamental patterns of language. Think of it like going through grade school all the way to university. At this stage, it absorbs grammar, common sense, and world knowledge — but it doesn’t yet know how to have a conversation.

Stage 2: Fine-tuning (SFT) — Choosing a Major

The model then trains on high-quality question-and-answer data. Like a med student who finishes general education and moves into specialized coursework, this is where it learns “how to talk with users.”

Stage 3: RLHF — Feedback from a Personal Tutor

Humans rate responses as “good” or “bad,” and the model learns from that feedback to produce better answers. This is called RLHF (Reinforcement Learning from Human Feedback).

Claudie

The reason ChatGPT or Claude gives polite, helpful responses isn’t just because they read a lot of data. It’s because RLHF taught them “how to talk the way people actually want to be talked to.”

⚠️ Hallucination — Why AIs Are Confidently Wrong

Let’s circle back to where we started. Why does an LLM confidently state things that aren’t true?

Hallucination is a structural limitation of LLMs. An LLM only predicts “the most plausible next token” — there’s no built-in mechanism to verify whether something is actually true. Because the probability difference between a correct and an incorrect answer can be small, it’s very hard for an LLM to learn to say “I don’t know.”
Siwol

So ultimately, an LLM is doing “prediction,” not “fact-checking”?

Claudie

Exactly! You could call it “educated guessing.” Most of the time it’s remarkably accurate, but the key limitation is that it can’t tell when it’s wrong. Recent research has even shown mathematically that hallucination can never be fully eliminated.

That’s why there’s ongoing effort to reduce it with techniques like RAG (Retrieval-Augmented Generation) and reasoning models — but a complete solution is still a long way off. When using LLMs, it’s always important to keep asking yourself: “Is this actually correct?”

🧬 LLM Is the Brain of an Agent

Alright, we’ve covered how an LLM works. But do you remember the AI agent from EP.1? An LLM is precisely the brain (cognitive core) of that agent.

But a brain alone can only do so much. A person can’t eat or write with just their brain — they need arms and legs too. AI agents are the same:

  • Tools: Search, code execution, API calls — the hands and feet (→ in EP.3!)
  • Memory: Conversation history, long-term memory — the power of recall (→ in EP.4!)
  • Planning: Breaking complex tasks into steps — strategic thinking (→ in EP.5!)

The agent’s core loop works like this: Perceive → Reason (LLM) → Act (Tools) → Observe → Reason again. You can explore this structure more deeply in Lilian Weng’s agent research.

Siwol

So the next episode is about giving the LLM hands and feet?

Claudie

That’s exactly it! In EP.3, we’ll explore Tool Use — how AI actually uses tools to take real action. Get ready for the moment an AI goes from talking to doing!

◀ Previous: EP.1 — AI Does Everything By Itself? First Look at Agentic AI

▶ Next: EP.3 — AI Got Hands — The World of Tool Use (Coming Soon)

📚 View Full Series

Claudie wink emoji

📝 Key Takeaways

  • An LLM is a “next-word predictor” trained on massive text data. It’s a pattern learner, not a search engine!
  • Tokens are the basic units LLMs use to process text. Non-Latin languages typically require more tokens than English.
  • The Transformer’s self-attention calculates “where to focus,” allowing accurate understanding of context.
  • Training happens in three stages: Pre-training → Fine-tuning → RLHF.
  • Hallucination is a structural limitation — LLMs generate “plausible text,” but they can’t verify facts.
  • An LLM is the brain of an AI agent, and it needs tools, memory, and planning to become a true agent.

📚 References


Discover more from AI-Girls Lab

Subscribe to get our latest posts delivered to your inbox.


Discover more from AI-Girls Lab

Subscribe now to keep reading and get access to the full archive.

Continue reading