Put the steps of a basic RAG query pipeline in order.
- 1Embed the user query
- 2Generate the answer with the LLM
- 3Optionally rerank the retrieved chunks
- 4Search the vector index for top-k similar chunks
- 5Assemble the LLM prompt with retrieved context
Embed the query, retrieve top-k chunks, optionally rerank, stuff retrieved context into the prompt, then generate. Five steps, always in that order.
Imagine you ask a friend a tricky factual question. First, your friend writes down the key idea of your question on an index card (embed the query). Then they walk into a library, find the shelf with notes that match (vector search for top-k chunks), maybe filter to the most relevant few (rerank). Next they bring those notes back to the desk and lay them next to your question (assemble the prompt). Finally, they read everything and write an answer for you (generate). RAG is just that workflow, automated. The model is the friend, the embeddings are the index, the vector store is the library, and the LLM does the final writing.
Detailed answer & concept explanation~4 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 min: five steps + why the order is forced by data dependencies + where query rewrite fits + what hybrid retrieval changes + what kills the pipeline.
Real products, models, and research that use this idea.
- Perplexity runs query embed plus web retrieval plus a rerank plus Claude or GPT generation, the canonical web-RAG flow.
- GitHub Copilot Chat embeds the active query, retrieves repo chunks, and stuffs them into the prompt before generation.
- Cohere Rerank v3 and BGE-reranker-v2 are the two reranker families most production RAG stacks use in 2026.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhere would you add query rewriting in this pipeline?
QHow would you handle a 10M-document corpus where exhaustive search is too slow?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Putting reranking before retrieval. You can't rerank what you haven't retrieved, the reranker scores a candidate list.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.