Add add_bos=False, add_eos=False
to SentencePieceTokenizer.__init__()
#1811
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.
Minor change that exposes the
add_bos
&add_eos
parameters fromtf_text.SentencepieceTokenizer.__init__()
tokeras_nlp.tokenizers.SentencePieceTokenizer.__init__()
. from #1710Also adds tests for bos/eos token emission.
There is a potential issue about truncating long sequences when emitting the EOS token (
'</s>'
).The current behavior does not give the EOS token special treatment when truncating sequences based on
sequence_length
, meaning a truncated sequence will not have the EOS token at its end.While this is necessary in some tasks (e.g. sequence generation) for the model to not learn wrong sequence terminators, always having the EOS token as the last token of a sequence may be potentially beneficial in others.
I did not believe this warrants an additional implementation of
tokenize()
however; I assume that users would not specifysequence_length
inSentencePieceTokenizer.__init__()
and add their own pad/truncator afterwards.