Created
October 18, 2020 21:36
-
-
Save negedng/839d3520714bf191ae1029099cc05c90 to your computer and use it in GitHub Desktop.
See tutorial: https://github.com/huggingface/tokenizers/tree/91f602f744f7fee72f2f5fa8d6c7c48bb1d72d3b/bindings/python
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
with open("imdb_train_plain_lines.txt",'w') as f: | |
for examples in ds2_train: | |
f.write(examples['text']) | |
f.write('\n') | |
from tokenizers import Tokenizer, models, pre_tokenizers, decoders, trainers, processors, BertWordPieceTokenizer | |
# Initialize a tokenizer | |
tokenizer = BertWordPieceTokenizer() | |
# Customize pre-tokenization and decoding | |
tokenizer.pre_tokenizer = pre_tokenizers.BertPreTokenizer() | |
tokenizer.decoder = decoders.WordPiece() | |
# And then train | |
tokenizer.train([ | |
"imdb_train_plain_lines.txt" | |
], vocab_size=max_features, min_frequency=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment