Skip to main content

Command Palette

Search for a command to run...

How Does ChatGPT Think? Large Language Models Explained

Updated
8 min readView as Markdown
How Does ChatGPT Think? Large Language Models Explained
H
CS Graduate | Technical Writing | Software development | 50K+ impressions

Arthur C. Clarke's famous third law: "Any sufficiently advanced technology is indistinguishable from magic" perfectly captures how the pace of human innovation works. From carrying supercomputers in our pockets to using global positioning satellites, what seems normal today would look entirely supernatural to anyone from just a few decades ago.

You type a question into ChatGPT, press Send, and within seconds, it starts typing back a fluent, highly intelligent response.

It feels like magic. It probably is magic disguised as Science and Math. It feels like there’s a little person sitting inside your computer, frantically Googling answers and summarizing them for you. But alas, it’s not magic, and it’s definitely not simply copy-pasting from Wikipedia or StackOverflow.

If you are a developer or just a curious creator, you don't need a Machine Learning degree to build incredible AI applications. Think of it like this: The ML Engine is the motor, and your AI application is the car. You don't need to know how to smelt engine block metals to be an incredible driver or car manufacturer!

Let’s see how the engine actually works in plain English.


1. What is an LLM? (The Car vs. The Engine)

When people talk about AI today, they usually throw around the acronym LLM. It stands for Large Language Model.

Let's break that down without the jargon:

  • Large: It was given unimaginably big corpus of text to train, almost the entire public internet, millions of books, research papers, and code repositories.

  • Language: It deals exclusively with human communication, reading it, understanding context, and generating it.

  • Model: A giant mathematical system (a neural network) trained to recognize statistical patterns in how humans use words.

The Car vs. The Engine Analogy

To make sense of the terminology you hear in tech:

  • GPT (Generative Pretrained Transformer): This is the Engine (the underlying math and ML architecture).

  • ChatGPT: This is the Car (the user-friendly chat application built on top of the GPT engine).

What problems do LLMs actually solve?

Before LLMs, getting a computer to understand text was painfully rigid. You had to program strict code: if user says "hello", reply "hi". But human language is messy! We use sarcasm, slang, typos, and double meanings.

LLMs solved this by moving away from hardcoded rules. They read enough human text to develop a statistical intuition for what words mean in context and what a "good answer" should look like.

  • GPT-5 (by OpenAI) — Powers ChatGPT.

  • Claude Opus 4.8 (by Anthropic) — Famous for coding and natural-sounding writing.

  • Gemini 3.1 Pro (by Google DeepMind) — Integrated into Google Search and Android.

  • LLaMA 3 (by Meta) — Open-source engine anyone can build on.

You already use them daily: Autocompleting code in VS Code (GitHub Copilot), summarizing messy email chains, or asking Siri/Google Assistant complex questions.


2. Why Computers Don't Understand Human Language

To understand how ChatGPT works, you first have to understand that Computers run on math, they cannot understand words directly.

At the hardware level, your computer only understands binary—zeros and ones (0 and 1, ON or OFF). It processes numbers, stores numbers, and transmits numbers.

To a computer, the word "Love" has no emotional weight; it’s just a string of ASCII or Unicode character numbers. And letters don't capture meaning. A computer looking at character codes can't tell that "Silicon" and "Technology" are related concepts.

To make an LLM understand human language, we have to build a translation bridge. We have to convert our words into a mathematical language the computer can understand.

There are steps to this. First being Tokenization.


3. Tokenization

We don't feed words into an AI letter-by-letter (that would take too much computing power), and we don't feed them whole-word-by-whole-word (there are too many hundreds of thousands of words and typos in the world to make a dictionary for all of them). Too big.

Instead, we settled on a middle ground called Tokens.

A token is a bite-sized chunk of text. It can be a whole word, part of a word, a single space, or a punctuation mark.

  • Rule of thumb: 1 Token ≈ 0.75 words (or roughly 4 characters in English).

A Simple Tokenization Example

If you give an AI the sentence: "ChatGPT is super cool!"

The Tokenizer chops it up into sub-word units and assigns each piece a unique ID number from its fixed dictionary (called a Vocabulary):

Now, the computer is happy! Instead of English, it is looking at a sequence of numbers: [16047, 38, 2898, 374, 2307, 7155, 0]

Let's see what happens when I add my name in the mix. My first name alone is three tokens.

💡
Look at 'is'. It is common in both and got the same tokens!

4. Transformers & Context

Once the words are turned into token numbers, they are passed into the "T" in GPT: The Transformer.

Introduced by Google researchers in 2017 in a famous paper called "Attention Is All You Need," the Transformer architecture completely revolutionized AI.

Before Transformers, AIs read text sequentially from left to right like a human reading a book. By the time the AI got to the end of a long paragraph, it literally "forgot" what happened at the beginning. Much like humans.

Transformers changed everything using Self-Attention. A Transformer can look at every single word in a sentence simultaneously and figure out which words are deeply connected to each other.

How Self-Attention Works: Silicon Valley vs. Uncanny Valley

Words change their meaning depending on accompanying words. Let’s look at the word "Valley". In a dictionary, a valley is just a low area of land between hills. But what happens when we put it into two different contexts?

  1. "Silicon Valley"

  2. "Uncanny Valley"

If an old-school computer sees the token ID for "Valley", it treats it the exact same way both times. But a Transformer uses Self-Attention to let the tokens "talk" to each other:

In the first sentence, the word "Silicon" grabs "Valley" and pulls its mathematical meaning toward technology, venture capital, and startups.

In the second sentence, the word "Uncanny" grabs "Valley" and pulls its mathematical meaning toward creepy humanoid robots, CGI, and human psychological unease.

This is done through Vector Embeddings, a multi-dimensional mathematical map where concepts with similar meanings live close together. Because of Self-Attention, the model knows exactly which version of "Valley" you are talking about!


5. What Actually Happens When You Send a Message?

Now let’s trace the exact lifecycle of your prompt from start to finish.

Step 1: You Type a Prompt

You ask: "What is Silicon Valley famous for?"

Step 2: Tokenization & Embedding

Your text is chopped into tokens and converted into a sequence of numbers. Those numbers are mapped onto the AI's complex mathematical vector space so it understands the inherent concepts.

Step 3: The Transformer Thinks (Self-Attention)

The numbers pass through billions of parameters. The Self-Attention mechanism fires up, connecting "Silicon" with "Valley" so it knows you mean the California tech hub, not a random ditch in the dirt.

Step 4: Next-Token Prediction (The Softmax Game)

Here is the big secret of LLMs: They are just ridiculously smart autocomplete engines.

The AI does not "know" the answer in the way a human does. Instead, it looks at your sentence and calculates a massive probability scorecard (using a math function called Softmax) to guess: What is the most statistically logical token to type next?

It generates a probability scorecard that looks like this:

It picks the winning token (" startups"), prints it to your screen, and then repeats the entire process from the beginning, predicting the next word, and the next word, over and over. Let's glance over the whole process again -

Why You See It Type Word-by-Word

ChatGPT outputs text in a stream because it is literally calculating and predicting the answer one token at a time in real-time!

Why ChatGPT is NOT Copy-Pasting from the Internet

When ChatGPT explains Silicon Valley, it is not running a live Google search or copy-pasting an article from Wikipedia.

Instead, it is reconstructing an answer out of the compressed statistical patterns it absorbed during its training phase. The knowledge is no longer saved in a database of web pages; it's baked into the mathematical connections between its billions of artificial neurons.


Summary: The Workflow at a Glance

  1. You ask a question in human language.

  2. The Tokenizer chops your words into numbers (tokens).

  3. The Transformer uses Self-Attention to look at all words simultaneously, figuring out context (like Silicon Valley vs. Uncanny Valley).

  4. The Model plays a probability game, predicting what single token should logically come next.

  5. The Decoder translates that winning number back into English and streams it to your screen.

You don't need a PhD in Machine Learning to build amazing things with AI. By understanding that an LLM is essentially a super-powered, context-aware prediction engine, you are ready to start driving the car and building the next generation of applications!