Skip to content

Fix empty tagger prediction shape - #14060

Open
riddhigupta1110 wants to merge 1 commit into
explosion:masterfrom
riddhigupta1110:fix-tagger-predict-empty-shape
Open

riddhigupta1110 wants to merge 1 commit into
explosion:masterfrom
riddhigupta1110:fix-tagger-predict-empty-shape

Conversation

@riddhigupta1110

Copy link
Copy Markdown

Description

Fixes an inconsistency in Tagger.predict() when all input documents are empty. The method previously returned arrays with shape (0, n_labels), whereas the normal prediction path returns one-dimensional arrays of tag IDs.

This change returns empty arrays with shape (0,) and adds a regression test covering multiple empty documents.

Fixes #14048

Testing:

  • The regression test test_tagger_predict_empty_docs_shape passes on the fix branch.
  • python -m pytest spacy/tests/pipeline/test_tagger.py -q -k "not test_overfitting_IO": 12 passed, 1 deselected.
  • test_overfitting_IO fails with OverflowError: Python int too large to convert to C ssize_t during tokenizer deserialization in spacy/tokenizer.pyx. I reproduced the same failure on the local master branch without the changes from this PR.

Types of change

It is a Bug Fix

Checklist

  • 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shape inconsistency in Tagger.predict

1 participant