fix: Unigram prune_sentence_pieces uses alternatives[id].len() not alternatives.len() - #2394
Open
VirajMishra1 wants to merge 1 commit into
Open
Conversation
…ternatives.len() The loss computation for piece removal used alternatives.len() (the total number of pieces) instead of alternatives[id].len() (the number of re-segmentation alternatives for the specific piece being scored). This made the logsum_alt term wrong: the probability mass was redistributed over all pieces rather than just the alternatives for piece uid=501(viraj) gid=20(staff) groups=20(staff),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),33(_appstore),100(_lpoperator),204(_developer),250(_analyticsusers),395(com.apple.access_ftp),398(com.apple.access_screensharing),399(com.apple.access_ssh),400(com.apple.access_remote_ae), producing an incorrect loss and therefore incorrect pruning decisions. Fixes huggingface#2069
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.
Problem
prune_sentence_piecescomputes the log-normaliser after hypothetically removing pieceidusing:alternatives.len()is the total number of pieces in the vocabulary. The comment immediately above says:but
alternatives.size()here meansalternatives[id].size()— the number of re-segmentation pieces for pieceidspecifically — not the wholealternativesvector length (which ispieces.len()).Using the wrong length makes the probability mass appear to be redistributed over all
pieces.len() - 1alternatives instead of just thealternatives[id].len() - 1that actually replace pieceid, producing an incorrectlogsum_altand therefore incorrect pruning loss for every piece.This was first reported in #1536.
Fix
One character change. The comment is updated to match.
Fixes #2069