AI6 min read10 interview questionsNew · November
RAG: let the model look things up
How to make an AI answer from your own documents.
In one sentenceRetrieval-augmented generation finds the most relevant passages from your documents first, then gives them to the model so it answers from them.
Think of it like thisIt is an open-book exam: instead of answering from memory, the student first finds the right pages, then writes the answer.
The big picture
Tap any step to see where to use it, how to use it and an example result.
Why not just ask the model
Models do not know your private documents, and their knowledge stops at a certain date. Retrieval brings the right facts into the prompt at the moment they are needed.
The steps
Documents are cut into pieces, each piece is converted into an embedding (numbers that capture meaning) and stored in a vector index. At question time, the question gets an embedding too, the closest pieces are found, and the model is told to answer using only those.
Making it good
Quality depends on cutting sensibly, retrieving the right pieces, showing sources so people can check, and saying "I do not know" when nothing relevant is found. Test with real questions and note where it fails.
Common mistakes
- Cutting documents into pieces that are too small to make sense.
- Not showing where each answer came from.
- Never testing with real questions, so failures stay hidden.
Quick recap
- Find the facts first, then answer
- Embeddings let you search by meaning
- Show your sources
- Test with real questions
Try it yourself
Take ten paragraphs from a document you know, write five questions, and check by hand which paragraph best answers each. That is your first test set.
Top 10 interview questions
Ordered from basic to advanced. Try answering out loud first, then open the answer.
What is RAG?Basic
Retrieval-Augmented Generation. Before answering, the system looks up relevant documents and gives them to the language model, so the answer is based on your own data.
Why use RAG instead of just asking the model?Basic
Models do not know your private or recent data and may guess. RAG supplies the facts, reduces made-up answers and lets you show the sources.
What are the main steps in a RAG system?Basic
Prepare the documents (split them into chunks and create embeddings), store them in a vector database, retrieve the chunks closest to the question, and put them into the prompt for the model to answer.
What is a chunk and why split documents?Basic
A chunk is a small piece of a document. Splitting keeps each piece focused and small enough to fit in the prompt, so retrieval returns only what is relevant.
How do you choose chunk size?Intermediate
Small enough to be precise, large enough to keep meaning. A few hundred tokens with some overlap is a common start, then you test with real questions and adjust.
What is a vector database?Intermediate
A database built to store embeddings and quickly find the ones closest in meaning to a query. Examples include pgvector, Pinecone, Qdrant and Cloudflare Vectorize.
How is RAG different from fine-tuning?Intermediate
RAG adds knowledge at question time from documents you can update at once. Fine-tuning changes the model itself, which suits style or task behaviour, and is slow and costly to refresh.
What happens when retrieval returns the wrong chunks?Intermediate
The model answers from poor context and the result is wrong or vague. Improve chunking, use hybrid keyword plus vector search, add reranking, and tell the model to say when the context lacks the answer.
How do you evaluate a RAG system?Advanced
Measure retrieval (is the right chunk in the top results?) and generation (is the answer correct, complete and grounded in the sources?). Build a test set of real questions with expected answers and track it as you change things.
What advanced techniques improve RAG?Advanced
Hybrid search, reranking, query rewriting, metadata filters, parent-document retrieval, citations, and keeping access control so users only retrieve documents they are allowed to see.
Guides are simplified on purpose. Tool names and details change, so check the official documentation before relying on a detail.