From Question to Cited Answer: The AI Search Pipeline
When you ask an AI search tool a question, a lot happens in a few seconds. Your question is rewritten, split into several searches, matched to pages, cut down to short passages, and then turned into an answer with citations.
This lesson walks through each step in order. Once you know the steps, you can guess where an answer might have gone wrong.
What You'll Learn
- How your question is rewritten before any search happens
- What "fan-out" means and why one question becomes several searches
- How pages are retrieved and ranked
- Why the AI reads passages, not whole pages
- How the model writes the answer and attaches citations
The pipeline at a glance
Different tools build this in different ways, and most companies do not publish every detail. But the general shape is the same across the tools you met in Lesson 1.
- 1. RewriteTurn your question into search queries
- 2. Fan outRun several searches at once
- 3. RetrieveCollect and rank candidate pages
- 4. Pick passagesKeep the most relevant chunks
- 5. Write and citeModel writes the answer and adds links
Let's follow one example question through every step:
"Is it cheaper to take the train or fly from Berlin to Munich, and how long does each take?"
Step 1: Rewriting your question
People ask questions the way they talk. Search engines work best with short, focused queries. So the first step is often query rewriting: a model reads your question and turns it into one or more search queries.
It may also use the earlier messages in your chat. If you first asked about Berlin and then wrote "what about Munich?", the rewrite step fills in the missing context so the search makes sense on its own.
For our example, the rewrite might produce queries like:
- "Berlin to Munich train price"
- "Berlin to Munich flight price"
- "Berlin Munich train travel time"
- "Berlin Munich flight duration"
Notice what happened. The AI decided what to search for, not you. If the rewrite misses a part of your question, the answer will likely miss it too.
Step 2: Fan-out into several searches
Our example question has four parts: two prices and two travel times. One search would rarely cover all of them well. So the tool runs several searches at once and combines the results. This is often called query fan-out. Google, for example, has used this term when describing how its AI Mode works.
Fan-out is why AI search can answer questions that would take you five tabs. Each sub-search hunts for one piece of the answer.
It also has a cost. More searches mean more pages to sort through, and more chances for a weak page to slip in.
Step 3: Retrieving and ranking pages
Each search returns a list of pages, the same as classic search. The tool may use its own search index, a partner's search engine, or both. Then it ranks the candidates.
Ranking here looks at things like:
- how closely the page matches the query,
- how fresh it is, which matters a lot for prices and news,
- and signals about the site's quality and reputation.
Only the top pages move on. If a great source ranks low, the AI never reads it. If a weak page ranks high, the AI may lean on it heavily.
Step 4: Picking passages, not pages
A language model can only read a limited amount of text at once. This limit is called the context window. Reading twenty full web pages would fill it with menus, ads, and comments.
So the tool cuts each page into short chunks, often a few paragraphs each, and keeps only the chunks that best match the question. Some tools match by keywords, some by meaning, and many use both. Matching by meaning uses embeddings, lists of numbers that capture what a sentence means. The Embeddings Explained course shows how that works in plain language.
For our example, the model might get a passage from a rail company page with a price range, a passage from a travel blog with flight times, and a passage from a comparison site.
The answer can only be as good as the passages that reach the model.
| Criteria | What the model sees | What it does not see |
|---|---|---|
| Text | A handful of short passages | The rest of each page |
| Context | The page title and link | Notes, dates, or warnings outside the chunk |
| Sources | Pages that ranked high | Pages that ranked low or were never found |
What the model sees
- Text
- A handful of short passages
- Context
- The page title and link
- Sources
- Pages that ranked high
What it does not see
- Text
- The rest of each page
- Context
- Notes, dates, or warnings outside the chunk
- Sources
- Pages that ranked low or were never found
This step explains a lot of AI search mistakes. A passage might say "from 20 euros" but the line saying "with a discount card, booked weeks ahead" was in the next paragraph and got cut off.
Step 5: Writing the answer and attaching citations
Now the language model gets your question plus the chosen passages, along with instructions like "answer using these sources and cite them." It writes the answer one piece at a time, the same way any chatbot writes.
Citations are added in one of two broad ways:
- While writing. The model is trained or told to place a source marker, like [1] or a small link, next to each claim.
- After writing. A separate step matches each sentence of the answer back to the passage it seems to come from, and adds the link.
Either way, the link means "this passage was used near this sentence." It does not mean a person checked that the sentence and the passage say the same thing. That gap is the topic of Lesson 4.
Why the same question gives different answers
If you ask the same question twice, or in two tools, you may get different answers. Each step can change:
- the rewrite may produce different queries,
- the search results may have shifted since last time,
- different passages may be picked,
- and the model writes with some randomness.
This is normal. It is also why comparing two tools is a good check, as you will see in Lesson 5.
Try it: ask the AI to show its steps
Some tools show the searches they ran. If yours does not, you can ask. Try this with any AI tool that has web search turned on. A model without search can only guess what it would search for.
The playground below cannot search the web. If you run the prompt here, it will invent the queries and the sources. Use it to see the format, then paste the same prompt into a tool with web search to see real steps.
Treat the list of queries as a rough guide, not an exact log. Some tools describe their searches accurately, and some do not.
Key Takeaways
- AI search runs a pipeline: rewrite, fan out, retrieve, pick passages, write and cite.
- Query rewriting means the AI decides what to search for. If it drops part of your question, the answer will too.
- Fan-out splits one question into several searches, which helps with multi-part questions but brings in more pages to sort.
- The model reads short passages, not whole pages, so missing context is a common cause of errors.
- A citation means a passage was used near that sentence, not that someone checked the claim against it.
Quiz
Up next ยท Lesson 3 of 5
AI Search Is RAG on the Open Web
4 min read
2 of 5 lessons done

