Skip to content

latent.scores.ner

NER span-level evaluation scoring.

Classes

Span

Span(start: int, end: int, label: str)

A named entity span.

Functions

ner_span_metrics

ner_span_metrics(predicted: list[list[Span]], gold: list[list[Span]], match_mode: MatchMode = 'exact', iou_threshold: float = 0.5, labels: list[str] | None = None, n_resamples: int = 10000, confidence_level: float = 0.95, seed: int | None = None) -> dict[str, MetricResult]

Compute entity-level precision, recall, F1 with bootstrap CIs.

Args: predicted: Per-document list of predicted spans. gold: Per-document list of gold spans (same length). match_mode: "exact", "overlap", or "iou". iou_threshold: IoU threshold for match_mode="iou". labels: Entity types to report on. If None, uses all observed. n_resamples: Bootstrap resamples. confidence_level: CI confidence level. seed: Random seed.

Returns: Dict with overall + per-entity-type precision, recall, F1 MetricResults.

Attributes

MatchMode