IInvest Like the Best
← All frameworks
Innovation

The Retrieve-and-Generate Answer Engine Pipeline

Turn a question into a grounded, cited answer instead of a list of links.

Difficulty
Advanced
Time to result
~months to results
Steps
5
Confidence
90%

This is the core mechanism Perplexity uses to replace '10 blue links' with a direct, trustworthy answer. A query is first reformulated and expanded, then matched against a continuously updated web index. Only the relevant paragraphs ('chunks') are pulled from the highest-quality pages, and a language model is constrained to summarize strictly from those chunks, attaching a citation to every sentence. The result is a concise, referenced answer that lets users go deeper if they want, or simply trust the summary. The philosophy is that intelligence (reasoning) and knowledge (retrieval) should be separate systems working together, rather than trying to bake all facts into the model itself.

Origin

Perplexity started as a small wrapper connecting the Bing API to GPT-3.5, then rebuilt the pipeline in-house once usage outgrew what third-party APIs could reliably support.

Core principles

  • 01Reformulate the question before searching, not after
  • 02Retrieval quality of the index matters more than model size
  • 03Ground every generated sentence in a cited source
  • 04Let the model say 'I don't know' rather than fabricate

How to run it

  1. 1

    Reformulate the query

    The system expands and rewrites the user's raw question into a more well-formatted search query, adding prefixes/suffixes to clarify intent before any retrieval happens.

    Pro tip Treat this as the 'question engine' layer — it should compensate for the fact that most users are not skilled at articulating precise questions.

  2. 2

    Pull candidate links from the index

    The reformulated query is run against a proprietary index (a cached, continuously refreshed copy of relevant parts of the web) to surface the most relevant pages.

    Watch out Chasing index size instead of index quality was the mistake earlier search competitors made.

  3. 3

    Extract only relevant chunks

    Rather than passing entire pages to the model, the system extracts just the paragraphs relevant to the query from each candidate link.

  4. 4

    Generate a grounded, cited answer

    A language model, fine-tuned for summarization, reads only the retrieved chunks and produces a concise (4-5 sentence) answer, with every sentence tagged to the source it came from.

    Pro tip Train the model specifically to abstain ('I don't know') when the retrieved chunks are insufficient, rather than relying on prompt engineering alone.

    Watch out LLMs are conditioned to always be 'helpful,' which makes them prone to fabricating answers when information is missing.

  5. 5

    Render and enable follow-up

    The answer is rendered (markdown, bullets, images) with sources listed at the top, and the user can either click into a source or continue the conversation with a follow-up question.

In the wild

From wrapper to owned pipeline

Perplexity initially wrapped Bing search results with GPT-3.5 to launch fast. As usage grew, they rebuilt every layer themselves — crawler, parser, indexer, ranking, and their own fine-tuned inference models — to control latency and accuracy end to end.

→ Perplexity became widely regarded as one of the fastest chatbots despite doing more work per query than ChatGPT.

Common mistakes

Optimizing for index size over quality

Aravind notes that prior search competitors obsessed over how many pages they indexed rather than which domains actually mattered for question-answering, and Perplexity deliberately avoided repeating this mistake.

Trying to fix hallucination with prompt engineering alone

Reducing hallucinations required retraining the model to recognize insufficient context and abstain, not just tweaking prompts.

Ignoring corner cases like ambiguous names or future dates

A grounded answer engine must explicitly handle ambiguity and events that haven't happened yet, or it will confidently produce wrong answers.

Is it for you?

Not ideal for

Simple navigational tasks (e.g., 'go to my bank's login page') where a direct link is faster than a generated answer.

From the transcript

“So when you type in a question into Perplexity, the first thing that happens is, it first reformulates the question, it tries to understand the…”

Aravind

“That AI model looks at all these chunks of knowledge the bits of study that surface from important or relevant links and takes only those…”

Aravind

From the episode

Aravind Srinivas - Building An Answer Engine - [Invest Like the Best, EP.363]

→