Have you tried to get into AI and hit a wall of jargon on the first page? Training, inference, weights, tokens, embeddings, fine-tuning, context windows, RAG, hallucination, temperature. It reads like a foreign language, and every article assumes you already know the other ten terms.
Here is the good news: most of it is simpler than it sounds. This article builds the vocabulary and the mental models once, so the rest of your AI journey stops feeling like guesswork.
Think of it like learning HTTP before you pick up a web framework. You can skip it β but you will be guessing every time something breaks. This is your HTTP for AI.
The first thing to fix is a common mix-up. AI, ML, deep learning, and LLMs are not synonyms. They are nested, like Russian dolls β each one sits inside a bigger one.
Every LLM is deep learning, which is machine learning, which is AI. But it does not work the other way around. AI is much bigger than ML. Genetic algorithms, ant-colony optimization, and edge detection (Sobel/Canny) are all clearly AI, yet none of them learn from data. Keep this picture in your head and half the confusion disappears.
In machine learning, you do not write the rules. You show the model examples, and it figures out the rules on its own β stored as numbers called parameters (also called weights).
Why bother? Because for problems like finding cats in photos or translating a sentence, nobody can write the rules by hand. There are too many edge cases. So you let the model learn them from examples instead.
Compare that with traditional programming, where you write the rules and the program just applies them:
Here is the flip that matters: in machine learning, the rules are the output. You learn them from examples instead of typing them out.
FlavorIdeaExampleSupervised learn from labeled examplesspam / not-spamUnsupervised find structure, no labelscluster customers (k-means)Reinforcement learn by trial + rewardgame-playing, robotics
Where do LLMs fit? Mostly self-supervised β the label comes free from the text itself: predict the next word. Then they get polished with RLHF (reinforcement learning from human feedback) to be helpful and safe.
Strip away the mystery and training is a single loop, repeated an enormous number of times.
Two words you will see everywhere describe the two halves of a modelβs life:
Remember this one line: almost everything you do as an app developer is inference. You use models that other people trained.
Abstract talk about βlearning rulesβ is easy to nod along to and hard to believe. So letβs watch it happen on the smallest possible problem.
XOR outputs 1 only when the two inputs differ:
x1 x2 | answer βββββββββββββββ 0 0 | 0 0 1 | 1 1 0 | 1 1 1 | 0
Four rows. Two inputs. A tiny network with just 17 parameters can learn this rule. Here is its shape β 2 inputs, 4 hidden neurons, 1 output:
Those 17 numbers break down as 8 (inputβhidden) + 4 (biases) + 4 (hiddenβoutput) + 1 (bias). The hidden layer bends the space so XOR becomes separable. That is exactly why βdeepβ learning stacks layers.
XOR is really OR, but not AND. Two hidden neurons can learn those two features, and the output combines them:
x1 x2 | A (OR) | B (AND) | out = A β B β 0.5 | XOR βββββββΌβββββββββΌββββββββββΌββββββββββββββββββββΌβββββ 0 0 | 0 | 0 | β0.5 | 0 β 0 1 | 1 | 0 | +0.5 | 1 β 1 0 | 1 | 0 | +0.5 | 1 β 1 1 | 1 | 1 | β0.5 | 0 β
This is the secret of depth in one table. Early neurons build simple features (OR, AND); later neurons combine them into something richer. An LLM does the same thing β with billions of features instead of two.
Here is the real loss dropping as the network trains. Loss is just how wrong it is right now β lower is better.
epoch loss what the network "knows" βββββββββββββββββββββββββββββββββββββββββββββ 0 0.5835 nothing β every guess β 0.5 500 0.3573 starting to separate cases 1,000 0.0733 "getting it" 2,000 0.0064 essentially solved 5,000 0.0014 polished β 4/4 correct βββββββββββββββββββββββββββββββββββββββββββββ β 20,000 tiny guess-and-correct steps β¦to learn a rule you'd write in one line of code.
Sit with that for a second. Nobody handed the network the rule. It discovered XOR by being wrong thousands of times and nudging its knobs after each mistake.
The XOR toy is the whole story of an LLM, just multiplied by an almost unimaginable factor.
This is intuition, not literal math. But the shape of the cost is exactly this, scaled up roughly 100 billion times.
A language model has one job: given some text, predict what comes next. It is a supercharged autocomplete.
Input: "The capital of Italy is" βΌ Rome βββββββββββββββββ 81% a βββ 6% located ββ 4%
The surprising part is what falls out of that simple goal. Get really good at βnext wordβ across the whole internet, and you accidentally learn grammar, facts, reasoning, translation, and code. The model generates one token, appends it, and repeats β a process called autoregressive generation.
L L M β β βββΊ MODEL a neural network (a math function) β βββββββββββββΊ LANGUAGE trained on human text & code ββββββββββββββββββββββΊ LARGE two things: DATA & PARAMETERS
βLargeβ is not marketing. It is a real jump in scale:
Classic ML model ~10Β²β10β΄ dozensβthousands "Small" LM ~10βΈ hundreds of millions Frontier LLM ~10ΒΉΒΉβ10ΒΉΒ² hundreds of billions β trillions β "LARGE"
This is the idea behind scaling laws: more parameters, plus more good data, plus more compute, tends to give you a smoothly more capable model. With LLMs, scale is the point.
Models do not read letters or whole words. They read tokens β sub-word chunks β and each token is really just a number.
"Developers love coffee!" βΌ (sub-word chunks)[ "Develop" ][ "ers" ][ " love" ][ " coffee" ][ "!" ] 1042 513 2415 8871 0 βΌ [1042, 513, 2415, 8871, 0]
A useful rule of thumb: 1 token β 4 characters β ΒΎ of a word, so 1,000 tokens is roughly 750 words. This matters for a very practical reason β tokens are the unit of billing and the unit of the context window. You pay per token, and you fit a limited number of them.
Here is a detail that surprises people. The same sentence can cost twice as much depending on the language:
English: "Developers love coffee!" [ Develop | ers | love | coffee | ! ] β 5 tokens
Turkish: "YazΔ±lΔ±mcΔ±lar kahveyi Γ§ok sever!" (same meaning) [ Yaz | Δ±lΔ±m | cΔ± | lar | kah | veyi | Γ§ok | sev | er | ! ] β 10 tokens
Agglutinative languages stack suffixes onto word roots, so they split into more tokens β roughly 2Γ the tokens means 2Γ the cost. It is worth knowing which languages your product serves.
That imbalance is not random. Most models are trained on web content, and the web leans heavily toward a few languages:
Source: W3Techs, top 10M sites, late 2025. Shares shift over time.
If tokens are how a model reads text, embeddings are how it represents meaning. Each token becomes a vector β a list of numbers β and similar meanings land close together in that space.
cat β’ β’ dog β’ kitten β’ king β’ coffee β’ queen β’ tea β’ man β’ woman
The classic party trick is that this space has structure you can do arithmetic on: king β man + woman β queen. Embeddings are what power semantic search, recommendations, and RAG β and they deserve a deeper look of their own.
Every modern LLM is built on one architecture: the Transformer (that is the βTβ in GPT). You do not need the math, but you should know the one idea that makes it work.
Attention means that when the model reads each word, it weighs every other word to decide what matters right now.
"The trophy didn't fit in the suitcase because it was too big."
it ββattends most toβββΊ trophy (not the suitcase)
That single idea buys two big wins: the model reads the whole input in parallel (fast on GPUs), and it captures long-range relationships that older models kept forgetting. The paper that introduced it, back in 2017, was fittingly titled βAttention Is All You Need.β
You have probably heard βgenerative AIβ used as a catch-all. Here is the clean distinction.
A discriminative model judges or sorts existing content. A generative model creates new content: LLMs (text and code), diffusion models (images), speech and audio, video. An LLM is simply the text-shaped instance of generative AI.
You will hear a lot about the eye-watering cost of training frontier models. It comes down to a simple product.
πΈ Training cost β params Γ tokens Γ passes
Thousands of GPUs, weeks to months of runtime, tens to hundreds of millions of dollars β plus data cleaning, failed runs, and human feedback. But here is the good news for you: you will almost never train from scratch. Your job is to use and adapt models that already exist, which is dramatically cheaper.
The core trick is transfer learning: train once, then reuse and adapt many times. In practice you climb the cheapest rung that solves your problem.
RUNG COST WHEN TO USE ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ 1. Prompting cent start here for ~everything 2. RAG low model needs YOUR / fresh knowledge 3. Fine-tuning medium need a consistent style / format / skill 4. Train scratch extreme almost never β only frontier labs ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β² ~90% of real product work lives on rungs 1 & 2.
You will also hear these cost-cutting techniques thrown around:
If GitHub is where code lives, Hugging Face is where models live β an open hub of pre-trained models at every size. Tiny ones that run on a laptop, large open models like Llama, plus embedding models and image models, mostly free to build on. It is the main reason you rarely start from scratch: someone has usually already trained a model close to what you need.
This one trips up almost everyone at first. An LLM has no memory between calls. Each request is completely stateless. Chatbots seem to remember your conversation only because the app resends the whole history every single turn.
Everything the model can see fits inside its context window β measured, of course, in tokens.
Three practical consequences follow directly from this:
Once you accept that context is everything, RAG (retrieval-augmented generation) stops sounding fancy and starts sounding obvious.
The basic idea is nothing more than: put the right text in the prompt. The hard part β finding that text across thousands of documents β is the βretrievalβ half, and it is a topic worth its own deep dive.
These two get confused constantly, so here is the clean mental model side by side.
The one-line version to remember:
They solve different problems, and in real systems they are often used together.
That is the whole map. AI contains ML contains deep learning contains LLMs. A model learns by guessing and correcting billions of times, trains once and runs inference forever. It reads text as tokens, represents meaning as embeddings, and pays attention across a limited context window. When it needs your knowledge, you reach for RAG; when it needs a new behavior, you reach for fine-tuning.
None of these ideas is as complicated as the jargon made it seem. You now share the vocabulary and the mental models that everything else builds on β and from here, it all compounds.
From Tokens to RAG: An AI Field Guide for Developers was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.