Class QwenTokenizer
java.lang.Object
com.alibaba.dashscope.tokenization.QwenTokenizer
- All Implemented Interfaces:
Tokenizer
BPE encode and decode (3.0 owner of the 2.x
tokenizers.QwenTokenizer leaf);
implementation reference https://github.com/openai/tiktoken and
https://github.com/karpathy/minbpe. The vocabulary qwen.tiktoken is resolved at runtime
from DASHSCOPE_QWEN_VOCAB, the classpath, a verified local cache, or a ModelScope
download (it is no longer shipped in the jar).-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
QwenTokenizer
public QwenTokenizer()
-
-
Method Details
-
encodeOrdinary
Description copied from interface:TokenizerEncoding that ignores any special tokens. There is no guarantee that the results will be completely consistent with the model output. Compared with the python version, there are some differences. It is known that the results of processing 2 or 4 consecutive spaces are different. Detailed information for qwen reference: https://github.com/QwenLM/Qwen/blob/main/tokenization_note_zh.md- Specified by:
encodeOrdinaryin interfaceTokenizer- Parameters:
text- The input.- Returns:
- The list of token ids.
-
encode
Description copied from interface:TokenizerEncode the input text, handles special tokens. Same accuracy caveats asTokenizer.encodeOrdinary(String).- Specified by:
encodein interfaceTokenizer- Parameters:
text- The input to be encoded.allowedSpecial- The special token options, one of "all"|"none"|"none_raise"; with "none_raise" aNoSpecialTokenExceptionis thrown when no special token is present; null means "all".- Returns:
- The list of token ids.
-
decode
Description copied from interface:TokenizerDecode token ids to String.
-