llmcompressor.modeling.kimi_k3.tokenization_kimi
Classes:
-
TikTokenTokenizer–Tokenizing and encoding/decoding text using the Tiktoken tokenizer. See megatron/tokenizer/tiktoken_tokenizer.py.
TikTokenTokenizer
TikTokenTokenizer(
vocab_file,
bos_token: Union[str, AddedToken] = "[BOS]",
eos_token: Union[str, AddedToken] = "[EOS]",
unk_token: Union[str, AddedToken, None] = None,
pad_token: Union[str, AddedToken, None] = None,
additional_special_tokens: List[str] = None,
added_tokens_decoder: Optional[dict] = None,
**kwargs,
)
Bases: PreTrainedTokenizer
Tokenizing and encoding/decoding text using the Tiktoken tokenizer. See megatron/tokenizer/tiktoken_tokenizer.py.
This tokenizer inherits from [PreTrainedTokenizer] which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.
Args:
vocab_file (str):
The path to the Tiktoken model file.
bos_token (str or tokenizers.AddedToken, optional, defaults to "<|begin_of_text|>",):
The beginning of sequence token that was used during pretraining. Can be used a sequence classifier token.
eos_token (str or tokenizers.AddedToken, optional, defaults to "<|end_of_text|>"):
The end of sequence token.
unk_token (str or tokenizers.AddedToken, optional, defaults to "<|reserved_special_token_249|>"):
The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
token instead. The second to last item in special_tokens.
pad_token (str or tokenizers.AddedToken, optional, defaults to "<|reserved_special_token_250|>"):
The token used for padding, for example when batching sequences of different lengths.
additional_special_tokens (list of str, optional):
A tuple or a list of additional tokens, which will be marked as special, meaning that they will be
skipped when decoding if skip_special_tokens is set to True.
Methods:
-
decode–Decodes a list of token IDs into a string.
-
encode–Encodes a string into a list of token IDs.
Source code in src/llmcompressor/modeling/kimi_k3/tokenization_kimi.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
decode
Decodes a list of token IDs into a string.
Args: token_ids (List[int]): The list of token IDs to be decoded.
Returns: str: The decoded string.
Source code in src/llmcompressor/modeling/kimi_k3/tokenization_kimi.py
encode
Encodes a string into a list of token IDs.
Args: text (str): The input string to be encoded.
Returns: list[int]: A list of token IDs.