Skip to content

Retrieval with Decisions: Filter, Rerank, and Verify

Retrieval is a sequence of bounded judgments. How a decision model slots into passage filtering, semantic find, reranking, and citation checks, and what stays in deterministic code.

Published
Category
Jev Cookbooks
Resources cited
6
Reading time
3 min
Tags#retrieval#reranking#rag#search

Retrieval is a sequence of small decisions: is this passage relevant, which of these candidates is best, does this citation support the claim. Every one of them is a bounded judgment, which is exactly the shape Jev answers. The result is that a decision model slots into a retrieval pipeline at three points, and the three cookbooks that show it are worth reading together.

Passage filtering, before the model sees context

The first decision is whether a retrieved passage belongs in the context at all. The RAG passage classification cookbook asks a Noul per passage — is this relevant to the query — and drops the ones that are not before an expensive reader ever runs. Because output is free, the relevance check is cheap next to the tokens it saves downstream.

The design point: one Noul per passage, batched in a single request. Not one question that asks the model to rank the list.

Finding the passage, not the document

When answers live inside long documents, the useful decision is "which part." The semantic find cookbook treats the document as a set of candidate passages and asks Jev to choose among them, which is the Choice primitive doing the retrieval itself rather than an embedding lookup. It is the pattern for when a keyword or vector search returns the right document but the wrong span.

Reranking a candidate list

Once you have candidates, ordering them is a Score job. The rerank cookbook scores each candidate independently and sorts in code, which beats asking one question to output an ordered list: scoring is a judgment the model does well, and ordering is arithmetic it does not do.

questions = {
    f"relevance_{i}": Score(
        instructions=f"Rate how well this passage answers `query`.",
        criteria=["off-topic", "related", "directly answers"],
    )
    for i, _ in enumerate(candidates)
}

The scores come back flat and you sort them yourself — the same divide-and-conquer that the composite scoring pattern applies to multi-dimension decisions.

Checking whether a citation supports the claim

The last decision is the one retrieval systems most often skip: does the cited source actually support the sentence? The citation-check cookbook asks Jev to compare the claim against the passage and returns a Noul, which a confidence gate turns into accept, revise, or reject. It is a verification use case, and it is the cheapest guard against a fluent answer built on a passage that does not say what it claims.

Do the three in one pass where you can

Each of these is a separate judgment, but they do not have to be separate requests. The fan-out pattern puts the relevance Nouls, the rerank Scores, and the support check behind one state and one call when the branching allows it. The one-request-many-questions article works through the batching arithmetic.

What stays deterministic

Retrieval itself — the index, the vector search, the keyword pass, the filters — is code. Jev decides about the results, it does not fetch them. The semantic find cookbook keeps the candidate generation in code and only the selection in the model, which is the boundary worth preserving: a retrieval bug should never be something you ask a model to fix at query time.

Filter, choose, rerank, verify, and keep the fetching in code. Four small decisions, each one a primitive Jev already has.

From the Jev directory

The resources behind this article.

Score retrieved passages with four Noul questions each, then route in code: prompt injections dropped, false premises kept as conflicts, and evidence assembled separately for the generator.
Jev CookbooksDocs#official#cookbook#search
Official
Semantic search over GitHub's Terms of Service: one request ranks all 218 lines with a Choice while a Noul checks whether the document contains an answer at all, including when it should say no.
Jev CookbooksDocs#official#cookbook#search
Official
One question per query-candidate pair raises top-1 accuracy from 5% to 18% and top-10 accuracy from 38% to 62% on 40 CLERC legal queries.
Jev CookbooksDocs#official#cookbook#reranking
Official
Catch wrong and hallucinated citations against RFC 7519 with a string match plus one Choice question: four accurate citations verified at 0.93 or more and all four planted failures caught.
Jev CookbooksDocs#official#cookbook#citations
Official
Ask everything the system might need in one request, then let code throw away what it does not use. The ticket-triage example sends a category plus four speculative questions in parallel.
Jev Practices & PatternsDocs#official#patterns#batching
Official
Explore TypeSafe use cases by industry and turn promising ideas into concrete software workflows.
Jev Practices & PatternsDocs#official#use-cases
Official
Back to all articles

More Jev articles

Most Jev accuracy problems are state problems. What belongs in a state, what is a pre-made judgment to leave out, and why naming the slice you ask about matters more than the wording.
Jev Practices & Patterns#state#design#primitives
Read article
A Noul returns one number and no separate confidence. How to read the value, pin its boundary with criteria, split compound questions, and set a per-action threshold that matches the cost of being wrong.
Jev Practices & Patterns#noul#primitives#confidence
Read article

From the Jev community

Posts from builders shipping with Jev right now.

Follow @typesafeai