From d6e56b62b964bdb94acfc76217bf1284c0c3f0ba Mon Sep 17 00:00:00 2001 From: Lj Miranda Date: Thu, 25 Aug 2022 13:23:15 +0800 Subject: [PATCH] [ci skip] Add breakpoint for debugging --- spacy/pipeline/spancat_exclusive.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/spacy/pipeline/spancat_exclusive.py b/spacy/pipeline/spancat_exclusive.py index 03bcc7b83..d2a4e5dc4 100644 --- a/spacy/pipeline/spancat_exclusive.py +++ b/spacy/pipeline/spancat_exclusive.py @@ -79,9 +79,9 @@ def make_spancat( spans_key: str, scorer: Optional[Callable], negative_weight: float = 1.0, - allow_overlap: Optional[bool] = True, + allow_overlap: bool = True, ) -> "SpanCategorizerExclusive": - """Create a SpanCategorizer component. The span categorizer consists of two + """Create a SpanCategorizerExclusive component. The span categorizer consists of two parts: a suggester function that proposes candidate spans, and a labeller model that predicts one or more labels for each span. @@ -97,7 +97,7 @@ def make_spancat( reference document under the same key. negative_weight (float): Multiplier for the loss terms. Can be used to down weigh the negative samples if there are too many. - allow_overlap (Optional[bool]): If True the data is assumed to + allow_overlap (bool): If True the data is assumed to contain overlapping spans. """ return SpanCategorizerExclusive( @@ -148,8 +148,8 @@ class SpanCategorizerExclusive(TrainablePipe): *, spans_key: str = "spans", negative_weight: float = 1.0, + allow_overlap: bool = True, scorer: Optional[Callable] = spancat_score, - allow_overlap: Optional[bool] = True, ) -> None: """Initialize the span categorizer. vocab (Vocab): The shared vocabulary. @@ -162,11 +162,11 @@ class SpanCategorizerExclusive(TrainablePipe): `"spans"`. negative_weight (float): Multiplier for the loss terms. Can be used to down weigh the negative samples if there are too many. + allow_overlap (bool): If True the data is assumed to + contain overlapping spans. scorer (Optional[Callable]): The scoring method. Defaults to Scorer.score_spans for the Doc.spans[spans_key] with overlapping spans allowed. - allow_overlap (Optional[bool]): If True the data is assumed to - contain overlapping spans. DOCS: https://spacy.io/api/spancategorizerexclusive#init """ @@ -376,6 +376,7 @@ class SpanCategorizerExclusive(TrainablePipe): offset += spans.lengths[i] target = self.model.ops.asarray(target, dtype="f") # type: ignore negative_samples = numpy.nonzero(negative_spans)[0] + breakpoint() target[negative_samples, self._negative_label] = 1.0 d_scores = scores - target neg_weight = self.cfg["negative_weight"]