TOKENIZER#

Classes#

class models.moe_adapters_utils.tokenizer.SimpleTokenizer(bpe_path='/home/runner/work/mammoth/mammoth/models/moe_adapters_utils/bpe_simple_vocab_16e6.txt.gz', special_tokens=None)[source]#

Bases: object

bpe(token)[source]#
decode(tokens)[source]#
encode(text)[source]#

Functions#

models.moe_adapters_utils.tokenizer.basic_clean(text)[source]#
models.moe_adapters_utils.tokenizer.bytes_to_unicode()[source]#

Returns list of utf-8 byte and a corresponding list of unicode strings. The reversible bpe codes work on unicode strings. This means you need a large # of unicode characters in your vocab if you want to avoid UNKs. When you’re at something like a 10B token dataset you end up needing around 5K for decent coverage. This is a signficant percentage of your normal, say, 32K bpe vocab. To avoid that, we want lookup tables between utf-8 bytes and unicode strings. And avoids mapping to whitespace/control characters the bpe code barfs on.

models.moe_adapters_utils.tokenizer.default_bpe()[source]#
models.moe_adapters_utils.tokenizer.get_pairs(word)[source]#

Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings).

models.moe_adapters_utils.tokenizer.whitespace_clean(text)[source]#