Pattern: AI research citation verification
Legal — AI research citation verification pattern. Citation-existence scorer, holding-accuracy judge, per-session block on unverified output.
Last updated
Was this helpful?
Was this helpful?
# Python (SDK)
from layerlens import Stratix
client = Stratix()
citation_scorer = client.scorers.create_code(
name="citation-existence",
code="""
unresolved = [c for c in extract_citations(output) if not legal_db.lookup(c)]
result = {'passed': len(unresolved) == 0, 'fabricated': unresolved}
""",
)
holding_judge = client.judges.create(
name="holding-accuracy",
evaluation_goal="For each cited case, does the case actually stand for the proposition the OUTPUT claims? Quoted passages must match the source verbatim.",
)
trace_eval = client.trace_evaluations.create(
trace_set={"tags": {"feature": "legal-research"}},
scorers=[citation_scorer.id],
judges=[holding_judge.id],
schedule="per-session",
)// TypeScript (REST) — same trace eval from a Node service
const r = await fetch("https://stratix.layerlens.ai/api/v1/trace-evaluations", {
method: "POST",
headers: {
"X-API-Key": process.env.LAYERLENS_STRATIX_API_KEY!,
"Content-Type": "application/json",
},
body: JSON.stringify({
trace_set: { tags: { feature: "legal-research" } },
scorers: [citationScorerId],
judges: [holdingJudgeId],
schedule: "per-session",
}),
});