diff --git a/spacy/pipeline/spancat.py b/spacy/pipeline/spancat.py index 1de51bb09..2f10a2ff4 100644 --- a/spacy/pipeline/spancat.py +++ b/spacy/pipeline/spancat.py @@ -712,9 +712,8 @@ class SpanCategorizer(TrainablePipe): ) -> SpanGroup: """Find the argmax label for each span.""" # Handle cases when there are zero suggestions - spans = SpanGroup(doc, name=self.key) if scores.size == 0: - return spans + return SpanGroup(doc, name=self.key) scores = self.model.ops.to_numpy(scores) indices = self.model.ops.to_numpy(indices) predicted = scores.argmax(axis=1)