Metrics & Judges
Synthesis judge
DspyGeneralSynthesisJudge(lm, enable_reasoning_traces=False, confidence_threshold=0.7, signature=None, retry_temperatures=None)
Bases: SynthesisJudgeInterface
Enhanced DSPy module for evaluating GeneralSynthesisOntology extraction quality against source synthesis text.
Implements a two-level fallback chain for robust structured output
- Strict json_schema(native for Claude/Gemini; extra_body for OpenRouter)
- json_object mode (valid JSON, prompt-guided schema compliance)
Within each strategy, temperature is escalated on validation failures. API-level format errors (400/unsupported) skip immediately to the next strategy without wasting temperature retries.
Initialize the unified synthesis judge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signature
|
type[Signature] | None
|
DSPy signature for evaluation |
None
|
lm
|
LM
|
Language model for evaluation |
required |
enable_reasoning_traces
|
bool
|
Whether to include detailed reasoning |
False
|
confidence_threshold
|
float
|
Minimum confidence threshold for reliable |
0.7
|
retry_temperatures
|
list[float] | None
|
Temperatures to try per strategy on content |
None
|
Source code in src/llm_synthesis/metrics/judge/general_synthesis_judge.py
Methods:
forward(input)
Evaluate extracted GeneralSynthesisOntology against source text.
Tries each format strategy in order. Within a strategy, retries at escalating temperatures on content-validation failures. API-level format errors skip immediately to the next strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
tuple[str, str] | tuple[str, str, str]
|
Tuple of (source_text, extracted_ontology_json) or (source_text, extracted_ontology_json, target_material) |
required |
Returns:
| Type | Description |
|---|---|
GeneralSynthesisEvaluation
|
Comprehensive evaluation of the ontology extraction |
Source code in src/llm_synthesis/metrics/judge/general_synthesis_judge.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
GeneralSynthesisEvaluation
Bases: BaseModel
Complete evaluation of GeneralSynthesisOntology extraction quality.
GeneralSynthesisEvaluationScore
Bases: BaseModel
Evaluation scores for GeneralSynthesisOntology extraction quality. Scores are on a scale of 1.0 (poor) to 5.0 (excellent) with 0.5 increments.
make_general_synthesis_judge_signature(signature_name='GeneralSynthesisJudgeSignature', instructions=None, source_text_description='Original synthesis text for ontology extraction evaluation.', extracted_ontology_description='JSON representation of extracted GeneralSynthesisOntology.', target_material_description='Target material for synthesis context.', evaluation_description='Comprehensive evaluation of ontology extraction quality. CRITICAL: populate ALL fields — reasoning, confidence_level, all seven *_score and *_reasoning pairs inside scores, and scores.overall_reasoning. Omitting any field is invalid.')
Create a DSPy signature for GeneralSynthesisOntology evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signature_name
|
str
|
Name of the signature class |
'GeneralSynthesisJudgeSignature'
|
instructions
|
str | None
|
Custom instructions for the evaluation |
None
|
source_text_description
|
str
|
Description for source text input |
'Original synthesis text for ontology extraction evaluation.'
|
extracted_ontology_description
|
str
|
Description for ontology JSON input |
'JSON representation of extracted GeneralSynthesisOntology.'
|
target_material_description
|
str
|
Description for target material input |
'Target material for synthesis context.'
|
evaluation_description
|
str
|
Description for evaluation output |
'Comprehensive evaluation of ontology extraction quality. CRITICAL: populate ALL fields — reasoning, confidence_level, all seven *_score and *_reasoning pairs inside scores, and scores.overall_reasoning. Omitting any field is invalid.'
|
Returns:
| Type | Description |
|---|---|
type[Signature]
|
DSPy signature class for ontology evaluation |
Source code in src/llm_synthesis/metrics/judge/general_synthesis_judge.py
Linking judge
DspyLinkingJudge(lm, enable_reasoning_traces=False, confidence_threshold=0.7, signature=None)
Bases: LinkingJudgeInterface
DSPy module for evaluating synthesis-to-performance linking quality.
The judge receives
- The full paper text (source of truth).
- The extracted synthesis ontologies (JSON list).
- The extracted plot data (JSON list).
- The linking output mapping syntheses to plot series (JSON).
It produces a LinkingEvaluation with four criterion scores
(1-5 in 0.5 increments), nine failure-mode flags, and supporting
reasoning.
Source code in src/llm_synthesis/metrics/judge/linking_judge.py
Methods:
forward(input)
Evaluate linking output against the paper and extracted data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
tuple[str, str, str, str]
|
Tuple of (source_text, synthesis_json, plot_data_json, linking_output_json) |
required |
Returns:
| Type | Description |
|---|---|
LinkingEvaluation
|
A |
Source code in src/llm_synthesis/metrics/judge/linking_judge.py
LinkingEvaluation
Bases: BaseModel
Complete evaluation of synthesis-to-performance linking quality.
make_linking_judge_signature(signature_name='LinkingJudgeSignature', instructions=None, source_text_description='Full paper text for linking evaluation.', synthesis_json_description='JSON list of extracted synthesis ontologies.', plot_data_json_description='JSON list of extracted plot data with series and coordinates.', linking_output_json_description='JSON linking output mapping syntheses to plot series.', evaluation_description='Comprehensive evaluation of linking quality.')
Factory for creating a customised LinkingJudge DSPy signature.
Follows the same pattern as
make_general_synthesis_judge_signature.
Source code in src/llm_synthesis/metrics/judge/linking_judge.py
Figure extraction metric
FigureExtractionMetric
Bases: LinePlotExtractionMetric
Methods:
__call__(preds, refs, error_metric='rmse')
Compute average RMSE or MAE across all matching series. For each series, it uses normalized-to-axis-sclae nearest-neighbor matching to find the closest points in the ground truth data to the extracted points from the LLM output. And then computes the error metric (RMSE or MAE) based on these matches.
Source code in src/llm_synthesis/metrics/figure_extraction/figure_extraction_metric.py
compute_scale(ground_truth)
staticmethod
Compute normalization scales for x and y.
Source code in src/llm_synthesis/metrics/figure_extraction/figure_extraction_metric.py
pointwise_rmse(extracted_coords, gt_coords, x_scale, y_scale)
staticmethod
Compute RMSE using nearest-neighbor matching for one series.
Source code in src/llm_synthesis/metrics/figure_extraction/figure_extraction_metric.py
pointwise_mae(extracted_coords, gt_coords, x_scale, y_scale)
staticmethod
Compute MAE using nearest-neighbor matching for one series.