Skip to content
A few questions to tell if someone has worked on RAG

A few questions to tell if someone has worked on RAG

One year I helped my team interview for a RAG position. The candidate recited the seven-step pipeline smoothly: cleaning, chunking, embedding, indexing, retrieval, reranking, generation—and could name the corresponding tools and frameworks for each step. I asked one last question: the last bad case you encountered—which step did it fall on? He paused for a moment and said he couldn’t remember.

After that, I cut the question bank in half. Pipelines can be memorized; bad cases cannot.

Being able to recite the pipeline doesn’t mean you’ve run it

The standard pipeline itself isn’t wrong—it’s a map for troubleshooting. The difference is that someone who has actually done it will point out which segment of the map is most likely to collapse.

I usually ask three questions in a row. The first is the specific shape of the failure case: did retrieval simply fail to recall, did it recall correctly but the model not use it, or were the data and expectations mismatched from the start. The second is what they tried and what they gave up at the time. The third is which part of the current system is most fragile.

These three questions have no standard answers. But people who can answer them usually have a feel for the system’s boundaries: knowledge base updates are asynchronous, so a file a user just uploaded takes a few minutes to become retrievable; permission filtering must happen before retrieval, not after generation; when the same policy is stored in three versions, the system can only pick one, and the responsibility for picking wrong doesn’t lie with the model.

Data-side problems are the hardest to fake. Ask how cross-page tables in a PDF are handled, and the answers immediately stratify: someone who hasn’t done it will say fixed-length chunking; someone who has will first talk about layout analysis, converting tables to structured form, and attaching headings to metadata. The latter isn’t necessarily all correct, but at least they know where the pitfalls are. Ask next about scanned documents and screenshots—if the other person only mentions OCR and not recognition error rates and downstream cleaning, you can basically conclude they haven’t really run this part.

Multi-tenancy is another point I often ask about. Pre-retrieval filtering versus post-retrieval filtering looks like a mere difference in order, but it actually determines whether privilege escalation can happen. The vector store’s metadata filtering capability, index synchronization after permission changes, and how vectors are cleaned up when user data is deleted—these details say more about whether a system has been in production than model selection does. Many demos don’t have a “delete” action; in production it’s a mandatory question.

People who can’t answer tend to attribute every error to the model not being strong enough, or the prompt not being tuned well. Both attributions are too convenient, and neither can be verified.

The capability gap also isn’t about whether someone can use frameworks. A junior can build the pipeline; a senior knows under what conditions each segment fails: after concurrency rises, the vector store’s connection pool gets exhausted; the reranking model times out on long text; incremental writes make the index briefly invisible. None of this is in the docs—you only know it after stepping on it.

When interviewing, I have the candidate draw the pipeline, then mark three things on the diagram: the segment with the highest latency, the segment most prone to errors, and the segment with the highest cost. These three are often not the same place, and someone who can mark them separately has clearly looked at monitoring. Someone who can only mark “the model” usually hasn’t been in production yet.

These questions, asked to the end, all point to the same thing: evaluation. Someone who can’t articulate failure cases usually hasn’t really done evaluation either—the essence of evaluation is systematically collecting failures. Without an evaluation set, bad cases only arrive via user complaints, and that feedback is both sparse and lagging.

Hybrid retrieval and reranking both trade complexity for accuracy

Pure vector retrieval has a stable weakness: exact matching. Product model numbers, error codes, obscure names, contract IDs—these get compressed in semantic space into “some kind of error” or “some kind of file,” and the returned results look relevant but are actually useless.

Production environments almost always add a keyword retrieval path. BM25 handles string hits, vectors handle meaning hits, and the two result sets are merged with RRF (reciprocal rank fusion). RRF only looks at ranks, not scores, which sidesteps the scale mismatch between BM25’s unbounded scores and cosine similarity stuck between zero and one; it’s also simple to implement and doesn’t require training an extra fusion model.

The cost is real. Two indexes to maintain, two sets of parameters to tune, double the failure surface, and a longer write path. When the knowledge base has only a few thousand chunks, this layer of complexity doesn’t pay back equivalently, so I usually don’t add it first.

Reranking is another trade. A bi-encoder can precompute document vectors offline and only compute the query online; a cross-encoder must concatenate query and document and run them through the model together—much higher precision, but every pair must be computed in real time. It can only be used at the second layer of the funnel, scoring the top few dozen candidates from coarse ranking; it can’t scan the whole corpus.

Reranking doesn’t buy accuracy; it buys the ability to “pick the right one among these candidates.” If the candidates themselves are wrong, reranking can’t save it.

Whether it’s worth adding depends on how long users can wait. A few hundred extra milliseconds in an internal knowledge base doesn’t matter; in real-time voice dialogue, those few hundred milliseconds are an incident. The reranking model also needs to stay resident in GPU memory, which for small teams is a fixed cost, not pay-as-you-go.

Model size matters more than you’d think. For the same reranking task, a small model is fast and memory-friendly but can’t distinguish documents that are “similar in meaning but opposite in conclusion”; a large model judges more accurately, with latency and cost rising together. I usually run the small model against the evaluation set first to see whether it ranks the top few dozen correctly, and only switch to a larger one if it’s not enough. Going straight to the largest often just postpones the latency problem to launch day.

Some also argue for replacing retrieval with long context entirely—stuff all the material in together. For short documents and small amounts of material, it’s indeed feasible and saves indexing and maintenance. But as material grows, cost and latency rise, and the middle part tends to get ignored. The value of retrieval isn’t just saving tokens; it’s also doing filtering and ranking, which a long window can’t replace.

I choose vector stores by maintenance cost. Faiss is strictly speaking a library—fast, but persistence, sharding, and metadata filtering all have to be built yourself. Milvus is full-featured, at the cost of a K8s cluster and dedicated ops. Chroma and LanceDB suit prototypes, with limited scalability once you scale up. In the past two years I’ve preferred pgvector, because business data is already in Postgres—joint filtering of vectors with permissions and timestamps is natural, and one fewer system means one fewer class of failure. The cost is that the scale ceiling and index tunability are inferior to dedicated stores; once data reaches the hundred-million level, you have to reconsider.

Index algorithms are the same kind of trade-off. HNSW queries fast with high recall, but the graph structure must stay resident in memory, construction is slow, and real-time deletion is unfriendly; IVF with quantization saves memory and suits massive data, with somewhat lower recall, and requires training cluster centers first. Once data volume and memory budget are fixed, the answer is basically determined.

Incremental updates are a point I often probe. Vector indexes are unfriendly to single-point insertion; the common approach is to keep a small in-memory index for increments and a large on-disk index merged periodically, querying both and merging results. The downside is delayed data visibility—could be seconds, could be minutes. RAG scenarios mostly tolerate this, but if the product promises “ask as soon as you upload,” that delay must be written into the interaction.

One step further is query rewriting. Users’ phrasings are often unsuitable for direct retrieval—two intents crammed into one sentence, or wording that doesn’t exist in the documents. Having the model split it into several sub-queries, recall each separately, then merge improves hit rates on multi-intent questions. The cost is an extra inference, and if the split is wrong, even the original recall can be lost.

HyDE is another approach: first generate a hypothetical answer, then use that answer’s vector to retrieve. It turns “question finds document” into “document finds document,” and it’s genuinely effective when questions are short and phrased very differently from the documents. But it depends on the hypothetical answer being roughly on the right track; if the model goes astray from the start, retrieval gets dragged further off. I’ve used it in short-query-dominant scenarios; in long-query scenarios the gain isn’t obvious, and it costs an extra generation.

Don’t set hybrid retrieval weights by feel. Keep a validation set and grid-search the weights of the two paths, looking at recall rather than the total score. This process is crude, but it’s more reliable than guessing, and it makes recalibration easy after switching embedding models.

The cost of index rebuilding also needs to be calculated in advance. A full rebuild on tens of millions of records can take a long time, and writes need somewhere to land in the meantime. My approach is to make the rebuild a repeatable offline job and switch over after it finishes, avoiding in-place updates on the main path.

Fine-tuning changes the form; RAG changes the facts

These two are often compared side by side, but they solve different problems. RAG provides external context and takes effect when the data source is updated; fine-tuning changes the model’s output habits—format, tone, terminology, instruction following.

For fact queries that need precise citations, use RAG. For getting the model to reliably output a certain structure, or to learn a set of industry jargon, use fine-tuning. Combining both is also common: first use SFT to lock down the output format, then use RAG to inject data that changed that day.

At the SFT stage, what I care about most is data quality, not quantity. This has been basically consensus since the LIMA work: a small number of carefully selected samples can activate capabilities already present in pretraining—SFT is more about surface alignment than injecting new knowledge. Stacking tens of thousands of noisy samples is usually worse than a few hundred samples that a human has gone through. Sample diversity matters more than the polish of any single sample; if everything is Q&A from one template, the trained model will only be more rigid.

In the alignment stage, the difference between RLHF and DPO is mainly engineering cost. PPO requires maintaining policy, value, reward, and reference models at the same time, is sensitive to hyperparameters, and training easily diverges; DPO optimizes directly on preference pairs, with much lighter memory and implementation. But DPO isn’t free either—it easily overfits on the preference set, and the output distribution can collapse, so you have to hold it down with the beta parameter, mixing in SFT loss, early stopping, and similar measures.

My judgment is that most teams never even reach the alignment stage. Business “hallucinations” are 80% due to poor retrieval or the lack of a refusal mechanism, not a values problem. Treating RLHF as the solution to hallucination is the wrong direction: it optimizes preferences, not facts.

The truly effective order is: first confirm retrieval can recall, then compress the prompt so it answers only from the material, then give it a decent refusal exit, and only then consider using training to change behavior. Each step up in this order costs an order of magnitude more, while the benefit doesn’t necessarily increase.

Fine-tuning has another cost that’s easy to overlook: maintenance. When the data changes, you have to retrain; retraining requires re-evaluation; evaluation requires re-labeling. Updating a document in RAG takes only one write, while updating knowledge in a model touches the entire training chain. I tend to put all fast-changing knowledge on the retrieval side and put only stable format, tone, and output structure into the weights. The criterion is simple: will this knowledge change within six months? If it will, don’t train it in.

There’s another boundary worth clarifying: SFT solves “can it speak in the format,” alignment solves “should it say it, and is it appropriate,” and neither solves “is it correct.” Mixing safety problems with factual problems often means doing both badly. I’ve seen solutions that use preference training to fix factual errors; in the end the model became more prone to refusing, while the error rate didn’t drop.

Hallucination is first an information problem, and only second a model problem.

I use this sentence to judge whether someone has really tuned a system. Pushing all failures onto model capability usually means they haven’t seriously looked at the intermediate results.

Evaluation is the step most easily skipped

General benchmarks test parametric knowledge—physics, history, common-sense reasoning. They have nothing to do with a company’s internal contracts, tickets, or product manuals. Using a C-Eval ranking to prove a selection is correct is a minus in an interview.

What I require is a small-scale golden set: dozens to a hundred real questions, each annotated with a standard answer and the key conditions that must appear. Real questions matter—self-made questions are too tidy and fail to cover users’ phrasings that omit subjects or contain typos.

Metrics should be viewed in layers. The retrieval layer checks whether the chunk containing the correct answer made it into the top-k; the generation layer checks whether the answer relied only on the recalled content. Mixing these two layers together only yields a total score whose source you can’t explain. Adjusting the prompt when retrieval is bad is the most common wasted effort.

When using off-the-shelf frameworks, I usually borrow only three concepts from them: whether the recalled content is relevant, whether the answer is supported by the content, and whether the answer responds to the question. The first belongs to retrieval; the last two belong to generation. Taking any one alone is misleading: high faithfulness but low relevance means the model is earnestly answering a different question; strong relevance but low faithfulness means it’s using the material’s tone to tell its own memory.

Layering also saves time. If the answer isn’t in the recall at all, there’s no need to look at generation; only when the answer is in the recall but the model didn’t use it do you check instructions, context order, temperature, and other parameters. If you troubleshoot in the wrong order, you’ll spin around among a bunch of irrelevant variables.

Using an LLM as a judge is fine, but you have to accept its preferences: it favors long answers, favors neatly structured answers, and is insensitive to numbers. Scoring the same output in a different order can give different results. So I still manually spot-check key conclusions, especially those answers that look especially complete—complete answers most easily mask omissions.

The evaluation set also needs to support regression. Every time you change the prompt, switch models, or adjust top-k, run it once, and only ship if the metrics don’t drop. This is tedious, and maintenance costs are not low: questions expire, answers change, and annotators change. I haven’t yet found a way to update it automatically, so I can only go through it manually on a regular basis.

Before launch, I also look separately at a batch of “most easily wrong” samples. Not randomly sampled—I pick out the ones that have had problems historically, the borderline ones, and the ones involving multiple documents, and read the full answers one by one. Automated metrics tell me whether things got worse; manual reading tells me where they got worse. The two cannot replace each other.

Sampling cost also needs to be controlled. Having humans look at everything is impossible, and having a model look at everything is too expensive. My approach is fixed-ratio sampling plus stratified sampling: randomly take a small portion of normal traffic, then take a few from each business category. The ratio is very low; I mainly look at trends, not single scores.

Technical metrics and business metrics should be recorded separately. Recall, faithfulness, and latency are means; whether users solve their problems is the end. There will be a period of divergence: metrics are all rising, but satisfaction doesn’t move, because the part that’s rising is all in scenarios users don’t care about. In that case, I go back to look at the question distribution first, rather than continuing to tune the model.

What I still don’t have a good way to handle is multi-hop questions. The answer is spread across three documents, requiring association first and then reasoning, which a single retrieval can’t get. Solutions like GraphRAG can solve it, but building the graph, extracting entities, and maintaining updates cost more than the entire retrieval pipeline. In most businesses I’d first talk people out of it, splitting the question into two single-hop queries and asking the user to click one more time.

This trade-off isn’t pretty, but it’s maintainable. And maintainability is the item I weight most heavily when evaluating any solution right now.

Further reading: Before switching embeddings, look at those 70% bad cases, Whether RAG is done well is mostly decided by chunking and context layout

About this Post

This post is written by Lu's Blog, licensed under CC BY-NC 4.0.

#Engineering Practices #Evaluation #RAG #Retrieval

Comments