How AI Search Works

Retrieval-augmented generation, query fan-out, embeddings, re-ranking, context windows, the lost-in-the-middle effect and AI hallucination.

When someone asks ChatGPT, Perplexity, Gemini or Google’s AI Mode a question that needs current information, the system usually does not answer from memory alone. It turns the question into searches, retrieves pages, picks passages from them and writes an answer based on those passages. This guide explains each step and what it means for a website that wants to be one of the sources.

Retrieval-augmented generation (RAG)

Retrieval-augmented generation is the method of giving a language model relevant documents at the moment it answers, instead of relying only on what it learned in training. The term comes from a 2020 paper by Lewis and colleagues at Facebook AI Research. Almost every AI assistant that shows source links works this way.

RAG has three stages: retrieve candidate documents, select the most relevant passages, and generate an answer from them. A page can drop out at any stage. It may not be in the index, it may not be retrieved for the query, or it may be retrieved but lose to a passage that answers more directly.

What it means for your site: the unit that competes is a passage, usually a few sentences, not a whole page. A page with one clear answer per section gives the system more usable passages than a page where the answer is spread across several paragraphs.

Query fan-out and query decomposition

A question like “best CRM for a 20-person B2B sales team in India under 50,000 rupees a month” contains several separate needs. Systems split it into smaller searches, for example “CRM for small B2B teams”, “CRM pricing India” and “CRM comparison 2026”, run them, and combine the results. Google described this approach, which it calls query fan-out, when it introduced AI Mode in 2025.

What it means for your site: you can be cited for a question you would never target as a keyword, because one of your pages answers one of the sub-queries well. Pages that cover the specific parts of a decision (pricing, comparisons, requirements, limitations) have more chances to be pulled in than a single general page.

Multi-source synthesis

After retrieval, the model writes one answer from several sources. It tends to repeat what sources agree on and to attribute specific facts, figures and quotations to the source that stated them most clearly.

What it means for your site: generic statements that appear on many sites get merged and rarely credited. A specific figure, a named example or a clearly worded definition is more likely to be attributed to you.

Zero-click searches

A zero-click search ends without the user visiting any website, because the answer was shown on the results page or in the AI reply. A 2024 study by SparkToro using Datos clickstream data estimated that 58.5% of Google searches in the United States and 59.7% in the European Union ended without a click to the open web.

What it means for your site: visibility inside the answer has value even when it does not produce a visit, because the buyer still sees your name. It also means traffic alone understates how often you are seen, so AI mentions and snippet appearances need to be tracked separately. The zero-click guide lists what to measure.

Embeddings and vector similarity

An embedding is a list of numbers, often several hundred or a few thousand long, that represents the meaning of a piece of text. Texts with similar meanings produce vectors that point in similar directions. Search systems compare a query vector with passage vectors, commonly using cosine similarity, which measures the angle between two vectors.

This is why a page can match a query without sharing its exact words. A passage about “reducing hosting bills” can match a question about “cutting cloud costs”.

What it means for your site: repeating a keyword does not help much in vector search. Covering the actual concepts, and the related terms people use for them, does. The full guide to embeddings and cosine similarity goes into more detail.

Dense passage retrieval

Dense passage retrieval (DPR) is a retrieval method in which both questions and passages are converted into embeddings and matched by similarity. In the 2020 paper that introduced it, Karpukhin and colleagues reported that DPR beat the traditional keyword method BM25 by 9 to 19 percentage points in top-20 passage retrieval accuracy on open-domain question answering tests.

Most production systems now combine both: keyword matching catches exact names, codes and numbers, and dense retrieval catches meaning. This combination is called hybrid retrieval.

What it means for your site: exact terms still matter for product names, model numbers and technical terms, while clear explanations matter for meaning. Pages need both.

Re-ranking with cross-encoders

The first retrieval step is fast but rough. Many systems then re-rank the top results with a cross-encoder, a model that reads the question and a passage together and scores how well the passage answers it. It is more accurate but too slow to run on the whole index, so it only sees the shortlist.

What it means for your site: to win at this stage, a passage has to answer the question directly. A passage that is on topic but builds up to the answer slowly can be pushed down by a shorter, more direct one. See the guide to dense retrieval and re-ranking.

Multi-turn conversations and unstated conditions

In a chat, the second and third questions depend on the first. A user who asked about CRMs for small teams and then asks “which one integrates with Tally?” still means small-team CRMs. Assistants carry that context into their new searches.

Buyers also leave conditions unstated: budget, company size, location, existing tools. We call these latent constraints. An answer that fits the unstated conditions is more useful, and assistants look for sources that mention them.

What it means for your site: say who a product or service is for, what it costs or what drives the cost, where it is available and what it works with. These details let an assistant match your page to a specific buyer’s situation. The guide to multi-turn intent and latent constraints covers this in depth.

Context windows and token budgets

A language model can only read a limited amount of text at once, measured in tokens (roughly three quarters of an English word each). Even models with very large context windows are given a selection of passages rather than whole pages, because longer inputs cost more and slow the answer down.

What it means for your site: long introductions, repeated boilerplate and navigation text use up space without adding information. The part of your page that gets passed to the model should be the part that answers the question.

The lost-in-the-middle effect

A 2023 study by Liu and colleagues at Stanford, “Lost in the Middle: How Language Models Use Long Contexts”, found that models used information best when it appeared at the beginning or end of their input, and worst when it sat in the middle. Performance on the same question dropped noticeably when the relevant passage was moved to the middle of a long context.

What it means for your site: state the answer at the start of each section. A key fact buried in the fourth paragraph of a long section is both less likely to be selected and less likely to be used if it is selected.

Hallucination and grounding

A hallucination is a statement from a language model that sounds confident but is false. Grounding the answer in retrieved sources reduces this but does not remove it. A 2023 Stanford study of generative search engines, “Evaluating Verifiability in Generative Search Engines” by Liu, Zhang and Liang, found that only about half of the generated sentences were fully supported by their citations, and about a quarter of citations did not support the sentence they were attached to.

What it means for your site: AI answers can describe your company wrongly even when they cite you. Clear, consistent facts on your own site, repeated identically on your other profiles, give the model less room to guess. When an assistant gets something wrong about you, the source of the error is usually an outdated or unclear page somewhere, and finding and fixing it is part of GEO work. The guide to hallucination and grounding sets out the steps.

In-depth guides

Related guides