PlainLogic

Interactive lab · Practical AI

AI Lab — How LLMs, RAG & Agents Work

Three animated flows explain modern AI: a model writing one token at a time, RAG grounding answers, agents looping through tools.

Watch it happen

Your words become an answer

Four steps, one moving picture. Follow the numbers as a request flows through a simplified model and comes out as readable text.

  1. Your words inthe request — for example, “write a haiku”.
  2. Tokens (pieces a model reads)your words sliced into the chunks the model actually processes.
  3. Thinking (four processing layers)each layer finds what matters and guesses what comes next.
  4. Answer outthe winning pieces stream out one by one as readable text.

Watch your words become an answer.

Simplified educational visualization. The four layers are labeled with their plain jobs — words become numbers, the model finds what matters, guesses the next piece, and numbers become words again. No real model runs here; the animation is illustrative.

The experiments

Press Run, watch the idea move

Each flow is an animated diagram. Follow the packet along the edges — every step is labeled as it fires.

Everything here is a simplified educational visualization — the shape of the idea, not real model internals. The Run buttons drive simulated animations in your browser; no real AI model runs and nothing is sent anywhere.

The LLM flow — one token at a time

Simplified educational visualization

A model doesn't look up answers — it writes them one piece at a time. Your prompt is sliced into tokens, the model reads the full context, and predicts the most likely next token, repeating until it stops. No real tokenization or model math runs here — the animation shows only the shape of the idea.

Ready. Press Run to watch a prompt travel through the flow.

Simplified educational visualization. No real tokenization runs in your browser; the packet animation is illustrative.

The RAG flow — answers with receipts

Simplified educational visualization

RAG fixes the model's knowledge cutoff by handing it cheat sheets: your question becomes a search, matching documents are pulled from a knowledge store, and the best chunks land in the model's context before it writes. Real systems use vector indexes and similarity search — this shows the shape of the idea, not the machinery.

Ready. Press Run to watch a question get answered with documents.

Simplified educational visualization. No real embeddings, search, or retrieval runs here; the packets are illustrative.

The agent flow — the loop that does work

Simplified educational visualization

An agent doesn't just answer — it works in a loop toward a goal: decide, act, observe, decide again. Watch the loop-back edge — the first tool call fails, the agent retries, re-plans from the observation, and finishes on the second pass. Real agents juggle far more; this is a loop illustration, nothing more.

Ready. Press Run to watch the agent iterate: attempt 1 fails, attempt 2 lands.

Simplified educational visualization. The loop-back edge from Observation to Decision is the whole idea of an agent: iteration.

Plain-language AI

What each step means

The six boxes in each flow, in plain words. Nothing here requires a math degree.

LLM flow

  1. PROMPT — the words you type to start.
  2. TOKENIZE — your words, sliced into the small chunks the model actually reads. Illustrated, not computed.
  3. CONTEXT — everything the model may consider: your prompt plus what it has written so far.
  4. MODEL — the trained predictor guessing what comes next.
  5. NEXT TOKEN — the winning piece is picked, one at a time.
  6. OUTPUT — the picked tokens accumulate into readable text.

RAG flow

  1. QUESTION — what you ask.
  2. EMBEDDING / SEARCH — your question becomes a search over the knowledge store. (Real systems use vector indexes.)
  3. DOCUMENTS — the stored knowledge: manuals, articles, notes.
  4. RETRIEVED CHUNKS — only the few most relevant passages move forward.
  5. CONTEXT — question plus evidence, handed to the model together.
  6. ANSWER — the model's reply, now grounded in your documents.

Agent flow

  1. GOAL — the task to complete.
  2. DECISION — the agent picks its next action.
  3. TOOL — a search, a file write, an API call. It can fail, and be retried.
  4. OBSERVATION — the agent reads what the tool returned.
  5. NEXT DECISION — the plan adjusts from the observation. The loop closes here.
  6. RESULT — the goal is reached and the loop exits.

Honest answers

What this page is (and is not)

Is this how AI really works?

Conceptually, yes — literally, no. Each flow shows the real shape of the idea: a language model predicts one token at a time; RAG retrieves documents and then answers; an agent decides, acts, observes, and repeats. Real systems involve billions of parameters, vector indexes, and tooling this page only hints at, which is why every visualization is labeled "simplified educational visualization."

Does pressing Run use a real AI model?

No. The Run buttons drive a simulated animation built with the PlainLogic flow engine. No prompts are sent anywhere and no real model runs — it is an educational illustration, not a working AI. Nothing leaves your browser.

What is the difference between RAG and an AI agent?

RAG gives the model documents to read before it answers — the model itself stays passive. An agent gives the model tools to act with and a loop to keep trying until the goal is done. In practice they combine: agents routinely call retrieval as one of their tools.