DEV Community

Cover image for Why RAG without context judgment is just a fancier grep
tony tong
tony tong

Posted on

Why RAG without context judgment is just a fancier grep

I keep seeing teams ship a "RAG system" that's really a vector database with a thin wrapper. They measure recall@10, ship to production, and then wonder why the model hallucinates on documents the retriever clearly found.

The retriever is doing its job. The model is doing its job. What's missing is the context judgment layer in between.

Retrieval ≠ selection

Most RAG tutorials stop at "embed the docs, embed the query, cosine, top-k". But cosine is a relevance proxy, not a usefulness proxy. A chunk can be semantically similar to the query and still actively mislead the model:

  • A pricing table from 2019 that contradicts the 2024 version
  • A code snippet that solves a similar problem in a different language
  • A legal disclaimer that looks like a substantive answer

A naive top-k return will mix these in. The model, trained to be helpful, will dutifully stitch them together.

What "context judgment" looks like

The simplest version is a re-ranker: take top-50 from the retriever, score each chunk for answerability (does this chunk actually contain the answer, or just the topic?), keep top-5. A cross-encoder does this well, costs ~50ms per chunk on a small model, and usually lifts answer quality 10-20% on my evals.

The harder version is a judge that filters out chunks the model is likely to misuse. Things like:

  • Recency checks: drop chunks that pre-date the user's "current" frame
  • Source authority: prefer internal docs over scraped blog posts
  • Conflict detection: if two chunks disagree, surface the conflict instead of averaging it

Where it falls apart

The trap is doing this in isolation. If the judge is just another LLM, you've moved the problem one step back. The judge also hallucinates, also misreads, also has its own blind spots. The honest framing is: the judgment layer is where the product lives. A vector DB is a 5-line integration. A trustworthy RAG system is months of work on the judgment layer.

That's the part most RAG marketing glosses over.

A small checklist

When I'm reviewing a team's RAG pipeline, these are the questions that catch the most issues:

  1. What does your retriever's top-k look like, not just its top-1 score? Manually skim 20.
  2. Is the model told which chunks it should prefer to use, and which it should ignore?
  3. Do you have an eval set that includes conflicting sources?
  4. When two chunks disagree, does the system surface the conflict or pick one silently?

If you can't answer these, your RAG system is a demo, not a product.

Top comments (0)