Use case · Score
RAG passage classification and reranking with Jev
Score each retrieved passage for actual relevance to the question and drop the ones that only matched on embedding similarity.
The problem
Vector search returns things that are semantically near but not useful. Stuffing all of them into context costs tokens and dilutes the answer, while a cross-encoder reranker is another model to host and tune.
How Jev handles it
Score each candidate passage against a relevance rubric. The calls are cheap and fast enough to run across your whole candidate set, and you get a distribution to threshold rather than an opaque similarity number.
RELEVANCE = Score(
instructions="How useful is this passage for answering the question?",
criteria=["Irrelevant", "Tangential", "Useful", "Directly answers"],
)
def rank(passage):
response = client.system_one(
model="jev-latest",
state=f"QUESTION: {question}\n\nPASSAGE: {passage.text}",
questions={"relevance": RELEVANCE},
)
return response.answers["relevance"]
scored = [(p, rank(p)) for p in candidates]
keep = [p for p, s in scored if s.score in ("Useful", "Directly answers")]Notes from the field
- Passage classification appears among TypeSafe's published cookbook examples.
- Add a Noul for "this passage contradicts the question's premise" to catch a failure mode similarity scoring is blind to.
- Batch and cache — the same passage scored against the same question does not change.