Section6

chapter6hf-notebooksthcourse

WordPiece tokenization

Install the Transformers, Datasets, and Evaluate libraries to run this notebook.

[ ]
[ ]
[ ]
[ ]
defaultdict(
,    int, {'This': 3, 'is': 2, 'the': 1, 'Hugging': 1, 'Face': 1, 'Course': 1, '.': 4, 'chapter': 1, 'about': 1,
,    'tokenization': 1, 'section': 1, 'shows': 1, 'several': 1, 'tokenizer': 1, 'algorithms': 1, 'Hopefully': 1,
,    ',': 1, 'you': 1, 'will': 1, 'be': 1, 'able': 1, 'to': 1, 'understand': 1, 'how': 1, 'they': 1, 'are': 1,
,    'trained': 1, 'and': 1, 'generate': 1, 'tokens': 1})
[ ]
['##a', '##b', '##c', '##d', '##e', '##f', '##g', '##h', '##i', '##k', '##l', '##m', '##n', '##o', '##p', '##r', '##s',
, '##t', '##u', '##v', '##w', '##y', '##z', ',', '.', 'C', 'F', 'H', 'T', 'a', 'b', 'c', 'g', 'h', 'i', 's', 't', 'u',
, 'w', 'y']
[ ]
[ ]
[ ]
[ ]
('T', '##h'): 0.125
,('##h', '##i'): 0.03409090909090909
,('##i', '##s'): 0.02727272727272727
,('i', '##s'): 0.1
,('t', '##h'): 0.03571428571428571
,('##h', '##e'): 0.011904761904761904
[ ]
('a', '##b') 0.2
[ ]
[ ]
[ ]
['ab', '##o', '##u', '##t']
[ ]
[ ]
['[PAD]', '[UNK]', '[CLS]', '[SEP]', '[MASK]', '##a', '##b', '##c', '##d', '##e', '##f', '##g', '##h', '##i', '##k',
, '##l', '##m', '##n', '##o', '##p', '##r', '##s', '##t', '##u', '##v', '##w', '##y', '##z', ',', '.', 'C', 'F', 'H',
, 'T', 'a', 'b', 'c', 'g', 'h', 'i', 's', 't', 'u', 'w', 'y', '##fu', 'Fa', 'Fac', '##ct', '##ful', '##full', '##fully',
, 'Th', 'ch', '##hm', 'cha', 'chap', 'chapt', '##thm', 'Hu', 'Hug', 'Hugg', 'sh', 'th', 'is', '##thms', '##za', '##zat',
, '##ut']
[ ]
[ ]
['Hugg', '##i', '##n', '##g']
,['[UNK]']
[ ]
[ ]
['Th', '##i', '##s', 'is', 'th', '##e', 'Hugg', '##i', '##n', '##g', 'Fac', '##e', 'c', '##o', '##u', '##r', '##s',
, '##e', '[UNK]']