spaCy icon indicating copy to clipboard operation
spaCy copied to clipboard

Add Softmax scorer for spancat

Open ljvmiranda921 opened this issue 1 year ago • 1 comments

WIP: This PR adds a Softmax scorer for the spancat component that should be used in cases where classes are exclusive.

Description

Spancat currently has a LinearLogistic layer that creates multilabel annotations on text. However, this is not necessary when classes are exclusive or when spans are non-overlapping. Switching from a LinearLogistic to a Softmax layer is recommended. This issue came up when we're doing the spancat experiments.

Usage

In order for the user to switch to spacy.Softmax.v1, they have to update the config and specify the architecture in the scorer. Alternative usage (not yet implemented): Add a parameter, exclusive_classes:bool (a la textcat), in the SpanCategorizer architecture to use Softmax automatically.

Types of change

New feature

Checklist

  • [x] I confirm that I have the right to submit this contribution under the project's MIT license.
  • [ ] I ran the tests, and all new and existing tests passed.
  • [ ] My changes don't require a change to the documentation, or if they do, I've added all required information.

ljvmiranda921 avatar Jul 05 '22 01:07 ljvmiranda921

In order for the user to switch to spacy.Softmax.v1, they have to update the config and specify the architecture in the scorer. Alternative usage (not yet implemented): Add a parameter, exclusive_classes:bool (a la textcat), in the SpanCategorizer architecture to use Softmax automatically.

It would make sense to make the implementation & usage consistent with how we do it in textcat.

svlandeg avatar Jul 26 '22 09:07 svlandeg

After internal conversations: we'll want to implement this as a new component, somewhat similar to textcat vs textcat_multilabel. I'll close this PR while we work on a more extensive PR to address that.

svlandeg avatar Aug 17 '22 14:08 svlandeg