latent.flows.judge_flow¶
judge_flow — Score a dataset with one or more Judges, analyze, and gate.
Each Judge supplies a Pydantic output_type; rows are scored concurrently
via asyncio.gather (bounded by an asyncio.Semaphore) and the judge's
output fields are appended to a copy of the input DataFrame. Multiple judges
run sequentially across judges but concurrent across rows. Eligibility and
row-mapping per judge let one Judge be applied to a subset of rows (e.g.
FaithfulnessJudge skips rows without context).
run_judge is the library entry point and never imports Prefect.
judge_flow is the same run, with gates=None read from the active
@latent.flow's thresholds.yaml section.
Functions¶
judge_flow¶
judge_flow(eval_data: pd.DataFrame, judges: Any, concurrency: int = 10, per_task_timeout_s: float | None = None, gates: dict[str, float | GateSpec] | None = None, score_types: dict[str, str] | None = None, rubrics: dict | None = None, n_resamples: int = 10000, confidence_level: float = 0.95, seed: int | None = None, summary_model: str | None = None, summary_label: str | None = None) -> dict[str, Any]
run_judge, with gates=None read from thresholds.yaml.
Inside a @latent.flow, gates=None resolves to that flow's
thresholds.yaml section (None when there is none); an explicit
gates wins verbatim. Resolving the active flow imports Prefect, which
is why the lookup lives here and not in run_judge. Arguments and return
value are run_judge's.
run_judge¶
run_judge(eval_data: pd.DataFrame, judges: Any, concurrency: int = 10, per_task_timeout_s: float | None = None, gates: dict[str, float | GateSpec] | None = None, score_types: dict[str, str] | None = None, rubrics: dict | None = None, n_resamples: int = 10000, confidence_level: float = 0.95, seed: int | None = None, summary_model: str | None = None, summary_label: str | None = None) -> dict[str, Any]
Score a dataset with one or more Judges, run statistical analysis, check gates.
Args:
eval_data: DataFrame with columns matching each judge's prompt_template
(or with the columns each judge's row_mapper translates from).
judges: A Judge[T] instance OR a list of Judge instances. When a list,
each judge scores rows in parallel (per-judge) and their output
columns are concatenated onto a single scored_df. Judges with
an is_eligible(row) -> bool method are only applied to rows
where that returns True.
concurrency: Number of rows scored concurrently per judge (bound of
an asyncio.Semaphore).
per_task_timeout_s: Deadline for one judge call after it acquires a
concurrency slot. A timed-out row is left unscored while remaining
rows continue. None disables the deadline.
gates: Optional dict mapping metric name to threshold (float or
GateSpec), used as given. judge_flow is the variant that reads
thresholds.yaml.
score_types: Optional override for score type detection.
rubrics: Optional override for rubric detection.
n_resamples: Bootstrap resamples for analysis.
confidence_level: CI confidence level.
seed: Random seed for reproducibility.
Returns: Dict with keys: scored_data, report, markdown, all_passed, score_types (column -> score type, prefixes applied).