-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for special tokens in nvtext::subword_tokenizer (#7254)
Closes #6937 This PR adds support for the following 7 special tokens in the `subword_tokenize` [BOS], [EOS], [UNK], [SEP], [PAD], [CLS], and [MASK] Descriptions for these can be found in links/text found in #6937 These can be placed anywhere in the text and may be upper or lower-case. They will be recognized regardless if they exist in the given vocabulary hash table. Example using vocab-hash.txt and code snippet from #6937 ``` >>> text = '[CLS]I ate dinner.[SEP][BOS]It was yummy.[EOS]' >>> cudf_ser = cudf.Series([text]) >>> tokens, attention_masks, metadata = cudf_ser.str.subword_tokenize('vocab-hash.txt', do_lower=True, do_truncate=False) >>> print(id2vocab[tokens[0:17].get()]) ['[CLS]' 'i' 'ate' 'dinner' '.' '[SEP]' '[BOS]' 'it' 'was' 'yummy' '.' '[EOS]' '[PAD]' '[PAD]' '[PAD]' '[PAD]' '[PAD]'] ``` A new gtest was added for this feature. This requires no API change to the C++ or Python interfaces. Authors: - David (@davidwendt) Approvers: - Devavret Makkar (@devavret) - Karthikeyan (@karthikeyann) URL: #7254
- Loading branch information
1 parent
aa72df7
commit 21d2ce6
Showing
3 changed files
with
270 additions
and
16 deletions.
There are no files selected for viewing
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
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
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