Views
No views yet
command-nightly tokenizercommand-nightly chat model.1from tokenizers import Tokenizer
2
3tokenizer = Tokenizer.from_pretrained("CohereLabs/Command-nightly")
4text = "Hellö World, this is my input string!"
5enc = tokenizer.encode(text)
6print("Encoded input:")
7print(enc)
8
9inv_vocab = {v: k for k, v in tokenizer.get_vocab().items()}
10tokens = [inv_vocab[token_id] for token_id in enc.ids]
11print("Tokens:")
12print(tokens)
13
14number_of_tokens = len(enc.ids)
15print("Number of tokens:", number_of_tokens)