Fix scoring of explicit whitespace tokens - #14018
Open
tandede wants to merge 1 commit into
Open
Conversation
tandede
marked this pull request as ready for review
August 19, 2026 11:38
tandede
force-pushed
the
agent/fix-whitespace-scoring
branch
from
August 20, 2026 03:20
110f745 to
6773115
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Explicit whitespace tokens were skipped while collecting predicted token attributes and dependencies, but the corresponding reference loops still included them. As a result, even otherwise identical predicted and reference documents containing a whitespace token could receive
0.8instead of1.0for token attributes and dependency scores.This change applies the existing whitespace-token policy symmetrically to the reference side of:
score_token_attrscore_token_attr_per_featscore_depsAlignment indices remain unchanged because both sides continue to use the original token positions. The regression deliberately assigns different tag, POS, morphology, and dependency values to the predicted whitespace token and verifies that all affected scores remain
1.0, while the non-whitespace annotations still match.Closes #13739.
Types of change
Bug fix.
Validation
0.8fortag_acc,pos_acc,morph_acc,morph_micro_f,dep_uas, anddep_las; after the fix all six are1.0.python -m pytest -q spacy/tests/test_scorer.py— 11 passedpython -m pytest -q spacy— 3,615 passed, 1,229 skipped, 24 xfailed, 7 xpassed, 5 subtests passedpython -m ruff format spacy --check— 886 files already formattedpython -m ruff check spacy --select I— passedgit diff --check— passedThe repository-wide all-rule Ruff hook reports pre-existing complexity and legacy-style findings in
spacy/scorer.py; the official CI format and import-order checks pass.Checklist