How a RAG-based LLM builds an answer
Query, document retrieval, selection, synthesis, citation: the five concrete steps a chatbot uses to build an answer from the web.
When you ask a chatbot like ChatGPT or Perplexity a question and it answers while citing sources, that's not a simple copy-paste. The system follows a chain of steps: reformulate the question, retrieve documents, select the most relevant passages, synthesize them into a coherent answer, then cite its sources. Understanding this chain lets you know precisely where and how your content can fit into it. It's worth keeping in mind that this chain isn't perfectly linear or identical from one tool to another: some systems merge several of these steps, others add extra ones, but the general logic, search then synthesize, remains common to the vast majority of current RAG architectures.
Step 1: the query gets rewritten before it's sent out
Your question, exactly as you typed it, is almost never used as-is to search for information. The system generally rewrites it into one or more more precise search queries, sometimes breaking it down into several distinct sub-questions. This is the fan-out query mechanism, covered in the lesson Fan-out queries: the key concept: a single question from the user can trigger several parallel searches, each covering a different angle of the topic. The number of sub-queries generated varies with how complex the question is perceived to be: sometimes two or three reformulations are enough, sometimes the breakdown is much broader. This number isn't fixed and depends on the tool and the topic at hand.
Step 2: retrieving relevant documents
Once the queries are formulated, the system looks for documents likely to answer them: results from a web search engine, content from an internal database, or a combination of both depending on the tool. This step generally produces a broader set of candidates than what will ultimately be used, somewhat like a first list of results before filtering. In practice, this step often relies on a combination of keyword search and semantic similarity search, the latter making it possible to find relevant passages even when they don't use exactly the same words as the question asked.
Step 3: selecting and ranking passages (reranking)
Among the retrieved documents, not all are equal. A ranking mechanism, often called reranking, evaluates how relevant each passage is to the question asked, and only keeps the excerpts judged most useful. This filtering generally happens at the passage level, not the whole-document level: a page can contain one highly relevant paragraph in the middle of otherwise unhelpful content, and only that paragraph will be kept. This mechanism is explained in more detail in the lesson How the LLM merges results (reranking).
Step 4: synthesis into a coherent answer
The language model receives the selected passages as context, alongside the initial question, and writes an answer that synthesizes them. This isn't a matter of stitching quotes together: the model rephrases, summarizes, sometimes compares several sources that contradict each other, and produces a coherent piece of natural-language text. This is the step where the writing quality of the source content matters: a clear, self-contained passage is easier to integrate correctly than an ambiguous paragraph that depends on surrounding context. When several selected sources contradict each other, for instance on a price or a technical specification, the model also has to arbitrate: it may present both versions, favor the source it judges most recent or reliable, or sometimes stay vague rather than pick a side. This is one reason why the freshness and consistency of content matters as much as simply being available online.
Step 5: citation, when it exists
Depending on the tool, the final answer may or may not include an explicit citation to the source used: a link, a domain name, a footnote. This step isn't systematic or uniform across tools, and it also depends on the nature of the question. One thing holds true across most architectures: to be cited, you first have to survive steps 2 and 3 — that is, be retrieved and then judged sufficiently relevant. It isn't unusual for content to shape the wording of an answer without ever being explicitly cited, which makes measuring its real impact more complex than simply counting cited links.
What this chain of steps means for your content
Each step in this chain is a filter. Your content first needs to be accessible and indexable to survive step 2. It then needs self-contained, clear passages to survive step 3. Finally, it needs to be written so that an automatic synthesis renders it faithfully at step 4. It's this whole set of constraints that defines what's called "GEO-ready" content, a notion developed in the lesson What makes content "GEO-ready"?. A concrete example sums up the stakes well: two articles can cover exactly the same topic with the same level of accuracy, and yet one will get cited three times more often than the other simply because its structure makes each of these steps easier, while the other's makes them harder.
Keeping this chain in mind changes how you write: rather than optimizing for a single ranking algorithm, the goal is to produce content that stays useful and understandable at every step an AI puts it through before answering someone else. None of these steps is optional from the content's point of view, and skipping the analysis of even one of them tends to produce blind spots in how you evaluate why a piece of content did, or didn't, get used. Thinking through each step separately, rather than treating the whole process as one opaque black box, makes it far easier to pinpoint where a specific piece of content is falling short.