Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge remote-tracking branch 'origin/dev' into pr421-merge
# Conflicts:
#	CHANGELOG.md
#	src/stickler/auto/facade.py
#	src/stickler/structured_object_evaluator/models/structured_model.py
  • Loading branch information
sromoam committed Oct 28, 2026
commit f3acaa7067d074c0c9ddda63567edda4376f8e08
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ Each release links to full notes on the
([#417](https://github.com/awslabs/stickler/issues/417)). See
[Meeting a Threshold](https://awslabs.github.io/stickler/Getting-Started/thresholds-and-metrics/#meeting-a-threshold)

- **Breaking:** `evaluator_format=True` output carries `non_matches` only
with `document_non_matches=True`, as the default `compare_with()` dict does,
so `result["non_matches"]` without it now raises `KeyError`. It always wrote
`"non_matches": []`, so `print_non_matches` and the HTML report both said
`No non-matches found.` over a document with a wrong field, despite the #298
and #411 fixes. Both now say the records are missing. To read records, pass
`document_non_matches=True`; to tell "not collected" from "none found", test
`"non_matches" in result`. Scores and counts are unchanged
([#413](https://github.com/awslabs/stickler/issues/413))

- The Strands Evals golden snapshot now covers three `NaN` shapes
(`lead/nan_for_value`, `lead/nan_both`, `lead/nan_vs_none`), so the `NaN`
change ([#367](https://github.com/awslabs/stickler/issues/367)) is recorded
Expand Down
6 changes: 5 additions & 1 deletion src/stickler/auto/facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@

from pydantic import BaseModel

from ..structured_object_evaluator.models.structured_model import StructuredModel
from ..structured_object_evaluator.models.structured_model import (
StructuredModel,
_annotation_is_list,
)
from ..structured_object_evaluator.models.threshold_helper import ThresholdHelper
from .builder import specs_for, structured_model_for

Expand Down Expand Up @@ -142,6 +145,7 @@ def explain(self) -> Dict[str, Dict[str, Any]]:
and raw_sim
and threshold is not None
and ThresholdHelper.is_below_threshold(raw_sim, threshold)
and not self._is_list_of_models(name)
):
if self._is_list_field(name):
entry["verdict"] = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from .null_helper import NullHelper
from .optional_annotation import union_args, unwrap_annotated, unwrap_optional
from .rich_value_helper import RichValueHelper
from .threshold_helper import THRESHOLD_DOCS_URL, ThresholdHelper
from .threshold_helper import THRESHOLD_DOCS_URL
from .threshold_helper import model_identity as _model_identity
from .threshold_helper import warn_if_threshold_is_zero as _warn_if_threshold_is_zero

Expand Down Expand Up @@ -1281,61 +1281,6 @@ def _handle_list_field_dispatch(
dispatcher = ComparisonDispatcher(self)
return dispatcher.handle_list_field_dispatch(gt_val, pred_val, weight)

def _calculate_object_level_metrics(
self,
gt_list: List["StructuredModel"],
pred_list: List["StructuredModel"],
match_threshold: float,
) -> tuple:
"""Calculate object-level metrics using Hungarian matching.

Args:
gt_list: Ground truth list
pred_list: Predicted list
match_threshold: Threshold for considering objects as matches

Returns:
Tuple of (object_metrics_dict, matched_pairs, matched_gt_indices, matched_pred_indices)
"""
# Use Hungarian matching for OBJECT-LEVEL counts - OPTIMIZED: Single call gets all info
hungarian_helper = HungarianHelper()
hungarian_info = hungarian_helper.get_complete_matching_info(gt_list, pred_list)
matched_pairs = hungarian_info["matched_pairs"]

# Count OBJECTS, not individual fields
tp_objects = 0 # Objects with similarity >= match_threshold
fd_objects = 0 # Objects with similarity < match_threshold
for gt_idx, pred_idx, similarity in matched_pairs:
if ThresholdHelper.is_above_threshold(similarity, match_threshold):
tp_objects += 1
else:
fd_objects += 1

# Count unmatched objects
matched_gt_indices = {idx for idx, _, _ in matched_pairs}
matched_pred_indices = {idx for _, idx, _ in matched_pairs}
fn_objects = len(gt_list) - len(matched_gt_indices) # Unmatched GT objects
fa_objects = len(pred_list) - len(
matched_pred_indices
) # Unmatched pred objects

# Build list-level metrics counting OBJECTS (not fields)
object_level_metrics = {
"tp": tp_objects,
"fa": fa_objects,
"fd": fd_objects,
"fp": fa_objects + fd_objects, # Total false positives
"tn": 0, # No true negatives at object level for non-empty lists
"fn": fn_objects,
}

return (
object_level_metrics,
matched_pairs,
matched_gt_indices,
matched_pred_indices,
)

def _compare_unordered_lists(
self,
gt_list: List[Any],
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.