Class QwenTokenizer

java.lang.Object
com.alibaba.dashscope.legacy_2x.tokenizers.QwenTokenizer
All Implemented Interfaces:
Tokenizer

@Deprecated public class QwenTokenizer extends Object implements Tokenizer
Deprecated.
BPE encode and decode, implementation reference https://github.com/openai/tiktoken and https://github.com/karpathy/minbpe
  • Constructor Details

    • QwenTokenizer

      public QwenTokenizer()
      Deprecated.
  • Method Details

    • encodeOrdinary

      public List<Integer> encodeOrdinary(String text)
      Deprecated.
      Encoding that ignores any special tokens.
      Specified by:
      encodeOrdinary in interface Tokenizer
      Parameters:
      text - The input.
      Returns:
      The list of token ids.
    • encode

      public List<Integer> encode(String text, String allowedSpecial) throws NoSpecialTokenExists, UnSupportedSpecialTokenMode
      Deprecated.
      Encode the input text, handles special tokens.
      Specified by:
      encode in interface Tokenizer
      Parameters:
      text - The input to be encode.
      allowedSpecial - The special token options can be "all"|"none"|"none_raise", if none_raise, then an error is raised if any special token is encountered in text, if null, use "all"
      Returns:
      The list of token encode.
      Throws:
      NoSpecialTokenExists - No special token in the input.
      UnSupportedSpecialTokenMode - the allowedSpecial is not["all"|"none"|"none_raise"]
    • decode

      public String decode(List<Integer> tokens)
      Deprecated.
      Description copied from interface: Tokenizer
      Decode token ids to String
      Specified by:
      decode in interface Tokenizer
      Parameters:
      tokens - The input token ids, eg: [2610, 525, 264, 10950, 17847, 13], will be Decoded to "You are a helpful assistant."
      Returns:
      The token ids corresponding string.