Fix bug in strip incomplete words of StreamAtt policy#33
Open
Fix bug in strip incomplete words of StreamAtt policy#33
Conversation
mgaido91
reviewed
Mar 27, 2026
|
|
||
| @staticmethod | ||
| def _strip_incomplete_words(tokens: List[str]) -> List[str]: | ||
| def _strip_incomplete_words(self, tokens: List[str]) -> List[str]: |
Contributor
There was a problem hiding this comment.
Suggested change
| def _strip_incomplete_words(self, tokens: List[str]) -> List[str]: | |
| @staticmethod | |
| def _strip_incomplete_words(tokens: List[str]) -> List[str]: |
Comment on lines
+196
to
+208
| # Some tokenizers emit a trailing empty token after punctuation/EOS; drop it first so | ||
| # complete outputs like [" output", ".", ""] are not mistaken for incomplete words | ||
| while tokens and tokens[-1] == "": | ||
| tokens = tokens[:-1] | ||
|
|
||
| if not tokens: | ||
| return [] | ||
|
|
||
| last_token = tokens[-1].strip() | ||
| # If the hypothesis already ends with punctuation, keep it as a complete segment | ||
| if last_token and last_token[-1] in STRONG_PUNCTUATION: | ||
| return tokens | ||
|
|
Contributor
There was a problem hiding this comment.
I think we should not assume this is the right thing to do. We can try and add this variant but at the very minimum I'd add a flag in the configuration to control this.
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.
Closes #32