Recipe catalog / passage-compare
Compare two passages for a question
passage-compare is a Jev recipe from the jev-recipes TypeScript package. Which of firstPassage and secondPassage better helps answer question? Use it when you need a head-to-head preference between two retrieved passages, for tie-breaking, evaluation data, or reranker calibration.
Last updated .
Explore this recipe interactively · Source and implementation guide · Markdown version
How do I use passage-compare in TypeScript?
Install with npm install jev-recipes. Requires Node.js 22.9 or newer and ES modules. Set TYPESAFE_API_KEY in your server environment for live calls, which send input to TypeSafe and use API quota. See the installation guide.
import { passageCompare } from 'jev-recipes/passage-compare';
const result = await passageCompare({
"question": "How long do refunds take to appear on a card?",
"firstPassage": "Refunds are issued to the original payment method and typically appear within 5 to 10 business days, depending on the card issuer.",
"secondPassage": "You can request a refund from the Orders page by selecting the item and choosing Return.",
"minConfidence": 0.8
});
console.log(result);
What input does passage-compare take?
| Field | Type | Needed |
|---|---|---|
| question | string | Required |
| firstPassage | string | Required |
| secondPassage | string | Required |
| minConfidence | number | Optional |
Full input and result schemas
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"question": {
"type": "string"
},
"firstPassage": {
"type": "string"
},
"secondPassage": {
"type": "string"
},
"minConfidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"question",
"firstPassage",
"secondPassage"
]
},
"result": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"model": {
"type": "string"
},
"usage": {
"type": "object",
"properties": {
"input_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"output_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"input_tokens",
"output_tokens"
],
"additionalProperties": false
},
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"verdict": {
"type": "string",
"enum": [
"first",
"second",
"tie",
"neither",
"unclear"
]
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"probabilities": {
"type": "object",
"propertyNames": {
"type": "string",
"enum": [
"first",
"second",
"tie",
"neither",
"unclear"
]
},
"additionalProperties": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"required": [
"first",
"second",
"tie",
"neither",
"unclear"
]
}
},
"required": [
"model",
"usage",
"status",
"verdict",
"confidence",
"probabilities"
],
"additionalProperties": false
}
}What does a passage-compare result look like?
This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo passage-compare.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "ready",
"verdict": "first",
"confidence": 0.9,
"probabilities": {
"first": 0.9,
"second": 0.03,
"tie": 0.03,
"neither": 0.02,
"unclear": 0.02
}
}
Input
See shared options and behavior for client configuration, validation, and errors. Types are inferred from this folder's Zod 4 schemas.
Result
verdict is first, second, tie, neither, or unclear. first and second name the passage that helps more. tie means both help about equally. neither means no passage contains useful information, which is a confident answer rather than a failure.
A result is ready when confidence meets minConfidence and the verdict is not unclear. probabilities covers all five outcomes.
Reuse and calls
Uses the shared comparison helper, which fixes the five outcomes and tells Jev that presentation order is irrelevant. This folder owns the question wording and the four outcome descriptions. A live invocation makes one logical Jev request.
Limits
The recipe compares exactly two passages. For many candidates, use rerank or run pairwise comparisons in application code. It judges how much each passage helps with the question, not whether the passage is true. When building evaluation data, run each pair in both orders and keep only agreeing results.
Example input
demo.json contains editable input and a hand-authored response. After installing jev-recipes, npx jev-recipes demo passage-compare shows an offline illustration, not an accuracy measurement. Use npx jev-recipes describe passage-compare to inspect the input and result schemas.
How accurate is passage-compare?
No verified live accuracy measurement is available. Evaluate representative cases before using this decision in your workflow.
Use the evaluation guide to measure this decision on your own labeled cases.
What are the limits of passage-compare?
- Compares two passages only. Order is declared irrelevant, but run both orders when calibrating.
- Judges helpfulness for the question, not the factual accuracy of either passage.
Which recipes are related to passage-compare?
- rerank: Use rerank to score many passages independently against one query.
- context-role: Use context-role to label what one passage contributes to a question.