Grade each retrieved chunk's relevance to a question (high/medium/low/none + a filter boolean) for reranking and filtering before answer synthesis.
Grade each retrieved chunk for relevance to the question — high / medium / low / none, plus a boolean filter decision and a one-line reason — so you can filter and rerank before answer synthesis. Cleaner context in means a more grounded answer out. This is the LLM-reranker / retrieval-grader step (think the grading node in a corrective-RAG / self-RAG graph).
| Entrypoint | Renders | Inputs |
|---|---|---|
system | The grading rubric + embedded output schema | — |
user | The delimited chunks + question | chunks, question |
Render system as the system message and user as the user message.
question (string, required) — the question each chunk is graded against.chunks (array of { id, text }, required) — the retrieved chunks. Each grading echoes the chunk's id back.parseOutput() returns:
{
"reasoning": "Chunk 1 directly answers the pricing question; chunk 2 is about a different product.",
"gradings": [
{ "chunk_id": "1", "relevance": "high", "is_relevant": true, "reason": "States the Pro plan monthly price." },
{ "chunk_id": "2", "relevance": "none", "is_relevant": false, "reason": "About shipping, unrelated to pricing." }
]
}
reasoning is a one-sentence overall note, emitted before the per-chunk grades.gradings has exactly one entry per input chunk, in input order, each echoing chunk_id. Nothing is added, dropped, merged, or reordered — so you can zip it straight back onto your chunk list.relevance is the four-level grade; is_relevant is the derived filter boolean (true for high/medium, false for low/none) kept consistent with it. Filter on whichever you prefer — the boolean for a hard cut, the level for ranking.additionalProperties: false, closed enum, one entry per chunk.maxTokens is sized up (1536) for grading many chunks. Verified against the live API on a mixed relevant/irrelevant set (one entry per chunk, graded correctly). Suggested default claude-sonnet-4-6 at temperature: 0. The grading stage of the RAG Essentials pipeline: rewrite → decompose → grade → guardrail → synthesize. Pair it with answer-synthesis: grade and filter, then synthesize over what's left.