> For the complete documentation index, see [llms.txt](https://docs.layerlens.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.layerlens.ai/more-in-this-section-6/rag-faithfulness-judge.md).

# Recipe: build a faithfulness judge for RAG

Recipe — RAG faithfulness judge. Pointer to the SDK rag\_assessment sample.

Canonical sample: [`samples/cowork/rag_assessment.py`](https://github.com/layerlens/stratix-python/blob/main/samples/cowork/rag_assessment.py) — RAG Runner-Quality Judge multi-agent pattern. One agent executes retrieval queries; the other evaluates groundedness and retrieval quality.

## Pattern

1. Capture traces with retrieval and generation spans separately.
2. Build a faithfulness judge: `client.judges.create(name=, evaluation_goal=)` whose rubric checks claims against retrieved chunks.
3. GEPA-optimize against ≥50 labeled examples — see [Bootstrap a judge before GEPA](/more-in-this-section-6/bootstrap-judges.md).
4. Apply via `client.trace_evaluations.create(trace_id=, judge_id=)`.

## See also

* [Use case: RAG evaluation](/4.1-general-use-cases/rag-evaluation.md)
* [Concept: Judges](/8.-evaluate-score-the-outputs/judges-1.md)
* [Tutorial 5: GEPA optimize](/9.-improve-tune-the-system/05-gepa-optimize.md)
