This repository was archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Implementing abstraction to score final sequences in BeamSearch
#5208
Merged
Conversation
This file contains 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
epwalsh
reviewed
May 17, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also looks great! I appreciate the thorough documentation 🙂 Just a few minor comments
Co-authored-by: Pete <[email protected]>
auto-merge was automatically disabled
May 18, 2021 01:21
Head branch was pushed to by a user without write access
epwalsh
approved these changes
May 18, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thank you @danieldeutsch!
10 tasks
Abhishek-P
pushed a commit
to Abhishek-P/allennlp
that referenced
this pull request
Aug 11, 2021
…lenai#5208) * Implementing FinalSequenceScorer in BeamSearch * Including the end token in the normalization * Reformating * Apply suggestions from code review Co-authored-by: Pete <[email protected]> * Sorting the sequences by the final scores Co-authored-by: Pete <[email protected]> Co-authored-by: Pete <[email protected]>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Implements feature requests 2 and 3 from #5205 and closes #5113.
Changes proposed in this pull request:
transformers
orfairseq
pick the top outputs from beam search by taking the sequence with the highest average log probability per token. See here for thetransformers
implementation. The AllenNLP implementation takes the sequence with the best total log probability of the sequence. This change adds an abstraction calledFinalSequenceScorer
to decide how the final sequences will be scored. The default isSequenceLogProbabilityScorer
, which assigns a score equal to sum of the log probabilities per token (i.e., the current implementation). This PR also includesLengthNormalizedSequenceLogProbabilityScorer
which assigns a score equal to the average log probability per token.LengthNormalizedSequenceLogProbabilityScorer
also has alength_penalty
parameter, which will increase or decrease sequence scores based on their length. This is also included in thetransformers
beam search.Notes
search
method inBeamSearch
. Previously it was the log probabilities of the sequences, but now it is the score that is returned by theFinalSequenceScorer
class. The new default is to return what is currently returned, so this should not break any models.Before submitting
section of the
CONTRIBUTING
docs.Writing docstrings section of the
CONTRIBUTING
docs.After submitting
codecov/patch
reports high test coverage (at least 90%).You can find this under the "Actions" tab of the pull request once the other checks have finished.