How AI Works

How AI Works: From Your Prompt to Intelligent Action

An interactive journey through everything that happens between the moment you press Enter and the moment AI completes a task for you. No math. No jargon. Just click, hover, and explore.

💡 Switch the learning mode at the top any time — every section adapts to you.
1

The User Prompt

It all starts with you typing a message. But the AI receives much more than just your words.

You type…
💬
“AI doesn’t understand words like humans do. It converts your words into numbers called tokens.”
What the AI actually receives
  • ✍️Your text — the words you just typed
  • 🧩Context — what this conversation is about
  • 📋Instructions — rules for how it should behave
  • 🕑Conversation history — everything said so far
  • Your preferences — saved settings & style
Your sentence
Plan a holiday to Japan
▼  converts into  ▼
Tokens — the AI’s word pieces
PlanaholidaytoJapan
▼  becomes  ▼
Numbers — the only language AI speaks
245689134216785102
Every word (or word piece) has its own ID number. The AI does all its “thinking” with these numbers.
Beginner Think of tokens like LEGO bricks for language. The AI snaps your sentence apart into small bricks, gives each brick a number, and works with the numbers. When it replies, it snaps bricks back together into words you can read.
Product Manager Why this matters for your product: everything you send the model — user message, system instructions, history, retrieved data — competes for a limited context window and is billed per token.
  • Opportunity: well-designed prompts and context = better answers with zero model changes.
  • Risk: long conversations silently push out earlier context; costs scale with tokens.
  • Metric: tokens per request, cost per conversation, context-window utilisation.
Technical Text is split by a tokenizer (e.g. BPE) into subword units, each mapped to an integer ID from a fixed vocabulary (~50k–200k entries). IDs are looked up in an embedding matrix, producing dense vectors the transformer operates on. The full request = system prompt + conversation history + user turn, concatenated into one token sequence bounded by the context window.
2

The AI Understanding Layer

The AI looks at patterns it learned during training to work out what you actually want.

The AI reads between the lines
“Book me a flight”
IntentTravel request — the user wants an action, not information
Entities✈️ Flight
MissingDestination? Date? Budget? — the AI knows it should ask
👆 Hover each word to see the AI’s interpretation
Goal · The action verb — this tells the AI
what job to do: search for flights
Find
Preference · A constraint — sort results
by price, lowest first
cheap
Goal · Confirms the object of the search:
flights, not hotels or trains
flights
Connector · Small words still help the AI
link ideas together
to
Entity · A real-world place —
the destination: Sydney, Australia
Sydney
Goal
Find flights
Location
Sydney
Preference
Cheap
Beginner The AI is like a really good waiter. Say “something light, I’m in a hurry” and a good waiter knows: small dish, fast to prepare. The AI does the same — it figures out your goal, spots the important details, and notices what’s missing.
Product Manager User problem solved: people express goals in messy, incomplete language. The model’s ability to infer intent is what makes natural-language products feel magical.
  • Opportunity: replace rigid forms and menus with “just say what you want”.
  • Risk: misread intent = confidently wrong actions. Design confirmation steps for high-stakes intents.
  • Metric: intent recognition accuracy, clarification-question rate, task abandonment.
Technical There is no separate “NLU module” in an LLM — understanding is implicit. Self-attention lets every token attend to every other token, so “cheap” modifies “flights” and “Sydney” binds as destination. Semantically similar phrases land near each other in embedding space, which is why paraphrases (“low-cost fares to SYD”) resolve to the same meaning.
3

The AI Model (LLM)

The Large Language Model predicts the most useful next word, based on patterns learned from billions of examples.

Press play to watch the AI think…
blue
0%
green
0%
red
0%
falling
0%
“The AI is not searching for a stored answer. It generates an answer, one word at a time, based on probability.”
📚 Training on billions of examples 🧠 Learning patterns 💬 Generating responses
Beginner It’s like super-powered autocomplete. Your phone can guess the next word of a text message; an LLM has read so much that it can “guess the next word” so well, it writes whole essays, answers, and plans — one word at a time, really fast.
Product Manager Key mental model: the LLM is a probabilistic engine, not a database.
  • Opportunity: it can handle inputs nobody wrote code for — the long tail of user requests.
  • Risk: hallucination — fluent, confident, wrong. Never ship LLM output as ground truth for facts, prices, or policies without grounding (see RAG, Section 5).
  • Metric: answer accuracy vs. human eval, hallucination rate, latency per response.
Technical A decoder-only transformer maps the token sequence to a probability distribution over the vocabulary for the next token. Sampling parameters (temperature, top_p) trade determinism for creativity. Generation is autoregressive: each emitted token is appended and the pass repeats. Weights are frozen at inference — the model learns nothing new while answering you.
4

Context & Memory

The same question can get a completely different answer — depending on what the AI knows about you.

Three kinds of memory
💭

Short-term memory

The current conversation.

You: “My name is Sarah”
…later…
You: “What’s my name?”
AI: “Sarah” ✓
🗂️

Long-term memory

Saved preferences that persist across chats.

Saved: “User prefers
vegetarian restaurants”
🔌

External knowledge

Connected databases and APIs.

🌦️ Weather API
👥 CRM
🛒 Product catalogue
Try it: same request, with and without context
Without context With context
🧑
Recommend a laptop
Sure! Are you looking for gaming, work, or casual use? What’s your budget? Any preferred screen size…? 🤔 (The AI has to guess or ask — it knows nothing about you.)
🧑
Recommend a laptop
+ context: “I’m a product manager who travels often and prefers lightweight laptops”
For a travelling PM, I’d go with a 13–14″ ultralight (~1 kg) with all-day battery — e.g. a MacBook Air or an XPS 13. Great for docs, dashboards and video calls, and it disappears into a carry-on. ✈️ (Specific and useful on the first try.)
Beginner Context is like the difference between asking a stranger for advice and asking a friend who knows you. The words of your question are the same — but the friend’s answer fits you. Memory is how AI goes from stranger to friend.
Product Manager Personalisation is a context-engineering problem, not a model problem.
  • Opportunity: injecting user profile + history into prompts is the cheapest quality win available.
  • Risk: privacy & consent — users must know what’s remembered and be able to delete it. Wrong memories compound.
  • Metric: first-response usefulness, follow-up questions per task, retention lift from personalisation.
Technical “Memory” is engineered, not innate. Short-term = the conversation replayed into the context window each turn. Long-term = facts persisted in a store (often a vector database), retrieved by similarity and injected into the prompt. External knowledge = API/tool calls at inference time. The model itself is stateless between requests.
5

Retrieval Augmented Generation (RAG)

Sometimes the AI needs information it was never trained on — like your company’s documents.

The problem
“What is our company refund policy?”

The model has never seen your company’s internal documents. Instead of guessing (and hallucinating), it looks the answer up first — like an open-book exam. 📖

Watch RAG work
User question
“What is our refund policy?”
🔎
Search documents
Scans the company knowledge library
📄
Retrieve relevant information
Found: “Refund-Policy-2026.pdf”, section 3
Add it to the prompt
The found text is placed next to your question
AI generates the answer
Grounded in the real document
✦ “Customers can request a full refund within 30 days of purchase. After 30 days, store credit is offered for unopened items.”
📎 Source: Refund-Policy-2026.pdf — the AI can cite where the answer came from.
Beginner Imagine a brilliant new employee on day one. They’re smart, but they don’t know your company’s rules yet. RAG hands them the right page of the company handbook just before they answer. Smart brain + right page = correct answer.
Product Manager RAG is how you make AI trustworthy on your data.
  • Opportunity: support bots, internal knowledge search, policy Q&A — without retraining any model.
  • Risk: answers are only as good as the documents. Stale or contradictory docs = confident wrong answers with citations.
  • Metric: retrieval hit rate, answer groundedness, deflection rate (for support), doc freshness.
Technical Docs are chunked and embedded into a vector database. At query time the question is embedded, nearest chunks retrieved (cosine similarity, often + keyword/BM25 hybrid, then reranking), and the top chunks are stuffed into the prompt with instructions to answer only from them and cite sources. Quality levers: chunking strategy, embedding model, k, reranker, and prompt grounding.
6

AI Tools

AI can use tools to do things — not just answer questions.

Tools an AI can pick up
🌐Search internet
📧Send emails
📅Schedule meetings
📊Analyse data
💻Write code
💳Process payments
The model can’t browse or book anything by itself — it asks a tool to do it, then reads the result and decides what’s next.
Watch a request become actions
🧑 “Book me a restaurant tomorrow at 7 PM”
🧠 Understand the request
📅 Check your calendar — you’re free at 7
🔎 Search restaurants near you
🍽️ Make the booking — table for 2, 7:00 PM
✉️ Confirm with you & add to calendar
Beginner Words alone can’t book a table — hands can. Tools are the AI’s hands. The AI thinks (“I need the calendar”), reaches for the right tool, uses it, looks at what happened, and picks up the next tool. One request, several small actions.
Product Manager Tools turn a chat feature into a product that does work.
  • Opportunity: every API your product already has can become an AI capability.
  • Risk: real-world side effects — wrong booking, wrong email, wrong payment. Define permissions, spending limits, and human-approval gates for irreversible actions.
  • Metric: task completion rate, tool-error rate, human interventions per task.
Technical Tool/function calling: tools are described to the model as schemas (name, parameters). The model emits a structured call like book_table(time:"19:00", size:2); the runtime executes it and feeds the result back as a new message, looping until done. Standards like MCP make tools plug-and-play across apps. Guardrails live in the runtime, not the model.
7

From Chatbot to AI Agent

A chatbot tells you how. An agent does it for you. This is the biggest shift in modern AI.

💬 Chatbot: User asks → AI answers vs 🤖 Agent: Goal → Plan → Actions → Done
💬 Chatbot
“How do I reset my password?”
“Here are the instructions: 1. Go to Settings → Security. 2. Click ‘Reset password’. 3. Check your email…”
You still have to do all of it yourself. 😮‍💨
🤖 AI Agent
“Reset my password”
  • Understands the goal
  • Checks your identity
  • Finds your account
  • Creates a reset link
  • Sends the email
  • Confirms: “Done — check your inbox ✉️”
Beginner A chatbot is like a librarian: ask a question, get a great explanation. An agent is like a personal assistant: give them the goal, and they make the calls, fill the forms, and come back with “done”. Same brain — plus permission to act.
Product Manager The product question changes from “can it answer?” to “can it finish the job?”
  • Opportunity: agents collapse multi-step workflows (10 clicks → 1 sentence). Huge for support, ops, and back-office work.
  • Risk: autonomy needs trust: audit logs, undo, approval steps, and clear boundaries on what the agent may touch.
  • Metric: end-to-end task completion, time-to-done vs. manual, escalation rate, user trust scores.
Technical An agent = an LLM in a loop with tools and state: while not done: observe → reason → call tool → read result. The chatbot is a single model call; the agent is an orchestrated runtime with termination conditions, error handling, retries, and permission scopes. Same model — different harness.
8

How AI Agents Work Internally

Under the hood, every agent runs the same loop. Click any step — or watch it cycle.

The Agent Loop 🔄
🧠 Think 🗺️ Plan ⚡ Act 🔍 Check 📈 Improve 🔁 repeat until done
Beginner It’s exactly how you’d cook a new recipe: decide what you’re making (goal), read the recipe (plan), do the next step (act), taste it (check), add more salt (improve) — and repeat until dinner is ready. Agents just do this with software instead of saucepans.
Product Manager Each loop stage is a product surface you can design and measure.
  • Planning: show the plan to users before executing — instant trust win.
  • Reflection: this is your quality control; weak reflection = agents that “finish” badly.
  • Risk: loops can run away — cap iterations, budget, and time. Metric: iterations per task, cost per task, self-correction rate.
Technical Patterns: ReAct (interleaved reasoning + tool calls), plan-then-execute, and reflection/self-critique passes. State (goal, plan, tool results, scratchpad) is carried in context or external memory. Orchestration frameworks handle retries, timeouts, max-iteration caps, and structured termination (“goal satisfied” vs “blocked — ask human”).
9

Multi-Agent AI Systems

For complex tasks, multiple specialised agents work together — like a project team.

Meet the AI team
🔬

Research Agent

Finds customer needs

📦

Product Agent

Creates the roadmap

📣

Marketing Agent

Creates the campaign

📊

Analytics Agent

Measures success

The team’s work log will appear here…
Beginner One person can’t be a great chef, accountant, and pilot at once — teams work because everyone specialises. AI teams are the same: each agent is great at one job, they pass work to each other, and a lead agent keeps everyone on track.
Product Manager Multi-agent = divide and conquer for AI quality.
  • Opportunity: specialised agents beat one generalist on complex workflows; you can also review/verify each other’s work (checker agents).
  • Risk: coordination overhead, compounding errors passed between agents, and cost multiplication. Start with one agent; add more only when it measurably wins.
  • Metric: quality vs. single-agent baseline, cost per completed workflow, hand-off failure rate.
Technical Architectures: orchestrator–worker (a lead agent decomposes and delegates), pipelines (sequential hand-offs), and debate/critique panels. Agents exchange structured messages; shared state lives in a common store. Hard problems: context hand-off fidelity, deadlock/loop detection, and end-to-end tracing across agents.
10

The Full Journey, End to End

Everything you just learned, in one flow. Press replay and watch your prompt travel through the whole system.

🧑Useryou have a goal
💬Promptyou type it
🧩Tokenisationwords → numbers
🔮AI Modelthe LLM
🧠Understandingintent + entities
📚Context + Memorywhat it knows about you
🔎RAG / Knowledgelooks up real facts
🤔Reasoningdecides what to do
🛠️Toolstakes real actions
🤖AI Agentplans & loops until done
Actionthe work gets done
Answer / Outcomeyour goal, completed
You now understand:
What happens after you type a prompt
How AI generates answers (prediction, not lookup)
Why context and memory change everything
How RAG grounds AI in real documents
How AI uses tools to take action
How agents differ from chatbots
How multiple agents collaborate
How to think about designing AI-powered products
Beginner 🎉 That’s the whole story: your words become numbers, a prediction engine turns them into understanding, memory and lookups keep it truthful, tools give it hands, and the agent loop keeps going until your goal is actually done.
Product Manager Design checklist for AI products: ground answers (RAG) before you trust them; engineer context before you fine-tune; gate risky actions with human approval; show plans to build trust; and instrument everything — completion rate, cost per task, and hallucination rate are your new core metrics.
Technical The full stack: tokenizer → embeddings → transformer inference → context assembly (history + memory + RAG chunks) → tool-calling loop → agent orchestration. Each layer is independently swappable and testable — which is exactly how you should build, evaluate, and debug an AI system.